dev-manual-common-tasks.xml 716 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775
  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. You need to 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, BSD,
  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. LCONF_VERSION = "6"
  596. BBPATH = "${TOPDIR}"
  597. BBFILES ?= ""
  598. BBLAYERS ?= " \
  599. $HOME/poky/meta \
  600. $HOME/poky/meta-poky \
  601. $HOME/poky/meta-yocto-bsp \
  602. $HOME/poky/meta-mylayer \
  603. "
  604. </literallayout>
  605. </para>
  606. <para>
  607. BitBake parses each <filename>conf/layer.conf</filename> file
  608. from the top down as specified in the
  609. <filename>BBLAYERS</filename> variable
  610. within the <filename>conf/bblayers.conf</filename> file.
  611. During the processing of each
  612. <filename>conf/layer.conf</filename> file, BitBake adds the
  613. recipes, classes and configurations contained within the
  614. particular layer to the source directory.
  615. </para>
  616. </section>
  617. <section id='using-bbappend-files'>
  618. <title>Using .bbappend Files in Your Layer</title>
  619. <para>
  620. A recipe that appends Metadata to another recipe is called a
  621. BitBake append file.
  622. A BitBake append file uses the <filename>.bbappend</filename>
  623. file type suffix, while the corresponding recipe to which
  624. Metadata is being appended uses the <filename>.bb</filename>
  625. file type suffix.
  626. </para>
  627. <para>
  628. You can use a <filename>.bbappend</filename> file in your
  629. layer to make additions or changes to the content of another
  630. layer's recipe without having to copy the other layer's
  631. recipe into your layer.
  632. Your <filename>.bbappend</filename> file resides in your layer,
  633. while the main <filename>.bb</filename> recipe file to
  634. which you are appending Metadata resides in a different layer.
  635. </para>
  636. <para>
  637. Being able to append information to an existing recipe not only
  638. avoids duplication, but also automatically applies recipe
  639. changes from a different layer into your layer.
  640. If you were copying recipes, you would have to manually merge
  641. changes as they occur.
  642. </para>
  643. <para>
  644. When you create an append file, you must use the same root
  645. name as the corresponding recipe file.
  646. For example, the append file
  647. <filename>someapp_&DISTRO;.bbappend</filename> must apply to
  648. <filename>someapp_&DISTRO;.bb</filename>.
  649. This means the original recipe and append file names are
  650. version number-specific.
  651. If the corresponding recipe is renamed to update to a newer
  652. version, you must also rename and possibly update
  653. the corresponding <filename>.bbappend</filename> as well.
  654. During the build process, BitBake displays an error on starting
  655. if it detects a <filename>.bbappend</filename> file that does
  656. not have a corresponding recipe with a matching name.
  657. See the
  658. <ulink url='&YOCTO_DOCS_REF_URL;#var-BB_DANGLINGAPPENDS_WARNONLY'><filename>BB_DANGLINGAPPENDS_WARNONLY</filename></ulink>
  659. variable for information on how to handle this error.
  660. </para>
  661. <para>
  662. As an example, consider the main formfactor recipe and a
  663. corresponding formfactor append file both from the
  664. <ulink url='&YOCTO_DOCS_REF_URL;#source-directory'>Source Directory</ulink>.
  665. Here is the main formfactor recipe, which is named
  666. <filename>formfactor_0.0.bb</filename> and located in the
  667. "meta" layer at
  668. <filename>meta/recipes-bsp/formfactor</filename>:
  669. <literallayout class='monospaced'>
  670. SUMMARY = "Device formfactor information"
  671. SECTION = "base"
  672. LICENSE = "MIT"
  673. LIC_FILES_CHKSUM = "file://${COREBASE}/meta/COPYING.MIT;md5=3da9cfbcb788c80a0384361b4de20420"
  674. PR = "r45"
  675. SRC_URI = "file://config file://machconfig"
  676. S = "${WORKDIR}"
  677. PACKAGE_ARCH = "${MACHINE_ARCH}"
  678. INHIBIT_DEFAULT_DEPS = "1"
  679. do_install() {
  680. # Install file only if it has contents
  681. install -d ${D}${sysconfdir}/formfactor/
  682. install -m 0644 ${S}/config ${D}${sysconfdir}/formfactor/
  683. if [ -s "${S}/machconfig" ]; then
  684. install -m 0644 ${S}/machconfig ${D}${sysconfdir}/formfactor/
  685. fi
  686. } </literallayout>
  687. In the main recipe, note the
  688. <ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'><filename>SRC_URI</filename></ulink>
  689. variable, which tells the OpenEmbedded build system where to
  690. find files during the build.
  691. </para>
  692. <para>
  693. Following is the append file, which is named
  694. <filename>formfactor_0.0.bbappend</filename> and is from the
  695. Raspberry Pi BSP Layer named
  696. <filename>meta-raspberrypi</filename>.
  697. The file is in the layer at
  698. <filename>recipes-bsp/formfactor</filename>:
  699. <literallayout class='monospaced'>
  700. FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:"
  701. </literallayout>
  702. </para>
  703. <para>
  704. By default, the build system uses the
  705. <ulink url='&YOCTO_DOCS_REF_URL;#var-FILESPATH'><filename>FILESPATH</filename></ulink>
  706. variable to locate files.
  707. This append file extends the locations by setting the
  708. <ulink url='&YOCTO_DOCS_REF_URL;#var-FILESEXTRAPATHS'><filename>FILESEXTRAPATHS</filename></ulink>
  709. variable.
  710. Setting this variable in the <filename>.bbappend</filename>
  711. file is the most reliable and recommended method for adding
  712. directories to the search path used by the build system
  713. to find files.
  714. </para>
  715. <para>
  716. The statement in this example extends the directories to
  717. include
  718. <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>,
  719. which resolves to a directory named
  720. <filename>formfactor</filename> in the same directory
  721. in which the append file resides (i.e.
  722. <filename>meta-raspberrypi/recipes-bsp/formfactor</filename>.
  723. This implies that you must have the supporting directory
  724. structure set up that will contain any files or patches you
  725. will be including from the layer.
  726. </para>
  727. <para>
  728. Using the immediate expansion assignment operator
  729. <filename>:=</filename> is important because of the reference
  730. to <filename>THISDIR</filename>.
  731. The trailing colon character is important as it ensures that
  732. items in the list remain colon-separated.
  733. <note>
  734. <para>
  735. BitBake automatically defines the
  736. <filename>THISDIR</filename> variable.
  737. You should never set this variable yourself.
  738. Using "_prepend" as part of the
  739. <filename>FILESEXTRAPATHS</filename> ensures your path
  740. will be searched prior to other paths in the final
  741. list.
  742. </para>
  743. <para>
  744. Also, not all append files add extra files.
  745. Many append files simply exist to add build options
  746. (e.g. <filename>systemd</filename>).
  747. For these cases, your append file would not even
  748. use the <filename>FILESEXTRAPATHS</filename> statement.
  749. </para>
  750. </note>
  751. </para>
  752. </section>
  753. <section id='prioritizing-your-layer'>
  754. <title>Prioritizing Your Layer</title>
  755. <para>
  756. Each layer is assigned a priority value.
  757. Priority values control which layer takes precedence if there
  758. are recipe files with the same name in multiple layers.
  759. For these cases, the recipe file from the layer with a higher
  760. priority number takes precedence.
  761. Priority values also affect the order in which multiple
  762. <filename>.bbappend</filename> files for the same recipe are
  763. applied.
  764. You can either specify the priority manually, or allow the
  765. build system to calculate it based on the layer's dependencies.
  766. </para>
  767. <para>
  768. To specify the layer's priority manually, use the
  769. <ulink url='&YOCTO_DOCS_REF_URL;#var-BBFILE_PRIORITY'><filename>BBFILE_PRIORITY</filename></ulink>
  770. variable and append the layer's root name:
  771. <literallayout class='monospaced'>
  772. BBFILE_PRIORITY_mylayer = "1"
  773. </literallayout>
  774. </para>
  775. <note>
  776. <para>It is possible for a recipe with a lower version number
  777. <ulink url='&YOCTO_DOCS_REF_URL;#var-PV'><filename>PV</filename></ulink>
  778. in a layer that has a higher priority to take precedence.</para>
  779. <para>Also, the layer priority does not currently affect the
  780. precedence order of <filename>.conf</filename>
  781. or <filename>.bbclass</filename> files.
  782. Future versions of BitBake might address this.</para>
  783. </note>
  784. </section>
  785. <section id='managing-layers'>
  786. <title>Managing Layers</title>
  787. <para>
  788. You can use the BitBake layer management tool
  789. <filename>bitbake-layers</filename> to provide a view
  790. into the structure of recipes across a multi-layer project.
  791. Being able to generate output that reports on configured layers
  792. with their paths and priorities and on
  793. <filename>.bbappend</filename> files and their applicable
  794. recipes can help to reveal potential problems.
  795. </para>
  796. <para>
  797. For help on the BitBake layer management tool, use the
  798. following command:
  799. <literallayout class='monospaced'>
  800. $ bitbake-layers --help
  801. NOTE: Starting bitbake server...
  802. usage: bitbake-layers [-d] [-q] [-F] [--color COLOR] [-h] &lt;subcommand&gt; ...
  803. BitBake layers utility
  804. optional arguments:
  805. -d, --debug Enable debug output
  806. -q, --quiet Print only errors
  807. -F, --force Force add without recipe parse verification
  808. --color COLOR Colorize output (where COLOR is auto, always, never)
  809. -h, --help show this help message and exit
  810. subcommands:
  811. &lt;subcommand&gt;
  812. show-layers show current configured layers.
  813. show-overlayed list overlayed recipes (where the same recipe exists
  814. in another layer)
  815. show-recipes list available recipes, showing the layer they are
  816. provided by
  817. show-appends list bbappend files and recipe files they apply to
  818. show-cross-depends Show dependencies between recipes that cross layer
  819. boundaries.
  820. add-layer Add one or more layers to bblayers.conf.
  821. remove-layer Remove one or more layers from bblayers.conf.
  822. flatten flatten layer configuration into a separate output
  823. directory.
  824. layerindex-fetch Fetches a layer from a layer index along with its
  825. dependent layers, and adds them to conf/bblayers.conf.
  826. layerindex-show-depends
  827. Find layer dependencies from layer index.
  828. create-layer Create a basic layer
  829. Use bitbake-layers &lt;subcommand&gt; --help to get help on a specific command
  830. </literallayout>
  831. </para>
  832. <para>
  833. The following list describes the available commands:
  834. <itemizedlist>
  835. <listitem><para>
  836. <emphasis><filename>help:</filename></emphasis>
  837. Displays general help or help on a specified command.
  838. </para></listitem>
  839. <listitem><para>
  840. <emphasis><filename>show-layers:</filename></emphasis>
  841. Shows the current configured layers.
  842. </para></listitem>
  843. <listitem><para>
  844. <emphasis><filename>show-overlayed:</filename></emphasis>
  845. Lists overlayed recipes.
  846. A recipe is overlayed when a recipe with the same name
  847. exists in another layer that has a higher layer
  848. priority.
  849. </para></listitem>
  850. <listitem><para>
  851. <emphasis><filename>show-recipes:</filename></emphasis>
  852. Lists available recipes and the layers that provide them.
  853. </para></listitem>
  854. <listitem><para>
  855. <emphasis><filename>show-appends:</filename></emphasis>
  856. Lists <filename>.bbappend</filename> files and the
  857. recipe files to which they apply.
  858. </para></listitem>
  859. <listitem><para>
  860. <emphasis><filename>show-cross-depends:</filename></emphasis>
  861. Lists dependency relationships between recipes that
  862. cross layer boundaries.
  863. </para></listitem>
  864. <listitem><para>
  865. <emphasis><filename>add-layer:</filename></emphasis>
  866. Adds a layer to <filename>bblayers.conf</filename>.
  867. </para></listitem>
  868. <listitem><para>
  869. <emphasis><filename>remove-layer:</filename></emphasis>
  870. Removes a layer from <filename>bblayers.conf</filename>
  871. </para></listitem>
  872. <listitem><para>
  873. <emphasis><filename>flatten:</filename></emphasis>
  874. Flattens the layer configuration into a separate output
  875. directory.
  876. Flattening your layer configuration builds a "flattened"
  877. directory that contains the contents of all layers,
  878. with any overlayed recipes removed and any
  879. <filename>.bbappend</filename> files appended to the
  880. corresponding recipes.
  881. You might have to perform some manual cleanup of the
  882. flattened layer as follows:
  883. <itemizedlist>
  884. <listitem><para>
  885. Non-recipe files (such as patches)
  886. are overwritten.
  887. The flatten command shows a warning for these
  888. files.
  889. </para></listitem>
  890. <listitem><para>
  891. Anything beyond the normal layer
  892. setup has been added to the
  893. <filename>layer.conf</filename> file.
  894. Only the lowest priority layer's
  895. <filename>layer.conf</filename> is used.
  896. </para></listitem>
  897. <listitem><para>
  898. Overridden and appended items from
  899. <filename>.bbappend</filename> files need to be
  900. cleaned up.
  901. The contents of each
  902. <filename>.bbappend</filename> end up in the
  903. flattened recipe.
  904. However, if there are appended or changed
  905. variable values, you need to tidy these up
  906. yourself.
  907. Consider the following example.
  908. Here, the <filename>bitbake-layers</filename>
  909. command adds the line
  910. <filename>#### bbappended ...</filename> so that
  911. you know where the following lines originate:
  912. <literallayout class='monospaced'>
  913. ...
  914. DESCRIPTION = "A useful utility"
  915. ...
  916. EXTRA_OECONF = "--enable-something"
  917. ...
  918. #### bbappended from meta-anotherlayer ####
  919. DESCRIPTION = "Customized utility"
  920. EXTRA_OECONF += "--enable-somethingelse"
  921. </literallayout>
  922. Ideally, you would tidy up these utilities as
  923. follows:
  924. <literallayout class='monospaced'>
  925. ...
  926. DESCRIPTION = "Customized utility"
  927. ...
  928. EXTRA_OECONF = "--enable-something --enable-somethingelse"
  929. ...
  930. </literallayout>
  931. </para></listitem>
  932. </itemizedlist>
  933. </para></listitem>
  934. <listitem><para>
  935. <emphasis><filename>layerindex-fetch</filename>:</emphasis>
  936. Fetches a layer from a layer index, along with its
  937. dependent layers, and adds the layers to the
  938. <filename>conf/bblayers.conf</filename> file.
  939. </para></listitem>
  940. <listitem><para>
  941. <emphasis><filename>layerindex-show-depends</filename>:</emphasis>
  942. Finds layer dependencies from the layer index.
  943. </para></listitem>
  944. <listitem><para>
  945. <emphasis><filename>create-layer</filename>:</emphasis>
  946. Creates a basic layer.
  947. </para></listitem>
  948. </itemizedlist>
  949. </para>
  950. </section>
  951. <section id='creating-a-general-layer-using-the-bitbake-layers-script'>
  952. <title>Creating a General Layer Using the <filename>bitbake-layers</filename> Script</title>
  953. <para>
  954. The <filename>bitbake-layers</filename> script with the
  955. <filename>create-layer</filename> subcommand simplifies
  956. creating a new general layer.
  957. <note><title>Notes</title>
  958. <itemizedlist>
  959. <listitem><para>
  960. For information on BSP layers, see the
  961. "<ulink url='&YOCTO_DOCS_BSP_URL;#bsp-layers'>BSP Layers</ulink>"
  962. section in the Yocto Project Board Specific (BSP)
  963. Developer's Guide.
  964. </para></listitem>
  965. <listitem><para>
  966. In order to use a layer with the OpenEmbedded
  967. build system, you need to add the layer to your
  968. <filename>bblayers.conf</filename> configuration
  969. file.
  970. See the
  971. "<link linkend='adding-a-layer-using-the-bitbake-layers-script'>Adding a Layer Using the <filename>bitbake-layers</filename> Script</link>"
  972. section for more information.
  973. </para></listitem>
  974. </itemizedlist>
  975. </note>
  976. The default mode of the script's operation with this
  977. subcommand is to create a layer with the following:
  978. <itemizedlist>
  979. <listitem><para>A layer priority of 6.
  980. </para></listitem>
  981. <listitem><para>A <filename>conf</filename>
  982. subdirectory that contains a
  983. <filename>layer.conf</filename> file.
  984. </para></listitem>
  985. <listitem><para>
  986. A <filename>recipes-example</filename> subdirectory
  987. that contains a further subdirectory named
  988. <filename>example</filename>, which contains
  989. an <filename>example.bb</filename> recipe file.
  990. </para></listitem>
  991. <listitem><para>A <filename >COPYING.MIT</filename>,
  992. which is the license statement for the layer.
  993. The script assumes you want to use the MIT license,
  994. which is typical for most layers, for the contents of
  995. the layer itself.
  996. </para></listitem>
  997. <listitem><para>
  998. A <filename>README</filename> file, which is a file
  999. describing the contents of your new layer.
  1000. </para></listitem>
  1001. </itemizedlist>
  1002. </para>
  1003. <para>
  1004. In its simplest form, you can use the following command form
  1005. to create a layer.
  1006. The command creates a layer whose name corresponds to
  1007. <replaceable>your_layer_name</replaceable> in the current
  1008. directory:
  1009. <literallayout class='monospaced'>
  1010. $ bitbake-layers create-layer <replaceable>your_layer_name</replaceable>
  1011. </literallayout>
  1012. As an example, the following command creates a layer named
  1013. <filename>meta-scottrif</filename> in your home directory:
  1014. <literallayout class='monospaced'>
  1015. $ cd /usr/home
  1016. $ bitbake-layers create-layer meta-scottrif
  1017. NOTE: Starting bitbake server...
  1018. Add your new layer with 'bitbake-layers add-layer meta-scottrif'
  1019. </literallayout>
  1020. </para>
  1021. <para>
  1022. If you want to set the priority of the layer to other than the
  1023. default value of "6", you can either use the
  1024. <filename>&dash;&dash;priority</filename> option or you can
  1025. edit the
  1026. <ulink url='&YOCTO_DOCS_REF_URL;#var-BBFILE_PRIORITY'><filename>BBFILE_PRIORITY</filename></ulink>
  1027. value in the <filename>conf/layer.conf</filename> after the
  1028. script creates it.
  1029. Furthermore, if you want to give the example recipe file
  1030. some name other than the default, you can
  1031. use the
  1032. <filename>&dash;&dash;example-recipe-name</filename> option.
  1033. </para>
  1034. <para>
  1035. The easiest way to see how the
  1036. <filename>bitbake-layers create-layer</filename> command
  1037. works is to experiment with the script.
  1038. You can also read the usage information by entering the
  1039. following:
  1040. <literallayout class='monospaced'>
  1041. $ bitbake-layers create-layer --help
  1042. NOTE: Starting bitbake server...
  1043. usage: bitbake-layers create-layer [-h] [--priority PRIORITY]
  1044. [--example-recipe-name EXAMPLERECIPE]
  1045. layerdir
  1046. Create a basic layer
  1047. positional arguments:
  1048. layerdir Layer directory to create
  1049. optional arguments:
  1050. -h, --help show this help message and exit
  1051. --priority PRIORITY, -p PRIORITY
  1052. Layer directory to create
  1053. --example-recipe-name EXAMPLERECIPE, -e EXAMPLERECIPE
  1054. Filename of the example recipe
  1055. </literallayout>
  1056. </para>
  1057. </section>
  1058. <section id='adding-a-layer-using-the-bitbake-layers-script'>
  1059. <title>Adding a Layer Using the <filename>bitbake-layers</filename> Script</title>
  1060. <para>
  1061. Once you create your general layer, you must add it to your
  1062. <filename>bblayers.conf</filename> file.
  1063. Adding the layer to this configuration file makes the
  1064. OpenEmbedded build system aware of your layer so that it can
  1065. search it for metadata.
  1066. </para>
  1067. <para>
  1068. Add your layer by using the
  1069. <filename>bitbake-layers add-layer</filename> command:
  1070. <literallayout class='monospaced'>
  1071. $ bitbake-layers add-layer <replaceable>your_layer_name</replaceable>
  1072. </literallayout>
  1073. Here is an example that adds a layer named
  1074. <filename>meta-scottrif</filename> to the configuration file.
  1075. Following the command that adds the layer is another
  1076. <filename>bitbake-layers</filename> command that shows the
  1077. layers that are in your <filename>bblayers.conf</filename>
  1078. file:
  1079. <literallayout class='monospaced'>
  1080. $ bitbake-layers add-layer meta-scottrif
  1081. NOTE: Starting bitbake server...
  1082. Parsing recipes: 100% |##########################################################| Time: 0:00:49
  1083. Parsing of 1441 .bb files complete (0 cached, 1441 parsed). 2055 targets, 56 skipped, 0 masked, 0 errors.
  1084. $ bitbake-layers show-layers
  1085. NOTE: Starting bitbake server...
  1086. layer path priority
  1087. ==========================================================================
  1088. meta /home/scottrif/poky/meta 5
  1089. meta-poky /home/scottrif/poky/meta-poky 5
  1090. meta-yocto-bsp /home/scottrif/poky/meta-yocto-bsp 5
  1091. workspace /home/scottrif/poky/build/workspace 99
  1092. meta-scottrif /home/scottrif/poky/build/meta-scottrif 6
  1093. </literallayout>
  1094. Adding the layer to this file enables the build system to
  1095. locate the layer during the build.
  1096. <note>
  1097. During a build, the OpenEmbedded build system looks in
  1098. the layers from the top of the list down to the bottom
  1099. in that order.
  1100. </note>
  1101. </para>
  1102. </section>
  1103. </section>
  1104. <section id='usingpoky-extend-customimage'>
  1105. <title>Customizing Images</title>
  1106. <para>
  1107. You can customize images to satisfy particular requirements.
  1108. This section describes several methods and provides guidelines for each.
  1109. </para>
  1110. <section id='usingpoky-extend-customimage-localconf'>
  1111. <title>Customizing Images Using <filename>local.conf</filename></title>
  1112. <para>
  1113. Probably the easiest way to customize an image is to add a
  1114. package by way of the <filename>local.conf</filename>
  1115. configuration file.
  1116. Because it is limited to local use, this method generally only
  1117. allows you to add packages and is not as flexible as creating
  1118. your own customized image.
  1119. When you add packages using local variables this way, you need
  1120. to realize that these variable changes are in effect for every
  1121. build and consequently affect all images, which might not
  1122. be what you require.
  1123. </para>
  1124. <para>
  1125. To add a package to your image using the local configuration
  1126. file, use the
  1127. <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-IMAGE_INSTALL'>IMAGE_INSTALL</ulink></filename>
  1128. variable with the <filename>_append</filename> operator:
  1129. <literallayout class='monospaced'>
  1130. IMAGE_INSTALL_append = " strace"
  1131. </literallayout>
  1132. Use of the syntax is important - specifically, the space between
  1133. the quote and the package name, which is
  1134. <filename>strace</filename> in this example.
  1135. This space is required since the <filename>_append</filename>
  1136. operator does not add the space.
  1137. </para>
  1138. <para>
  1139. Furthermore, you must use <filename>_append</filename> instead
  1140. of the <filename>+=</filename> operator if you want to avoid
  1141. ordering issues.
  1142. The reason for this is because doing so unconditionally appends
  1143. to the variable and avoids ordering problems due to the
  1144. variable being set in image recipes and
  1145. <filename>.bbclass</filename> files with operators like
  1146. <filename>?=</filename>.
  1147. Using <filename>_append</filename> ensures the operation takes
  1148. affect.
  1149. </para>
  1150. <para>
  1151. As shown in its simplest use,
  1152. <filename>IMAGE_INSTALL_append</filename> affects all images.
  1153. It is possible to extend the syntax so that the variable
  1154. applies to a specific image only.
  1155. Here is an example:
  1156. <literallayout class='monospaced'>
  1157. IMAGE_INSTALL_append_pn-core-image-minimal = " strace"
  1158. </literallayout>
  1159. This example adds <filename>strace</filename> to the
  1160. <filename>core-image-minimal</filename> image only.
  1161. </para>
  1162. <para>
  1163. You can add packages using a similar approach through the
  1164. <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-CORE_IMAGE_EXTRA_INSTALL'>CORE_IMAGE_EXTRA_INSTALL</ulink></filename>
  1165. variable.
  1166. If you use this variable, only
  1167. <filename>core-image-*</filename> images are affected.
  1168. </para>
  1169. </section>
  1170. <section id='usingpoky-extend-customimage-imagefeatures'>
  1171. <title>Customizing Images Using Custom <filename>IMAGE_FEATURES</filename> and
  1172. <filename>EXTRA_IMAGE_FEATURES</filename></title>
  1173. <para>
  1174. Another method for customizing your image is to enable or
  1175. disable high-level image features by using the
  1176. <ulink url='&YOCTO_DOCS_REF_URL;#var-IMAGE_FEATURES'><filename>IMAGE_FEATURES</filename></ulink>
  1177. and <ulink url='&YOCTO_DOCS_REF_URL;#var-EXTRA_IMAGE_FEATURES'><filename>EXTRA_IMAGE_FEATURES</filename></ulink>
  1178. variables.
  1179. Although the functions for both variables are nearly equivalent,
  1180. best practices dictate using <filename>IMAGE_FEATURES</filename>
  1181. from within a recipe and using
  1182. <filename>EXTRA_IMAGE_FEATURES</filename> from within
  1183. your <filename>local.conf</filename> file, which is found in the
  1184. <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink>.
  1185. </para>
  1186. <para>
  1187. To understand how these features work, the best reference is
  1188. <filename>meta/classes/core-image.bbclass</filename>.
  1189. This class lists out the available
  1190. <filename>IMAGE_FEATURES</filename> of which most map to
  1191. package groups while some, such as
  1192. <filename>debug-tweaks</filename> and
  1193. <filename>read-only-rootfs</filename>, resolve as general
  1194. configuration settings.
  1195. </para>
  1196. <para>
  1197. In summary, the file looks at the contents of the
  1198. <filename>IMAGE_FEATURES</filename> variable and then maps
  1199. or configures the feature accordingly.
  1200. Based on this information, the build system automatically
  1201. adds the appropriate packages or configurations to the
  1202. <ulink url='&YOCTO_DOCS_REF_URL;#var-IMAGE_INSTALL'><filename>IMAGE_INSTALL</filename></ulink>
  1203. variable.
  1204. Effectively, you are enabling extra features by extending the
  1205. class or creating a custom class for use with specialized image
  1206. <filename>.bb</filename> files.
  1207. </para>
  1208. <para>
  1209. Use the <filename>EXTRA_IMAGE_FEATURES</filename> variable
  1210. from within your local configuration file.
  1211. Using a separate area from which to enable features with
  1212. this variable helps you avoid overwriting the features in the
  1213. image recipe that are enabled with
  1214. <filename>IMAGE_FEATURES</filename>.
  1215. The value of <filename>EXTRA_IMAGE_FEATURES</filename> is added
  1216. to <filename>IMAGE_FEATURES</filename> within
  1217. <filename>meta/conf/bitbake.conf</filename>.
  1218. </para>
  1219. <para>
  1220. To illustrate how you can use these variables to modify your
  1221. image, consider an example that selects the SSH server.
  1222. The Yocto Project ships with two SSH servers you can use
  1223. with your images: Dropbear and OpenSSH.
  1224. Dropbear is a minimal SSH server appropriate for
  1225. resource-constrained environments, while OpenSSH is a
  1226. well-known standard SSH server implementation.
  1227. By default, the <filename>core-image-sato</filename> image
  1228. is configured to use Dropbear.
  1229. The <filename>core-image-full-cmdline</filename> and
  1230. <filename>core-image-lsb</filename> images both
  1231. include OpenSSH.
  1232. The <filename>core-image-minimal</filename> image does not
  1233. contain an SSH server.
  1234. </para>
  1235. <para>
  1236. You can customize your image and change these defaults.
  1237. Edit the <filename>IMAGE_FEATURES</filename> variable
  1238. in your recipe or use the
  1239. <filename>EXTRA_IMAGE_FEATURES</filename> in your
  1240. <filename>local.conf</filename> file so that it configures the
  1241. image you are working with to include
  1242. <filename>ssh-server-dropbear</filename> or
  1243. <filename>ssh-server-openssh</filename>.
  1244. </para>
  1245. <note>
  1246. See the
  1247. "<ulink url='&YOCTO_DOCS_REF_URL;#ref-images'>Images</ulink>"
  1248. section in the Yocto Project Reference Manual for a complete
  1249. list of image features that ship with the Yocto Project.
  1250. </note>
  1251. </section>
  1252. <section id='usingpoky-extend-customimage-custombb'>
  1253. <title>Customizing Images Using Custom .bb Files</title>
  1254. <para>
  1255. You can also customize an image by creating a custom recipe
  1256. that defines additional software as part of the image.
  1257. The following example shows the form for the two lines you need:
  1258. <literallayout class='monospaced'>
  1259. IMAGE_INSTALL = "packagegroup-core-x11-base package1 package2"
  1260. inherit core-image
  1261. </literallayout>
  1262. </para>
  1263. <para>
  1264. Defining the software using a custom recipe gives you total
  1265. control over the contents of the image.
  1266. It is important to use the correct names of packages in the
  1267. <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-IMAGE_INSTALL'>IMAGE_INSTALL</ulink></filename>
  1268. variable.
  1269. You must use the OpenEmbedded notation and not the Debian notation for the names
  1270. (e.g. <filename>glibc-dev</filename> instead of <filename>libc6-dev</filename>).
  1271. </para>
  1272. <para>
  1273. The other method for creating a custom image is to base it on an existing image.
  1274. For example, if you want to create an image based on <filename>core-image-sato</filename>
  1275. but add the additional package <filename>strace</filename> to the image,
  1276. copy the <filename>meta/recipes-sato/images/core-image-sato.bb</filename> to a
  1277. new <filename>.bb</filename> and add the following line to the end of the copy:
  1278. <literallayout class='monospaced'>
  1279. IMAGE_INSTALL += "strace"
  1280. </literallayout>
  1281. </para>
  1282. </section>
  1283. <section id='usingpoky-extend-customimage-customtasks'>
  1284. <title>Customizing Images Using Custom Package Groups</title>
  1285. <para>
  1286. For complex custom images, the best approach for customizing
  1287. an image is to create a custom package group recipe that is
  1288. used to build the image or images.
  1289. A good example of a package group recipe is
  1290. <filename>meta/recipes-core/packagegroups/packagegroup-base.bb</filename>.
  1291. </para>
  1292. <para>
  1293. If you examine that recipe, you see that the
  1294. <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGES'>PACKAGES</ulink></filename>
  1295. variable lists the package group packages to produce.
  1296. The <filename>inherit packagegroup</filename> statement
  1297. sets appropriate default values and automatically adds
  1298. <filename>-dev</filename>, <filename>-dbg</filename>, and
  1299. <filename>-ptest</filename> complementary packages for each
  1300. package specified in the <filename>PACKAGES</filename>
  1301. statement.
  1302. <note>
  1303. The <filename>inherit packages</filename> should be
  1304. located near the top of the recipe, certainly before
  1305. the <filename>PACKAGES</filename> statement.
  1306. </note>
  1307. </para>
  1308. <para>
  1309. For each package you specify in <filename>PACKAGES</filename>,
  1310. you can use
  1311. <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-RDEPENDS'>RDEPENDS</ulink></filename>
  1312. and
  1313. <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-RRECOMMENDS'>RRECOMMENDS</ulink></filename>
  1314. entries to provide a list of packages the parent task package
  1315. should contain.
  1316. You can see examples of these further down in the
  1317. <filename>packagegroup-base.bb</filename> recipe.
  1318. </para>
  1319. <para>
  1320. Here is a short, fabricated example showing the same basic
  1321. pieces:
  1322. <literallayout class='monospaced'>
  1323. DESCRIPTION = "My Custom Package Groups"
  1324. inherit packagegroup
  1325. PACKAGES = "\
  1326. packagegroup-custom-apps \
  1327. packagegroup-custom-tools \
  1328. "
  1329. RDEPENDS_packagegroup-custom-apps = "\
  1330. dropbear \
  1331. portmap \
  1332. psplash"
  1333. RDEPENDS_packagegroup-custom-tools = "\
  1334. oprofile \
  1335. oprofileui-server \
  1336. lttng-tools"
  1337. RRECOMMENDS_packagegroup-custom-tools = "\
  1338. kernel-module-oprofile"
  1339. </literallayout>
  1340. </para>
  1341. <para>
  1342. In the previous example, two package group packages are created with their dependencies and their
  1343. recommended package dependencies listed: <filename>packagegroup-custom-apps</filename>, and
  1344. <filename>packagegroup-custom-tools</filename>.
  1345. To build an image using these package group packages, you need to add
  1346. <filename>packagegroup-custom-apps</filename> and/or
  1347. <filename>packagegroup-custom-tools</filename> to
  1348. <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-IMAGE_INSTALL'>IMAGE_INSTALL</ulink></filename>.
  1349. For other forms of image dependencies see the other areas of this section.
  1350. </para>
  1351. </section>
  1352. <section id='usingpoky-extend-customimage-image-name'>
  1353. <title>Customizing an Image Hostname</title>
  1354. <para>
  1355. By default, the configured hostname (i.e.
  1356. <filename>/etc/hostname</filename>) in an image is the
  1357. same as the machine name.
  1358. For example, if
  1359. <ulink url='&YOCTO_DOCS_REF_URL;#var-MACHINE'><filename>MACHINE</filename></ulink>
  1360. equals "qemux86", the configured hostname written to
  1361. <filename>/etc/hostname</filename> is "qemux86".
  1362. </para>
  1363. <para>
  1364. You can customize this name by altering the value of the
  1365. "hostname" variable in the
  1366. <filename>base-files</filename> recipe using either
  1367. an append file or a configuration file.
  1368. Use the following in an append file:
  1369. <literallayout class='monospaced'>
  1370. hostname="myhostname"
  1371. </literallayout>
  1372. Use the following in a configuration file:
  1373. <literallayout class='monospaced'>
  1374. hostname_pn-base-files = "myhostname"
  1375. </literallayout>
  1376. </para>
  1377. <para>
  1378. Changing the default value of the variable "hostname" can be
  1379. useful in certain situations.
  1380. For example, suppose you need to do extensive testing on an
  1381. image and you would like to easily identify the image
  1382. under test from existing images with typical default
  1383. hostnames.
  1384. In this situation, you could change the default hostname to
  1385. "testme", which results in all the images using the name
  1386. "testme".
  1387. Once testing is complete and you do not need to rebuild the
  1388. image for test any longer, you can easily reset the default
  1389. hostname.
  1390. </para>
  1391. <para>
  1392. Another point of interest is that if you unset the variable,
  1393. the image will have no default hostname in the filesystem.
  1394. Here is an example that unsets the variable in a
  1395. configuration file:
  1396. <literallayout class='monospaced'>
  1397. hostname_pn-base-files = ""
  1398. </literallayout>
  1399. Having no default hostname in the filesystem is suitable for
  1400. environments that use dynamic hostnames such as virtual
  1401. machines.
  1402. </para>
  1403. </section>
  1404. </section>
  1405. <section id='new-recipe-writing-a-new-recipe'>
  1406. <title>Writing a New Recipe</title>
  1407. <para>
  1408. Recipes (<filename>.bb</filename> files) are fundamental components
  1409. in the Yocto Project environment.
  1410. Each software component built by the OpenEmbedded build system
  1411. requires a recipe to define the component.
  1412. This section describes how to create, write, and test a new
  1413. recipe.
  1414. <note>
  1415. For information on variables that are useful for recipes and
  1416. for information about recipe naming issues, see the
  1417. "<ulink url='&YOCTO_DOCS_REF_URL;#ref-varlocality-recipe-required'>Required</ulink>"
  1418. section of the Yocto Project Reference Manual.
  1419. </note>
  1420. </para>
  1421. <section id='new-recipe-overview'>
  1422. <title>Overview</title>
  1423. <para>
  1424. The following figure shows the basic process for creating a
  1425. new recipe.
  1426. The remainder of the section provides details for the steps.
  1427. <imagedata fileref="figures/recipe-workflow.png" width="6in" depth="7in" align="center" scalefit="1" />
  1428. </para>
  1429. </section>
  1430. <section id='new-recipe-locate-or-automatically-create-a-base-recipe'>
  1431. <title>Locate or Automatically Create a Base Recipe</title>
  1432. <para>
  1433. You can always write a recipe from scratch.
  1434. However, three choices exist that can help you quickly get a
  1435. start on a new recipe:
  1436. <itemizedlist>
  1437. <listitem><para>
  1438. <emphasis><filename>devtool add</filename>:</emphasis>
  1439. A command that assists in creating a recipe and
  1440. an environment conducive to development.
  1441. </para></listitem>
  1442. <listitem><para>
  1443. <emphasis><filename>recipetool create</filename>:</emphasis>
  1444. A command provided by the Yocto Project that automates
  1445. creation of a base recipe based on the source
  1446. files.
  1447. </para></listitem>
  1448. <listitem><para>
  1449. <emphasis>Existing Recipes:</emphasis>
  1450. Location and modification of an existing recipe that is
  1451. similar in function to the recipe you need.
  1452. </para></listitem>
  1453. </itemizedlist>
  1454. <note>
  1455. For information on recipe syntax, see the
  1456. "<link linkend='recipe-syntax'>Recipe Syntax</link>"
  1457. section.
  1458. </note>
  1459. </para>
  1460. <section id='new-recipe-creating-the-base-recipe-using-devtool'>
  1461. <title>Creating the Base Recipe Using <filename>devtool add</filename></title>
  1462. <para>
  1463. The <filename>devtool add</filename> command uses the same
  1464. logic for auto-creating the recipe as
  1465. <filename>recipetool create</filename>, which is listed
  1466. below.
  1467. Additionally, however, <filename>devtool add</filename>
  1468. sets up an environment that makes it easy for you to
  1469. patch the source and to make changes to the recipe as
  1470. is often necessary when adding a recipe to build a new
  1471. piece of software to be included in a build.
  1472. </para>
  1473. <para>
  1474. You can find a complete description of the
  1475. <filename>devtool add</filename> command in the
  1476. "<ulink url='&YOCTO_DOCS_SDK_URL;#sdk-a-closer-look-at-devtool-add'>A Closer Look at <filename>devtool</filename> add</ulink>"
  1477. section in the Yocto Project Application Development
  1478. and the Extensible Software Development Kit (eSDK) manual.
  1479. </para>
  1480. </section>
  1481. <section id='new-recipe-creating-the-base-recipe-using-recipetool'>
  1482. <title>Creating the Base Recipe Using <filename>recipetool create</filename></title>
  1483. <para>
  1484. <filename>recipetool create</filename> automates creation
  1485. of a base recipe given a set of source code files.
  1486. As long as you can extract or point to the source files,
  1487. the tool will construct a recipe and automatically
  1488. configure all pre-build information into the recipe.
  1489. For example, suppose you have an application that builds
  1490. using Autotools.
  1491. Creating the base recipe using
  1492. <filename>recipetool</filename> results in a recipe
  1493. that has the pre-build dependencies, license requirements,
  1494. and checksums configured.
  1495. </para>
  1496. <para>
  1497. To run the tool, you just need to be in your
  1498. <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink>
  1499. and have sourced the build environment setup script
  1500. (i.e.
  1501. <ulink url='&YOCTO_DOCS_REF_URL;#structure-core-script'><filename>oe-init-build-env</filename></ulink>).
  1502. To get help on the tool, use the following command:
  1503. <literallayout class='monospaced'>
  1504. $ recipetool -h
  1505. NOTE: Starting bitbake server...
  1506. usage: recipetool [-d] [-q] [--color COLOR] [-h] &lt;subcommand&gt; ...
  1507. OpenEmbedded recipe tool
  1508. options:
  1509. -d, --debug Enable debug output
  1510. -q, --quiet Print only errors
  1511. --color COLOR Colorize output (where COLOR is auto, always, never)
  1512. -h, --help show this help message and exit
  1513. subcommands:
  1514. create Create a new recipe
  1515. newappend Create a bbappend for the specified target in the specified
  1516. layer
  1517. setvar Set a variable within a recipe
  1518. appendfile Create/update a bbappend to replace a target file
  1519. appendsrcfiles Create/update a bbappend to add or replace source files
  1520. appendsrcfile Create/update a bbappend to add or replace a source file
  1521. Use recipetool &lt;subcommand&gt; --help to get help on a specific command
  1522. </literallayout>
  1523. </para>
  1524. <para>
  1525. Running
  1526. <filename>recipetool create -o</filename>&nbsp;<replaceable>OUTFILE</replaceable>
  1527. creates the base recipe and locates it properly in the
  1528. layer that contains your source files.
  1529. Following are some syntax examples:
  1530. </para>
  1531. <para>
  1532. Use this syntax to generate a recipe based on
  1533. <replaceable>source</replaceable>.
  1534. Once generated, the recipe resides in the existing source
  1535. code layer:
  1536. <literallayout class='monospaced'>
  1537. recipetool create -o <replaceable>OUTFILE</replaceable>&nbsp;<replaceable>source</replaceable>
  1538. </literallayout>
  1539. Use this syntax to generate a recipe using code that you
  1540. extract from <replaceable>source</replaceable>.
  1541. The extracted code is placed in its own layer defined
  1542. by <replaceable>EXTERNALSRC</replaceable>.
  1543. <literallayout class='monospaced'>
  1544. recipetool create -o <replaceable>OUTFILE</replaceable> -x <replaceable>EXTERNALSRC</replaceable> <replaceable>source</replaceable>
  1545. </literallayout>
  1546. Use this syntax to generate a recipe based on
  1547. <replaceable>source</replaceable>.
  1548. The options direct <filename>recipetool</filename> to
  1549. generate debugging information.
  1550. Once generated, the recipe resides in the existing source
  1551. code layer:
  1552. <literallayout class='monospaced'>
  1553. recipetool create -d -o <replaceable>OUTFILE</replaceable> <replaceable>source</replaceable>
  1554. </literallayout>
  1555. </para>
  1556. </section>
  1557. <section id='new-recipe-locating-and-using-a-similar-recipe'>
  1558. <title>Locating and Using a Similar Recipe</title>
  1559. <para>
  1560. Before writing a recipe from scratch, it is often useful to
  1561. discover whether someone else has already written one that
  1562. meets (or comes close to meeting) your needs.
  1563. The Yocto Project and OpenEmbedded communities maintain many
  1564. recipes that might be candidates for what you are doing.
  1565. You can find a good central index of these recipes in the
  1566. <ulink url='http://layers.openembedded.org'>OpenEmbedded Layer Index</ulink>.
  1567. </para>
  1568. <para>
  1569. Working from an existing recipe or a skeleton recipe is the
  1570. best way to get started.
  1571. Here are some points on both methods:
  1572. <itemizedlist>
  1573. <listitem><para><emphasis>Locate and modify a recipe that
  1574. is close to what you want to do:</emphasis>
  1575. This method works when you are familiar with the
  1576. current recipe space.
  1577. The method does not work so well for those new to
  1578. the Yocto Project or writing recipes.</para>
  1579. <para>Some risks associated with this method are
  1580. using a recipe that has areas totally unrelated to
  1581. what you are trying to accomplish with your recipe,
  1582. not recognizing areas of the recipe that you might
  1583. have to add from scratch, and so forth.
  1584. All these risks stem from unfamiliarity with the
  1585. existing recipe space.</para></listitem>
  1586. <listitem><para><emphasis>Use and modify the following
  1587. skeleton recipe:</emphasis>
  1588. If for some reason you do not want to use
  1589. <filename>recipetool</filename> and you cannot
  1590. find an existing recipe that is close to meeting
  1591. your needs, you can use the following structure to
  1592. provide the fundamental areas of a new recipe.
  1593. <literallayout class='monospaced'>
  1594. DESCRIPTION = ""
  1595. HOMEPAGE = ""
  1596. LICENSE = ""
  1597. SECTION = ""
  1598. DEPENDS = ""
  1599. LIC_FILES_CHKSUM = ""
  1600. SRC_URI = ""
  1601. </literallayout>
  1602. </para></listitem>
  1603. </itemizedlist>
  1604. </para>
  1605. </section>
  1606. </section>
  1607. <section id='new-recipe-storing-and-naming-the-recipe'>
  1608. <title>Storing and Naming the Recipe</title>
  1609. <para>
  1610. Once you have your base recipe, you should put it in your
  1611. own layer and name it appropriately.
  1612. Locating it correctly ensures that the OpenEmbedded build
  1613. system can find it when you use BitBake to process the
  1614. recipe.
  1615. </para>
  1616. <itemizedlist>
  1617. <listitem><para><emphasis>Storing Your Recipe:</emphasis>
  1618. The OpenEmbedded build system locates your recipe
  1619. through the layer's <filename>conf/layer.conf</filename>
  1620. file and the
  1621. <ulink url='&YOCTO_DOCS_REF_URL;#var-BBFILES'><filename>BBFILES</filename></ulink>
  1622. variable.
  1623. This variable sets up a path from which the build system can
  1624. locate recipes.
  1625. Here is the typical use:
  1626. <literallayout class='monospaced'>
  1627. BBFILES += "${LAYERDIR}/recipes-*/*/*.bb \
  1628. ${LAYERDIR}/recipes-*/*/*.bbappend"
  1629. </literallayout>
  1630. Consequently, you need to be sure you locate your new recipe
  1631. inside your layer such that it can be found.</para>
  1632. <para>You can find more information on how layers are
  1633. structured in the
  1634. "<link linkend='understanding-and-creating-layers'>Understanding and Creating Layers</link>"
  1635. section.</para></listitem>
  1636. <listitem><para><emphasis>Naming Your Recipe:</emphasis>
  1637. When you name your recipe, you need to follow this naming
  1638. convention:
  1639. <literallayout class='monospaced'>
  1640. <replaceable>basename</replaceable>_<replaceable>version</replaceable>.bb
  1641. </literallayout>
  1642. Use lower-cased characters and do not include the reserved
  1643. suffixes <filename>-native</filename>,
  1644. <filename>-cross</filename>, <filename>-initial</filename>,
  1645. or <filename>-dev</filename> casually (i.e. do not use them
  1646. as part of your recipe name unless the string applies).
  1647. Here are some examples:
  1648. <literallayout class='monospaced'>
  1649. cups_1.7.0.bb
  1650. gawk_4.0.2.bb
  1651. irssi_0.8.16-rc1.bb
  1652. </literallayout></para></listitem>
  1653. </itemizedlist>
  1654. </section>
  1655. <section id='new-recipe-running-a-build-on-the-recipe'>
  1656. <title>Running a Build on the Recipe</title>
  1657. <para>
  1658. Creating a new recipe is usually an iterative process that
  1659. requires using BitBake to process the recipe multiple times in
  1660. order to progressively discover and add information to the
  1661. recipe file.
  1662. </para>
  1663. <para>
  1664. Assuming you have sourced the build environment setup script (i.e.
  1665. <ulink url='&YOCTO_DOCS_REF_URL;#structure-core-script'><filename>&OE_INIT_FILE;</filename></ulink>)
  1666. and you are in the
  1667. <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink>,
  1668. use BitBake to process your recipe.
  1669. All you need to provide is the
  1670. <filename><replaceable>basename</replaceable></filename> of the recipe as described
  1671. in the previous section:
  1672. <literallayout class='monospaced'>
  1673. $ bitbake <replaceable>basename</replaceable>
  1674. </literallayout>
  1675. </para>
  1676. <para>
  1677. During the build, the OpenEmbedded build system creates a
  1678. temporary work directory for each recipe
  1679. (<filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-WORKDIR'><filename>WORKDIR</filename></ulink><filename>}</filename>)
  1680. where it keeps extracted source files, log files, intermediate
  1681. compilation and packaging files, and so forth.
  1682. </para>
  1683. <para>
  1684. The path to the per-recipe temporary work directory depends
  1685. on the context in which it is being built.
  1686. The quickest way to find this path is to have BitBake return it
  1687. by running the following:
  1688. <literallayout class='monospaced'>
  1689. $ bitbake -e <replaceable>basename</replaceable> | grep ^WORKDIR=
  1690. </literallayout>
  1691. As an example, assume a Source Directory top-level folder named
  1692. <filename>poky</filename>, a default Build Directory at
  1693. <filename>poky/build</filename>, and a
  1694. <filename>qemux86-poky-linux</filename> machine target system.
  1695. Furthermore, suppose your recipe is named
  1696. <filename>foo_1.3.0.bb</filename>.
  1697. In this case, the work directory the build system uses to
  1698. build the package would be as follows:
  1699. <literallayout class='monospaced'>
  1700. poky/build/tmp/work/qemux86-poky-linux/foo/1.3.0-r0
  1701. </literallayout>
  1702. Inside this directory you can find sub-directories such as
  1703. <filename>image</filename>, <filename>packages-split</filename>,
  1704. and <filename>temp</filename>.
  1705. After the build, you can examine these to determine how well
  1706. the build went.
  1707. <note>
  1708. You can find log files for each task in the recipe's
  1709. <filename>temp</filename> directory (e.g.
  1710. <filename>poky/build/tmp/work/qemux86-poky-linux/foo/1.3.0-r0/temp</filename>).
  1711. Log files are named <filename>log.<replaceable>taskname</replaceable></filename>
  1712. (e.g. <filename>log.do_configure</filename>,
  1713. <filename>log.do_fetch</filename>, and
  1714. <filename>log.do_compile</filename>).
  1715. </note>
  1716. </para>
  1717. <para>
  1718. You can find more information about the build process in
  1719. "<ulink url='&YOCTO_DOCS_OM_URL;#overview-development-environment'>The Yocto Project Development Environment</ulink>"
  1720. chapter of the Yocto Project Overview and Concepts Manual.
  1721. </para>
  1722. </section>
  1723. <section id='new-recipe-fetching-code'>
  1724. <title>Fetching Code</title>
  1725. <para>
  1726. The first thing your recipe must do is specify how to fetch
  1727. the source files.
  1728. Fetching is controlled mainly through the
  1729. <ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'><filename>SRC_URI</filename></ulink>
  1730. variable.
  1731. Your recipe must have a <filename>SRC_URI</filename> variable
  1732. that points to where the source is located.
  1733. For a graphical representation of source locations, see the
  1734. "<ulink url='&YOCTO_DOCS_OM_URL;#sources-dev-environment'>Sources</ulink>"
  1735. section in the Yocto Project Overview and Concepts Manual.
  1736. </para>
  1737. <para>
  1738. The
  1739. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-fetch'><filename>do_fetch</filename></ulink>
  1740. task uses the prefix of each entry in the
  1741. <filename>SRC_URI</filename> variable value to determine which
  1742. fetcher to use to get your source files.
  1743. It is the <filename>SRC_URI</filename> variable that triggers
  1744. the fetcher.
  1745. The
  1746. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-patch'><filename>do_patch</filename></ulink>
  1747. task uses the variable after source is fetched to apply
  1748. patches.
  1749. The OpenEmbedded build system uses
  1750. <ulink url='&YOCTO_DOCS_REF_URL;#var-FILESOVERRIDES'><filename>FILESOVERRIDES</filename></ulink>
  1751. for scanning directory locations for local files in
  1752. <filename>SRC_URI</filename>.
  1753. </para>
  1754. <para>
  1755. The <filename>SRC_URI</filename> variable in your recipe must
  1756. define each unique location for your source files.
  1757. It is good practice to not hard-code pathnames in an URL used
  1758. in <filename>SRC_URI</filename>.
  1759. Rather than hard-code these paths, use
  1760. <filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-PV'><filename>PV</filename></ulink><filename>}</filename>,
  1761. which causes the fetch process to use the version specified in
  1762. the recipe filename.
  1763. Specifying the version in this manner means that upgrading the
  1764. recipe to a future version is as simple as renaming the recipe
  1765. to match the new version.
  1766. </para>
  1767. <para>
  1768. Here is a simple example from the
  1769. <filename>meta/recipes-devtools/cdrtools/cdrtools-native_3.01a20.bb</filename>
  1770. recipe where the source comes from a single tarball.
  1771. Notice the use of the
  1772. <ulink url='&YOCTO_DOCS_REF_URL;#var-PV'><filename>PV</filename></ulink>
  1773. variable:
  1774. <literallayout class='monospaced'>
  1775. SRC_URI = "ftp://ftp.berlios.de/pub/cdrecord/alpha/cdrtools-${PV}.tar.bz2"
  1776. </literallayout>
  1777. </para>
  1778. <para>
  1779. Files mentioned in <filename>SRC_URI</filename> whose names end
  1780. in a typical archive extension (e.g. <filename>.tar</filename>,
  1781. <filename>.tar.gz</filename>, <filename>.tar.bz2</filename>,
  1782. <filename>.zip</filename>, and so forth), are automatically
  1783. extracted during the
  1784. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-unpack'><filename>do_unpack</filename></ulink>
  1785. task.
  1786. For another example that specifies these types of files, see
  1787. the
  1788. "<link linkend='new-recipe-autotooled-package'>Autotooled Package</link>"
  1789. section.
  1790. </para>
  1791. <para>
  1792. Another way of specifying source is from an SCM.
  1793. For Git repositories, you must specify
  1794. <ulink url='&YOCTO_DOCS_REF_URL;#var-SRCREV'><filename>SRCREV</filename></ulink>
  1795. and you should specify
  1796. <ulink url='&YOCTO_DOCS_REF_URL;#var-PV'><filename>PV</filename></ulink>
  1797. to include the revision with
  1798. <ulink url='&YOCTO_DOCS_REF_URL;#var-SRCPV'><filename>SRCPV</filename></ulink>.
  1799. Here is an example from the recipe
  1800. <filename>meta/recipes-kernel/blktrace/blktrace_git.bb</filename>:
  1801. <literallayout class='monospaced'>
  1802. SRCREV = "d6918c8832793b4205ed3bfede78c2f915c23385"
  1803. PR = "r6"
  1804. PV = "1.0.5+git${SRCPV}"
  1805. SRC_URI = "git://git.kernel.dk/blktrace.git \
  1806. file://ldflags.patch"
  1807. </literallayout>
  1808. </para>
  1809. <para>
  1810. If your <filename>SRC_URI</filename> statement includes
  1811. URLs pointing to individual files fetched from a remote server
  1812. other than a version control system, BitBake attempts to
  1813. verify the files against checksums defined in your recipe to
  1814. ensure they have not been tampered with or otherwise modified
  1815. since the recipe was written.
  1816. Two checksums are used:
  1817. <filename>SRC_URI[md5sum]</filename> and
  1818. <filename>SRC_URI[sha256sum]</filename>.
  1819. </para>
  1820. <para>
  1821. If your <filename>SRC_URI</filename> variable points to
  1822. more than a single URL (excluding SCM URLs), you need to
  1823. provide the <filename>md5</filename> and
  1824. <filename>sha256</filename> checksums for each URL.
  1825. For these cases, you provide a name for each URL as part of
  1826. the <filename>SRC_URI</filename> and then reference that name
  1827. in the subsequent checksum statements.
  1828. Here is an example:
  1829. <literallayout class='monospaced'>
  1830. SRC_URI = "${DEBIAN_MIRROR}/main/a/apmd/apmd_3.2.2.orig.tar.gz;name=tarball \
  1831. ${DEBIAN_MIRROR}/main/a/apmd/apmd_${PV}.diff.gz;name=patch"
  1832. SRC_URI[tarball.md5sum] = "b1e6309e8331e0f4e6efd311c2d97fa8"
  1833. SRC_URI[tarball.sha256sum] = "7f7d9f60b7766b852881d40b8ff91d8e39fccb0d1d913102a5c75a2dbb52332d"
  1834. SRC_URI[patch.md5sum] = "57e1b689264ea80f78353519eece0c92"
  1835. SRC_URI[patch.sha256sum] = "7905ff96be93d725544d0040e425c42f9c05580db3c272f11cff75b9aa89d430"
  1836. </literallayout>
  1837. </para>
  1838. <para>
  1839. Proper values for <filename>md5</filename> and
  1840. <filename>sha256</filename> checksums might be available
  1841. with other signatures on the download page for the upstream
  1842. source (e.g. <filename>md5</filename>,
  1843. <filename>sha1</filename>, <filename>sha256</filename>,
  1844. <filename>GPG</filename>, and so forth).
  1845. Because the OpenEmbedded build system only deals with
  1846. <filename>sha256sum</filename> and <filename>md5sum</filename>,
  1847. you should verify all the signatures you find by hand.
  1848. </para>
  1849. <para>
  1850. If no <filename>SRC_URI</filename> checksums are specified
  1851. when you attempt to build the recipe, or you provide an
  1852. incorrect checksum, the build will produce an error for each
  1853. missing or incorrect checksum.
  1854. As part of the error message, the build system provides
  1855. the checksum string corresponding to the fetched file.
  1856. Once you have the correct checksums, you can copy and paste
  1857. them into your recipe and then run the build again to continue.
  1858. <note>
  1859. As mentioned, if the upstream source provides signatures
  1860. for verifying the downloaded source code, you should
  1861. verify those manually before setting the checksum values
  1862. in the recipe and continuing with the build.
  1863. </note>
  1864. </para>
  1865. <para>
  1866. This final example is a bit more complicated and is from the
  1867. <filename>meta/recipes-sato/rxvt-unicode/rxvt-unicode_9.20.bb</filename>
  1868. recipe.
  1869. The example's <filename>SRC_URI</filename> statement identifies
  1870. multiple files as the source files for the recipe: a tarball, a
  1871. patch file, a desktop file, and an icon.
  1872. <literallayout class='monospaced'>
  1873. SRC_URI = "http://dist.schmorp.de/rxvt-unicode/Attic/rxvt-unicode-${PV}.tar.bz2 \
  1874. file://xwc.patch \
  1875. file://rxvt.desktop \
  1876. file://rxvt.png"
  1877. </literallayout>
  1878. </para>
  1879. <para>
  1880. When you specify local files using the
  1881. <filename>file://</filename> URI protocol, the build system
  1882. fetches files from the local machine.
  1883. The path is relative to the
  1884. <ulink url='&YOCTO_DOCS_REF_URL;#var-FILESPATH'><filename>FILESPATH</filename></ulink>
  1885. variable and searches specific directories in a certain order:
  1886. <filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-BP'><filename>BP</filename></ulink><filename>}</filename>,
  1887. <filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-BPN'><filename>BPN</filename></ulink><filename>}</filename>,
  1888. and <filename>files</filename>.
  1889. The directories are assumed to be subdirectories of the
  1890. directory in which the recipe or append file resides.
  1891. For another example that specifies these types of files, see the
  1892. "<link linkend='new-recipe-single-c-file-package-hello-world'>Single .c File Package (Hello World!)</link>"
  1893. section.
  1894. </para>
  1895. <para>
  1896. The previous example also specifies a patch file.
  1897. Patch files are files whose names usually end in
  1898. <filename>.patch</filename> or <filename>.diff</filename> but
  1899. can end with compressed suffixes such as
  1900. <filename>diff.gz</filename> and
  1901. <filename>patch.bz2</filename>, for example.
  1902. The build system automatically applies patches as described
  1903. in the
  1904. "<link linkend='new-recipe-patching-code'>Patching Code</link>" section.
  1905. </para>
  1906. </section>
  1907. <section id='new-recipe-unpacking-code'>
  1908. <title>Unpacking Code</title>
  1909. <para>
  1910. During the build, the
  1911. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-unpack'><filename>do_unpack</filename></ulink>
  1912. task unpacks the source with
  1913. <filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-S'><filename>S</filename></ulink><filename>}</filename>
  1914. pointing to where it is unpacked.
  1915. </para>
  1916. <para>
  1917. If you are fetching your source files from an upstream source
  1918. archived tarball and the tarball's internal structure matches
  1919. the common convention of a top-level subdirectory named
  1920. <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>,
  1921. then you do not need to set <filename>S</filename>.
  1922. However, if <filename>SRC_URI</filename> specifies to fetch
  1923. source from an archive that does not use this convention,
  1924. or from an SCM like Git or Subversion, your recipe needs to
  1925. define <filename>S</filename>.
  1926. </para>
  1927. <para>
  1928. If processing your recipe using BitBake successfully unpacks
  1929. the source files, you need to be sure that the directory
  1930. pointed to by <filename>${S}</filename> matches the structure
  1931. of the source.
  1932. </para>
  1933. </section>
  1934. <section id='new-recipe-patching-code'>
  1935. <title>Patching Code</title>
  1936. <para>
  1937. Sometimes it is necessary to patch code after it has been
  1938. fetched.
  1939. Any files mentioned in <filename>SRC_URI</filename> whose
  1940. names end in <filename>.patch</filename> or
  1941. <filename>.diff</filename> or compressed versions of these
  1942. suffixes (e.g. <filename>diff.gz</filename> are treated as
  1943. patches.
  1944. The
  1945. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-patch'><filename>do_patch</filename></ulink>
  1946. task automatically applies these patches.
  1947. </para>
  1948. <para>
  1949. The build system should be able to apply patches with the "-p1"
  1950. option (i.e. one directory level in the path will be stripped
  1951. off).
  1952. If your patch needs to have more directory levels stripped off,
  1953. specify the number of levels using the "striplevel" option in
  1954. the <filename>SRC_URI</filename> entry for the patch.
  1955. Alternatively, if your patch needs to be applied in a specific
  1956. subdirectory that is not specified in the patch file, use the
  1957. "patchdir" option in the entry.
  1958. </para>
  1959. <para>
  1960. As with all local files referenced in
  1961. <ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'><filename>SRC_URI</filename></ulink>
  1962. using <filename>file://</filename>, you should place
  1963. patch files in a directory next to the recipe either
  1964. named the same as the base name of the recipe
  1965. (<ulink url='&YOCTO_DOCS_REF_URL;#var-BP'><filename>BP</filename></ulink>
  1966. and
  1967. <ulink url='&YOCTO_DOCS_REF_URL;#var-BPN'><filename>BPN</filename></ulink>)
  1968. or "files".
  1969. </para>
  1970. </section>
  1971. <section id='new-recipe-licensing'>
  1972. <title>Licensing</title>
  1973. <para>
  1974. Your recipe needs to have both the
  1975. <ulink url='&YOCTO_DOCS_REF_URL;#var-LICENSE'><filename>LICENSE</filename></ulink>
  1976. and
  1977. <ulink url='&YOCTO_DOCS_REF_URL;#var-LIC_FILES_CHKSUM'><filename>LIC_FILES_CHKSUM</filename></ulink>
  1978. variables:
  1979. <itemizedlist>
  1980. <listitem><para><emphasis><filename>LICENSE</filename>:</emphasis>
  1981. This variable specifies the license for the software.
  1982. If you do not know the license under which the software
  1983. you are building is distributed, you should go to the
  1984. source code and look for that information.
  1985. Typical files containing this information include
  1986. <filename>COPYING</filename>,
  1987. <filename>LICENSE</filename>, and
  1988. <filename>README</filename> files.
  1989. You could also find the information near the top of
  1990. a source file.
  1991. For example, given a piece of software licensed under
  1992. the GNU General Public License version 2, you would
  1993. set <filename>LICENSE</filename> as follows:
  1994. <literallayout class='monospaced'>
  1995. LICENSE = "GPLv2"
  1996. </literallayout></para>
  1997. <para>The licenses you specify within
  1998. <filename>LICENSE</filename> can have any name as long
  1999. as you do not use spaces, since spaces are used as
  2000. separators between license names.
  2001. For standard licenses, use the names of the files in
  2002. <filename>meta/files/common-licenses/</filename>
  2003. or the <filename>SPDXLICENSEMAP</filename> flag names
  2004. defined in <filename>meta/conf/licenses.conf</filename>.
  2005. </para></listitem>
  2006. <listitem><para><emphasis><filename>LIC_FILES_CHKSUM</filename>:</emphasis>
  2007. The OpenEmbedded build system uses this variable to
  2008. make sure the license text has not changed.
  2009. If it has, the build produces an error and it affords
  2010. you the chance to figure it out and correct the problem.
  2011. </para>
  2012. <para>You need to specify all applicable licensing
  2013. files for the software.
  2014. At the end of the configuration step, the build process
  2015. will compare the checksums of the files to be sure
  2016. the text has not changed.
  2017. Any differences result in an error with the message
  2018. containing the current checksum.
  2019. For more explanation and examples of how to set the
  2020. <filename>LIC_FILES_CHKSUM</filename> variable, see the
  2021. "<ulink url='&YOCTO_DOCS_OM_URL;#usingpoky-configuring-LIC_FILES_CHKSUM'>Tracking License Changes</ulink>"
  2022. section in the Yocto Project Overview and Concepts
  2023. Manual.</para>
  2024. <para>To determine the correct checksum string, you
  2025. can list the appropriate files in the
  2026. <filename>LIC_FILES_CHKSUM</filename> variable with
  2027. incorrect md5 strings, attempt to build the software,
  2028. and then note the resulting error messages that will
  2029. report the correct md5 strings.
  2030. See the
  2031. "<link linkend='new-recipe-fetching-code'>Fetching Code</link>"
  2032. section for additional information.
  2033. </para>
  2034. <para>
  2035. Here is an example that assumes the software has a
  2036. <filename>COPYING</filename> file:
  2037. <literallayout class='monospaced'>
  2038. LIC_FILES_CHKSUM = "file://COPYING;md5=xxx"
  2039. </literallayout>
  2040. When you try to build the software, the build system
  2041. will produce an error and give you the correct string
  2042. that you can substitute into the recipe file for a
  2043. subsequent build.
  2044. </para></listitem>
  2045. </itemizedlist>
  2046. </para>
  2047. <!--
  2048. <para>
  2049. For trying this out I created a new recipe named
  2050. <filename>htop_1.0.2.bb</filename> and put it in
  2051. <filename>poky/meta/recipes-extended/htop</filename>.
  2052. There are two license type statements in my very simple
  2053. recipe:
  2054. <literallayout class='monospaced'>
  2055. LICENSE = ""
  2056. LIC_FILES_CHKSUM = ""
  2057. SRC_URI[md5sum] = ""
  2058. SRC_URI[sha256sum] = ""
  2059. </literallayout>
  2060. Evidently, you need to run a <filename>bitbake -c cleanall htop</filename>.
  2061. Next, you delete or comment out the two <filename>SRC_URI</filename>
  2062. lines at the end and then attempt to build the software with
  2063. <filename>bitbake htop</filename>.
  2064. Doing so causes BitBake to report some errors and and give
  2065. you the actual strings you need for the last two
  2066. <filename>SRC_URI</filename> lines.
  2067. Prior to this, you have to dig around in the home page of the
  2068. source for <filename>htop</filename> and determine that the
  2069. software is released under GPLv2.
  2070. You can provide that in the <filename>LICENSE</filename>
  2071. statement.
  2072. Now you edit your recipe to have those two strings for
  2073. the <filename>SRC_URI</filename> statements:
  2074. <literallayout class='monospaced'>
  2075. LICENSE = "GPLv2"
  2076. LIC_FILES_CHKSUM = ""
  2077. SRC_URI = "${SOURCEFORGE_MIRROR}/htop/htop-${PV}.tar.gz"
  2078. SRC_URI[md5sum] = "0d01cca8df3349c74569cefebbd9919e"
  2079. SRC_URI[sha256sum] = "ee60657b044ece0df096c053060df7abf3cce3a568ab34d260049e6a37ccd8a1"
  2080. </literallayout>
  2081. At this point, you can build the software again using the
  2082. <filename>bitbake htop</filename> command.
  2083. There is just a set of errors now associated with the
  2084. empty <filename>LIC_FILES_CHKSUM</filename> variable now.
  2085. </para>
  2086. -->
  2087. </section>
  2088. <section id='new-dependencies'>
  2089. <title>Dependencies</title>
  2090. <para>
  2091. Most software packages have a short list of other packages
  2092. that they require, which are called dependencies.
  2093. These dependencies fall into two main categories: build-time
  2094. dependencies, which are required when the software is built;
  2095. and runtime dependencies, which are required to be installed
  2096. on the target in order for the software to run.
  2097. </para>
  2098. <para>
  2099. Within a recipe, you specify build-time dependencies using the
  2100. <ulink url='&YOCTO_DOCS_REF_URL;#var-DEPENDS'><filename>DEPENDS</filename></ulink>
  2101. variable.
  2102. Although nuances exist, items specified in
  2103. <filename>DEPENDS</filename> should be names of other recipes.
  2104. It is important that you specify all build-time dependencies
  2105. explicitly.
  2106. If you do not, due to the parallel nature of BitBake's
  2107. execution, you can end up with a race condition where the
  2108. dependency is present for one task of a recipe (e.g.
  2109. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-configure'><filename>do_configure</filename></ulink>)
  2110. and then gone when the next task runs (e.g.
  2111. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-compile'><filename>do_compile</filename></ulink>).
  2112. </para>
  2113. <para>
  2114. Another consideration is that configure scripts might
  2115. automatically check for optional dependencies and enable
  2116. corresponding functionality if those dependencies are found.
  2117. This behavior means that to ensure deterministic results and
  2118. thus avoid more race conditions, you need to either explicitly
  2119. specify these dependencies as well, or tell the configure
  2120. script explicitly to disable the functionality.
  2121. If you wish to make a recipe that is more generally useful
  2122. (e.g. publish the recipe in a layer for others to use),
  2123. instead of hard-disabling the functionality, you can use the
  2124. <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGECONFIG'><filename>PACKAGECONFIG</filename></ulink>
  2125. variable to allow functionality and the corresponding
  2126. dependencies to be enabled and disabled easily by other
  2127. users of the recipe.
  2128. </para>
  2129. <para>
  2130. Similar to build-time dependencies, you specify runtime
  2131. dependencies through a variable -
  2132. <ulink url='&YOCTO_DOCS_REF_URL;#var-RDEPENDS'><filename>RDEPENDS</filename></ulink>,
  2133. which is package-specific.
  2134. All variables that are package-specific need to have the name
  2135. of the package added to the end as an override.
  2136. Since the main package for a recipe has the same name as the
  2137. recipe, and the recipe's name can be found through the
  2138. <filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-PN'><filename>PN</filename></ulink><filename>}</filename>
  2139. variable, then you specify the dependencies for the main
  2140. package by setting <filename>RDEPENDS_${PN}</filename>.
  2141. If the package were named <filename>${PN}-tools</filename>,
  2142. then you would set <filename>RDEPENDS_${PN}-tools</filename>,
  2143. and so forth.
  2144. </para>
  2145. <para>
  2146. Some runtime dependencies will be set automatically at
  2147. packaging time.
  2148. These dependencies include any shared library dependencies
  2149. (i.e. if a package "example" contains "libexample" and
  2150. another package "mypackage" contains a binary that links to
  2151. "libexample" then the OpenEmbedded build system will
  2152. automatically add a runtime dependency to "mypackage" on
  2153. "example").
  2154. See the
  2155. "<ulink url='&YOCTO_DOCS_OM_URL;#automatically-added-runtime-dependencies'>Automatically Added Runtime Dependencies</ulink>"
  2156. section in the Yocto Project Overview and Concepts Manual for
  2157. further details.
  2158. </para>
  2159. </section>
  2160. <section id='new-recipe-configuring-the-recipe'>
  2161. <title>Configuring the Recipe</title>
  2162. <para>
  2163. Most software provides some means of setting build-time
  2164. configuration options before compilation.
  2165. Typically, setting these options is accomplished by running a
  2166. configure script with some options, or by modifying a build
  2167. configuration file.
  2168. <note>
  2169. As of Yocto Project Release 1.7, some of the core recipes
  2170. that package binary configuration scripts now disable the
  2171. scripts due to the scripts previously requiring error-prone
  2172. path substitution.
  2173. The OpenEmbedded build system uses
  2174. <filename>pkg-config</filename> now, which is much more
  2175. robust.
  2176. You can find a list of the <filename>*-config</filename>
  2177. scripts that are disabled list in the
  2178. "<ulink url='&YOCTO_DOCS_REF_URL;#migration-1.7-binary-configuration-scripts-disabled'>Binary Configuration Scripts Disabled</ulink>"
  2179. section in the Yocto Project Reference Manual.
  2180. </note>
  2181. </para>
  2182. <para>
  2183. A major part of build-time configuration is about checking for
  2184. build-time dependencies and possibly enabling optional
  2185. functionality as a result.
  2186. You need to specify any build-time dependencies for the
  2187. software you are building in your recipe's
  2188. <ulink url='&YOCTO_DOCS_REF_URL;#var-DEPENDS'><filename>DEPENDS</filename></ulink>
  2189. value, in terms of other recipes that satisfy those
  2190. dependencies.
  2191. You can often find build-time or runtime
  2192. dependencies described in the software's documentation.
  2193. </para>
  2194. <para>
  2195. The following list provides configuration items of note based
  2196. on how your software is built:
  2197. <itemizedlist>
  2198. <listitem><para><emphasis>Autotools:</emphasis>
  2199. If your source files have a
  2200. <filename>configure.ac</filename> file, then your
  2201. software is built using Autotools.
  2202. If this is the case, you just need to worry about
  2203. modifying the configuration.</para>
  2204. <para>When using Autotools, your recipe needs to inherit
  2205. the
  2206. <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-autotools'><filename>autotools</filename></ulink>
  2207. class and your recipe does not have to contain a
  2208. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-configure'><filename>do_configure</filename></ulink>
  2209. task.
  2210. However, you might still want to make some adjustments.
  2211. For example, you can set
  2212. <ulink url='&YOCTO_DOCS_REF_URL;#var-EXTRA_OECONF'><filename>EXTRA_OECONF</filename></ulink>
  2213. or
  2214. <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGECONFIG_CONFARGS'><filename>PACKAGECONFIG_CONFARGS</filename></ulink>
  2215. to pass any needed configure options that are specific
  2216. to the recipe.</para></listitem>
  2217. <listitem><para><emphasis>CMake:</emphasis>
  2218. If your source files have a
  2219. <filename>CMakeLists.txt</filename> file, then your
  2220. software is built using CMake.
  2221. If this is the case, you just need to worry about
  2222. modifying the configuration.</para>
  2223. <para>When you use CMake, your recipe needs to inherit
  2224. the
  2225. <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-cmake'><filename>cmake</filename></ulink>
  2226. class and your recipe does not have to contain a
  2227. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-configure'><filename>do_configure</filename></ulink>
  2228. task.
  2229. You can make some adjustments by setting
  2230. <ulink url='&YOCTO_DOCS_REF_URL;#var-EXTRA_OECMAKE'><filename>EXTRA_OECMAKE</filename></ulink>
  2231. to pass any needed configure options that are specific
  2232. to the recipe.</para></listitem>
  2233. <listitem><para><emphasis>Other:</emphasis>
  2234. If your source files do not have a
  2235. <filename>configure.ac</filename> or
  2236. <filename>CMakeLists.txt</filename> file, then your
  2237. software is built using some method other than Autotools
  2238. or CMake.
  2239. If this is the case, you normally need to provide a
  2240. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-configure'><filename>do_configure</filename></ulink>
  2241. task in your recipe
  2242. unless, of course, there is nothing to configure.
  2243. </para>
  2244. <para>Even if your software is not being built by
  2245. Autotools or CMake, you still might not need to deal
  2246. with any configuration issues.
  2247. You need to determine if configuration is even a required step.
  2248. You might need to modify a Makefile or some configuration file
  2249. used for the build to specify necessary build options.
  2250. Or, perhaps you might need to run a provided, custom
  2251. configure script with the appropriate options.</para>
  2252. <para>For the case involving a custom configure
  2253. script, you would run
  2254. <filename>./configure --help</filename> and look for
  2255. the options you need to set.</para></listitem>
  2256. </itemizedlist>
  2257. </para>
  2258. <para>
  2259. Once configuration succeeds, it is always good practice to
  2260. look at the <filename>log.do_configure</filename> file to
  2261. ensure that the appropriate options have been enabled and no
  2262. additional build-time dependencies need to be added to
  2263. <filename>DEPENDS</filename>.
  2264. For example, if the configure script reports that it found
  2265. something not mentioned in <filename>DEPENDS</filename>, or
  2266. that it did not find something that it needed for some
  2267. desired optional functionality, then you would need to add
  2268. those to <filename>DEPENDS</filename>.
  2269. Looking at the log might also reveal items being checked for,
  2270. enabled, or both that you do not want, or items not being found
  2271. that are in <filename>DEPENDS</filename>, in which case
  2272. you would need to look at passing extra options to the
  2273. configure script as needed.
  2274. For reference information on configure options specific to the
  2275. software you are building, you can consult the output of the
  2276. <filename>./configure --help</filename> command within
  2277. <filename>${S}</filename> or consult the software's upstream
  2278. documentation.
  2279. </para>
  2280. </section>
  2281. <section id='new-recipe-using-headers-to-interface-with-devices'>
  2282. <title>Using Headers to Interface with Devices</title>
  2283. <para>
  2284. If your recipe builds an application that needs to
  2285. communicate with some device or needs an API into a custom
  2286. kernel, you will need to provide appropriate header files.
  2287. Under no circumstances should you ever modify the existing
  2288. <filename>meta/recipes-kernel/linux-libc-headers/linux-libc-headers.inc</filename>
  2289. file.
  2290. These headers are used to build <filename>libc</filename> and
  2291. must not be compromised with custom or machine-specific
  2292. header information.
  2293. If you customize <filename>libc</filename> through modified
  2294. headers all other applications that use
  2295. <filename>libc</filename> thus become affected.
  2296. <note><title>Warning</title>
  2297. Never copy and customize the <filename>libc</filename>
  2298. header file (i.e.
  2299. <filename>meta/recipes-kernel/linux-libc-headers/linux-libc-headers.inc</filename>).
  2300. </note>
  2301. The correct way to interface to a device or custom kernel is
  2302. to use a separate package that provides the additional headers
  2303. for the driver or other unique interfaces.
  2304. When doing so, your application also becomes responsible for
  2305. creating a dependency on that specific provider.
  2306. </para>
  2307. <para>
  2308. Consider the following:
  2309. <itemizedlist>
  2310. <listitem><para>
  2311. Never modify
  2312. <filename>linux-libc-headers.inc</filename>.
  2313. Consider that file to be part of the
  2314. <filename>libc</filename> system, and not something
  2315. you use to access the kernel directly.
  2316. You should access <filename>libc</filename> through
  2317. specific <filename>libc</filename> calls.
  2318. </para></listitem>
  2319. <listitem><para>
  2320. Applications that must talk directly to devices
  2321. should either provide necessary headers themselves,
  2322. or establish a dependency on a special headers package
  2323. that is specific to that driver.
  2324. </para></listitem>
  2325. </itemizedlist>
  2326. </para>
  2327. <para>
  2328. For example, suppose you want to modify an existing header
  2329. that adds I/O control or network support.
  2330. If the modifications are used by a small number programs,
  2331. providing a unique version of a header is easy and has little
  2332. impact.
  2333. When doing so, bear in mind the guidelines in the previous
  2334. list.
  2335. <note>
  2336. If for some reason your changes need to modify the behavior
  2337. of the <filename>libc</filename>, and subsequently all
  2338. other applications on the system, use a
  2339. <filename>.bbappend</filename> to modify the
  2340. <filename>linux-kernel-headers.inc</filename> file.
  2341. However, take care to not make the changes
  2342. machine specific.
  2343. </note>
  2344. </para>
  2345. <para>
  2346. Consider a case where your kernel is older and you need
  2347. an older <filename>libc</filename> ABI.
  2348. The headers installed by your recipe should still be a
  2349. standard mainline kernel, not your own custom one.
  2350. </para>
  2351. <para>
  2352. When you use custom kernel headers you need to get them from
  2353. <ulink url='&YOCTO_DOCS_REF_URL;#var-STAGING_KERNEL_DIR'><filename>STAGING_KERNEL_DIR</filename></ulink>,
  2354. which is the directory with kernel headers that are
  2355. required to build out-of-tree modules.
  2356. Your recipe will also need the following:
  2357. <literallayout class='monospaced'>
  2358. do_configure[depends] += "virtual/kernel:do_shared_workdir"
  2359. </literallayout>
  2360. </para>
  2361. </section>
  2362. <section id='new-recipe-compilation'>
  2363. <title>Compilation</title>
  2364. <para>
  2365. During a build, the <filename>do_compile</filename> task
  2366. happens after source is fetched, unpacked, and configured.
  2367. If the recipe passes through <filename>do_compile</filename>
  2368. successfully, nothing needs to be done.
  2369. </para>
  2370. <para>
  2371. However, if the compile step fails, you need to diagnose the
  2372. failure.
  2373. Here are some common issues that cause failures.
  2374. <note>
  2375. For cases where improper paths are detected for
  2376. configuration files or for when libraries/headers cannot
  2377. be found, be sure you are using the more robust
  2378. <filename>pkg-config</filename>.
  2379. See the note in section
  2380. "<link linkend='new-recipe-configuring-the-recipe'>Configuring the Recipe</link>"
  2381. for additional information.
  2382. </note>
  2383. <itemizedlist>
  2384. <listitem><para><emphasis>Parallel build failures:</emphasis>
  2385. These failures manifest themselves as intermittent
  2386. errors, or errors reporting that a file or directory
  2387. that should be created by some other part of the build
  2388. process could not be found.
  2389. This type of failure can occur even if, upon inspection,
  2390. the file or directory does exist after the build has
  2391. failed, because that part of the build process happened
  2392. in the wrong order.</para>
  2393. <para>To fix the problem, you need to either satisfy
  2394. the missing dependency in the Makefile or whatever
  2395. script produced the Makefile, or (as a workaround)
  2396. set
  2397. <ulink url='&YOCTO_DOCS_REF_URL;#var-PARALLEL_MAKE'><filename>PARALLEL_MAKE</filename></ulink>
  2398. to an empty string:
  2399. <literallayout class='monospaced'>
  2400. PARALLEL_MAKE = ""
  2401. </literallayout></para>
  2402. <para>
  2403. For information on parallel Makefile issues, see the
  2404. "<link linkend='debugging-parallel-make-races'>Debugging Parallel Make Races</link>"
  2405. section.
  2406. </para></listitem>
  2407. <listitem><para><emphasis>Improper host path usage:</emphasis>
  2408. This failure applies to recipes building for the target
  2409. or <filename>nativesdk</filename> only.
  2410. The failure occurs when the compilation process uses
  2411. improper headers, libraries, or other files from the
  2412. host system when cross-compiling for the target.
  2413. </para>
  2414. <para>To fix the problem, examine the
  2415. <filename>log.do_compile</filename> file to identify
  2416. the host paths being used (e.g.
  2417. <filename>/usr/include</filename>,
  2418. <filename>/usr/lib</filename>, and so forth) and then
  2419. either add configure options, apply a patch, or do both.
  2420. </para></listitem>
  2421. <listitem><para><emphasis>Failure to find required
  2422. libraries/headers:</emphasis>
  2423. If a build-time dependency is missing because it has
  2424. not been declared in
  2425. <ulink url='&YOCTO_DOCS_REF_URL;#var-DEPENDS'><filename>DEPENDS</filename></ulink>,
  2426. or because the dependency exists but the path used by
  2427. the build process to find the file is incorrect and the
  2428. configure step did not detect it, the compilation
  2429. process could fail.
  2430. For either of these failures, the compilation process
  2431. notes that files could not be found.
  2432. In these cases, you need to go back and add additional
  2433. options to the configure script as well as possibly
  2434. add additional build-time dependencies to
  2435. <filename>DEPENDS</filename>.</para>
  2436. <para>Occasionally, it is necessary to apply a patch
  2437. to the source to ensure the correct paths are used.
  2438. If you need to specify paths to find files staged
  2439. into the sysroot from other recipes, use the variables
  2440. that the OpenEmbedded build system provides
  2441. (e.g.
  2442. <filename>STAGING_BINDIR</filename>,
  2443. <filename>STAGING_INCDIR</filename>,
  2444. <filename>STAGING_DATADIR</filename>, and so forth).
  2445. <!--
  2446. (e.g.
  2447. <ulink url='&YOCTO_DOCS_REF_URL;#var-STAGING_BINDIR'><filename>STAGING_BINDIR</filename></ulink>,
  2448. <ulink url='&YOCTO_DOCS_REF_URL;#var-STAGING_INCDIR'><filename>STAGING_INCDIR</filename></ulink>,
  2449. <ulink url='&YOCTO_DOCS_REF_URL;#var-STAGING_DATADIR'><filename>STAGING_DATADIR</filename></ulink>,
  2450. and so forth).
  2451. -->
  2452. </para></listitem>
  2453. </itemizedlist>
  2454. </para>
  2455. </section>
  2456. <section id='new-recipe-installing'>
  2457. <title>Installing</title>
  2458. <para>
  2459. During <filename>do_install</filename>, the task copies the
  2460. built files along with their hierarchy to locations that
  2461. would mirror their locations on the target device.
  2462. The installation process copies files from the
  2463. <filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-S'><filename>S</filename></ulink><filename>}</filename>,
  2464. <filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-B'><filename>B</filename></ulink><filename>}</filename>,
  2465. and
  2466. <filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-WORKDIR'><filename>WORKDIR</filename></ulink><filename>}</filename>
  2467. directories to the
  2468. <filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-D'><filename>D</filename></ulink><filename>}</filename>
  2469. directory to create the structure as it should appear on the
  2470. target system.
  2471. </para>
  2472. <para>
  2473. How your software is built affects what you must do to be
  2474. sure your software is installed correctly.
  2475. The following list describes what you must do for installation
  2476. depending on the type of build system used by the software
  2477. being built:
  2478. <itemizedlist>
  2479. <listitem><para><emphasis>Autotools and CMake:</emphasis>
  2480. If the software your recipe is building uses Autotools
  2481. or CMake, the OpenEmbedded build
  2482. system understands how to install the software.
  2483. Consequently, you do not have to have a
  2484. <filename>do_install</filename> task as part of your
  2485. recipe.
  2486. You just need to make sure the install portion of the
  2487. build completes with no issues.
  2488. However, if you wish to install additional files not
  2489. already being installed by
  2490. <filename>make install</filename>, you should do this
  2491. using a <filename>do_install_append</filename> function
  2492. using the install command as described in
  2493. the "Manual" bulleted item later in this list.
  2494. </para></listitem>
  2495. <listitem><para><emphasis>Other (using
  2496. <filename>make install</filename>):</emphasis>
  2497. You need to define a
  2498. <filename>do_install</filename> function in your
  2499. recipe.
  2500. The function should call
  2501. <filename>oe_runmake install</filename> and will likely
  2502. need to pass in the destination directory as well.
  2503. How you pass that path is dependent on how the
  2504. <filename>Makefile</filename> being run is written
  2505. (e.g. <filename>DESTDIR=${D}</filename>,
  2506. <filename>PREFIX=${D}</filename>,
  2507. <filename>INSTALLROOT=${D}</filename>, and so forth).
  2508. </para>
  2509. <para>For an example recipe using
  2510. <filename>make install</filename>, see the
  2511. "<link linkend='new-recipe-makefile-based-package'>Makefile-Based Package</link>"
  2512. section.</para></listitem>
  2513. <listitem><para><emphasis>Manual:</emphasis>
  2514. You need to define a
  2515. <filename>do_install</filename> function in your
  2516. recipe.
  2517. The function must first use
  2518. <filename>install -d</filename> to create the
  2519. directories under
  2520. <filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-D'><filename>D</filename></ulink><filename>}</filename>.
  2521. Once the directories exist, your function can use
  2522. <filename>install</filename> to manually install the
  2523. built software into the directories.</para>
  2524. <para>You can find more information on
  2525. <filename>install</filename> at
  2526. <ulink url='http://www.gnu.org/software/coreutils/manual/html_node/install-invocation.html'></ulink>.
  2527. </para></listitem>
  2528. </itemizedlist>
  2529. </para>
  2530. <para>
  2531. For the scenarios that do not use Autotools or
  2532. CMake, you need to track the installation
  2533. and diagnose and fix any issues until everything installs
  2534. correctly.
  2535. You need to look in the default location of
  2536. <filename>${D}</filename>, which is
  2537. <filename>${WORKDIR}/image</filename>, to be sure your
  2538. files have been installed correctly.
  2539. </para>
  2540. <note><title>Notes</title>
  2541. <itemizedlist>
  2542. <listitem><para>
  2543. During the installation process, you might need to
  2544. modify some of the installed files to suit the target
  2545. layout.
  2546. For example, you might need to replace hard-coded paths
  2547. in an initscript with values of variables provided by
  2548. the build system, such as replacing
  2549. <filename>/usr/bin/</filename> with
  2550. <filename>${bindir}</filename>.
  2551. If you do perform such modifications during
  2552. <filename>do_install</filename>, be sure to modify the
  2553. destination file after copying rather than before
  2554. copying.
  2555. Modifying after copying ensures that the build system
  2556. can re-execute <filename>do_install</filename> if
  2557. needed.
  2558. </para></listitem>
  2559. <listitem><para>
  2560. <filename>oe_runmake install</filename>, which can be
  2561. run directly or can be run indirectly by the
  2562. <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-autotools'><filename>autotools</filename></ulink>
  2563. and
  2564. <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-cmake'><filename>cmake</filename></ulink>
  2565. classes, runs <filename>make install</filename> in
  2566. parallel.
  2567. Sometimes, a Makefile can have missing dependencies
  2568. between targets that can result in race conditions.
  2569. If you experience intermittent failures during
  2570. <filename>do_install</filename>, you might be able to
  2571. work around them by disabling parallel Makefile
  2572. installs by adding the following to the recipe:
  2573. <literallayout class='monospaced'>
  2574. PARALLEL_MAKEINST = ""
  2575. </literallayout>
  2576. See
  2577. <ulink url='&YOCTO_DOCS_REF_URL;#var-PARALLEL_MAKEINST'><filename>PARALLEL_MAKEINST</filename></ulink>
  2578. for additional information.
  2579. </para></listitem>
  2580. </itemizedlist>
  2581. </note>
  2582. </section>
  2583. <section id='new-recipe-enabling-system-services'>
  2584. <title>Enabling System Services</title>
  2585. <para>
  2586. If you want to install a service, which is a process that
  2587. usually starts on boot and runs in the background, then
  2588. you must include some additional definitions in your recipe.
  2589. </para>
  2590. <para>
  2591. If you are adding services and the service initialization
  2592. script or the service file itself is not installed, you must
  2593. provide for that installation in your recipe using a
  2594. <filename>do_install_append</filename> function.
  2595. If your recipe already has a <filename>do_install</filename>
  2596. function, update the function near its end rather than
  2597. adding an additional <filename>do_install_append</filename>
  2598. function.
  2599. </para>
  2600. <para>
  2601. When you create the installation for your services, you need
  2602. to accomplish what is normally done by
  2603. <filename>make install</filename>.
  2604. In other words, make sure your installation arranges the output
  2605. similar to how it is arranged on the target system.
  2606. </para>
  2607. <para>
  2608. The OpenEmbedded build system provides support for starting
  2609. services two different ways:
  2610. <itemizedlist>
  2611. <listitem><para><emphasis>SysVinit:</emphasis>
  2612. SysVinit is a system and service manager that
  2613. manages the init system used to control the very basic
  2614. functions of your system.
  2615. The init program is the first program
  2616. started by the Linux kernel when the system boots.
  2617. Init then controls the startup, running and shutdown
  2618. of all other programs.</para>
  2619. <para>To enable a service using SysVinit, your recipe
  2620. needs to inherit the
  2621. <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-update-rc.d'><filename>update-rc.d</filename></ulink>
  2622. class.
  2623. The class helps facilitate safely installing the
  2624. package on the target.</para>
  2625. <para>You will need to set the
  2626. <ulink url='&YOCTO_DOCS_REF_URL;#var-INITSCRIPT_PACKAGES'><filename>INITSCRIPT_PACKAGES</filename></ulink>,
  2627. <ulink url='&YOCTO_DOCS_REF_URL;#var-INITSCRIPT_NAME'><filename>INITSCRIPT_NAME</filename></ulink>,
  2628. and
  2629. <ulink url='&YOCTO_DOCS_REF_URL;#var-INITSCRIPT_PARAMS'><filename>INITSCRIPT_PARAMS</filename></ulink>
  2630. variables within your recipe.</para></listitem>
  2631. <listitem><para><emphasis>systemd:</emphasis>
  2632. System Management Daemon (systemd) was designed to
  2633. replace SysVinit and to provide
  2634. enhanced management of services.
  2635. For more information on systemd, see the systemd
  2636. homepage at
  2637. <ulink url='http://freedesktop.org/wiki/Software/systemd/'></ulink>.
  2638. </para>
  2639. <para>To enable a service using systemd, your recipe
  2640. needs to inherit the
  2641. <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-systemd'><filename>systemd</filename></ulink>
  2642. class.
  2643. See the <filename>systemd.bbclass</filename> file
  2644. located in your
  2645. <ulink url='&YOCTO_DOCS_REF_URL;#source-directory'>Source Directory</ulink>.
  2646. section for more information.
  2647. </para></listitem>
  2648. </itemizedlist>
  2649. </para>
  2650. </section>
  2651. <section id='new-recipe-packaging'>
  2652. <title>Packaging</title>
  2653. <para>
  2654. Successful packaging is a combination of automated processes
  2655. performed by the OpenEmbedded build system and some
  2656. specific steps you need to take.
  2657. The following list describes the process:
  2658. <itemizedlist>
  2659. <listitem><para><emphasis>Splitting Files</emphasis>:
  2660. The <filename>do_package</filename> task splits the
  2661. files produced by the recipe into logical components.
  2662. Even software that produces a single binary might
  2663. still have debug symbols, documentation, and other
  2664. logical components that should be split out.
  2665. The <filename>do_package</filename> task ensures
  2666. that files are split up and packaged correctly.
  2667. </para></listitem>
  2668. <listitem><para><emphasis>Running QA Checks</emphasis>:
  2669. The
  2670. <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-insane'><filename>insane</filename></ulink>
  2671. class adds a step to
  2672. the package generation process so that output quality
  2673. assurance checks are generated by the OpenEmbedded
  2674. build system.
  2675. This step performs a range of checks to be sure the
  2676. build's output is free of common problems that show
  2677. up during runtime.
  2678. For information on these checks, see the
  2679. <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-insane'><filename>insane</filename></ulink>
  2680. class and the
  2681. "<ulink url='&YOCTO_DOCS_REF_URL;#ref-qa-checks'>QA Error and Warning Messages</ulink>"
  2682. chapter in the Yocto Project Reference Manual.
  2683. </para></listitem>
  2684. <listitem><para><emphasis>Hand-Checking Your Packages</emphasis>:
  2685. After you build your software, you need to be sure
  2686. your packages are correct.
  2687. Examine the
  2688. <filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-WORKDIR'><filename>WORKDIR</filename></ulink><filename>}/packages-split</filename>
  2689. directory and make sure files are where you expect
  2690. them to be.
  2691. If you discover problems, you can set
  2692. <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGES'><filename>PACKAGES</filename></ulink>,
  2693. <ulink url='&YOCTO_DOCS_REF_URL;#var-FILES'><filename>FILES</filename></ulink>,
  2694. <filename>do_install(_append)</filename>, and so forth as
  2695. needed.
  2696. </para></listitem>
  2697. <listitem><para><emphasis>Splitting an Application into Multiple Packages</emphasis>:
  2698. If you need to split an application into several
  2699. packages, see the
  2700. "<link linkend='splitting-an-application-into-multiple-packages'>Splitting an Application into Multiple Packages</link>"
  2701. section for an example.
  2702. </para></listitem>
  2703. <listitem><para><emphasis>Installing a Post-Installation Script</emphasis>:
  2704. For an example showing how to install a
  2705. post-installation script, see the
  2706. "<link linkend='new-recipe-post-installation-scripts'>Post-Installation Scripts</link>"
  2707. section.
  2708. </para></listitem>
  2709. <listitem><para><emphasis>Marking Package Architecture</emphasis>:
  2710. Depending on what your recipe is building and how it
  2711. is configured, it might be important to mark the
  2712. packages produced as being specific to a particular
  2713. machine, or to mark them as not being specific to
  2714. a particular machine or architecture at all.</para>
  2715. <para>By default, packages apply to any machine with the
  2716. same architecture as the target machine.
  2717. When a recipe produces packages that are
  2718. machine-specific (e.g. the
  2719. <ulink url='&YOCTO_DOCS_REF_URL;#var-MACHINE'><filename>MACHINE</filename></ulink>
  2720. value is passed into the configure script or a patch
  2721. is applied only for a particular machine), you should
  2722. mark them as such by adding the following to the
  2723. recipe:
  2724. <literallayout class='monospaced'>
  2725. PACKAGE_ARCH = "${MACHINE_ARCH}"
  2726. </literallayout></para>
  2727. <para>On the other hand, if the recipe produces packages
  2728. that do not contain anything specific to the target
  2729. machine or architecture at all (e.g. recipes
  2730. that simply package script files or configuration
  2731. files), you should use the
  2732. <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-allarch'><filename>allarch</filename></ulink>
  2733. class to do this for you by adding this to your
  2734. recipe:
  2735. <literallayout class='monospaced'>
  2736. inherit allarch
  2737. </literallayout>
  2738. Ensuring that the package architecture is correct is
  2739. not critical while you are doing the first few builds
  2740. of your recipe.
  2741. However, it is important in order
  2742. to ensure that your recipe rebuilds (or does not
  2743. rebuild) appropriately in response to changes in
  2744. configuration, and to ensure that you get the
  2745. appropriate packages installed on the target machine,
  2746. particularly if you run separate builds for more
  2747. than one target machine.
  2748. </para></listitem>
  2749. </itemizedlist>
  2750. </para>
  2751. </section>
  2752. <section id='new-sharing-files-between-recipes'>
  2753. <title>Sharing Files Between Recipes</title>
  2754. <para>
  2755. Recipes often need to use files provided by other recipes on
  2756. the build host.
  2757. For example, an application linking to a common library needs
  2758. access to the library itself and its associated headers.
  2759. The way this access is accomplished is by populating a sysroot
  2760. with files.
  2761. Each recipe has two sysroots in its work directory, one for
  2762. target files
  2763. (<filename>recipe-sysroot</filename>) and one for files that
  2764. are native to the build host
  2765. (<filename>recipe-sysroot-native</filename>).
  2766. <note>
  2767. You could find the term "staging" used within the Yocto
  2768. project regarding files populating sysroots (e.g. the
  2769. <ulink url='&YOCTO_DOCS_REF_URL;#var-STAGING_DIR'><filename>STAGING_DIR</filename></ulink>
  2770. variable).
  2771. </note>
  2772. </para>
  2773. <para>
  2774. Recipes should never populate the sysroot directly (i.e. write
  2775. files into sysroot).
  2776. Instead, files should be installed into standard locations
  2777. during the
  2778. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-install'><filename>do_install</filename></ulink>
  2779. task within the
  2780. <filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-D'><filename>D</filename></ulink><filename>}</filename>
  2781. directory.
  2782. The reason for this limitation is that almost all files that
  2783. populate the sysroot are cataloged in manifests in order to
  2784. ensure the files can be removed later when a recipe is either
  2785. modified or removed.
  2786. Thus, the sysroot is able to remain free from stale files.
  2787. </para>
  2788. <para>
  2789. A subset of the files installed by the
  2790. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-install'><filename>do_install</filename></ulink>
  2791. task are used by the
  2792. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-populate_sysroot'><filename>do_populate_sysroot</filename></ulink>
  2793. task as defined by the the
  2794. <ulink url='&YOCTO_DOCS_REF_URL;#var-SYSROOT_DIRS'><filename>SYSROOT_DIRS</filename></ulink>
  2795. variable to automatically populate the sysroot.
  2796. It is possible to modify the list of directories that populate
  2797. the sysroot.
  2798. The following example shows how you could add the
  2799. <filename>/opt</filename> directory to the list of
  2800. directories within a recipe:
  2801. <literallayout class='monospaced'>
  2802. SYSROOT_DIRS += "/opt"
  2803. </literallayout>
  2804. </para>
  2805. <para>
  2806. For a more complete description of the
  2807. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-populate_sysroot'><filename>do_populate_sysroot</filename></ulink>
  2808. task and its associated functions, see the
  2809. <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-staging'><filename>staging</filename></ulink>
  2810. class.
  2811. </para>
  2812. </section>
  2813. <section id='metadata-virtual-providers'>
  2814. <title>Using Virtual Providers</title>
  2815. <para>
  2816. Prior to a build, if you know that several different recipes
  2817. provide the same functionality, you can use a virtual provider
  2818. (i.e. <filename>virtual/*</filename>) as a placeholder for the
  2819. actual provider.
  2820. The actual provider is determined at build-time.
  2821. </para>
  2822. <para>
  2823. A common scenario where a virtual provider is used would be
  2824. for the kernel recipe.
  2825. Suppose you have three kernel recipes whose
  2826. <ulink url='&YOCTO_DOCS_REF_URL;#var-PN'><filename>PN</filename></ulink>
  2827. values map to <filename>kernel-big</filename>,
  2828. <filename>kernel-mid</filename>, and
  2829. <filename>kernel-small</filename>.
  2830. Furthermore, each of these recipes in some way uses a
  2831. <ulink url='&YOCTO_DOCS_REF_URL;#var-PROVIDES'><filename>PROVIDES</filename></ulink>
  2832. statement that essentially identifies itself as being able
  2833. to provide <filename>virtual/kernel</filename>.
  2834. Here is one way through the
  2835. <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-kernel'><filename>kernel</filename></ulink>
  2836. class:
  2837. <literallayout class='monospaced'>
  2838. PROVIDES += "${@ "virtual/kernel" if (d.getVar("KERNEL_PACKAGE_NAME") == "kernel") else "" }"
  2839. </literallayout>
  2840. Any recipe that inherits the <filename>kernel</filename> class
  2841. is going to utilize a <filename>PROVIDES</filename> statement
  2842. that identifies that recipe as being able to provide the
  2843. <filename>virtual/kernel</filename> item.
  2844. </para>
  2845. <para>
  2846. Now comes the time to actually build an image and you need a
  2847. kernel recipe, but which one?
  2848. You can configure your build to call out the kernel recipe
  2849. you want by using the
  2850. <ulink url='&YOCTO_DOCS_REF_URL;#var-PREFERRED_PROVIDER'><filename>PREFERRED_PROVIDER</filename></ulink>
  2851. variable.
  2852. As an example, consider the
  2853. <ulink url='https://git.yoctoproject.org/cgit/cgit.cgi/poky/tree/meta/conf/machine/include/x86-base.inc'><filename>x86-base.inc</filename></ulink>
  2854. include file, which is a machine
  2855. (i.e. <ulink url='&YOCTO_DOCS_REF_URL;#var-MACHINE'><filename>MACHINE</filename></ulink>)
  2856. configuration file.
  2857. This include file is the reason all x86-based machines use the
  2858. <filename>linux-yocto</filename> kernel.
  2859. Here are the relevant lines from the include file:
  2860. <literallayout class='monospaced'>
  2861. PREFERRED_PROVIDER_virtual/kernel ??= "linux-yocto"
  2862. PREFERRED_VERSION_linux-yocto ??= "4.15%"
  2863. </literallayout>
  2864. </para>
  2865. <para>
  2866. When you use a virtual provider, you do not have to
  2867. "hard code" a recipe name as a build dependency.
  2868. You can use the
  2869. <ulink url='&YOCTO_DOCS_REF_URL;#var-DEPENDS'><filename>DEPENDS</filename></ulink>
  2870. variable to state the build is dependent on
  2871. <filename>virtual/kernel</filename> for example:
  2872. <literallayout class='monospaced'>
  2873. DEPENDS = "virtual/kernel"
  2874. </literallayout>
  2875. During the build, the OpenEmbedded build system picks
  2876. the correct recipe needed for the
  2877. <filename>virtual/kernel</filename> dependency based on the
  2878. <filename>PREFERRED_PROVIDER</filename> variable.
  2879. If you want to use the small kernel mentioned at the beginning
  2880. of this section, configure your build as follows:
  2881. <literallayout class='monospaced'>
  2882. PREFERRED_PROVIDER_virtual/kernel ??= "kernel-small"
  2883. </literallayout>
  2884. <note>
  2885. Any recipe that
  2886. <ulink url='&YOCTO_DOCS_REF_URL;#var-PROVIDES'><filename>PROVIDES</filename></ulink>
  2887. a <filename>virtual/*</filename> item that is ultimately
  2888. not selected through
  2889. <filename>PREFERRED_PROVIDER</filename> does not get built.
  2890. Preventing these recipes from building is usually the
  2891. desired behavior since this mechanism's purpose is to
  2892. select between mutually exclusive alternative providers.
  2893. </note>
  2894. </para>
  2895. <para>
  2896. The following lists specific examples of virtual providers:
  2897. <itemizedlist>
  2898. <listitem><para>
  2899. <filename>virtual/kernel</filename>:
  2900. Provides the name of the kernel recipe to use when
  2901. building a kernel image.
  2902. </para></listitem>
  2903. <listitem><para>
  2904. <filename>virtual/bootloader</filename>:
  2905. Provides the name of the bootloader to use when
  2906. building an image.
  2907. </para></listitem>
  2908. <listitem><para>
  2909. <filename>virtual/mesa</filename>:
  2910. Provides <filename>gbm.pc</filename>.
  2911. </para></listitem>
  2912. <listitem><para>
  2913. <filename>virtual/egl</filename>:
  2914. Provides <filename>egl.pc</filename> and possibly
  2915. <filename>wayland-egl.pc</filename>.
  2916. </para></listitem>
  2917. <listitem><para>
  2918. <filename>virtual/libgl</filename>:
  2919. Provides <filename>gl.pc</filename> (i.e. libGL).
  2920. </para></listitem>
  2921. <listitem><para>
  2922. <filename>virtual/libgles1</filename>:
  2923. Provides <filename>glesv1_cm.pc</filename>
  2924. (i.e. libGLESv1_CM).
  2925. </para></listitem>
  2926. <listitem><para>
  2927. <filename>virtual/libgles2</filename>:
  2928. Provides <filename>glesv2.pc</filename>
  2929. (i.e. libGLESv2).
  2930. </para></listitem>
  2931. </itemizedlist>
  2932. </para>
  2933. </section>
  2934. <section id='properly-versioning-pre-release-recipes'>
  2935. <title>Properly Versioning Pre-Release Recipes</title>
  2936. <para>
  2937. Sometimes the name of a recipe can lead to versioning
  2938. problems when the recipe is upgraded to a final release.
  2939. For example, consider the
  2940. <filename>irssi_0.8.16-rc1.bb</filename> recipe file in
  2941. the list of example recipes in the
  2942. "<link linkend='new-recipe-storing-and-naming-the-recipe'>Storing and Naming the Recipe</link>"
  2943. section.
  2944. This recipe is at a release candidate stage (i.e.
  2945. "rc1").
  2946. When the recipe is released, the recipe filename becomes
  2947. <filename>irssi_0.8.16.bb</filename>.
  2948. The version change from <filename>0.8.16-rc1</filename>
  2949. to <filename>0.8.16</filename> is seen as a decrease by the
  2950. build system and package managers, so the resulting packages
  2951. will not correctly trigger an upgrade.
  2952. </para>
  2953. <para>
  2954. In order to ensure the versions compare properly, the
  2955. recommended convention is to set
  2956. <ulink url='&YOCTO_DOCS_REF_URL;#var-PV'><filename>PV</filename></ulink>
  2957. within the recipe to
  2958. "<replaceable>previous_version</replaceable>+<replaceable>current_version</replaceable>".
  2959. You can use an additional variable so that you can use the
  2960. current version elsewhere.
  2961. Here is an example:
  2962. <literallayout class='monospaced'>
  2963. REALPV = "0.8.16-rc1"
  2964. PV = "0.8.15+${REALPV}"
  2965. </literallayout>
  2966. </para>
  2967. </section>
  2968. <section id='new-recipe-post-installation-scripts'>
  2969. <title>Post-Installation Scripts</title>
  2970. <para>
  2971. Post-installation scripts run immediately after installing
  2972. a package on the target or during image creation when a
  2973. package is included in an image.
  2974. To add a post-installation script to a package, add a
  2975. <filename>pkg_postinst_</filename><replaceable>PACKAGENAME</replaceable><filename>()</filename> function to
  2976. the recipe file (<filename>.bb</filename>) and replace
  2977. <replaceable>PACKAGENAME</replaceable> with the name of the package
  2978. you want to attach to the <filename>postinst</filename>
  2979. script.
  2980. To apply the post-installation script to the main package
  2981. for the recipe, which is usually what is required, specify
  2982. <filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-PN'><filename>PN</filename></ulink><filename>}</filename>
  2983. in place of <replaceable>PACKAGENAME</replaceable>.
  2984. </para>
  2985. <para>
  2986. A post-installation function has the following structure:
  2987. <literallayout class='monospaced'>
  2988. pkg_postinst_<replaceable>PACKAGENAME</replaceable>() {
  2989. # Commands to carry out
  2990. }
  2991. </literallayout>
  2992. </para>
  2993. <para>
  2994. The script defined in the post-installation function is
  2995. called when the root filesystem is created.
  2996. If the script succeeds, the package is marked as installed.
  2997. If the script fails, the package is marked as unpacked and
  2998. the script is executed when the image boots again.
  2999. <note>
  3000. Any RPM post-installation script that runs on the target
  3001. should return a 0 exit code.
  3002. RPM does not allow non-zero exit codes for these scripts,
  3003. and the RPM package manager will cause the package to fail
  3004. installation on the target.
  3005. </note>
  3006. </para>
  3007. <para>
  3008. Sometimes it is necessary for the execution of a
  3009. post-installation script to be delayed until the first boot.
  3010. For example, the script might need to be executed on the
  3011. device itself.
  3012. To delay script execution until boot time, use the following
  3013. structure in the post-installation script:
  3014. <literallayout class='monospaced'>
  3015. pkg_postinst_<replaceable>PACKAGENAME</replaceable>() {
  3016. if [ x"$D" = "x" ]; then
  3017. # Actions to carry out on the device go here
  3018. else
  3019. exit 1
  3020. fi
  3021. }
  3022. </literallayout>
  3023. </para>
  3024. <para>
  3025. The previous example delays execution until the image boots
  3026. again because the environment variable <filename>D</filename>
  3027. points to the directory containing the image when
  3028. the root filesystem is created at build time but is unset
  3029. when executed on the first boot.
  3030. </para>
  3031. <para>
  3032. If you have recipes that use <filename>pkg_postinst</filename>
  3033. scripts and they require the use of non-standard native
  3034. tools that have dependencies during rootfs construction, you
  3035. need to use the
  3036. <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_WRITE_DEPS'><filename>PACKAGE_WRITE_DEPS</filename></ulink>
  3037. variable in your recipe to list these tools.
  3038. If you do not use this variable, the tools might be missing and
  3039. execution of the post-installation script is deferred until
  3040. first boot.
  3041. Deferring the script to first boot is undesirable and for
  3042. read-only rootfs impossible.
  3043. </para>
  3044. <note>
  3045. Equivalent support for pre-install, pre-uninstall, and
  3046. post-uninstall scripts exist by way of
  3047. <filename>pkg_preinst</filename>,
  3048. <filename>pkg_prerm</filename>, and
  3049. <filename>pkg_postrm</filename>, respectively.
  3050. These scrips work in exactly the same way as does
  3051. <filename>pkg_postinst</filename> with the exception that they
  3052. run at different times.
  3053. Also, because of when they run, they are not applicable to
  3054. being run at image creation time like
  3055. <filename>pkg_postinst</filename>.
  3056. </note>
  3057. </section>
  3058. <section id='new-recipe-testing'>
  3059. <title>Testing</title>
  3060. <para>
  3061. The final step for completing your recipe is to be sure that
  3062. the software you built runs correctly.
  3063. To accomplish runtime testing, add the build's output
  3064. packages to your image and test them on the target.
  3065. </para>
  3066. <para>
  3067. For information on how to customize your image by adding
  3068. specific packages, see the
  3069. "<link linkend='usingpoky-extend-customimage'>Customizing Images</link>"
  3070. section.
  3071. </para>
  3072. </section>
  3073. <section id='new-recipe-testing-examples'>
  3074. <title>Examples</title>
  3075. <para>
  3076. To help summarize how to write a recipe, this section provides
  3077. some examples given various scenarios:
  3078. <itemizedlist>
  3079. <listitem><para>Recipes that use local files</para></listitem>
  3080. <listitem><para>Using an Autotooled package</para></listitem>
  3081. <listitem><para>Using a Makefile-based package</para></listitem>
  3082. <listitem><para>Splitting an application into multiple packages</para></listitem>
  3083. <listitem><para>Adding binaries to an image</para></listitem>
  3084. </itemizedlist>
  3085. </para>
  3086. <section id='new-recipe-single-c-file-package-hello-world'>
  3087. <title>Single .c File Package (Hello World!)</title>
  3088. <para>
  3089. Building an application from a single file that is stored
  3090. locally (e.g. under <filename>files</filename>) requires
  3091. a recipe that has the file listed in the
  3092. <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'>SRC_URI</ulink></filename>
  3093. variable.
  3094. Additionally, you need to manually write the
  3095. <filename>do_compile</filename> and
  3096. <filename>do_install</filename> tasks.
  3097. The <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-S'>S</ulink></filename>
  3098. variable defines the directory containing the source code,
  3099. which is set to
  3100. <ulink url='&YOCTO_DOCS_REF_URL;#var-WORKDIR'><filename>WORKDIR</filename></ulink>
  3101. in this case - the directory BitBake uses for the build.
  3102. <literallayout class='monospaced'>
  3103. SUMMARY = "Simple helloworld application"
  3104. SECTION = "examples"
  3105. LICENSE = "MIT"
  3106. LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"
  3107. SRC_URI = "file://helloworld.c"
  3108. S = "${WORKDIR}"
  3109. do_compile() {
  3110. ${CC} helloworld.c -o helloworld
  3111. }
  3112. do_install() {
  3113. install -d ${D}${bindir}
  3114. install -m 0755 helloworld ${D}${bindir}
  3115. }
  3116. </literallayout>
  3117. </para>
  3118. <para>
  3119. By default, the <filename>helloworld</filename>,
  3120. <filename>helloworld-dbg</filename>, and
  3121. <filename>helloworld-dev</filename> packages are built.
  3122. For information on how to customize the packaging process,
  3123. see the
  3124. "<link linkend='splitting-an-application-into-multiple-packages'>Splitting an Application into Multiple Packages</link>"
  3125. section.
  3126. </para>
  3127. </section>
  3128. <section id='new-recipe-autotooled-package'>
  3129. <title>Autotooled Package</title>
  3130. <para>
  3131. Applications that use Autotools such as <filename>autoconf</filename> and
  3132. <filename>automake</filename> require a recipe that has a source archive listed in
  3133. <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'>SRC_URI</ulink></filename> and
  3134. also inherit the
  3135. <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-autotools'><filename>autotools</filename></ulink>
  3136. class, which contains the definitions of all the steps
  3137. needed to build an Autotool-based application.
  3138. The result of the build is automatically packaged.
  3139. And, if the application uses NLS for localization, packages with local information are
  3140. generated (one package per language).
  3141. Following is one example: (<filename>hello_2.3.bb</filename>)
  3142. <literallayout class='monospaced'>
  3143. SUMMARY = "GNU Helloworld application"
  3144. SECTION = "examples"
  3145. LICENSE = "GPLv2+"
  3146. LIC_FILES_CHKSUM = "file://COPYING;md5=751419260aa954499f7abaabaa882bbe"
  3147. SRC_URI = "${GNU_MIRROR}/hello/hello-${PV}.tar.gz"
  3148. inherit autotools gettext
  3149. </literallayout>
  3150. </para>
  3151. <para>
  3152. The variable
  3153. <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-LIC_FILES_CHKSUM'>LIC_FILES_CHKSUM</ulink></filename>
  3154. is used to track source license changes as described in the
  3155. "<ulink url='&YOCTO_DOCS_OM_URL;#usingpoky-configuring-LIC_FILES_CHKSUM'>Tracking License Changes</ulink>"
  3156. section in the Yocto Project Overview and Concepts Manual.
  3157. You can quickly create Autotool-based recipes in a manner
  3158. similar to the previous example.
  3159. </para>
  3160. </section>
  3161. <section id='new-recipe-makefile-based-package'>
  3162. <title>Makefile-Based Package</title>
  3163. <para>
  3164. Applications that use GNU <filename>make</filename> also require a recipe that has
  3165. the source archive listed in
  3166. <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'>SRC_URI</ulink></filename>.
  3167. You do not need to add a <filename>do_compile</filename> step since by default BitBake
  3168. starts the <filename>make</filename> command to compile the application.
  3169. If you need additional <filename>make</filename> options, you should store them in the
  3170. <ulink url='&YOCTO_DOCS_REF_URL;#var-EXTRA_OEMAKE'><filename>EXTRA_OEMAKE</filename></ulink>
  3171. or
  3172. <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGECONFIG_CONFARGS'><filename>PACKAGECONFIG_CONFARGS</filename></ulink>
  3173. variables.
  3174. BitBake passes these options into the GNU <filename>make</filename> invocation.
  3175. Note that a <filename>do_install</filename> task is still required.
  3176. Otherwise, BitBake runs an empty <filename>do_install</filename> task by default.
  3177. </para>
  3178. <para>
  3179. Some applications might require extra parameters to be passed to the compiler.
  3180. For example, the application might need an additional header path.
  3181. You can accomplish this by adding to the
  3182. <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-CFLAGS'>CFLAGS</ulink></filename> variable.
  3183. The following example shows this:
  3184. <literallayout class='monospaced'>
  3185. CFLAGS_prepend = "-I ${S}/include "
  3186. </literallayout>
  3187. </para>
  3188. <para>
  3189. In the following example, <filename>mtd-utils</filename> is a makefile-based package:
  3190. <literallayout class='monospaced'>
  3191. SUMMARY = "Tools for managing memory technology devices"
  3192. SECTION = "base"
  3193. DEPENDS = "zlib lzo e2fsprogs util-linux"
  3194. HOMEPAGE = "http://www.linux-mtd.infradead.org/"
  3195. LICENSE = "GPLv2+"
  3196. LIC_FILES_CHKSUM = "file://COPYING;md5=0636e73ff0215e8d672dc4c32c317bb3 \
  3197. file://include/common.h;beginline=1;endline=17;md5=ba05b07912a44ea2bf81ce409380049c"
  3198. # Use the latest version at 26 Oct, 2013
  3199. SRCREV = "9f107132a6a073cce37434ca9cda6917dd8d866b"
  3200. SRC_URI = "git://git.infradead.org/mtd-utils.git \
  3201. file://add-exclusion-to-mkfs-jffs2-git-2.patch \
  3202. "
  3203. PV = "1.5.1+git${SRCPV}"
  3204. S = "${WORKDIR}/git"
  3205. EXTRA_OEMAKE = "'CC=${CC}' 'RANLIB=${RANLIB}' 'AR=${AR}' 'CFLAGS=${CFLAGS} -I${S}/include -DWITHOUT_XATTR' 'BUILDDIR=${S}'"
  3206. do_install () {
  3207. oe_runmake install DESTDIR=${D} SBINDIR=${sbindir} MANDIR=${mandir} INCLUDEDIR=${includedir}
  3208. }
  3209. PACKAGES =+ "mtd-utils-jffs2 mtd-utils-ubifs mtd-utils-misc"
  3210. FILES_mtd-utils-jffs2 = "${sbindir}/mkfs.jffs2 ${sbindir}/jffs2dump ${sbindir}/jffs2reader ${sbindir}/sumtool"
  3211. FILES_mtd-utils-ubifs = "${sbindir}/mkfs.ubifs ${sbindir}/ubi*"
  3212. FILES_mtd-utils-misc = "${sbindir}/nftl* ${sbindir}/ftl* ${sbindir}/rfd* ${sbindir}/doc* ${sbindir}/serve_image ${sbindir}/recv_image"
  3213. PARALLEL_MAKE = ""
  3214. BBCLASSEXTEND = "native"
  3215. </literallayout>
  3216. </para>
  3217. </section>
  3218. <section id='splitting-an-application-into-multiple-packages'>
  3219. <title>Splitting an Application into Multiple Packages</title>
  3220. <para>
  3221. You can use the variables
  3222. <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGES'>PACKAGES</ulink></filename> and
  3223. <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-FILES'>FILES</ulink></filename>
  3224. to split an application into multiple packages.
  3225. </para>
  3226. <para>
  3227. Following is an example that uses the <filename>libxpm</filename> recipe.
  3228. By default, this recipe generates a single package that contains the library along
  3229. with a few binaries.
  3230. You can modify the recipe to split the binaries into separate packages:
  3231. <literallayout class='monospaced'>
  3232. require xorg-lib-common.inc
  3233. SUMMARY = "Xpm: X Pixmap extension library"
  3234. LICENSE = "BSD"
  3235. LIC_FILES_CHKSUM = "file://COPYING;md5=51f4270b012ecd4ab1a164f5f4ed6cf7"
  3236. DEPENDS += "libxext libsm libxt"
  3237. PE = "1"
  3238. XORG_PN = "libXpm"
  3239. PACKAGES =+ "sxpm cxpm"
  3240. FILES_cxpm = "${bindir}/cxpm"
  3241. FILES_sxpm = "${bindir}/sxpm"
  3242. </literallayout>
  3243. </para>
  3244. <para>
  3245. In the previous example, we want to ship the <filename>sxpm</filename>
  3246. and <filename>cxpm</filename> binaries in separate packages.
  3247. Since <filename>bindir</filename> would be packaged into the main
  3248. <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-PN'>PN</ulink></filename>
  3249. package by default, we prepend the <filename>PACKAGES</filename>
  3250. variable so additional package names are added to the start of list.
  3251. This results in the extra <filename>FILES_*</filename>
  3252. variables then containing information that define which files and
  3253. directories go into which packages.
  3254. Files included by earlier packages are skipped by latter packages.
  3255. Thus, the main <filename>PN</filename> package
  3256. does not include the above listed files.
  3257. </para>
  3258. </section>
  3259. <section id='packaging-externally-produced-binaries'>
  3260. <title>Packaging Externally Produced Binaries</title>
  3261. <para>
  3262. Sometimes, you need to add pre-compiled binaries to an
  3263. image.
  3264. For example, suppose that binaries for proprietary code
  3265. exist, which are created by a particular division of a
  3266. company.
  3267. Your part of the company needs to use those binaries as
  3268. part of an image that you are building using the
  3269. OpenEmbedded build system.
  3270. Since you only have the binaries and not the source code,
  3271. you cannot use a typical recipe that expects to fetch the
  3272. source specified in
  3273. <ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'><filename>SRC_URI</filename></ulink>
  3274. and then compile it.
  3275. </para>
  3276. <para>
  3277. One method is to package the binaries and then install them
  3278. as part of the image.
  3279. Generally, it is not a good idea to package binaries
  3280. since, among other things, it can hinder the ability to
  3281. reproduce builds and could lead to compatibility problems
  3282. with ABI in the future.
  3283. However, sometimes you have no choice.
  3284. </para>
  3285. <para>
  3286. The easiest solution is to create a recipe that uses
  3287. the
  3288. <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-bin-package'><filename>bin_package</filename></ulink>
  3289. class and to be sure that you are using default locations
  3290. for build artifacts.
  3291. In most cases, the <filename>bin_package</filename> class
  3292. handles "skipping" the configure and compile steps as well
  3293. as sets things up to grab packages from the appropriate
  3294. area.
  3295. In particular, this class sets <filename>noexec</filename>
  3296. on both the
  3297. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-configure'><filename>do_configure</filename></ulink>
  3298. and
  3299. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-compile'><filename>do_compile</filename></ulink>
  3300. tasks, sets
  3301. <filename>FILES_${PN}</filename> to "/" so that it picks
  3302. up all files, and sets up a
  3303. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-install'><filename>do_install</filename></ulink>
  3304. task, which effectively copies all files from
  3305. <filename>${S}</filename> to <filename>${D}</filename>.
  3306. The <filename>bin_package</filename> class works well when
  3307. the files extracted into <filename>${S}</filename> are
  3308. already laid out in the way they should be laid out
  3309. on the target.
  3310. For more information on these variables, see the
  3311. <ulink url='&YOCTO_DOCS_REF_URL;#var-FILES'><filename>FILES</filename></ulink>,
  3312. <ulink url='&YOCTO_DOCS_REF_URL;#var-PN'><filename>PN</filename></ulink>,
  3313. <ulink url='&YOCTO_DOCS_REF_URL;#var-S'><filename>S</filename></ulink>,
  3314. and
  3315. <ulink url='&YOCTO_DOCS_REF_URL;#var-D'><filename>D</filename></ulink>
  3316. variables in the Yocto Project Reference Manual's variable
  3317. glossary.
  3318. <note><title>Notes</title>
  3319. <itemizedlist>
  3320. <listitem><para>
  3321. Using
  3322. <ulink url='&YOCTO_DOCS_REF_URL;#var-DEPENDS'><filename>DEPENDS</filename></ulink>
  3323. is a good idea even for components distributed
  3324. in binary form, and is often necessary for
  3325. shared libraries.
  3326. For a shared library, listing the library
  3327. dependencies in
  3328. <filename>DEPENDS</filename> makes sure that
  3329. the libraries are available in the staging
  3330. sysroot when other recipes link against the
  3331. library, which might be necessary for
  3332. successful linking.
  3333. </para></listitem>
  3334. <listitem><para>
  3335. Using <filename>DEPENDS</filename> also
  3336. allows runtime dependencies between packages
  3337. to be added automatically.
  3338. See the
  3339. "<ulink url='&YOCTO_DOCS_OM_URL;#automatically-added-runtime-dependencies'>Automatically Added Runtime Dependencies</ulink>"
  3340. section in the Yocto Project Overview and
  3341. Concepts Manual for more information.
  3342. </para></listitem>
  3343. </itemizedlist>
  3344. </note>
  3345. </para>
  3346. <para>
  3347. If you cannot use the <filename>bin_package</filename>
  3348. class, you need to be sure you are doing the following:
  3349. <itemizedlist>
  3350. <listitem><para>
  3351. Create a recipe where the
  3352. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-configure'><filename>do_configure</filename></ulink>
  3353. and
  3354. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-compile'><filename>do_compile</filename></ulink>
  3355. tasks do nothing:
  3356. It is usually sufficient to just not define these
  3357. tasks in the recipe, because the default
  3358. implementations do nothing unless a Makefile is
  3359. found in
  3360. <filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-S'><filename>S</filename></ulink><filename>}</filename>.
  3361. </para>
  3362. <para>If
  3363. <filename>${S}</filename> might contain a Makefile,
  3364. or if you inherit some class that replaces
  3365. <filename>do_configure</filename> and
  3366. <filename>do_compile</filename> with custom
  3367. versions, then you can use the
  3368. <filename>[</filename><ulink url='&YOCTO_DOCS_BB_URL;#variable-flags'><filename>noexec</filename></ulink><filename>]</filename>
  3369. flag to turn the tasks into no-ops, as follows:
  3370. <literallayout class='monospaced'>
  3371. do_configure[noexec] = "1"
  3372. do_compile[noexec] = "1"
  3373. </literallayout>
  3374. Unlike
  3375. <ulink url='&YOCTO_DOCS_BB_URL;#deleting-a-task'><filename>deleting the tasks</filename></ulink>,
  3376. using the flag preserves the dependency chain from
  3377. the
  3378. <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>,
  3379. and
  3380. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-patch'><filename>do_patch</filename></ulink>
  3381. tasks to the
  3382. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-install'><filename>do_install</filename></ulink>
  3383. task.
  3384. </para></listitem>
  3385. <listitem><para>Make sure your
  3386. <filename>do_install</filename> task installs the
  3387. binaries appropriately.
  3388. </para></listitem>
  3389. <listitem><para>Ensure that you set up
  3390. <ulink url='&YOCTO_DOCS_REF_URL;#var-FILES'><filename>FILES</filename></ulink>
  3391. (usually
  3392. <filename>FILES_${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-PN'><filename>PN</filename></ulink><filename>}</filename>)
  3393. to point to the files you have installed, which of
  3394. course depends on where you have installed them
  3395. and whether those files are in different locations
  3396. than the defaults.
  3397. </para></listitem>
  3398. </itemizedlist>
  3399. </para>
  3400. </section>
  3401. </section>
  3402. <section id="following-recipe-style-guidelines">
  3403. <title>Following Recipe Style Guidelines</title>
  3404. <para>
  3405. When writing recipes, it is good to conform to existing
  3406. style guidelines.
  3407. The
  3408. <ulink url='http://www.openembedded.org/wiki/Styleguide'>OpenEmbedded Styleguide</ulink>
  3409. wiki page provides rough guidelines for preferred recipe style.
  3410. </para>
  3411. <para>
  3412. It is common for existing recipes to deviate a bit from this
  3413. style.
  3414. However, aiming for at least a consistent style is a good idea.
  3415. Some practices, such as omitting spaces around
  3416. <filename>=</filename> operators in assignments or ordering
  3417. recipe components in an erratic way, are widely seen as poor
  3418. style.
  3419. </para>
  3420. </section>
  3421. <section id='recipe-syntax'>
  3422. <title>Recipe Syntax</title>
  3423. <para>
  3424. Understanding recipe file syntax is important for writing
  3425. recipes.
  3426. The following list overviews the basic items that make up a
  3427. BitBake recipe file.
  3428. For more complete BitBake syntax descriptions, see the
  3429. "<ulink url='&YOCTO_DOCS_BB_URL;#bitbake-user-manual-metadata'>Syntax and Operators</ulink>"
  3430. chapter of the BitBake User Manual.
  3431. <itemizedlist>
  3432. <listitem><para>
  3433. <emphasis>Variable Assignments and Manipulations:</emphasis>
  3434. Variable assignments allow a value to be assigned to a
  3435. variable.
  3436. The assignment can be static text or might include
  3437. the contents of other variables.
  3438. In addition to the assignment, appending and prepending
  3439. operations are also supported.</para>
  3440. <para>The following example shows some of the ways
  3441. you can use variables in recipes:
  3442. <literallayout class='monospaced'>
  3443. S = "${WORKDIR}/postfix-${PV}"
  3444. CFLAGS += "-DNO_ASM"
  3445. SRC_URI_append = " file://fixup.patch"
  3446. </literallayout>
  3447. </para></listitem>
  3448. <listitem><para>
  3449. <emphasis>Functions:</emphasis>
  3450. Functions provide a series of actions to be performed.
  3451. You usually use functions to override the default
  3452. implementation of a task function or to complement
  3453. a default function (i.e. append or prepend to an
  3454. existing function).
  3455. Standard functions use <filename>sh</filename> shell
  3456. syntax, although access to OpenEmbedded variables and
  3457. internal methods are also available.</para>
  3458. <para>The following is an example function from the
  3459. <filename>sed</filename> recipe:
  3460. <literallayout class='monospaced'>
  3461. do_install () {
  3462. autotools_do_install
  3463. install -d ${D}${base_bindir}
  3464. mv ${D}${bindir}/sed ${D}${base_bindir}/sed
  3465. rmdir ${D}${bindir}/
  3466. }
  3467. </literallayout>
  3468. It is also possible to implement new functions that
  3469. are called between existing tasks as long as the
  3470. new functions are not replacing or complementing the
  3471. default functions.
  3472. You can implement functions in Python
  3473. instead of shell.
  3474. Both of these options are not seen in the majority of
  3475. recipes.
  3476. </para></listitem>
  3477. <listitem><para><emphasis>Keywords:</emphasis>
  3478. BitBake recipes use only a few keywords.
  3479. You use keywords to include common
  3480. functions (<filename>inherit</filename>), load parts
  3481. of a recipe from other files
  3482. (<filename>include</filename> and
  3483. <filename>require</filename>) and export variables
  3484. to the environment (<filename>export</filename>).
  3485. </para>
  3486. <para>The following example shows the use of some of
  3487. these keywords:
  3488. <literallayout class='monospaced'>
  3489. export POSTCONF = "${STAGING_BINDIR}/postconf"
  3490. inherit autoconf
  3491. require otherfile.inc
  3492. </literallayout>
  3493. </para></listitem>
  3494. <listitem><para>
  3495. <emphasis>Comments (#):</emphasis>
  3496. Any lines that begin with the hash character
  3497. (<filename>#</filename>) are treated as comment lines
  3498. and are ignored:
  3499. <literallayout class='monospaced'>
  3500. # This is a comment
  3501. </literallayout>
  3502. </para></listitem>
  3503. </itemizedlist>
  3504. </para>
  3505. <para>
  3506. This next list summarizes the most important and most commonly
  3507. used parts of the recipe syntax.
  3508. For more information on these parts of the syntax, you can
  3509. reference the
  3510. <ulink url='&YOCTO_DOCS_BB_URL;#bitbake-user-manual-metadata'>Syntax and Operators</ulink>
  3511. chapter in the BitBake User Manual.
  3512. <itemizedlist>
  3513. <listitem><para>
  3514. <emphasis>Line Continuation (\):</emphasis>
  3515. Use the backward slash (<filename>\</filename>)
  3516. character to split a statement over multiple lines.
  3517. Place the slash character at the end of the line that
  3518. is to be continued on the next line:
  3519. <literallayout class='monospaced'>
  3520. VAR = "A really long \
  3521. line"
  3522. </literallayout>
  3523. <note>
  3524. You cannot have any characters including spaces
  3525. or tabs after the slash character.
  3526. </note>
  3527. </para></listitem>
  3528. <listitem><para>
  3529. <emphasis>Using Variables (${<replaceable>VARNAME</replaceable>}):</emphasis>
  3530. Use the <filename>${<replaceable>VARNAME</replaceable>}</filename>
  3531. syntax to access the contents of a variable:
  3532. <literallayout class='monospaced'>
  3533. SRC_URI = "${SOURCEFORGE_MIRROR}/libpng/zlib-${PV}.tar.gz"
  3534. </literallayout>
  3535. <note>
  3536. It is important to understand that the value of a
  3537. variable expressed in this form does not get
  3538. substituted automatically.
  3539. The expansion of these expressions happens
  3540. on-demand later (e.g. usually when a function that
  3541. makes reference to the variable executes).
  3542. This behavior ensures that the values are most
  3543. appropriate for the context in which they are
  3544. finally used.
  3545. On the rare occasion that you do need the variable
  3546. expression to be expanded immediately, you can use
  3547. the <filename>:=</filename> operator instead of
  3548. <filename>=</filename> when you make the
  3549. assignment, but this is not generally needed.
  3550. </note>
  3551. </para></listitem>
  3552. <listitem><para>
  3553. <emphasis>Quote All Assignments ("<replaceable>value</replaceable>"):</emphasis>
  3554. Use double quotes around values in all variable
  3555. assignments (e.g.
  3556. <filename>"<replaceable>value</replaceable>"</filename>).
  3557. Following is an example:
  3558. <literallayout class='monospaced'>
  3559. VAR1 = "${OTHERVAR}"
  3560. VAR2 = "The version is ${PV}"
  3561. </literallayout>
  3562. </para></listitem>
  3563. <listitem><para>
  3564. <emphasis>Conditional Assignment (?=):</emphasis>
  3565. Conditional assignment is used to assign a
  3566. value to a variable, but only when the variable is
  3567. currently unset.
  3568. Use the question mark followed by the equal sign
  3569. (<filename>?=</filename>) to make a "soft" assignment
  3570. used for conditional assignment.
  3571. Typically, "soft" assignments are used in the
  3572. <filename>local.conf</filename> file for variables
  3573. that are allowed to come through from the external
  3574. environment.
  3575. </para>
  3576. <para>Here is an example where
  3577. <filename>VAR1</filename> is set to "New value" if
  3578. it is currently empty.
  3579. However, if <filename>VAR1</filename> has already been
  3580. set, it remains unchanged:
  3581. <literallayout class='monospaced'>
  3582. VAR1 ?= "New value"
  3583. </literallayout>
  3584. In this next example, <filename>VAR1</filename>
  3585. is left with the value "Original value":
  3586. <literallayout class='monospaced'>
  3587. VAR1 = "Original value"
  3588. VAR1 ?= "New value"
  3589. </literallayout>
  3590. </para></listitem>
  3591. <listitem><para>
  3592. <emphasis>Appending (+=):</emphasis>
  3593. Use the plus character followed by the equals sign
  3594. (<filename>+=</filename>) to append values to existing
  3595. variables.
  3596. <note>
  3597. This operator adds a space between the existing
  3598. content of the variable and the new content.
  3599. </note></para>
  3600. <para>Here is an example:
  3601. <literallayout class='monospaced'>
  3602. SRC_URI += "file://fix-makefile.patch"
  3603. </literallayout>
  3604. </para></listitem>
  3605. <listitem><para>
  3606. <emphasis>Prepending (=+):</emphasis>
  3607. Use the equals sign followed by the plus character
  3608. (<filename>=+</filename>) to prepend values to existing
  3609. variables.
  3610. <note>
  3611. This operator adds a space between the new content
  3612. and the existing content of the variable.
  3613. </note></para>
  3614. <para>Here is an example:
  3615. <literallayout class='monospaced'>
  3616. VAR =+ "Starts"
  3617. </literallayout>
  3618. </para></listitem>
  3619. <listitem><para>
  3620. <emphasis>Appending (_append):</emphasis>
  3621. Use the <filename>_append</filename> operator to
  3622. append values to existing variables.
  3623. This operator does not add any additional space.
  3624. Also, the operator is applied after all the
  3625. <filename>+=</filename>, and
  3626. <filename>=+</filename> operators have been applied and
  3627. after all <filename>=</filename> assignments have
  3628. occurred.
  3629. </para>
  3630. <para>The following example shows the space being
  3631. explicitly added to the start to ensure the appended
  3632. value is not merged with the existing value:
  3633. <literallayout class='monospaced'>
  3634. SRC_URI_append = " file://fix-makefile.patch"
  3635. </literallayout>
  3636. You can also use the <filename>_append</filename>
  3637. operator with overrides, which results in the actions
  3638. only being performed for the specified target or
  3639. machine:
  3640. <literallayout class='monospaced'>
  3641. SRC_URI_append_sh4 = " file://fix-makefile.patch"
  3642. </literallayout>
  3643. </para></listitem>
  3644. <listitem><para>
  3645. <emphasis>Prepending (_prepend):</emphasis>
  3646. Use the <filename>_prepend</filename> operator to
  3647. prepend values to existing variables.
  3648. This operator does not add any additional space.
  3649. Also, the operator is applied after all the
  3650. <filename>+=</filename>, and
  3651. <filename>=+</filename> operators have been applied and
  3652. after all <filename>=</filename> assignments have
  3653. occurred.
  3654. </para>
  3655. <para>The following example shows the space being
  3656. explicitly added to the end to ensure the prepended
  3657. value is not merged with the existing value:
  3658. <literallayout class='monospaced'>
  3659. CFLAGS_prepend = "-I${S}/myincludes "
  3660. </literallayout>
  3661. You can also use the <filename>_prepend</filename>
  3662. operator with overrides, which results in the actions
  3663. only being performed for the specified target or
  3664. machine:
  3665. <literallayout class='monospaced'>
  3666. CFLAGS_prepend_sh4 = "-I${S}/myincludes "
  3667. </literallayout>
  3668. </para></listitem>
  3669. <listitem><para>
  3670. <emphasis>Overrides:</emphasis>
  3671. You can use overrides to set a value conditionally,
  3672. typically based on how the recipe is being built.
  3673. For example, to set the
  3674. <ulink url='&YOCTO_DOCS_REF_URL;#var-KBRANCH'><filename>KBRANCH</filename></ulink>
  3675. variable's value to "standard/base" for any target
  3676. <ulink url='&YOCTO_DOCS_REF_URL;#var-MACHINE'><filename>MACHINE</filename></ulink>,
  3677. except for qemuarm where it should be set to
  3678. "standard/arm-versatile-926ejs", you would do the
  3679. following:
  3680. <literallayout class='monospaced'>
  3681. KBRANCH = "standard/base"
  3682. KBRANCH_qemuarm = "standard/arm-versatile-926ejs"
  3683. </literallayout>
  3684. Overrides are also used to separate alternate values
  3685. of a variable in other situations.
  3686. For example, when setting variables such as
  3687. <ulink url='&YOCTO_DOCS_REF_URL;#var-FILES'><filename>FILES</filename></ulink>
  3688. and
  3689. <ulink url='&YOCTO_DOCS_REF_URL;#var-RDEPENDS'><filename>RDEPENDS</filename></ulink>
  3690. that are specific to individual packages produced by
  3691. a recipe, you should always use an override that
  3692. specifies the name of the package.
  3693. </para></listitem>
  3694. <listitem><para>
  3695. <emphasis>Indentation:</emphasis>
  3696. Use spaces for indentation rather than than tabs.
  3697. For shell functions, both currently work.
  3698. However, it is a policy decision of the Yocto Project
  3699. to use tabs in shell functions.
  3700. Realize that some layers have a policy to use spaces
  3701. for all indentation.
  3702. </para></listitem>
  3703. <listitem><para>
  3704. <emphasis>Using Python for Complex Operations:</emphasis>
  3705. For more advanced processing, it is possible to use
  3706. Python code during variable assignments (e.g.
  3707. search and replacement on a variable).</para>
  3708. <para>You indicate Python code using the
  3709. <filename>${@<replaceable>python_code</replaceable>}</filename>
  3710. syntax for the variable assignment:
  3711. <literallayout class='monospaced'>
  3712. SRC_URI = "ftp://ftp.info-zip.org/pub/infozip/src/zip${@d.getVar('PV',1).replace('.', '')}.tgz
  3713. </literallayout>
  3714. </para></listitem>
  3715. <listitem><para>
  3716. <emphasis>Shell Function Syntax:</emphasis>
  3717. Write shell functions as if you were writing a shell
  3718. script when you describe a list of actions to take.
  3719. You should ensure that your script works with a generic
  3720. <filename>sh</filename> and that it does not require
  3721. any <filename>bash</filename> or other shell-specific
  3722. functionality.
  3723. The same considerations apply to various system
  3724. utilities (e.g. <filename>sed</filename>,
  3725. <filename>grep</filename>, <filename>awk</filename>,
  3726. and so forth) that you might wish to use.
  3727. If in doubt, you should check with multiple
  3728. implementations - including those from BusyBox.
  3729. </para></listitem>
  3730. </itemizedlist>
  3731. </para>
  3732. </section>
  3733. </section>
  3734. <section id="platdev-newmachine">
  3735. <title>Adding a New Machine</title>
  3736. <para>
  3737. Adding a new machine to the Yocto Project is a straightforward
  3738. process.
  3739. This section describes how to add machines that are similar
  3740. to those that the Yocto Project already supports.
  3741. <note>
  3742. Although well within the capabilities of the Yocto Project,
  3743. adding a totally new architecture might require
  3744. changes to <filename>gcc/glibc</filename> and to the site
  3745. information, which is beyond the scope of this manual.
  3746. </note>
  3747. </para>
  3748. <para>
  3749. For a complete example that shows how to add a new machine,
  3750. see the
  3751. "<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>"
  3752. section in the Yocto Project Board Support Package (BSP)
  3753. Developer's Guide.
  3754. </para>
  3755. <section id="platdev-newmachine-conffile">
  3756. <title>Adding the Machine Configuration File</title>
  3757. <para>
  3758. To add a new machine, you need to add a new machine
  3759. configuration file to the layer's
  3760. <filename>conf/machine</filename> directory.
  3761. This configuration file provides details about the device
  3762. you are adding.
  3763. </para>
  3764. <para>
  3765. The OpenEmbedded build system uses the root name of the
  3766. machine configuration file to reference the new machine.
  3767. For example, given a machine configuration file named
  3768. <filename>crownbay.conf</filename>, the build system
  3769. recognizes the machine as "crownbay".
  3770. </para>
  3771. <para>
  3772. The most important variables you must set in your machine
  3773. configuration file or include from a lower-level configuration
  3774. file are as follows:
  3775. <itemizedlist>
  3776. <listitem><para><filename><ulink url='&YOCTO_DOCS_REF_URL;#var-TARGET_ARCH'>TARGET_ARCH</ulink></filename>
  3777. (e.g. "arm")</para></listitem>
  3778. <listitem><para><filename><ulink url='&YOCTO_DOCS_REF_URL;#var-PREFERRED_PROVIDER'>PREFERRED_PROVIDER</ulink>_virtual/kernel</filename>
  3779. </para></listitem>
  3780. <listitem><para><filename><ulink url='&YOCTO_DOCS_REF_URL;#var-MACHINE_FEATURES'>MACHINE_FEATURES</ulink></filename>
  3781. (e.g. "apm screen wifi")</para></listitem>
  3782. </itemizedlist>
  3783. </para>
  3784. <para>
  3785. You might also need these variables:
  3786. <itemizedlist>
  3787. <listitem><para><filename><ulink url='&YOCTO_DOCS_REF_URL;#var-SERIAL_CONSOLES'>SERIAL_CONSOLES</ulink></filename>
  3788. (e.g. "115200;ttyS0 115200;ttyS1")</para></listitem>
  3789. <listitem><para><filename><ulink url='&YOCTO_DOCS_REF_URL;#var-KERNEL_IMAGETYPE'>KERNEL_IMAGETYPE</ulink></filename>
  3790. (e.g. "zImage")</para></listitem>
  3791. <listitem><para><filename><ulink url='&YOCTO_DOCS_REF_URL;#var-IMAGE_FSTYPES'>IMAGE_FSTYPES</ulink></filename>
  3792. (e.g. "tar.gz jffs2")</para></listitem>
  3793. </itemizedlist>
  3794. </para>
  3795. <para>
  3796. You can find full details on these variables in the reference
  3797. section.
  3798. You can leverage existing machine <filename>.conf</filename>
  3799. files from <filename>meta-yocto-bsp/conf/machine/</filename>.
  3800. </para>
  3801. </section>
  3802. <section id="platdev-newmachine-kernel">
  3803. <title>Adding a Kernel for the Machine</title>
  3804. <para>
  3805. The OpenEmbedded build system needs to be able to build a kernel
  3806. for the machine.
  3807. You need to either create a new kernel recipe for this machine,
  3808. or extend an existing kernel recipe.
  3809. You can find several kernel recipe examples in the
  3810. Source Directory at
  3811. <filename>meta/recipes-kernel/linux</filename>
  3812. that you can use as references.
  3813. </para>
  3814. <para>
  3815. If you are creating a new kernel recipe, normal recipe-writing
  3816. rules apply for setting up a
  3817. <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'>SRC_URI</ulink></filename>.
  3818. Thus, you need to specify any necessary patches and set
  3819. <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-S'>S</ulink></filename>
  3820. to point at the source code.
  3821. You need to create a <filename>do_configure</filename> task that
  3822. configures the unpacked kernel with a
  3823. <filename>defconfig</filename> file.
  3824. You can do this by using a <filename>make defconfig</filename>
  3825. command or, more commonly, by copying in a suitable
  3826. <filename>defconfig</filename> file and then running
  3827. <filename>make oldconfig</filename>.
  3828. By making use of <filename>inherit kernel</filename> and
  3829. potentially some of the <filename>linux-*.inc</filename> files,
  3830. most other functionality is centralized and the defaults of the
  3831. class normally work well.
  3832. </para>
  3833. <para>
  3834. If you are extending an existing kernel recipe, it is usually
  3835. a matter of adding a suitable <filename>defconfig</filename>
  3836. file.
  3837. The file needs to be added into a location similar to
  3838. <filename>defconfig</filename> files used for other machines
  3839. in a given kernel recipe.
  3840. A possible way to do this is by listing the file in the
  3841. <filename>SRC_URI</filename> and adding the machine to the
  3842. expression in
  3843. <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-COMPATIBLE_MACHINE'>COMPATIBLE_MACHINE</ulink></filename>:
  3844. <literallayout class='monospaced'>
  3845. COMPATIBLE_MACHINE = '(qemux86|qemumips)'
  3846. </literallayout>
  3847. For more information on <filename>defconfig</filename> files,
  3848. see the
  3849. "<ulink url='&YOCTO_DOCS_KERNEL_DEV_URL;#changing-the-configuration'>Changing the Configuration</ulink>"
  3850. section in the Yocto Project Linux Kernel Development Manual.
  3851. </para>
  3852. </section>
  3853. <section id="platdev-newmachine-formfactor">
  3854. <title>Adding a Formfactor Configuration File</title>
  3855. <para>
  3856. A formfactor configuration file provides information about the
  3857. target hardware for which the image is being built and information that
  3858. the build system cannot obtain from other sources such as the kernel.
  3859. Some examples of information contained in a formfactor configuration file include
  3860. framebuffer orientation, whether or not the system has a keyboard,
  3861. the positioning of the keyboard in relation to the screen, and
  3862. the screen resolution.
  3863. </para>
  3864. <para>
  3865. The build system uses reasonable defaults in most cases.
  3866. However, if customization is
  3867. necessary, you need to create a <filename>machconfig</filename> file
  3868. in the <filename>meta/recipes-bsp/formfactor/files</filename>
  3869. directory.
  3870. This directory contains directories for specific machines such as
  3871. <filename>qemuarm</filename> and <filename>qemux86</filename>.
  3872. For information about the settings available and the defaults, see the
  3873. <filename>meta/recipes-bsp/formfactor/files/config</filename> file found in the
  3874. same area.
  3875. </para>
  3876. <para>
  3877. Following is an example for "qemuarm" machine:
  3878. <literallayout class='monospaced'>
  3879. HAVE_TOUCHSCREEN=1
  3880. HAVE_KEYBOARD=1
  3881. DISPLAY_CAN_ROTATE=0
  3882. DISPLAY_ORIENTATION=0
  3883. #DISPLAY_WIDTH_PIXELS=640
  3884. #DISPLAY_HEIGHT_PIXELS=480
  3885. #DISPLAY_BPP=16
  3886. DISPLAY_DPI=150
  3887. DISPLAY_SUBPIXEL_ORDER=vrgb
  3888. </literallayout>
  3889. </para>
  3890. </section>
  3891. </section>
  3892. <section id='gs-upgrading-recipes'>
  3893. <title>Upgrading Recipes</title>
  3894. <para>
  3895. Over time, upstream developers publish new versions for software
  3896. built by layer recipes.
  3897. It is recommended to keep recipes up-to-date with upstream
  3898. version releases.
  3899. You can use the Automated Upgrade Helper (AUH) to set up
  3900. automatic version upgrades.
  3901. Alternatively, you can use <filename>devtool upgrade</filename>
  3902. to set up semi-automatic version upgrades.
  3903. Finally, you can even manually upgrade a recipe by editing the
  3904. recipe itself.
  3905. </para>
  3906. <section id='gs-using-the-auto-upgrade-helper'>
  3907. <title>Using the Auto Upgrade Helper (AUH)</title>
  3908. <para>
  3909. The AUH utility works in conjunction with the
  3910. OpenEmbedded build system in order to automatically generate
  3911. upgrades for recipes based on new versions being
  3912. published upstream.
  3913. Use AUH when you want to create a service that performs the
  3914. upgrades automatically and optionally sends you an email with
  3915. the results.
  3916. </para>
  3917. <para>
  3918. AUH allows you to update several recipes with a single use.
  3919. You can also optionally perform build and integration tests
  3920. using images with the results saved to your hard drive and
  3921. emails of results optionally sent to recipe maintainers.
  3922. Finally, AUH creates Git commits with appropriate commit
  3923. messages in the layer's tree for the changes made to recipes.
  3924. <note>
  3925. Conditions do exist when you should not use AUH to upgrade
  3926. recipes and you should instead use either
  3927. <filename>devtool upgrade</filename> or upgrade your
  3928. recipes manually:
  3929. <itemizedlist>
  3930. <listitem><para>
  3931. When AUH cannot complete the upgrade sequence.
  3932. This situation usually results because custom
  3933. patches carried by the recipe cannot be
  3934. automatically rebased to the new version.
  3935. In this case, <filename>devtool upgrade</filename>
  3936. allows you to manually resolve conflicts.
  3937. </para></listitem>
  3938. <listitem><para>
  3939. When for any reason you want fuller control over
  3940. the upgrade process.
  3941. For example, when you want special arrangements
  3942. for testing.
  3943. </para></listitem>
  3944. </itemizedlist>
  3945. </note>
  3946. </para>
  3947. <para>
  3948. The following steps describe how to set up the AUH utility:
  3949. <orderedlist>
  3950. <listitem><para>
  3951. <emphasis>Be Sure the Development Host is Set Up:</emphasis>
  3952. You need to be sure that your development host is
  3953. set up to use the Yocto Project.
  3954. For information on how to set up your host, see the
  3955. "<link linkend='setting-up-the-development-host-to-use-the-yocto-project'>Setting Up the Development Host to Use the Yocto Project</link>"
  3956. section.
  3957. </para></listitem>
  3958. <listitem><para>
  3959. <emphasis>Make Sure Git is Configured:</emphasis>
  3960. The AUH utility requires Git to be configured because
  3961. AUH uses Git to save upgrades.
  3962. Thus, you must have Git user and email configured.
  3963. The following command shows your configurations:
  3964. <literallayout class='monospaced'>
  3965. $ git config --list
  3966. </literallayout>
  3967. If you do not have the user and email configured, you
  3968. can use the following commands to do so:
  3969. <literallayout class='monospaced'>
  3970. $ git config --global user.name <replaceable>some_name</replaceable>
  3971. $ git config --global user.email <replaceable>username</replaceable>@<replaceable>domain</replaceable>.com
  3972. </literallayout>
  3973. </para></listitem>
  3974. <listitem><para>
  3975. <emphasis>Clone the AUH Repository:</emphasis>
  3976. To use AUH, you must clone the repository onto your
  3977. development host.
  3978. The following command uses Git to create a local
  3979. copy of the repository on your system:
  3980. <literallayout class='monospaced'>
  3981. $ git clone git://git.yoctoproject.org/auto-upgrade-helper
  3982. Cloning into 'auto-upgrade-helper'...
  3983. remote: Counting objects: 768, done.
  3984. remote: Compressing objects: 100% (300/300), done.
  3985. remote: Total 768 (delta 499), reused 703 (delta 434)
  3986. Receiving objects: 100% (768/768), 191.47 KiB | 98.00 KiB/s, done.
  3987. Resolving deltas: 100% (499/499), done.
  3988. Checking connectivity... done.
  3989. </literallayout>
  3990. AUH is not part of the
  3991. <ulink url='&YOCTO_DOCS_REF_URL;#oe-core'>OpenEmbedded-Core (OE-Core)</ulink>
  3992. or
  3993. <ulink url='&YOCTO_DOCS_REF_URL;#poky'>Poky</ulink>
  3994. repositories.
  3995. </para></listitem>
  3996. <listitem><para>
  3997. <emphasis>Create a Dedicated Build Directory:</emphasis>
  3998. Run the
  3999. <ulink url='&YOCTO_DOCS_REF_URL;#structure-core-script'><filename>oe-init-build-env</filename></ulink>
  4000. script to create a fresh build directory that you
  4001. use exclusively for running the AUH utility:
  4002. <literallayout class='monospaced'>
  4003. $ cd ~/poky
  4004. $ source oe-init-build-env <replaceable>your_AUH_build_directory</replaceable>
  4005. </literallayout>
  4006. Re-using an existing build directory and its
  4007. configurations is not recommended as existing settings
  4008. could cause AUH to fail or behave undesirably.
  4009. </para></listitem>
  4010. <listitem><para>
  4011. <emphasis>Make Configurations in Your Local Configuration File:</emphasis>
  4012. Several settings need to exist in the
  4013. <filename>local.conf</filename> file in the build
  4014. directory you just created for AUH.
  4015. Make these following configurations:
  4016. <itemizedlist>
  4017. <listitem><para>
  4018. Enable "distrodata" as follows:
  4019. <literallayout class='monospaced'>
  4020. INHERIT =+ "distrodata"
  4021. </literallayout>
  4022. </para></listitem>
  4023. <listitem><para>
  4024. If you want to enable
  4025. <ulink url='&YOCTO_DOCS_DEV_URL;#maintaining-build-output-quality'>Build History</ulink>,
  4026. which is optional, you need the following
  4027. lines in the
  4028. <filename>conf/local.conf</filename> file:
  4029. <literallayout class='monospaced'>
  4030. INHERIT =+ "buildhistory"
  4031. BUILDHISTORY_COMMIT = "1"
  4032. </literallayout>
  4033. With this configuration and a successful
  4034. upgrade, a build history "diff" file appears in
  4035. the
  4036. <filename>upgrade-helper/work/recipe/buildhistory-diff.txt</filename>
  4037. file found in your build directory.
  4038. </para></listitem>
  4039. <listitem><para>
  4040. If you want to enable testing through the
  4041. <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-testimage*'><filename>testimage</filename></ulink>
  4042. class, which is optional, you need to have the
  4043. following set in your
  4044. <filename>conf/local.conf</filename> file:
  4045. <literallayout class='monospaced'>
  4046. INHERIT += "testimage"
  4047. </literallayout>
  4048. <note>
  4049. If your distro does not enable by default
  4050. ptest, which Poky does, you need the
  4051. following in your
  4052. <filename>local.conf</filename> file:
  4053. <literallayout class='monospaced'>
  4054. DISTRO_FEATURES_append = " ptest"
  4055. </literallayout>
  4056. </note>
  4057. </para></listitem>
  4058. </itemizedlist>
  4059. </para></listitem>
  4060. <listitem><para>
  4061. <emphasis>Optionally Start a vncserver:</emphasis>
  4062. If you are running in a server without an X11 session,
  4063. you need to start a vncserver:
  4064. <literallayout class='monospaced'>
  4065. $ vncserver :1
  4066. $ export DISPLAY=:1
  4067. </literallayout>
  4068. </para></listitem>
  4069. <listitem><para>
  4070. <emphasis>Create and Edit an AUH Configuration File:</emphasis>
  4071. You need to have the
  4072. <filename>upgrade-helper/upgrade-helper.conf</filename>
  4073. configuration file in your build directory.
  4074. You can find a sample configuration file in the
  4075. <ulink url='http://git.yoctoproject.org/cgit/cgit.cgi/auto-upgrade-helper/tree/'>AUH source repository</ulink>.
  4076. </para>
  4077. <para>Read through the sample file and make
  4078. configurations as needed.
  4079. For example, if you enabled build history in your
  4080. <filename>local.conf</filename> as described earlier,
  4081. you must enable it in
  4082. <filename>upgrade-helper.conf</filename>.</para>
  4083. <para>Also, if you are using the default
  4084. <filename>maintainers.inc</filename> file supplied
  4085. with Poky and located in
  4086. <filename>meta-yocto</filename> and you do not set a
  4087. "maintainers_whitelist" or "global_maintainer_override"
  4088. in the <filename>upgrade-helper.conf</filename>
  4089. configuration, and you specify "-e all" on the
  4090. AUH command-line, the utility automatically sends out
  4091. emails to all the default maintainers.
  4092. Please avoid this.
  4093. </para></listitem>
  4094. </orderedlist>
  4095. </para>
  4096. <para>
  4097. This next set of examples describes how to use the AUH:
  4098. <itemizedlist>
  4099. <listitem><para>
  4100. <emphasis>Upgrading a Specific Recipe:</emphasis>
  4101. To upgrade a specific recipe, use the following
  4102. form:
  4103. <literallayout class='monospaced'>
  4104. $ upgrade-helper.py <replaceable>recipe_name</replaceable>
  4105. </literallayout>
  4106. For example, this command upgrades the
  4107. <filename>xmodmap</filename> recipe:
  4108. <literallayout class='monospaced'>
  4109. $ upgrade-helper.py xmodmap
  4110. </literallayout>
  4111. </para></listitem>
  4112. <listitem><para>
  4113. <emphasis>Upgrading a Specific Recipe to a Particular Version:</emphasis>
  4114. To upgrade a specific recipe to a particular version,
  4115. use the following form:
  4116. <literallayout class='monospaced'>
  4117. $ upgrade-helper.py <replaceable>recipe_name</replaceable> -t <replaceable>version</replaceable>
  4118. </literallayout>
  4119. For example, this command upgrades the
  4120. <filename>xmodmap</filename> recipe to version
  4121. 1.2.3:
  4122. <literallayout class='monospaced'>
  4123. $ upgrade-helper.py xmodmap -t 1.2.3
  4124. </literallayout>
  4125. </para></listitem>
  4126. <listitem><para>
  4127. <emphasis>Upgrading all Recipes to the Latest Versions and Suppressing Email Notifications:</emphasis>
  4128. To upgrade all recipes to their most recent versions
  4129. and suppress the email notifications, use the following
  4130. command:
  4131. <literallayout class='monospaced'>
  4132. $ upgrade-helper.py all
  4133. </literallayout>
  4134. </para></listitem>
  4135. <listitem><para>
  4136. <emphasis>Upgrading all Recipes to the Latest Versions and Send Email Notifications:</emphasis>
  4137. To upgrade all recipes to their most recent versions
  4138. and send email messages to maintainers for each
  4139. attempted recipe as well as a status email, use the
  4140. following command:
  4141. <literallayout class='monospaced'>
  4142. $ upgrade-helper.py -e all
  4143. </literallayout>
  4144. </para></listitem>
  4145. </itemizedlist>
  4146. </para>
  4147. <para>
  4148. Once you have run the AUH utility, you can find the results
  4149. in the AUH build directory:
  4150. <literallayout class='monospaced'>
  4151. ${BUILDDIR}/upgrade-helper/<replaceable>timestamp</replaceable>
  4152. </literallayout>
  4153. The AUH utility also creates recipe update commits from
  4154. successful upgrade attempts in the layer tree.
  4155. </para>
  4156. <para>
  4157. You can easily set up to run the AUH utility on a regular
  4158. basis by using a cron job.
  4159. See the
  4160. <ulink url='http://git.yoctoproject.org/cgit/cgit.cgi/auto-upgrade-helper/tree/weeklyjob.sh'><filename>weeklyjob.sh</filename></ulink>
  4161. file distributed with the utility for an example.
  4162. </para>
  4163. </section>
  4164. <section id='gs-using-devtool-upgrade'>
  4165. <title>Using <filename>devtool upgrade</filename></title>
  4166. <para>
  4167. As mentioned earlier, an alternative method for upgrading
  4168. recipes to newer versions is to use
  4169. <ulink url='&YOCTO_DOCS_REF_URL;#ref-devtool-reference'><filename>devtool upgrade</filename></ulink>.
  4170. You can read about <filename>devtool upgrade</filename> in
  4171. general in the
  4172. "<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>"
  4173. section in the Yocto Project Application Development and the
  4174. Extensible Software Development Kit (eSDK) Manual.
  4175. </para>
  4176. <para>
  4177. To see all the command-line options available with
  4178. <filename>devtool upgrade</filename>, use the following help
  4179. command:
  4180. <literallayout class='monospaced'>
  4181. $ devtool upgrade -h
  4182. </literallayout>
  4183. </para>
  4184. <para>
  4185. If you want to find out what version a recipe is currently at
  4186. upstream without any attempt to upgrade your local version of
  4187. the recipe, you can use the following command:
  4188. <literallayout class='monospaced'>
  4189. $ devtool latest-version <replaceable>recipe_name</replaceable>
  4190. </literallayout>
  4191. </para>
  4192. <para>
  4193. As mentioned in the previous section describing AUH,
  4194. <filename>devtool upgrade</filename> works in a
  4195. less-automated manner than AUH.
  4196. Specifically, <filename>devtool upgrade</filename> only
  4197. works on a single recipe that you name on the command line,
  4198. cannot perform build and integration testing using images,
  4199. and does not automatically generate commits for changes in
  4200. the source tree.
  4201. Despite all these "limitations",
  4202. <filename>devtool upgrade</filename> updates the recipe file
  4203. to the new upstream version and attempts to rebase custom
  4204. patches contained by the recipe as needed.
  4205. <note>
  4206. AUH uses much of <filename>devtool upgrade</filename>
  4207. behind the scenes making AUH somewhat of a "wrapper"
  4208. application for <filename>devtool upgrade</filename>.
  4209. </note>
  4210. </para>
  4211. <para>
  4212. A typical scenario involves having used Git to clone an
  4213. upstream repository that you use during build operations.
  4214. Because you are (or have) built the recipe in the past, the
  4215. layer is likely added to your configuration already.
  4216. If for some reason, the layer is not added, you could add
  4217. it easily using the
  4218. <ulink url='&YOCTO_DOCS_BSP_URL;#creating-a-new-bsp-layer-using-the-bitbake-layers-script'><filename>bitbake-layers</filename></ulink>
  4219. script.
  4220. For example, suppose you use the <filename>nano.bb</filename>
  4221. recipe from the <filename>meta-oe</filename> layer in the
  4222. <filename>meta-openembedded</filename> repository.
  4223. For this example, assume that the layer has been cloned into
  4224. following area:
  4225. <literallayout class='monospaced'>
  4226. /home/scottrif/meta-openembedded
  4227. </literallayout>
  4228. The following command from your
  4229. <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink>
  4230. adds the layer to your build configuration (i.e.
  4231. <filename>${BUILDDIR}/conf/bblayers.conf</filename>):
  4232. <literallayout class='monospaced'>
  4233. $ bitbake-layers add-layer /home/scottrif/meta-openembedded/meta-oe
  4234. NOTE: Starting bitbake server...
  4235. Parsing recipes: 100% |##########################################| Time: 0:00:55
  4236. Parsing of 1431 .bb files complete (0 cached, 1431 parsed). 2040 targets, 56 skipped, 0 masked, 0 errors.
  4237. Removing 12 recipes from the x86_64 sysroot: 100% |##############| Time: 0:00:00
  4238. Removing 1 recipes from the x86_64_i586 sysroot: 100% |##########| Time: 0:00:00
  4239. Removing 5 recipes from the i586 sysroot: 100% |#################| Time: 0:00:00
  4240. Removing 5 recipes from the qemux86 sysroot: 100% |##############| Time: 0:00:00
  4241. </literallayout>
  4242. For this example, assume that the <filename>nano.bb</filename>
  4243. recipe that is upstream has a 2.9.3 version number.
  4244. However, the version in the local repository is 2.7.4.
  4245. The following command from your build directory automatically
  4246. upgrades the recipe for you:
  4247. <note>
  4248. Using the <filename>-V</filename> option is not necessary.
  4249. Omitting the version number causes
  4250. <filename>devtool upgrade</filename> to upgrade the recipe
  4251. to the most recent version.
  4252. </note>
  4253. <literallayout class='monospaced'>
  4254. $ devtool upgrade nano -V 2.9.3
  4255. NOTE: Starting bitbake server...
  4256. NOTE: Creating workspace layer in /home/scottrif/poky/build/workspace
  4257. Parsing recipes: 100% |##########################################| Time: 0:00:46
  4258. Parsing of 1431 .bb files complete (0 cached, 1431 parsed). 2040 targets, 56 skipped, 0 masked, 0 errors.
  4259. NOTE: Extracting current version source...
  4260. NOTE: Resolving any missing task queue dependencies
  4261. .
  4262. .
  4263. .
  4264. NOTE: Executing SetScene Tasks
  4265. NOTE: Executing RunQueue Tasks
  4266. NOTE: Tasks Summary: Attempted 74 tasks of which 72 didn't need to be rerun and all succeeded.
  4267. Adding changed files: 100% |#####################################| Time: 0:00:00
  4268. NOTE: Upgraded source extracted to /home/scottrif/poky/build/workspace/sources/nano
  4269. NOTE: New recipe is /home/scottrif/poky/build/workspace/recipes/nano/nano_2.9.3.bb
  4270. </literallayout>
  4271. Continuing with this example, you can use
  4272. <filename>devtool build</filename> to build the newly upgraded
  4273. recipe:
  4274. <literallayout class='monospaced'>
  4275. $ devtool build nano
  4276. NOTE: Starting bitbake server...
  4277. Loading cache: 100% |################################################################################################| Time: 0:00:01
  4278. Loaded 2040 entries from dependency cache.
  4279. Parsing recipes: 100% |##############################################################################################| Time: 0:00:00
  4280. Parsing of 1432 .bb files complete (1431 cached, 1 parsed). 2041 targets, 56 skipped, 0 masked, 0 errors.
  4281. NOTE: Resolving any missing task queue dependencies
  4282. .
  4283. .
  4284. .
  4285. NOTE: Executing SetScene Tasks
  4286. NOTE: Executing RunQueue Tasks
  4287. NOTE: nano: compiling from external source tree /home/scottrif/poky/build/workspace/sources/nano
  4288. NOTE: Tasks Summary: Attempted 520 tasks of which 304 didn't need to be rerun and all succeeded.
  4289. </literallayout>
  4290. Within the <filename>devtool upgrade</filename> workflow,
  4291. opportunity exists to deploy and test your rebuilt software.
  4292. For this example, however, running
  4293. <filename>devtool finish</filename> cleans up the workspace
  4294. once the source in your workspace is clean.
  4295. This usually means using Git to stage and submit commits
  4296. for the changes generated by the upgrade process.
  4297. </para>
  4298. <para>
  4299. Once the tree is clean, you can clean things up in this
  4300. example with the following command from the
  4301. <filename>${BUILDDIR}/workspace/sources/nano</filename>
  4302. directory:
  4303. <literallayout class='monospaced'>
  4304. $ devtool finish nano meta-oe
  4305. NOTE: Starting bitbake server...
  4306. Loading cache: 100% |################################################################################################| Time: 0:00:00
  4307. Loaded 2040 entries from dependency cache.
  4308. Parsing recipes: 100% |##############################################################################################| Time: 0:00:01
  4309. Parsing of 1432 .bb files complete (1431 cached, 1 parsed). 2041 targets, 56 skipped, 0 masked, 0 errors.
  4310. NOTE: Adding new patch 0001-nano.bb-Stuff-I-changed-when-upgrading-nano.bb.patch
  4311. NOTE: Updating recipe nano_2.9.3.bb
  4312. NOTE: Removing file /home/scottrif/meta-openembedded/meta-oe/recipes-support/nano/nano_2.7.4.bb
  4313. NOTE: Moving recipe file to /home/scottrif/meta-openembedded/meta-oe/recipes-support/nano
  4314. NOTE: Leaving source tree /home/scottrif/poky/build/workspace/sources/nano as-is; if you no longer need it then please delete it manually
  4315. </literallayout>
  4316. Using the <filename>devtool finish</filename> command cleans
  4317. up the workspace and creates a patch file based on your
  4318. commits.
  4319. The tool puts all patch files back into the source directory
  4320. in a sub-directory named <filename>nano</filename> in this
  4321. case.
  4322. </para>
  4323. </section>
  4324. <section id='dev-manually-upgrading-a-recipe'>
  4325. <title>Manually Upgrading a Recipe</title>
  4326. <para>
  4327. If for some reason you choose not to upgrade recipes using the
  4328. <link linkend='gs-using-the-auto-upgrade-helper'>Auto Upgrade Helper (AUH)</link>
  4329. or by using
  4330. <link linkend='gs-using-devtool-upgrade'><filename>devtool upgrade</filename></link>,
  4331. you can manually edit the recipe files to upgrade the versions.
  4332. <note><title>Caution</title>
  4333. Manually updating multiple recipes scales poorly and
  4334. involves many steps.
  4335. The recommendation to upgrade recipe versions is through
  4336. AUH or <filename>devtool upgrade</filename>, both of which
  4337. automate some steps and provide guidance for others needed
  4338. for the manual process.
  4339. </note>
  4340. </para>
  4341. <para>
  4342. To manually upgrade recipe versions, follow these general steps:
  4343. <orderedlist>
  4344. <listitem><para>
  4345. <emphasis>Change the Version:</emphasis>
  4346. Rename the recipe such that the version (i.e. the
  4347. <ulink url='&YOCTO_DOCS_REF_URL;#var-PV'><filename>PV</filename></ulink>
  4348. part of the recipe name) changes appropriately.
  4349. If the version is not part of the recipe name, change
  4350. the value as it is set for <filename>PV</filename>
  4351. within the recipe itself.
  4352. </para></listitem>
  4353. <listitem><para>
  4354. <emphasis>Update <filename>SRCREV</filename> if Needed:</emphasis>
  4355. If the source code your recipe builds is fetched from
  4356. Git or some other version control system, update
  4357. <ulink url='&YOCTO_DOCS_REF_URL;#var-SRCREV'><filename>SRCREV</filename></ulink>
  4358. to point to the commit hash that matches the new
  4359. version.
  4360. </para></listitem>
  4361. <listitem><para>
  4362. <emphasis>Build the Software:</emphasis>
  4363. Try to build the recipe using BitBake.
  4364. Typical build failures include the following:
  4365. <itemizedlist>
  4366. <listitem><para>
  4367. License statements were updated for the new
  4368. version.
  4369. For this case, you need to review any changes
  4370. to the license and update the values of
  4371. <ulink url='&YOCTO_DOCS_REF_URL;#var-LICENSE'><filename>LICENSE</filename></ulink>
  4372. and
  4373. <ulink url='&YOCTO_DOCS_REF_URL;#var-LIC_FILES_CHKSUM'><filename>LIC_FILES_CHKSUM</filename></ulink>
  4374. as needed.
  4375. <note>
  4376. License changes are often inconsequential.
  4377. For example, the license text's copyright
  4378. year might have changed.
  4379. </note>
  4380. </para></listitem>
  4381. <listitem><para>
  4382. Custom patches carried by the older version of
  4383. the recipe might fail to apply to the new
  4384. version.
  4385. For these cases, you need to review the
  4386. failures.
  4387. Patches might not be necessary for the new
  4388. version of the software if the upgraded version
  4389. has fixed those issues.
  4390. If a patch is necessary and failing, you need
  4391. to rebase it into the new version.
  4392. </para></listitem>
  4393. </itemizedlist>
  4394. </para></listitem>
  4395. <listitem><para>
  4396. <emphasis>Optionally Attempt to Build for Several Architectures:</emphasis>
  4397. Once you successfully build the new software for a
  4398. given architecture, you could test the build for
  4399. other architectures by changing the
  4400. <ulink url='&YOCTO_DOCS_REF_URL;#var-MACHINE'><filename>MACHINE</filename></ulink>
  4401. variable and rebuilding the software.
  4402. This optional step is especially important if the
  4403. recipe is to be released publicly.
  4404. </para></listitem>
  4405. <listitem><para>
  4406. <emphasis>Check the Upstream Change Log or Release Notes:</emphasis>
  4407. Checking both these reveals if new features exist that
  4408. could break backwards-compatibility.
  4409. If so, you need to take steps to mitigate or eliminate
  4410. that situation.
  4411. </para></listitem>
  4412. <listitem><para>
  4413. <emphasis>Optionally Create a Bootable Image and Test:</emphasis>
  4414. If you want, you can test the new software by booting
  4415. it onto actual hardware.
  4416. </para></listitem>
  4417. <listitem><para>
  4418. <emphasis>Create a Commit with the Change in the Layer Repository:</emphasis>
  4419. After all builds work and any testing is successful,
  4420. you can create commits for any changes in the layer
  4421. holding your upgraded recipe.
  4422. </para></listitem>
  4423. </orderedlist>
  4424. </para>
  4425. </section>
  4426. </section>
  4427. <section id='finding-the-temporary-source-code'>
  4428. <title>Finding Temporary Source Code</title>
  4429. <para>
  4430. You might find it helpful during development to modify the
  4431. temporary source code used by recipes to build packages.
  4432. For example, suppose you are developing a patch and you need to
  4433. experiment a bit to figure out your solution.
  4434. After you have initially built the package, you can iteratively
  4435. tweak the source code, which is located in the
  4436. <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink>,
  4437. and then you can force a re-compile and quickly test your altered
  4438. code.
  4439. Once you settle on a solution, you can then preserve your changes
  4440. in the form of patches.
  4441. </para>
  4442. <para>
  4443. During a build, the unpacked temporary source code used by recipes
  4444. to build packages is available in the Build Directory as
  4445. defined by the
  4446. <ulink url='&YOCTO_DOCS_REF_URL;#var-S'><filename>S</filename></ulink>
  4447. variable.
  4448. Below is the default value for the <filename>S</filename> variable
  4449. as defined in the
  4450. <filename>meta/conf/bitbake.conf</filename> configuration file
  4451. in the
  4452. <ulink url='&YOCTO_DOCS_REF_URL;#source-directory'>Source Directory</ulink>:
  4453. <literallayout class='monospaced'>
  4454. S = "${WORKDIR}/${BP}"
  4455. </literallayout>
  4456. You should be aware that many recipes override the
  4457. <filename>S</filename> variable.
  4458. For example, recipes that fetch their source from Git usually set
  4459. <filename>S</filename> to <filename>${WORKDIR}/git</filename>.
  4460. <note>
  4461. The
  4462. <ulink url='&YOCTO_DOCS_REF_URL;#var-BP'><filename>BP</filename></ulink>
  4463. represents the base recipe name, which consists of the name
  4464. and version:
  4465. <literallayout class='monospaced'>
  4466. BP = "${BPN}-${PV}"
  4467. </literallayout>
  4468. </note>
  4469. </para>
  4470. <para>
  4471. The path to the work directory for the recipe
  4472. (<ulink url='&YOCTO_DOCS_REF_URL;#var-WORKDIR'><filename>WORKDIR</filename></ulink>)
  4473. is defined as follows:
  4474. <literallayout class='monospaced'>
  4475. ${TMPDIR}/work/${MULTIMACH_TARGET_SYS}/${PN}/${EXTENDPE}${PV}-${PR}
  4476. </literallayout>
  4477. The actual directory depends on several things:
  4478. <itemizedlist>
  4479. <listitem><para>
  4480. <ulink url='&YOCTO_DOCS_REF_URL;#var-TMPDIR'><filename>TMPDIR</filename></ulink>:
  4481. The top-level build output directory.
  4482. </para></listitem>
  4483. <listitem><para>
  4484. <ulink url='&YOCTO_DOCS_REF_URL;#var-MULTIMACH_TARGET_SYS'><filename>MULTIMACH_TARGET_SYS</filename></ulink>:
  4485. The target system identifier.
  4486. </para></listitem>
  4487. <listitem><para>
  4488. <ulink url='&YOCTO_DOCS_REF_URL;#var-PN'><filename>PN</filename></ulink>:
  4489. The recipe name.
  4490. </para></listitem>
  4491. <listitem><para>
  4492. <ulink url='&YOCTO_DOCS_REF_URL;#var-EXTENDPE'><filename>EXTENDPE</filename></ulink>:
  4493. The epoch - (if
  4494. <ulink url='&YOCTO_DOCS_REF_URL;#var-PE'><filename>PE</filename></ulink>
  4495. is not specified, which is usually the case for most
  4496. recipes, then <filename>EXTENDPE</filename> is blank).
  4497. </para></listitem>
  4498. <listitem><para>
  4499. <ulink url='&YOCTO_DOCS_REF_URL;#var-PV'><filename>PV</filename></ulink>:
  4500. The recipe version.
  4501. </para></listitem>
  4502. <listitem><para>
  4503. <ulink url='&YOCTO_DOCS_REF_URL;#var-PR'><filename>PR</filename></ulink>:
  4504. The recipe revision.
  4505. </para></listitem>
  4506. </itemizedlist>
  4507. </para>
  4508. <para>
  4509. As an example, assume a Source Directory top-level folder
  4510. named <filename>poky</filename>, a default Build Directory at
  4511. <filename>poky/build</filename>, and a
  4512. <filename>qemux86-poky-linux</filename> machine target
  4513. system.
  4514. Furthermore, suppose your recipe is named
  4515. <filename>foo_1.3.0.bb</filename>.
  4516. In this case, the work directory the build system uses to
  4517. build the package would be as follows:
  4518. <literallayout class='monospaced'>
  4519. poky/build/tmp/work/qemux86-poky-linux/foo/1.3.0-r0
  4520. </literallayout>
  4521. </para>
  4522. </section>
  4523. <section id="using-a-quilt-workflow">
  4524. <title>Using Quilt in Your Workflow</title>
  4525. <para>
  4526. <ulink url='http://savannah.nongnu.org/projects/quilt'>Quilt</ulink>
  4527. is a powerful tool that allows you to capture source code changes
  4528. without having a clean source tree.
  4529. This section outlines the typical workflow you can use to modify
  4530. source code, test changes, and then preserve the changes in the
  4531. form of a patch all using Quilt.
  4532. <note><title>Tip</title>
  4533. With regard to preserving changes to source files, if you
  4534. clean a recipe or have <filename>rm_work</filename> enabled,
  4535. the
  4536. <ulink url='&YOCTO_DOCS_SDK_URL;#using-devtool-in-your-sdk-workflow'><filename>devtool</filename> workflow</ulink>
  4537. as described in the Yocto Project Application Development
  4538. and the Extensible Software Development Kit (eSDK) manual
  4539. is a safer development flow than the flow that uses Quilt.
  4540. </note>
  4541. </para>
  4542. <para>
  4543. Follow these general steps:
  4544. <orderedlist>
  4545. <listitem><para>
  4546. <emphasis>Find the Source Code:</emphasis>
  4547. Temporary source code used by the OpenEmbedded build system
  4548. is kept in the
  4549. <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink>.
  4550. See the
  4551. "<link linkend='finding-the-temporary-source-code'>Finding Temporary Source Code</link>"
  4552. section to learn how to locate the directory that has the
  4553. temporary source code for a particular package.
  4554. </para></listitem>
  4555. <listitem><para>
  4556. <emphasis>Change Your Working Directory:</emphasis>
  4557. You need to be in the directory that has the temporary
  4558. source code.
  4559. That directory is defined by the
  4560. <ulink url='&YOCTO_DOCS_REF_URL;#var-S'><filename>S</filename></ulink>
  4561. variable.</para></listitem>
  4562. <listitem><para>
  4563. <emphasis>Create a New Patch:</emphasis>
  4564. Before modifying source code, you need to create a new
  4565. patch.
  4566. To create a new patch file, use
  4567. <filename>quilt new</filename> as below:
  4568. <literallayout class='monospaced'>
  4569. $ quilt new my_changes.patch
  4570. </literallayout>
  4571. </para></listitem>
  4572. <listitem><para>
  4573. <emphasis>Notify Quilt and Add Files:</emphasis>
  4574. After creating the patch, you need to notify Quilt about
  4575. the files you plan to edit.
  4576. You notify Quilt by adding the files to the patch you
  4577. just created:
  4578. <literallayout class='monospaced'>
  4579. $ quilt add file1.c file2.c file3.c
  4580. </literallayout>
  4581. </para></listitem>
  4582. <listitem><para>
  4583. <emphasis>Edit the Files:</emphasis>
  4584. Make your changes in the source code to the files you added
  4585. to the patch.
  4586. </para></listitem>
  4587. <listitem><para>
  4588. <emphasis>Test Your Changes:</emphasis>
  4589. Once you have modified the source code, the easiest way to
  4590. test your changes is by calling the
  4591. <filename>do_compile</filename> task as shown in the
  4592. following example:
  4593. <literallayout class='monospaced'>
  4594. $ bitbake -c compile -f <replaceable>package</replaceable>
  4595. </literallayout>
  4596. The <filename>-f</filename> or <filename>--force</filename>
  4597. option forces the specified task to execute.
  4598. If you find problems with your code, you can just keep
  4599. editing and re-testing iteratively until things work
  4600. as expected.
  4601. <note>
  4602. All the modifications you make to the temporary
  4603. source code disappear once you run the
  4604. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-clean'><filename>do_clean</filename></ulink>
  4605. or
  4606. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-cleanall'><filename>do_cleanall</filename></ulink>
  4607. tasks using BitBake (i.e.
  4608. <filename>bitbake -c clean <replaceable>package</replaceable></filename>
  4609. and
  4610. <filename>bitbake -c cleanall <replaceable>package</replaceable></filename>).
  4611. Modifications will also disappear if you use the
  4612. <filename>rm_work</filename> feature as described
  4613. in the
  4614. "<ulink url='&YOCTO_DOCS_DEV_URL;#dev-saving-memory-during-a-build'>Conserving Disk Space During Builds</ulink>"
  4615. section.
  4616. </note>
  4617. </para></listitem>
  4618. <listitem><para>
  4619. <emphasis>Generate the Patch:</emphasis>
  4620. Once your changes work as expected, you need to use Quilt
  4621. to generate the final patch that contains all your
  4622. modifications.
  4623. <literallayout class='monospaced'>
  4624. $ quilt refresh
  4625. </literallayout>
  4626. At this point, the <filename>my_changes.patch</filename>
  4627. file has all your edits made to the
  4628. <filename>file1.c</filename>, <filename>file2.c</filename>,
  4629. and <filename>file3.c</filename> files.</para>
  4630. <para>You can find the resulting patch file in the
  4631. <filename>patches/</filename> subdirectory of the source
  4632. (<filename>S</filename>) directory.
  4633. </para></listitem>
  4634. <listitem><para>
  4635. <emphasis>Copy the Patch File:</emphasis>
  4636. For simplicity, copy the patch file into a directory
  4637. named <filename>files</filename>, which you can create
  4638. in the same directory that holds the recipe
  4639. (<filename>.bb</filename>) file or the append
  4640. (<filename>.bbappend</filename>) file.
  4641. Placing the patch here guarantees that the OpenEmbedded
  4642. build system will find the patch.
  4643. Next, add the patch into the
  4644. <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'>SRC_URI</ulink></filename>
  4645. of the recipe.
  4646. Here is an example:
  4647. <literallayout class='monospaced'>
  4648. SRC_URI += "file://my_changes.patch"
  4649. </literallayout>
  4650. </para></listitem>
  4651. </orderedlist>
  4652. </para>
  4653. </section>
  4654. <section id="platdev-appdev-devshell">
  4655. <title>Using a Development Shell</title>
  4656. <para>
  4657. When debugging certain commands or even when just editing packages,
  4658. <filename>devshell</filename> can be a useful tool.
  4659. When you invoke <filename>devshell</filename>, all tasks up to and
  4660. including
  4661. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-patch'><filename>do_patch</filename></ulink>
  4662. are run for the specified target.
  4663. Then, a new terminal is opened and you are placed in
  4664. <filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-S'><filename>S</filename></ulink><filename>}</filename>,
  4665. the source directory.
  4666. In the new terminal, all the OpenEmbedded build-related environment variables are
  4667. still defined so you can use commands such as <filename>configure</filename> and
  4668. <filename>make</filename>.
  4669. The commands execute just as if the OpenEmbedded build system were executing them.
  4670. Consequently, working this way can be helpful when debugging a build or preparing
  4671. software to be used with the OpenEmbedded build system.
  4672. </para>
  4673. <para>
  4674. Following is an example that uses <filename>devshell</filename> on a target named
  4675. <filename>matchbox-desktop</filename>:
  4676. <literallayout class='monospaced'>
  4677. $ bitbake matchbox-desktop -c devshell
  4678. </literallayout>
  4679. </para>
  4680. <para>
  4681. This command spawns a terminal with a shell prompt within the OpenEmbedded build environment.
  4682. The <ulink url='&YOCTO_DOCS_REF_URL;#var-OE_TERMINAL'><filename>OE_TERMINAL</filename></ulink>
  4683. variable controls what type of shell is opened.
  4684. </para>
  4685. <para>
  4686. For spawned terminals, the following occurs:
  4687. <itemizedlist>
  4688. <listitem><para>The <filename>PATH</filename> variable includes the
  4689. cross-toolchain.</para></listitem>
  4690. <listitem><para>The <filename>pkgconfig</filename> variables find the correct
  4691. <filename>.pc</filename> files.</para></listitem>
  4692. <listitem><para>The <filename>configure</filename> command finds the
  4693. Yocto Project site files as well as any other necessary files.</para></listitem>
  4694. </itemizedlist>
  4695. </para>
  4696. <para>
  4697. Within this environment, you can run configure or compile
  4698. commands as if they were being run by
  4699. the OpenEmbedded build system itself.
  4700. As noted earlier, the working directory also automatically changes to the
  4701. Source Directory (<ulink url='&YOCTO_DOCS_REF_URL;#var-S'><filename>S</filename></ulink>).
  4702. </para>
  4703. <para>
  4704. To manually run a specific task using <filename>devshell</filename>,
  4705. run the corresponding <filename>run.*</filename> script in
  4706. the
  4707. <filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-WORKDIR'><filename>WORKDIR</filename></ulink><filename>}/temp</filename>
  4708. directory (e.g.,
  4709. <filename>run.do_configure.</filename><replaceable>pid</replaceable>).
  4710. If a task's script does not exist, which would be the case if the task was
  4711. skipped by way of the sstate cache, you can create the task by first running
  4712. it outside of the <filename>devshell</filename>:
  4713. <literallayout class='monospaced'>
  4714. $ bitbake -c <replaceable>task</replaceable>
  4715. </literallayout>
  4716. <note><title>Notes</title>
  4717. <itemizedlist>
  4718. <listitem><para>Execution of a task's <filename>run.*</filename>
  4719. script and BitBake's execution of a task are identical.
  4720. In other words, running the script re-runs the task
  4721. just as it would be run using the
  4722. <filename>bitbake -c</filename> command.
  4723. </para></listitem>
  4724. <listitem><para>Any <filename>run.*</filename> file that does not
  4725. have a <filename>.pid</filename> extension is a
  4726. symbolic link (symlink) to the most recent version of that
  4727. file.
  4728. </para></listitem>
  4729. </itemizedlist>
  4730. </note>
  4731. </para>
  4732. <para>
  4733. Remember, that the <filename>devshell</filename> is a mechanism that allows
  4734. you to get into the BitBake task execution environment.
  4735. And as such, all commands must be called just as BitBake would call them.
  4736. That means you need to provide the appropriate options for
  4737. cross-compilation and so forth as applicable.
  4738. </para>
  4739. <para>
  4740. When you are finished using <filename>devshell</filename>, exit the shell
  4741. or close the terminal window.
  4742. </para>
  4743. <note><title>Notes</title>
  4744. <itemizedlist>
  4745. <listitem><para>
  4746. It is worth remembering that when using <filename>devshell</filename>
  4747. you need to use the full compiler name such as <filename>arm-poky-linux-gnueabi-gcc</filename>
  4748. instead of just using <filename>gcc</filename>.
  4749. The same applies to other applications such as <filename>binutils</filename>,
  4750. <filename>libtool</filename> and so forth.
  4751. BitBake sets up environment variables such as <filename>CC</filename>
  4752. to assist applications, such as <filename>make</filename> to find the correct tools.
  4753. </para></listitem>
  4754. <listitem><para>
  4755. It is also worth noting that <filename>devshell</filename> still works over
  4756. X11 forwarding and similar situations.
  4757. </para></listitem>
  4758. </itemizedlist>
  4759. </note>
  4760. </section>
  4761. <section id="platdev-appdev-devpyshell">
  4762. <title>Using a Development Python Shell</title>
  4763. <para>
  4764. Similar to working within a development shell as described in
  4765. the previous section, you can also spawn and work within an
  4766. interactive Python development shell.
  4767. When debugging certain commands or even when just editing packages,
  4768. <filename>devpyshell</filename> can be a useful tool.
  4769. When you invoke <filename>devpyshell</filename>, all tasks up to and
  4770. including
  4771. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-patch'><filename>do_patch</filename></ulink>
  4772. are run for the specified target.
  4773. Then a new terminal is opened.
  4774. Additionally, key Python objects and code are available in the same
  4775. way they are to BitBake tasks, in particular, the data store 'd'.
  4776. So, commands such as the following are useful when exploring the data
  4777. store and running functions:
  4778. <literallayout class='monospaced'>
  4779. pydevshell> d.getVar("STAGING_DIR", True)
  4780. '/media/build1/poky/build/tmp/sysroots'
  4781. pydevshell> d.getVar("STAGING_DIR", False)
  4782. '${TMPDIR}/sysroots'
  4783. pydevshell> d.setVar("FOO", "bar")
  4784. pydevshell> d.getVar("FOO", True)
  4785. 'bar'
  4786. pydevshell> d.delVar("FOO")
  4787. pydevshell> d.getVar("FOO", True)
  4788. pydevshell> bb.build.exec_func("do_unpack", d)
  4789. pydevshell>
  4790. </literallayout>
  4791. The commands execute just as if the OpenEmbedded build system were executing them.
  4792. Consequently, working this way can be helpful when debugging a build or preparing
  4793. software to be used with the OpenEmbedded build system.
  4794. </para>
  4795. <para>
  4796. Following is an example that uses <filename>devpyshell</filename> on a target named
  4797. <filename>matchbox-desktop</filename>:
  4798. <literallayout class='monospaced'>
  4799. $ bitbake matchbox-desktop -c devpyshell
  4800. </literallayout>
  4801. </para>
  4802. <para>
  4803. This command spawns a terminal and places you in an interactive
  4804. Python interpreter within the OpenEmbedded build environment.
  4805. The <ulink url='&YOCTO_DOCS_REF_URL;#var-OE_TERMINAL'><filename>OE_TERMINAL</filename></ulink>
  4806. variable controls what type of shell is opened.
  4807. </para>
  4808. <para>
  4809. When you are finished using <filename>devpyshell</filename>, you
  4810. can exit the shell either by using Ctrl+d or closing the terminal
  4811. window.
  4812. </para>
  4813. </section>
  4814. <section id='platdev-building-targets-with-multiple-configurations'>
  4815. <title>Building Targets with Multiple Configurations</title>
  4816. <para>
  4817. Bitbake also has functionality that allows you to build
  4818. multiple targets at the same time, where each target uses
  4819. a different configuration.
  4820. </para>
  4821. <para>
  4822. In order to accomplish this, you setup each of the configurations
  4823. you need to use in parallel by placing the configuration files in
  4824. your current build directory alongside the usual
  4825. <filename>local.conf</filename> file.
  4826. </para>
  4827. <para>
  4828. Follow these guidelines to create an environment that supports
  4829. multiple configurations:
  4830. <itemizedlist>
  4831. <listitem><para>
  4832. <emphasis>Create Configuration Files</emphasis>:
  4833. You need to create a single configuration file for each
  4834. configuration for which you want to add support.
  4835. These files would contain lines such as the following:
  4836. <literallayout class='monospaced'>
  4837. MACHINE = "A"
  4838. </literallayout>
  4839. The files would contain any other variables that can
  4840. be set and built in the same directory.
  4841. <note>
  4842. You can change the
  4843. <ulink url='&YOCTO_DOCS_REF_URL;#var-TMPDIR'><filename>TMPDIR</filename></ulink>
  4844. to not conflict.
  4845. </note></para>
  4846. <para>
  4847. Furthermore, the configuration file must be located in the
  4848. current build directory in a directory named
  4849. <filename>multiconfig</filename> under the build's
  4850. <filename>conf</filename> directory where
  4851. <filename>local.conf</filename> resides.
  4852. The reason for this restriction is because the
  4853. <filename>BBPATH</filename> variable is not constructed
  4854. until the layers are parsed.
  4855. Consequently, using the configuration file as a
  4856. pre-configuration file is not possible unless it is
  4857. located in the current working directory.
  4858. </para></listitem>
  4859. <listitem><para>
  4860. <emphasis>Add the BitBake Multi-Config Variable to you Local Configuration File</emphasis>:
  4861. Use the
  4862. <filename>BBMULTICONFIG</filename>
  4863. variable in your <filename>conf/local.conf</filename>
  4864. configuration file to specify each separate configuration.
  4865. For example, the following line tells BitBake it should load
  4866. <filename>conf/multiconfig/configA.conf</filename>,
  4867. <filename>conf/multiconfig/configB.conf</filename>, and
  4868. <filename>conf/multiconfig/configC.conf</filename>.
  4869. <literallayout class='monospaced'>
  4870. BBMULTICONFIG = "configA configB configC"
  4871. </literallayout>
  4872. </para></listitem>
  4873. <listitem><para>
  4874. <emphasis>Launch BitBake</emphasis>:
  4875. Use the following BitBake command form to launch the
  4876. build:
  4877. <literallayout class='monospaced'>
  4878. $ bitbake [multiconfig:<replaceable>multiconfigname</replaceable>:]<replaceable>target</replaceable> [[[multiconfig:<replaceable>multiconfigname</replaceable>:]<replaceable>target</replaceable>] ... ]
  4879. </literallayout>
  4880. Following is an example that supports building a minimal
  4881. image for configuration A alongside a standard
  4882. <filename>core-image-sato</filename>, which takes its
  4883. configuration from <filename>local.conf</filename>:
  4884. <literallayout class='monospaced'>
  4885. $ bitbake multiconfig:configA:core-image-minimal core-image-sato
  4886. </literallayout>
  4887. </para></listitem>
  4888. </itemizedlist>
  4889. </para>
  4890. <para>
  4891. Support for multiple configurations in this current release of
  4892. the Yocto Project (&DISTRO_NAME; &DISTRO;) has some known issues:
  4893. <itemizedlist>
  4894. <listitem><para>
  4895. No inter-multi-configuration dependencies exist.
  4896. </para></listitem>
  4897. <listitem><para>
  4898. Shared State (sstate) optimizations do not exist.
  4899. Consequently, if the build uses the same object twice
  4900. in, for example, two different
  4901. <filename>TMPDIR</filename> directories, the build
  4902. will either load from an existing sstate cache at the
  4903. start or build the object twice.
  4904. </para></listitem>
  4905. </itemizedlist>
  4906. </para>
  4907. </section>
  4908. <section id="platdev-working-with-libraries">
  4909. <title>Working With Libraries</title>
  4910. <para>
  4911. Libraries are an integral part of your system.
  4912. This section describes some common practices you might find
  4913. helpful when working with libraries to build your system:
  4914. <itemizedlist>
  4915. <listitem><para><link linkend='including-static-library-files'>How to include static library files</link>
  4916. </para></listitem>
  4917. <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>
  4918. </para></listitem>
  4919. <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>
  4920. </para></listitem>
  4921. </itemizedlist>
  4922. </para>
  4923. <section id='including-static-library-files'>
  4924. <title>Including Static Library Files</title>
  4925. <para>
  4926. If you are building a library and the library offers static linking, you can control
  4927. which static library files (<filename>*.a</filename> files) get included in the
  4928. built library.
  4929. </para>
  4930. <para>
  4931. The <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGES'><filename>PACKAGES</filename></ulink>
  4932. and <ulink url='&YOCTO_DOCS_REF_URL;#var-FILES'><filename>FILES_*</filename></ulink>
  4933. variables in the
  4934. <filename>meta/conf/bitbake.conf</filename> configuration file define how files installed
  4935. by the <filename>do_install</filename> task are packaged.
  4936. By default, the <filename>PACKAGES</filename> variable includes
  4937. <filename>${PN}-staticdev</filename>, which represents all static library files.
  4938. <note>
  4939. Some previously released versions of the Yocto Project
  4940. defined the static library files through
  4941. <filename>${PN}-dev</filename>.
  4942. </note>
  4943. Following is part of the BitBake configuration file, where
  4944. you can see how the static library files are defined:
  4945. <literallayout class='monospaced'>
  4946. PACKAGE_BEFORE_PN ?= ""
  4947. PACKAGES = "${PN}-dbg ${PN}-staticdev ${PN}-dev ${PN}-doc ${PN}-locale ${PACKAGE_BEFORE_PN} ${PN}"
  4948. PACKAGES_DYNAMIC = "^${PN}-locale-.*"
  4949. FILES = ""
  4950. FILES_${PN} = "${bindir}/* ${sbindir}/* ${libexecdir}/* ${libdir}/lib*${SOLIBS} \
  4951. ${sysconfdir} ${sharedstatedir} ${localstatedir} \
  4952. ${base_bindir}/* ${base_sbindir}/* \
  4953. ${base_libdir}/*${SOLIBS} \
  4954. ${base_prefix}/lib/udev/rules.d ${prefix}/lib/udev/rules.d \
  4955. ${datadir}/${BPN} ${libdir}/${BPN}/* \
  4956. ${datadir}/pixmaps ${datadir}/applications \
  4957. ${datadir}/idl ${datadir}/omf ${datadir}/sounds \
  4958. ${libdir}/bonobo/servers"
  4959. FILES_${PN}-bin = "${bindir}/* ${sbindir}/*"
  4960. FILES_${PN}-doc = "${docdir} ${mandir} ${infodir} ${datadir}/gtk-doc \
  4961. ${datadir}/gnome/help"
  4962. SECTION_${PN}-doc = "doc"
  4963. FILES_SOLIBSDEV ?= "${base_libdir}/lib*${SOLIBSDEV} ${libdir}/lib*${SOLIBSDEV}"
  4964. FILES_${PN}-dev = "${includedir} ${FILES_SOLIBSDEV} ${libdir}/*.la \
  4965. ${libdir}/*.o ${libdir}/pkgconfig ${datadir}/pkgconfig \
  4966. ${datadir}/aclocal ${base_libdir}/*.o \
  4967. ${libdir}/${BPN}/*.la ${base_libdir}/*.la"
  4968. SECTION_${PN}-dev = "devel"
  4969. ALLOW_EMPTY_${PN}-dev = "1"
  4970. RDEPENDS_${PN}-dev = "${PN} (= ${EXTENDPKGV})"
  4971. FILES_${PN}-staticdev = "${libdir}/*.a ${base_libdir}/*.a ${libdir}/${BPN}/*.a"
  4972. SECTION_${PN}-staticdev = "devel"
  4973. RDEPENDS_${PN}-staticdev = "${PN}-dev (= ${EXTENDPKGV})"
  4974. </literallayout>
  4975. </para>
  4976. </section>
  4977. <section id="combining-multiple-versions-library-files-into-one-image">
  4978. <title>Combining Multiple Versions of Library Files into One Image</title>
  4979. <para>
  4980. The build system offers the ability to build libraries with different
  4981. target optimizations or architecture formats and combine these together
  4982. into one system image.
  4983. You can link different binaries in the image
  4984. against the different libraries as needed for specific use cases.
  4985. This feature is called "Multilib."
  4986. </para>
  4987. <para>
  4988. An example would be where you have most of a system compiled in 32-bit
  4989. mode using 32-bit libraries, but you have something large, like a database
  4990. engine, that needs to be a 64-bit application and uses 64-bit libraries.
  4991. Multilib allows you to get the best of both 32-bit and 64-bit libraries.
  4992. </para>
  4993. <para>
  4994. While the Multilib feature is most commonly used for 32 and 64-bit differences,
  4995. the approach the build system uses facilitates different target optimizations.
  4996. You could compile some binaries to use one set of libraries and other binaries
  4997. to use a different set of libraries.
  4998. The libraries could differ in architecture, compiler options, or other
  4999. optimizations.
  5000. </para>
  5001. <para>
  5002. Several examples exist in the
  5003. <filename>meta-skeleton</filename> layer found in the
  5004. <ulink url='&YOCTO_DOCS_REF_URL;#source-directory'>Source Directory</ulink>:
  5005. <itemizedlist>
  5006. <listitem><para><filename>conf/multilib-example.conf</filename>
  5007. configuration file</para></listitem>
  5008. <listitem><para><filename>conf/multilib-example2.conf</filename>
  5009. configuration file</para></listitem>
  5010. <listitem><para><filename>recipes-multilib/images/core-image-multilib-example.bb</filename>
  5011. recipe</para></listitem>
  5012. </itemizedlist>
  5013. </para>
  5014. <section id='preparing-to-use-multilib'>
  5015. <title>Preparing to Use Multilib</title>
  5016. <para>
  5017. User-specific requirements drive the Multilib feature.
  5018. Consequently, there is no one "out-of-the-box" configuration that likely
  5019. exists to meet your needs.
  5020. </para>
  5021. <para>
  5022. In order to enable Multilib, you first need to ensure your recipe is
  5023. extended to support multiple libraries.
  5024. Many standard recipes are already extended and support multiple libraries.
  5025. You can check in the <filename>meta/conf/multilib.conf</filename>
  5026. configuration file in the
  5027. <ulink url='&YOCTO_DOCS_REF_URL;#source-directory'>Source Directory</ulink> to see how this is
  5028. done using the
  5029. <ulink url='&YOCTO_DOCS_REF_URL;#var-BBCLASSEXTEND'><filename>BBCLASSEXTEND</filename></ulink>
  5030. variable.
  5031. Eventually, all recipes will be covered and this list will
  5032. not be needed.
  5033. </para>
  5034. <para>
  5035. For the most part, the Multilib class extension works automatically to
  5036. extend the package name from <filename>${PN}</filename> to
  5037. <filename>${MLPREFIX}${PN}</filename>, where <filename>MLPREFIX</filename>
  5038. is the particular multilib (e.g. "lib32-" or "lib64-").
  5039. Standard variables such as
  5040. <ulink url='&YOCTO_DOCS_REF_URL;#var-DEPENDS'><filename>DEPENDS</filename></ulink>,
  5041. <ulink url='&YOCTO_DOCS_REF_URL;#var-RDEPENDS'><filename>RDEPENDS</filename></ulink>,
  5042. <ulink url='&YOCTO_DOCS_REF_URL;#var-RPROVIDES'><filename>RPROVIDES</filename></ulink>,
  5043. <ulink url='&YOCTO_DOCS_REF_URL;#var-RRECOMMENDS'><filename>RRECOMMENDS</filename></ulink>,
  5044. <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGES'><filename>PACKAGES</filename></ulink>, and
  5045. <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGES_DYNAMIC'><filename>PACKAGES_DYNAMIC</filename></ulink>
  5046. are automatically extended by the system.
  5047. If you are extending any manual code in the recipe, you can use the
  5048. <filename>${MLPREFIX}</filename> variable to ensure those names are extended
  5049. correctly.
  5050. This automatic extension code resides in <filename>multilib.bbclass</filename>.
  5051. </para>
  5052. </section>
  5053. <section id='using-multilib'>
  5054. <title>Using Multilib</title>
  5055. <para>
  5056. After you have set up the recipes, you need to define the actual
  5057. combination of multiple libraries you want to build.
  5058. You accomplish this through your <filename>local.conf</filename>
  5059. configuration file in the
  5060. <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink>.
  5061. An example configuration would be as follows:
  5062. <literallayout class='monospaced'>
  5063. MACHINE = "qemux86-64"
  5064. require conf/multilib.conf
  5065. MULTILIBS = "multilib:lib32"
  5066. DEFAULTTUNE_virtclass-multilib-lib32 = "x86"
  5067. IMAGE_INSTALL_append = " lib32-glib-2.0"
  5068. </literallayout>
  5069. This example enables an
  5070. additional library named <filename>lib32</filename> alongside the
  5071. normal target packages.
  5072. When combining these "lib32" alternatives, the example uses "x86" for tuning.
  5073. For information on this particular tuning, see
  5074. <filename>meta/conf/machine/include/ia32/arch-ia32.inc</filename>.
  5075. </para>
  5076. <para>
  5077. The example then includes <filename>lib32-glib-2.0</filename>
  5078. in all the images, which illustrates one method of including a
  5079. multiple library dependency.
  5080. You can use a normal image build to include this dependency,
  5081. for example:
  5082. <literallayout class='monospaced'>
  5083. $ bitbake core-image-sato
  5084. </literallayout>
  5085. You can also build Multilib packages specifically with a command like this:
  5086. <literallayout class='monospaced'>
  5087. $ bitbake lib32-glib-2.0
  5088. </literallayout>
  5089. </para>
  5090. </section>
  5091. <section id='additional-implementation-details'>
  5092. <title>Additional Implementation Details</title>
  5093. <para>
  5094. Generic implementation details as well as details that are
  5095. specific to package management systems exist.
  5096. Following are implementation details that exist regardless
  5097. of the package management system:
  5098. <itemizedlist>
  5099. <listitem><para>The typical convention used for the
  5100. class extension code as used by
  5101. Multilib assumes that all package names specified
  5102. in
  5103. <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGES'><filename>PACKAGES</filename></ulink>
  5104. that contain <filename>${PN}</filename> have
  5105. <filename>${PN}</filename> at the start of the name.
  5106. When that convention is not followed and
  5107. <filename>${PN}</filename> appears at
  5108. the middle or the end of a name, problems occur.
  5109. </para></listitem>
  5110. <listitem><para>The
  5111. <ulink url='&YOCTO_DOCS_REF_URL;#var-TARGET_VENDOR'><filename>TARGET_VENDOR</filename></ulink>
  5112. value under Multilib will be extended to
  5113. "-<replaceable>vendor</replaceable>ml<replaceable>multilib</replaceable>"
  5114. (e.g. "-pokymllib32" for a "lib32" Multilib with
  5115. Poky).
  5116. The reason for this slightly unwieldy contraction
  5117. is that any "-" characters in the vendor
  5118. string presently break Autoconf's
  5119. <filename>config.sub</filename>, and
  5120. other separators are problematic for different
  5121. reasons.
  5122. </para></listitem>
  5123. </itemizedlist>
  5124. </para>
  5125. <para>
  5126. For the RPM Package Management System, the following implementation details
  5127. exist:
  5128. <itemizedlist>
  5129. <listitem><para>A unique architecture is defined for the Multilib packages,
  5130. along with creating a unique deploy folder under
  5131. <filename>tmp/deploy/rpm</filename> in the
  5132. <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink>.
  5133. For example, consider <filename>lib32</filename> in a
  5134. <filename>qemux86-64</filename> image.
  5135. The possible architectures in the system are "all", "qemux86_64",
  5136. "lib32_qemux86_64", and "lib32_x86".</para></listitem>
  5137. <listitem><para>The <filename>${MLPREFIX}</filename> variable is stripped from
  5138. <filename>${PN}</filename> during RPM packaging.
  5139. The naming for a normal RPM package and a Multilib RPM package in a
  5140. <filename>qemux86-64</filename> system resolves to something similar to
  5141. <filename>bash-4.1-r2.x86_64.rpm</filename> and
  5142. <filename>bash-4.1.r2.lib32_x86.rpm</filename>, respectively.
  5143. </para></listitem>
  5144. <listitem><para>When installing a Multilib image, the RPM backend first
  5145. installs the base image and then installs the Multilib libraries.
  5146. </para></listitem>
  5147. <listitem><para>The build system relies on RPM to resolve the identical files in the
  5148. two (or more) Multilib packages.</para></listitem>
  5149. </itemizedlist>
  5150. </para>
  5151. <para>
  5152. For the IPK Package Management System, the following implementation details exist:
  5153. <itemizedlist>
  5154. <listitem><para>The <filename>${MLPREFIX}</filename> is not stripped from
  5155. <filename>${PN}</filename> during IPK packaging.
  5156. The naming for a normal RPM package and a Multilib IPK package in a
  5157. <filename>qemux86-64</filename> system resolves to something like
  5158. <filename>bash_4.1-r2.x86_64.ipk</filename> and
  5159. <filename>lib32-bash_4.1-rw_x86.ipk</filename>, respectively.
  5160. </para></listitem>
  5161. <listitem><para>The IPK deploy folder is not modified with
  5162. <filename>${MLPREFIX}</filename> because packages with and without
  5163. the Multilib feature can exist in the same folder due to the
  5164. <filename>${PN}</filename> differences.</para></listitem>
  5165. <listitem><para>IPK defines a sanity check for Multilib installation
  5166. using certain rules for file comparison, overridden, etc.
  5167. </para></listitem>
  5168. </itemizedlist>
  5169. </para>
  5170. </section>
  5171. </section>
  5172. <section id='installing-multiple-versions-of-the-same-library'>
  5173. <title>Installing Multiple Versions of the Same Library</title>
  5174. <para>
  5175. Situations can exist where you need to install and use
  5176. multiple versions of the same library on the same system
  5177. at the same time.
  5178. These situations almost always exist when a library API
  5179. changes and you have multiple pieces of software that
  5180. depend on the separate versions of the library.
  5181. To accommodate these situations, you can install multiple
  5182. versions of the same library in parallel on the same system.
  5183. </para>
  5184. <para>
  5185. The process is straightforward as long as the libraries use
  5186. proper versioning.
  5187. With properly versioned libraries, all you need to do to
  5188. individually specify the libraries is create separate,
  5189. appropriately named recipes where the
  5190. <ulink url='&YOCTO_DOCS_REF_URL;#var-PN'><filename>PN</filename></ulink> part of the
  5191. name includes a portion that differentiates each library version
  5192. (e.g.the major part of the version number).
  5193. Thus, instead of having a single recipe that loads one version
  5194. of a library (e.g. <filename>clutter</filename>), you provide
  5195. multiple recipes that result in different versions
  5196. of the libraries you want.
  5197. As an example, the following two recipes would allow the
  5198. two separate versions of the <filename>clutter</filename>
  5199. library to co-exist on the same system:
  5200. <literallayout class='monospaced'>
  5201. clutter-1.6_1.6.20.bb
  5202. clutter-1.8_1.8.4.bb
  5203. </literallayout>
  5204. Additionally, if you have other recipes that depend on a given
  5205. library, you need to use the
  5206. <ulink url='&YOCTO_DOCS_REF_URL;#var-DEPENDS'><filename>DEPENDS</filename></ulink>
  5207. variable to create the dependency.
  5208. Continuing with the same example, if you want to have a recipe
  5209. depend on the 1.8 version of the <filename>clutter</filename>
  5210. library, use the following in your recipe:
  5211. <literallayout class='monospaced'>
  5212. DEPENDS = "clutter-1.8"
  5213. </literallayout>
  5214. </para>
  5215. </section>
  5216. </section>
  5217. <section id='using-x32-psabi'>
  5218. <title>Using x32 psABI</title>
  5219. <para>
  5220. x32 processor-specific Application Binary Interface
  5221. (<ulink url='https://software.intel.com/en-us/node/628948'>x32 psABI</ulink>)
  5222. is a native 32-bit processor-specific ABI for
  5223. <trademark class='registered'>Intel</trademark> 64 (x86-64)
  5224. architectures.
  5225. An ABI defines the calling conventions between functions in a
  5226. processing environment.
  5227. The interface determines what registers are used and what the
  5228. sizes are for various C data types.
  5229. </para>
  5230. <para>
  5231. Some processing environments prefer using 32-bit applications even
  5232. when running on Intel 64-bit platforms.
  5233. Consider the i386 psABI, which is a very old 32-bit ABI for Intel
  5234. 64-bit platforms.
  5235. The i386 psABI does not provide efficient use and access of the
  5236. Intel 64-bit processor resources, leaving the system underutilized.
  5237. Now consider the x86_64 psABI.
  5238. This ABI is newer and uses 64-bits for data sizes and program
  5239. pointers.
  5240. The extra bits increase the footprint size of the programs,
  5241. libraries, and also increases the memory and file system size
  5242. requirements.
  5243. Executing under the x32 psABI enables user programs to utilize CPU
  5244. and system resources more efficiently while keeping the memory
  5245. footprint of the applications low.
  5246. Extra bits are used for registers but not for addressing mechanisms.
  5247. </para>
  5248. <para>
  5249. The Yocto Project supports the final specifications of x32 psABI
  5250. as follows:
  5251. <itemizedlist>
  5252. <listitem><para>
  5253. You can create packages and images in x32 psABI format on
  5254. x86_64 architecture targets.
  5255. </para></listitem>
  5256. <listitem><para>
  5257. You can successfully build recipes with the x32 toolchain.
  5258. </para></listitem>
  5259. <listitem><para>
  5260. You can create and boot
  5261. <filename>core-image-minimal</filename> and
  5262. <filename>core-image-sato</filename> images.
  5263. </para></listitem>
  5264. <listitem><para>
  5265. RPM Package Manager (RPM) support exists for x32 binaries.
  5266. </para></listitem>
  5267. <listitem><para>
  5268. Support for large images exists.
  5269. </para></listitem>
  5270. </itemizedlist>
  5271. </para>
  5272. <para>
  5273. To use the x32 psABI, you need to edit your
  5274. <filename>conf/local.conf</filename> configuration file as
  5275. follows:
  5276. <literallayout class='monospaced'>
  5277. MACHINE = "qemux86-64"
  5278. DEFAULTTUNE = "x86-64-x32"
  5279. baselib = "${@d.getVar('BASE_LIB_tune-' + (d.getVar('DEFAULTTUNE', True) \
  5280. or 'INVALID'), True) or 'lib'}"
  5281. </literallayout>
  5282. Once you have set up your configuration file, use BitBake to
  5283. build an image that supports the x32 psABI.
  5284. Here is an example:
  5285. <literallayout class='monospaced'>
  5286. $ bitbake core-image-sato
  5287. </literallayout>
  5288. </para>
  5289. </section>
  5290. <section id='enabling-gobject-introspection-support'>
  5291. <title>Enabling GObject Introspection Support</title>
  5292. <para>
  5293. <ulink url='https://wiki.gnome.org/Projects/GObjectIntrospection'>GObject introspection</ulink>
  5294. is the standard mechanism for accessing GObject-based software
  5295. from runtime environments.
  5296. GObject is a feature of the GLib library that provides an object
  5297. framework for the GNOME desktop and related software.
  5298. GObject Introspection adds information to GObject that allows
  5299. objects created within it to be represented across different
  5300. programming languages.
  5301. If you want to construct GStreamer pipelines using Python, or
  5302. control UPnP infrastructure using Javascript and GUPnP,
  5303. GObject introspection is the only way to do it.
  5304. </para>
  5305. <para>
  5306. This section describes the Yocto Project support for generating
  5307. and packaging GObject introspection data.
  5308. GObject introspection data is a description of the
  5309. API provided by libraries built on top of GLib framework,
  5310. and, in particular, that framework's GObject mechanism.
  5311. GObject Introspection Repository (GIR) files go to
  5312. <filename>-dev</filename> packages,
  5313. <filename>typelib</filename> files go to main packages as they
  5314. are packaged together with libraries that are introspected.
  5315. </para>
  5316. <para>
  5317. The data is generated when building such a library, by linking
  5318. the library with a small executable binary that asks the library
  5319. to describe itself, and then executing the binary and
  5320. processing its output.
  5321. </para>
  5322. <para>
  5323. Generating this data in a cross-compilation environment
  5324. is difficult because the library is produced for the target
  5325. architecture, but its code needs to be executed on the build host.
  5326. This problem is solved with the OpenEmbedded build system by
  5327. running the code through QEMU, which allows precisely that.
  5328. Unfortunately, QEMU does not always work perfectly as mentioned
  5329. in the xxx section.
  5330. </para>
  5331. <section id='enabling-the-generation-of-introspection-data'>
  5332. <title>Enabling the Generation of Introspection Data</title>
  5333. <para>
  5334. Enabling the generation of introspection data (GIR files)
  5335. in your library package involves the following:
  5336. <orderedlist>
  5337. <listitem><para>
  5338. Inherit the
  5339. <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-gobject-introspection'><filename>gobject-introspection</filename></ulink>
  5340. class.
  5341. </para></listitem>
  5342. <listitem><para>
  5343. Make sure introspection is not disabled anywhere in
  5344. the recipe or from anything the recipe includes.
  5345. Also, make sure that "gobject-introspection-data" is
  5346. not in
  5347. <ulink url='&YOCTO_DOCS_REF_URL;#var-DISTRO_FEATURES_BACKFILL_CONSIDERED'><filename>DISTRO_FEATURES_BACKFILL_CONSIDERED</filename></ulink>
  5348. and that "qemu-usermode" is not in
  5349. <ulink url='&YOCTO_DOCS_REF_URL;#var-MACHINE_FEATURES_BACKFILL_CONSIDERED'><filename>MACHINE_FEATURES_BACKFILL_CONSIDERED</filename></ulink>.
  5350. If either of these conditions exist, nothing will
  5351. happen.
  5352. </para></listitem>
  5353. <listitem><para>
  5354. Try to build the recipe.
  5355. If you encounter build errors that look like
  5356. something is unable to find
  5357. <filename>.so</filename> libraries, check where these
  5358. libraries are located in the source tree and add
  5359. the following to the recipe:
  5360. <literallayout class='monospaced'>
  5361. GIR_EXTRA_LIBS_PATH = "${B}/<replaceable>something</replaceable>/.libs"
  5362. </literallayout>
  5363. <note>
  5364. See recipes in the <filename>oe-core</filename>
  5365. repository that use that
  5366. <filename>GIR_EXTRA_LIBS_PATH</filename> variable
  5367. as an example.
  5368. </note>
  5369. </para></listitem>
  5370. <listitem><para>
  5371. Look for any other errors, which probably mean that
  5372. introspection support in a package is not entirely
  5373. standard, and thus breaks down in a cross-compilation
  5374. environment.
  5375. For such cases, custom-made fixes are needed.
  5376. A good place to ask and receive help in these cases
  5377. is the
  5378. <ulink url='&YOCTO_DOCS_REF_URL;#resources-mailinglist'>Yocto Project mailing lists</ulink>.
  5379. </para></listitem>
  5380. </orderedlist>
  5381. <note>
  5382. Using a library that no longer builds against the latest
  5383. Yocto Project release and prints introspection related
  5384. errors is a good candidate for the previous procedure.
  5385. </note>
  5386. </para>
  5387. </section>
  5388. <section id='disabling-the-generation-of-introspection-data'>
  5389. <title>Disabling the Generation of Introspection Data</title>
  5390. <para>
  5391. You might find that you do not want to generate
  5392. introspection data.
  5393. Or, perhaps QEMU does not work on your build host and
  5394. target architecture combination.
  5395. If so, you can use either of the following methods to
  5396. disable GIR file generations:
  5397. <itemizedlist>
  5398. <listitem><para>
  5399. Add the following to your distro configuration:
  5400. <literallayout class='monospaced'>
  5401. DISTRO_FEATURES_BACKFILL_CONSIDERED = "gobject-introspection-data"
  5402. </literallayout>
  5403. Adding this statement disables generating
  5404. introspection data using QEMU but will still enable
  5405. building introspection tools and libraries
  5406. (i.e. building them does not require the use of QEMU).
  5407. </para></listitem>
  5408. <listitem><para>
  5409. Add the following to your machine configuration:
  5410. <literallayout class='monospaced'>
  5411. MACHINE_FEATURES_BACKFILL_CONSIDERED = "qemu-usermode"
  5412. </literallayout>
  5413. Adding this statement disables the use of QEMU
  5414. when building packages for your machine.
  5415. Currently, this feature is used only by introspection
  5416. recipes and has the same effect as the previously
  5417. described option.
  5418. <note>
  5419. Future releases of the Yocto Project might have
  5420. other features affected by this option.
  5421. </note>
  5422. </para></listitem>
  5423. </itemizedlist>
  5424. If you disable introspection data, you can still
  5425. obtain it through other means such as copying the data
  5426. from a suitable sysroot, or by generating it on the
  5427. target hardware.
  5428. The OpenEmbedded build system does not currently
  5429. provide specific support for these techniques.
  5430. </para>
  5431. </section>
  5432. <section id='testing-that-introspection-works-in-an-image'>
  5433. <title>Testing that Introspection Works in an Image</title>
  5434. <para>
  5435. Use the following procedure to test if generating
  5436. introspection data is working in an image:
  5437. <orderedlist>
  5438. <listitem><para>
  5439. Make sure that "gobject-introspection-data" is not in
  5440. <ulink url='&YOCTO_DOCS_REF_URL;#var-DISTRO_FEATURES_BACKFILL_CONSIDERED'><filename>DISTRO_FEATURES_BACKFILL_CONSIDERED</filename></ulink>
  5441. and that "qemu-usermode" is not in
  5442. <ulink url='&YOCTO_DOCS_REF_URL;#var-MACHINE_FEATURES_BACKFILL_CONSIDERED'><filename>MACHINE_FEATURES_BACKFILL_CONSIDERED</filename></ulink>.
  5443. </para></listitem>
  5444. <listitem><para>
  5445. Build <filename>core-image-sato</filename>.
  5446. </para></listitem>
  5447. <listitem><para>
  5448. Launch a Terminal and then start Python in the
  5449. terminal.
  5450. </para></listitem>
  5451. <listitem><para>
  5452. Enter the following in the terminal:
  5453. <literallayout class='monospaced'>
  5454. >>> from gi.repository import GLib
  5455. >>> GLib.get_host_name()
  5456. </literallayout>
  5457. </para></listitem>
  5458. <listitem><para>
  5459. For something a little more advanced, enter the
  5460. following:
  5461. <literallayout class='monospaced'>
  5462. http://python-gtk-3-tutorial.readthedocs.org/en/latest/introduction.html
  5463. </literallayout>
  5464. </para></listitem>
  5465. </orderedlist>
  5466. </para>
  5467. </section>
  5468. <section id='known-issues'>
  5469. <title>Known Issues</title>
  5470. <para>
  5471. The following know issues exist for
  5472. GObject Introspection Support:
  5473. <itemizedlist>
  5474. <listitem><para>
  5475. <filename>qemu-ppc64</filename> immediately crashes.
  5476. Consequently, you cannot build introspection data on
  5477. that architecture.
  5478. </para></listitem>
  5479. <listitem><para>
  5480. x32 is not supported by QEMU.
  5481. Consequently, introspection data is disabled.
  5482. </para></listitem>
  5483. <listitem><para>
  5484. musl causes transient GLib binaries to crash on
  5485. assertion failures.
  5486. Consequently, generating introspection data is
  5487. disabled.
  5488. </para></listitem>
  5489. <listitem><para>
  5490. Because QEMU is not able to run the binaries correctly,
  5491. introspection is disabled for some specific packages
  5492. under specific architectures (e.g.
  5493. <filename>gcr</filename>,
  5494. <filename>libsecret</filename>, and
  5495. <filename>webkit</filename>).
  5496. </para></listitem>
  5497. <listitem><para>
  5498. QEMU usermode might not work properly when running
  5499. 64-bit binaries under 32-bit host machines.
  5500. In particular, "qemumips64" is known to not work under
  5501. i686.
  5502. </para></listitem>
  5503. </itemizedlist>
  5504. </para>
  5505. </section>
  5506. </section>
  5507. <section id='dev-optionally-using-an-external-toolchain'>
  5508. <title>Optionally Using an External Toolchain</title>
  5509. <para>
  5510. You might want to use an external toolchain as part of your
  5511. development.
  5512. If this is the case, the fundamental steps you need to accomplish
  5513. are as follows:
  5514. <itemizedlist>
  5515. <listitem><para>
  5516. Understand where the installed toolchain resides.
  5517. For cases where you need to build the external toolchain,
  5518. you would need to take separate steps to build and install
  5519. the toolchain.
  5520. </para></listitem>
  5521. <listitem><para>
  5522. Make sure you add the layer that contains the toolchain to
  5523. your <filename>bblayers.conf</filename> file through the
  5524. <ulink url='&YOCTO_DOCS_REF_URL;#var-BBLAYERS'><filename>BBLAYERS</filename></ulink>
  5525. variable.
  5526. </para></listitem>
  5527. <listitem><para>
  5528. Set the
  5529. <ulink url='&YOCTO_DOCS_REF_URL;#var-EXTERNAL_TOOLCHAIN'><filename>EXTERNAL_TOOLCHAIN</filename></ulink>
  5530. variable in your <filename>local.conf</filename> file
  5531. to the location in which you installed the toolchain.
  5532. </para></listitem>
  5533. </itemizedlist>
  5534. A good example of an external toolchain used with the Yocto Project
  5535. is <trademark class='registered'>Mentor Graphics</trademark>
  5536. Sourcery G++ Toolchain.
  5537. You can see information on how to use that particular layer in the
  5538. <filename>README</filename> file at
  5539. <ulink url='http://github.com/MentorEmbedded/meta-sourcery/'></ulink>.
  5540. You can find further information by reading about the
  5541. <ulink url='&YOCTO_DOCS_REF_URL;#var-TCMODE'><filename>TCMODE</filename></ulink>
  5542. variable in the Yocto Project Reference Manual's variable glossary.
  5543. </para>
  5544. </section>
  5545. <section id='creating-partitioned-images-using-wic'>
  5546. <title>Creating Partitioned Images Using Wic</title>
  5547. <para>
  5548. Creating an image for a particular hardware target using the
  5549. OpenEmbedded build system does not necessarily mean you can boot
  5550. that image as is on your device.
  5551. Physical devices accept and boot images in various ways depending
  5552. on the specifics of the device.
  5553. Usually, information about the hardware can tell you what image
  5554. format the device requires.
  5555. Should your device require multiple partitions on an SD card, flash,
  5556. or an HDD, you can use the OpenEmbedded Image Creator,
  5557. Wic, to create the properly partitioned image.
  5558. </para>
  5559. <para>
  5560. The <filename>wic</filename> command generates partitioned
  5561. images from existing OpenEmbedded build artifacts.
  5562. Image generation is driven by partitioning commands
  5563. contained in an Openembedded kickstart file
  5564. (<filename>.wks</filename>) specified either directly on
  5565. the command line or as one of a selection of canned
  5566. kickstart files as shown with the
  5567. <filename>wic list images</filename> command in the
  5568. "<link linkend='using-a-provided-kickstart-file'>Using an Existing Kickstart File</link>"
  5569. section.
  5570. When you apply the command to a given set of build
  5571. artifacts, the result is an image or set of images that
  5572. can be directly written onto media and used on a particular
  5573. system.
  5574. <note>
  5575. For a kickstart file reference, see the
  5576. "<ulink url='&YOCTO_DOCS_REF_URL;#openembedded-kickstart-wks-reference'>OpenEmbedded Kickstart (<filename>.wks</filename>) Reference</ulink>"
  5577. Chapter in the Yocto Project Reference Manual.
  5578. </note>
  5579. </para>
  5580. <para>
  5581. The <filename>wic</filename> command and the infrastructure
  5582. it is based on is by definition incomplete.
  5583. The purpose of the command is to allow the generation of
  5584. customized images, and as such, was designed to be
  5585. completely extensible through a plug-in interface.
  5586. See the
  5587. "<link linkend='wic-using-the-wic-plug-ins-interface'>Using the Wic Plug-Ins Interface</link>"
  5588. section for information on these plug-ins.
  5589. </para>
  5590. <para>
  5591. This section provides some background information on Wic,
  5592. describes what you need to have in
  5593. place to run the tool, provides instruction on how to use
  5594. the Wic utility, provides information on using the Wic plug-ins
  5595. interface, and provides several examples that show how to use
  5596. Wic.
  5597. </para>
  5598. <section id='wic-background'>
  5599. <title>Background</title>
  5600. <para>
  5601. This section provides some background on the Wic utility.
  5602. While none of this information is required to use
  5603. Wic, you might find it interesting.
  5604. <itemizedlist>
  5605. <listitem><para>
  5606. The name "Wic" is derived from OpenEmbedded
  5607. Image Creator (oeic).
  5608. The "oe" diphthong in "oeic" was promoted to the
  5609. letter "w", because "oeic" is both difficult to
  5610. remember and to pronounce.
  5611. </para></listitem>
  5612. <listitem><para>
  5613. Wic is loosely based on the
  5614. Meego Image Creator (<filename>mic</filename>)
  5615. framework.
  5616. The Wic implementation has been
  5617. heavily modified to make direct use of OpenEmbedded
  5618. build artifacts instead of package installation and
  5619. configuration, which are already incorporated within
  5620. the OpenEmbedded artifacts.
  5621. </para></listitem>
  5622. <listitem><para>
  5623. Wic is a completely independent
  5624. standalone utility that initially provides
  5625. easier-to-use and more flexible replacements for an
  5626. existing functionality in OE-Core's
  5627. <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-image-live'><filename>image-live</filename></ulink>
  5628. class and <filename>mkefidisk.sh</filename> script.
  5629. The difference between
  5630. Wic and those examples is
  5631. that with Wic the
  5632. functionality of those scripts is implemented
  5633. by a general-purpose partitioning language, which is
  5634. based on Redhat kickstart syntax.</para></listitem>
  5635. </itemizedlist>
  5636. </para>
  5637. </section>
  5638. <section id='wic-requirements'>
  5639. <title>Requirements</title>
  5640. <para>
  5641. In order to use the Wic utility with the OpenEmbedded Build
  5642. system, your system needs to meet the following
  5643. requirements:
  5644. <itemizedlist>
  5645. <listitem><para>
  5646. The Linux distribution on your development host must
  5647. support the Yocto Project.
  5648. See the
  5649. "<ulink url='&YOCTO_DOCS_REF_URL;#detailed-supported-distros'>Supported Linux Distributions</ulink>"
  5650. section in the Yocto Project Reference Manual for
  5651. the list of distributions that support the
  5652. Yocto Project.
  5653. </para></listitem>
  5654. <listitem><para>
  5655. The standard system utilities, such as
  5656. <filename>cp</filename>, must be installed on your
  5657. development host system.
  5658. </para></listitem>
  5659. <listitem><para>
  5660. You must have sourced the build environment
  5661. setup script (i.e.
  5662. <ulink url='&YOCTO_DOCS_REF_URL;#structure-core-script'><filename>&OE_INIT_FILE;</filename></ulink>)
  5663. found in the
  5664. <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink>.
  5665. </para></listitem>
  5666. <listitem><para>
  5667. You need to have the build artifacts already
  5668. available, which typically means that you must
  5669. have already created an image using the
  5670. Openembedded build system (e.g.
  5671. <filename>core-image-minimal</filename>).
  5672. While it might seem redundant to generate an image
  5673. in order to create an image using
  5674. Wic, the current version of
  5675. Wic requires the artifacts
  5676. in the form generated by the OpenEmbedded build
  5677. system.
  5678. </para></listitem>
  5679. <listitem><para>
  5680. You must build several native tools, which are
  5681. built to run on the build system:
  5682. <literallayout class='monospaced'>
  5683. $ bitbake parted-native dosfstools-native mtools-native
  5684. </literallayout>
  5685. </para></listitem>
  5686. <listitem><para>
  5687. Include "wic" as part of the
  5688. <ulink url='&YOCTO_DOCS_REF_URL;#var-IMAGE_FSTYPES'><filename>IMAGE_FSTYPES</filename></ulink>
  5689. variable.
  5690. </para></listitem>
  5691. <listitem><para>
  5692. Include the name of the
  5693. <ulink url='&YOCTO_DOCS_REF_URL;#openembedded-kickstart-wks-reference'>wic kickstart file</ulink>
  5694. as part of the
  5695. <ulink url='&YOCTO_DOCS_REF_URL;#var-WKS_FILE'><filename>WKS_FILE</filename></ulink>
  5696. variable
  5697. </para></listitem>
  5698. </itemizedlist>
  5699. </para>
  5700. </section>
  5701. <section id='wic-getting-help'>
  5702. <title>Getting Help</title>
  5703. <para>
  5704. You can get general help for the <filename>wic</filename>
  5705. command by entering the <filename>wic</filename> command
  5706. by itself or by entering the command with a help argument
  5707. as follows:
  5708. <literallayout class='monospaced'>
  5709. $ wic -h
  5710. $ wic --help
  5711. $ wic help
  5712. </literallayout>
  5713. </para>
  5714. <para>
  5715. Currently, Wic supports seven commands:
  5716. <filename>cp</filename>, <filename>create</filename>,
  5717. <filename>help</filename>, <filename>list</filename>,
  5718. <filename>ls</filename>, <filename>rm</filename>, and
  5719. <filename>write</filename>.
  5720. You can get help for all these commands except "help" by
  5721. using the following form:
  5722. <literallayout class='monospaced'>
  5723. $ wic help <replaceable>command</replaceable>
  5724. </literallayout>
  5725. For example, the following command returns help for the
  5726. <filename>write</filename> command:
  5727. <literallayout class='monospaced'>
  5728. $ wic help write
  5729. </literallayout>
  5730. </para>
  5731. <para>
  5732. Wic supports help for three topics:
  5733. <filename>overview</filename>,
  5734. <filename>plugins</filename>, and
  5735. <filename>kickstart</filename>.
  5736. You can get help for any topic using the following form:
  5737. <literallayout class='monospaced'>
  5738. $ wic help <replaceable>topic</replaceable>
  5739. </literallayout>
  5740. For example, the following returns overview help for Wic:
  5741. <literallayout class='monospaced'>
  5742. $ wic help overview
  5743. </literallayout>
  5744. </para>
  5745. <para>
  5746. One additional level of help exists for Wic.
  5747. You can get help on individual images through the
  5748. <filename>list</filename> command.
  5749. You can use the <filename>list</filename> command to return the
  5750. available Wic images as follows:
  5751. <literallayout class='monospaced'>
  5752. $ wic list images
  5753. mpc8315e-rdb Create SD card image for MPC8315E-RDB
  5754. genericx86 Create an EFI disk image for genericx86*
  5755. beaglebone-yocto Create SD card image for Beaglebone
  5756. edgerouter Create SD card image for Edgerouter
  5757. qemux86-directdisk Create a qemu machine 'pcbios' direct disk image
  5758. directdisk-gpt Create a 'pcbios' direct disk image
  5759. mkefidisk Create an EFI disk image
  5760. directdisk Create a 'pcbios' direct disk image
  5761. systemd-bootdisk Create an EFI disk image with systemd-boot
  5762. mkhybridiso Create a hybrid ISO image
  5763. sdimage-bootpart Create SD card image with a boot partition
  5764. directdisk-multi-rootfs Create multi rootfs image using rootfs plugin
  5765. directdisk-bootloader-config Create a 'pcbios' direct disk image with custom bootloader config
  5766. </literallayout>
  5767. Once you know the list of available Wic images, you can use
  5768. <filename>help</filename> with the command to get help on a
  5769. particular image.
  5770. For example, the following command returns help on the
  5771. "beaglebone-yocto" image:
  5772. <literallayout class='monospaced'>
  5773. $ wic list beaglebone-yocto help
  5774. Creates a partitioned SD card image for Beaglebone.
  5775. Boot files are located in the first vfat partition.
  5776. </literallayout>
  5777. </para>
  5778. </section>
  5779. <section id='operational-modes'>
  5780. <title>Operational Modes</title>
  5781. <para>
  5782. You can use Wic in two different
  5783. modes, depending on how much control you need for
  5784. specifying the Openembedded build artifacts that are
  5785. used for creating the image: Raw and Cooked:
  5786. <itemizedlist>
  5787. <listitem><para>
  5788. <emphasis>Raw Mode:</emphasis>
  5789. You explicitly specify build artifacts through
  5790. Wic command-line arguments.
  5791. </para></listitem>
  5792. <listitem><para>
  5793. <emphasis>Cooked Mode:</emphasis>
  5794. The current
  5795. <ulink url='&YOCTO_DOCS_REF_URL;#var-MACHINE'><filename>MACHINE</filename></ulink>
  5796. setting and image name are used to automatically
  5797. locate and provide the build artifacts.
  5798. You just supply a kickstart file and the name
  5799. of the image from which to use artifacts.
  5800. </para></listitem>
  5801. </itemizedlist>
  5802. </para>
  5803. <para>
  5804. Regardless of the mode you use, you need to have the build
  5805. artifacts ready and available.
  5806. </para>
  5807. <section id='raw-mode'>
  5808. <title>Raw Mode</title>
  5809. <para>
  5810. Running Wic in raw mode allows you to specify all the
  5811. partitions through the <filename>wic</filename>
  5812. command line.
  5813. The primary use for raw mode is if you have built
  5814. your kernel outside of the Yocto Project
  5815. <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink>.
  5816. In other words, you can point to arbitrary kernel,
  5817. root filesystem locations, and so forth.
  5818. Contrast this behavior with cooked mode where Wic
  5819. looks in the Build Directory (e.g.
  5820. <filename>tmp/deploy/images/</filename><replaceable>machine</replaceable>).
  5821. </para>
  5822. <para>
  5823. The general form of the
  5824. <filename>wic</filename> command in raw mode is:
  5825. <literallayout class='monospaced'>
  5826. $ wic create <replaceable>wks_file</replaceable> <replaceable>options</replaceable> ...
  5827. Where:
  5828. <replaceable>wks_file</replaceable>:
  5829. An OpenEmbedded kickstart file. You can provide
  5830. your own custom file or use a file from a set of
  5831. existing files as described by further options.
  5832. optional arguments:
  5833. -h, --help show this help message and exit
  5834. -o <replaceable>OUTDIR</replaceable>, --outdir <replaceable>OUTDIR</replaceable>
  5835. name of directory to create image in
  5836. -e <replaceable>IMAGE_NAME</replaceable>, --image-name <replaceable>IMAGE_NAME</replaceable>
  5837. name of the image to use the artifacts from e.g. core-
  5838. image-sato
  5839. -r <replaceable>ROOTFS_DIR</replaceable>, --rootfs-dir <replaceable>ROOTFS_DIR</replaceable>
  5840. path to the /rootfs dir to use as the .wks rootfs
  5841. source
  5842. -b <replaceable>BOOTIMG_DIR</replaceable>, --bootimg-dir <replaceable>BOOTIMG_DIR</replaceable>
  5843. path to the dir containing the boot artifacts (e.g.
  5844. /EFI or /syslinux dirs) to use as the .wks bootimg
  5845. source
  5846. -k <replaceable>KERNEL_DIR</replaceable>, --kernel-dir <replaceable>KERNEL_DIR</replaceable>
  5847. path to the dir containing the kernel to use in the
  5848. .wks bootimg
  5849. -n <replaceable>NATIVE_SYSROOT</replaceable>, --native-sysroot <replaceable>NATIVE_SYSROOT</replaceable>
  5850. path to the native sysroot containing the tools to use
  5851. to build the image
  5852. -s, --skip-build-check
  5853. skip the build check
  5854. -f, --build-rootfs build rootfs
  5855. -c {gzip,bzip2,xz}, --compress-with {gzip,bzip2,xz}
  5856. compress image with specified compressor
  5857. -m, --bmap generate .bmap
  5858. --no-fstab-update Do not change fstab file.
  5859. -v <replaceable>VARS_DIR</replaceable>, --vars <replaceable>VARS_DIR</replaceable>
  5860. directory with &lt;image&gt;.env files that store bitbake
  5861. variables
  5862. -D, --debug output debug information
  5863. </literallayout>
  5864. <note>
  5865. You do not need root privileges to run
  5866. Wic.
  5867. In fact, you should not run as root when using the
  5868. utility.
  5869. </note>
  5870. </para>
  5871. </section>
  5872. <section id='cooked-mode'>
  5873. <title>Cooked Mode</title>
  5874. <para>
  5875. Running Wic in cooked mode leverages off artifacts in
  5876. the Build Directory.
  5877. In other words, you do not have to specify kernel or
  5878. root filesystem locations as part of the command.
  5879. All you need to provide is a kickstart file and the
  5880. name of the image from which to use artifacts by using
  5881. the "-e" option.
  5882. Wic looks in the Build Directory (e.g.
  5883. <filename>tmp/deploy/images/</filename><replaceable>machine</replaceable>)
  5884. for artifacts.
  5885. </para>
  5886. <para>
  5887. The general form of the <filename>wic</filename>
  5888. command using Cooked Mode is as follows:
  5889. <literallayout class='monospaced'>
  5890. $ wic create <replaceable>wks_file</replaceable> -e <replaceable>IMAGE_NAME</replaceable>
  5891. Where:
  5892. <replaceable>wks_file</replaceable>:
  5893. An OpenEmbedded kickstart file. You can provide
  5894. your own custom file or use a file from a set of
  5895. existing files provided with the Yocto Project
  5896. release.
  5897. required argument:
  5898. -e <replaceable>IMAGE_NAME</replaceable>, --image-name <replaceable>IMAGE_NAME</replaceable>
  5899. name of the image to use the artifacts from e.g. core-
  5900. image-sato
  5901. </literallayout>
  5902. </para>
  5903. </section>
  5904. </section>
  5905. <section id='using-a-provided-kickstart-file'>
  5906. <title>Using an Existing Kickstart File</title>
  5907. <para>
  5908. If you do not want to create your own kickstart file, you
  5909. can use an existing file provided by the Wic installation.
  5910. As shipped, kickstart files can be found in the
  5911. Yocto Project
  5912. <ulink url='&YOCTO_DOCS_OM_URL;#source-repositories'>Source Repositories</ulink>
  5913. in the following two locations:
  5914. <literallayout class='monospaced'>
  5915. poky/meta-yocto-bsp/wic
  5916. poky/scripts/lib/wic/canned-wks
  5917. </literallayout>
  5918. Use the following command to list the available kickstart
  5919. files:
  5920. <literallayout class='monospaced'>
  5921. $ wic list images
  5922. mpc8315e-rdb Create SD card image for MPC8315E-RDB
  5923. genericx86 Create an EFI disk image for genericx86*
  5924. beaglebone-yocto Create SD card image for Beaglebone
  5925. edgerouter Create SD card image for Edgerouter
  5926. qemux86-directdisk Create a qemu machine 'pcbios' direct disk image
  5927. directdisk-gpt Create a 'pcbios' direct disk image
  5928. mkefidisk Create an EFI disk image
  5929. directdisk Create a 'pcbios' direct disk image
  5930. systemd-bootdisk Create an EFI disk image with systemd-boot
  5931. mkhybridiso Create a hybrid ISO image
  5932. sdimage-bootpart Create SD card image with a boot partition
  5933. directdisk-multi-rootfs Create multi rootfs image using rootfs plugin
  5934. directdisk-bootloader-config Create a 'pcbios' direct disk image with custom bootloader config
  5935. </literallayout>
  5936. When you use an existing file, you do not have to use the
  5937. <filename>.wks</filename> extension.
  5938. Here is an example in Raw Mode that uses the
  5939. <filename>directdisk</filename> file:
  5940. <literallayout class='monospaced'>
  5941. $ wic create directdisk -r <replaceable>rootfs_dir</replaceable> -b <replaceable>bootimg_dir</replaceable> \
  5942. -k <replaceable>kernel_dir</replaceable> -n <replaceable>native_sysroot</replaceable>
  5943. </literallayout>
  5944. </para>
  5945. <para>
  5946. Here are the actual partition language commands
  5947. used in the <filename>genericx86.wks</filename> file to
  5948. generate an image:
  5949. <literallayout class='monospaced'>
  5950. # short-description: Create an EFI disk image for genericx86*
  5951. # long-description: Creates a partitioned EFI disk image for genericx86* machines
  5952. part /boot --source bootimg-efi --sourceparams="loader=grub-efi" --ondisk sda --label msdos --active --align 1024
  5953. part / --source rootfs --ondisk sda --fstype=ext4 --label platform --align 1024 --use-uuid
  5954. part swap --ondisk sda --size 44 --label swap1 --fstype=swap
  5955. bootloader --ptable gpt --timeout=5 --append="rootfstype=ext4 console=ttyS0,115200 console=tty0"
  5956. </literallayout>
  5957. </para>
  5958. </section>
  5959. <section id='wic-using-the-wic-plug-ins-interface'>
  5960. <title>Using the Wic Plug-Ins Interface</title>
  5961. <para>
  5962. You can extend and specialize Wic functionality by using
  5963. Wic plug-ins.
  5964. This section explains the Wic plug-in interface.
  5965. <note>
  5966. Wic plug-ins consist of "source" and "imager" plug-ins.
  5967. Imager plug-ins are beyond the scope of this section.
  5968. </note>
  5969. </para>
  5970. <para>
  5971. Source plug-ins provide a mechanism to customize partition
  5972. content during the Wic image generation process.
  5973. You can use source plug-ins to map values that you specify
  5974. using <filename>--source</filename> commands in kickstart
  5975. files (i.e. <filename>*.wks</filename>) to a plug-in
  5976. implementation used to populate a given partition.
  5977. <note>
  5978. If you use plug-ins that have build-time dependencies
  5979. (e.g. native tools, bootloaders, and so forth)
  5980. when building a Wic image, you need to specify those
  5981. dependencies using the
  5982. <ulink url='&YOCTO_DOCS_REF_URL;#var-WKS_FILE_DEPENDS'><filename>WKS_FILE_DEPENDS</filename></ulink>
  5983. variable.
  5984. </note>
  5985. </para>
  5986. <para>
  5987. Source plug-ins are subclasses defined in plug-in files.
  5988. As shipped, the Yocto Project provides several plug-in
  5989. files.
  5990. You can see the source plug-in files that ship with the
  5991. Yocto Project
  5992. <ulink url='&YOCTO_GIT_URL;/cgit/cgit.cgi/poky/tree/scripts/lib/wic/plugins/source'>here</ulink>.
  5993. Each of these plug-in files contains source plug-ins that
  5994. are designed to populate a specific Wic image partition.
  5995. </para>
  5996. <para>
  5997. Source plug-ins are subclasses of the
  5998. <filename>SourcePlugin</filename> class, which is
  5999. defined in the
  6000. <filename>poky/scripts/lib/wic/pluginbase.py</filename>
  6001. file.
  6002. For example, the <filename>BootimgEFIPlugin</filename>
  6003. source plug-in found in the
  6004. <filename>bootimg-efi.py</filename> file is a subclass of
  6005. the <filename>SourcePlugin</filename> class, which is found
  6006. in the <filename>pluginbase.py</filename> file.
  6007. </para>
  6008. <para>
  6009. You can also implement source plug-ins in a layer outside
  6010. of the Source Repositories (external layer).
  6011. To do so, be sure that your plug-in files are located in
  6012. a directory whose path is
  6013. <filename>scripts/lib/wic/plugins/source/</filename>
  6014. within your external layer.
  6015. When the plug-in files are located there, the source
  6016. plug-ins they contain are made available to Wic.
  6017. </para>
  6018. <para>
  6019. When the Wic implementation needs to invoke a
  6020. partition-specific implementation, it looks for the plug-in
  6021. with the same name as the <filename>--source</filename>
  6022. parameter used in the kickstart file given to that
  6023. partition.
  6024. For example, if the partition is set up using the following
  6025. command in a kickstart file:
  6026. <literallayout class='monospaced'>
  6027. part /boot --source bootimg-pcbios --ondisk sda --label boot --active --align 1024
  6028. </literallayout>
  6029. The methods defined as class members of the matching
  6030. source plug-in (i.e. <filename>bootimg-pcbios</filename>)
  6031. in the <filename>bootimg-pcbios.py</filename> plug-in file
  6032. are used.
  6033. </para>
  6034. <para>
  6035. To be more concrete, here is the corresponding plug-in
  6036. definition from the <filename>bootimg-pcbios.py</filename>
  6037. file for the previous command along with an example
  6038. method called by the Wic implementation when it needs to
  6039. prepare a partition using an implementation-specific
  6040. function:
  6041. <literallayout class='monospaced'>
  6042. .
  6043. .
  6044. .
  6045. class BootimgPcbiosPlugin(SourcePlugin):
  6046. """
  6047. Create MBR boot partition and install syslinux on it.
  6048. """
  6049. name = 'bootimg-pcbios'
  6050. .
  6051. .
  6052. .
  6053. @classmethod
  6054. def do_prepare_partition(cls, part, source_params, creator, cr_workdir,
  6055. oe_builddir, bootimg_dir, kernel_dir,
  6056. rootfs_dir, native_sysroot):
  6057. """
  6058. Called to do the actual content population for a partition i.e. it
  6059. 'prepares' the partition to be incorporated into the image.
  6060. In this case, prepare content for legacy bios boot partition.
  6061. """
  6062. .
  6063. .
  6064. .
  6065. </literallayout>
  6066. If a subclass (plug-in) itself does not implement a
  6067. particular function, Wic locates and uses the default
  6068. version in the superclass.
  6069. It is for this reason that all source plug-ins are derived
  6070. from the <filename>SourcePlugin</filename> class.
  6071. </para>
  6072. <para>
  6073. The <filename>SourcePlugin</filename> class defined in
  6074. the <filename>pluginbase.py</filename> file defines
  6075. a set of methods that source plug-ins can implement or
  6076. override.
  6077. Any plug-ins (subclass of
  6078. <filename>SourcePlugin</filename>) that do not implement
  6079. a particular method inherit the implementation of the
  6080. method from the <filename>SourcePlugin</filename> class.
  6081. For more information, see the
  6082. <filename>SourcePlugin</filename> class in the
  6083. <filename>pluginbase.py</filename> file for details:
  6084. </para>
  6085. <para>
  6086. The following list describes the methods implemented in the
  6087. <filename>SourcePlugin</filename> class:
  6088. <itemizedlist>
  6089. <listitem><para>
  6090. <emphasis><filename>do_prepare_partition()</filename>:</emphasis>
  6091. Called to populate a partition with actual content.
  6092. In other words, the method prepares the final
  6093. partition image that is incorporated into the
  6094. disk image.
  6095. </para></listitem>
  6096. <listitem><para>
  6097. <emphasis><filename>do_configure_partition()</filename>:</emphasis>
  6098. Called before
  6099. <filename>do_prepare_partition()</filename> to
  6100. create custom configuration files for a partition
  6101. (e.g. syslinux or grub configuration files).
  6102. </para></listitem>
  6103. <listitem><para>
  6104. <emphasis><filename>do_install_disk()</filename>:</emphasis>
  6105. Called after all partitions have been prepared and
  6106. assembled into a disk image.
  6107. This method provides a hook to allow finalization
  6108. of a disk image (e.g. writing an MBR).
  6109. </para></listitem>
  6110. <listitem><para>
  6111. <emphasis><filename>do_stage_partition()</filename>:</emphasis>
  6112. Special content-staging hook called before
  6113. <filename>do_prepare_partition()</filename>.
  6114. This method is normally empty.</para>
  6115. <para>Typically, a partition just uses the passed-in
  6116. parameters (e.g. the unmodified value of
  6117. <filename>bootimg_dir</filename>).
  6118. However, in some cases, things might need to be
  6119. more tailored.
  6120. As an example, certain files might additionally
  6121. need to be taken from
  6122. <filename>bootimg_dir + /boot</filename>.
  6123. This hook allows those files to be staged in a
  6124. customized fashion.
  6125. <note>
  6126. <filename>get_bitbake_var()</filename>
  6127. allows you to access non-standard variables
  6128. that you might want to use for this
  6129. behavior.
  6130. </note>
  6131. </para></listitem>
  6132. </itemizedlist>
  6133. </para>
  6134. <para>
  6135. You can extend the source plug-in mechanism.
  6136. To add more hooks, create more source plug-in methods
  6137. within <filename>SourcePlugin</filename> and the
  6138. corresponding derived subclasses.
  6139. The code that calls the plug-in methods uses the
  6140. <filename>plugin.get_source_plugin_methods()</filename>
  6141. function to find the method or methods needed by the call.
  6142. Retrieval of those methods is accomplished by filling up
  6143. a dict with keys that contain the method names of interest.
  6144. On success, these will be filled in with the actual
  6145. methods.
  6146. See the Wic implementation for examples and details.
  6147. </para>
  6148. </section>
  6149. <section id='wic-usage-examples'>
  6150. <title>Examples</title>
  6151. <para>
  6152. This section provides several examples that show how to use
  6153. the Wic utility.
  6154. All the examples assume the list of requirements in the
  6155. "<link linkend='wic-requirements'>Requirements</link>"
  6156. section have been met.
  6157. The examples assume the previously generated image is
  6158. <filename>core-image-minimal</filename>.
  6159. </para>
  6160. <section id='generate-an-image-using-a-provided-kickstart-file'>
  6161. <title>Generate an Image using an Existing Kickstart File</title>
  6162. <para role='writernotes'>
  6163. This example runs in Cooked Mode and uses the
  6164. <filename>mkefidisk</filename> kickstart file:
  6165. [OUTPUT IS WRONG DUE TO A BUG - ROOTFS_DIR AND BOOTIMG_DIR
  6166. ARE DISPLAYING TEMPORARY FILES THAT WIC CLEANS UP BY DELETING]
  6167. <literallayout class='monospaced'>
  6168. $ wic create mkefidisk -e core-image-minimal
  6169. INFO: Building wic-tools...
  6170. .
  6171. .
  6172. .
  6173. INFO: The new image(s) can be found here:
  6174. ./mkefidisk-201802211426-sda.direct
  6175. The following build artifacts were used to create the image(s):
  6176. ROOTFS_DIR: /home/scottrif/poky/build/tmp.wic.zjs_iw41/rootfs_copy
  6177. BOOTIMG_DIR: /home/scottrif/poky/build/tmp/work/qemux86-poky-linux/core-image-minimal/1.0-r0/recipe-sysroot/usr/share
  6178. KERNEL_DIR: /home/scottrif/poky/build/tmp/deploy/images/qemux86
  6179. NATIVE_SYSROOT: /home/scottrif/poky/build/tmp/work/i586-poky-linux/wic-tools/1.0-r0/recipe-sysroot-native
  6180. INFO: The image(s) were created using OE kickstart file:
  6181. /home/scottrif/poky/scripts/lib/wic/canned-wks/mkefidisk.wks
  6182. </literallayout>
  6183. The previous example shows the easiest way to create
  6184. an image by running in cooked mode and supplying
  6185. a kickstart file and the "-e" option to point to the
  6186. existing build artifacts.
  6187. Your <filename>local.conf</filename> file needs to have
  6188. the
  6189. <ulink url='&YOCTO_DOCS_REF_URL;#var-MACHINE'><filename>MACHINE</filename></ulink>
  6190. variable set to the machine you are using, which is
  6191. "qemux86" in this example.
  6192. </para>
  6193. <para>
  6194. Once the image builds, the output provides image
  6195. location, artifact use, and kickstart file information.
  6196. <note>
  6197. You should always verify the details provided in the
  6198. output to make sure that the image was indeed
  6199. created exactly as expected.
  6200. </note>
  6201. </para>
  6202. <para>
  6203. Continuing with the example, you can now write the
  6204. image from the Build Directory onto a USB stick, or
  6205. whatever media for which you built your image, and boot
  6206. from the media.
  6207. You can write the image by using
  6208. <filename>bmaptool</filename> or
  6209. <filename>dd</filename>:
  6210. <literallayout class='monospaced'>
  6211. $ oe-run-native bmaptool copy mkefidisk-201802211426-sda.direct /dev/sd<replaceable>X</replaceable>
  6212. </literallayout>
  6213. or
  6214. <literallayout class='monospaced'>
  6215. $ sudo dd if=mkefidisk-201802211426-sda.direct of=/dev/sd<replaceable>X</replaceable>
  6216. </literallayout>
  6217. <note>
  6218. For more information on how to use the
  6219. <filename>bmaptool</filename> to flash a device
  6220. with an image, see the
  6221. "<link linkend='flashing-images-using-bmaptool'>Flashing Images Using <filename>bmaptool</filename></link>"
  6222. section.
  6223. </note>
  6224. </para>
  6225. </section>
  6226. <section id='using-a-modified-kickstart-file'>
  6227. <title>Using a Modified Kickstart File</title>
  6228. <para>
  6229. Because partitioned image creation is driven by the
  6230. kickstart file, it is easy to affect image creation by
  6231. changing the parameters in the file.
  6232. This next example demonstrates that through modification
  6233. of the <filename>directdisk-gpt</filename> kickstart
  6234. file.
  6235. </para>
  6236. <para>
  6237. As mentioned earlier, you can use the command
  6238. <filename>wic list images</filename> to show the list
  6239. of existing kickstart files.
  6240. The directory in which the
  6241. <filename>directdisk-gpt.wks</filename> file resides is
  6242. <filename>scripts/lib/image/canned-wks/</filename>,
  6243. which is located in the
  6244. <ulink url='&YOCTO_DOCS_REF_URL;#source-directory'>Source Directory</ulink>
  6245. (e.g. <filename>poky</filename>).
  6246. Because available files reside in this directory,
  6247. you can create and add your own custom files to the
  6248. directory.
  6249. Subsequent use of the
  6250. <filename>wic list images</filename> command would then
  6251. include your kickstart files.
  6252. </para>
  6253. <para>
  6254. In this example, the existing
  6255. <filename>directdisk-gpt</filename> file already does
  6256. most of what is needed.
  6257. However, for the hardware in this example, the image
  6258. will need to boot from <filename>sdb</filename> instead
  6259. of <filename>sda</filename>, which is what the
  6260. <filename>directdisk-gpt</filename> kickstart file
  6261. uses.
  6262. </para>
  6263. <para>
  6264. The example begins by making a copy of the
  6265. <filename>directdisk-gpt.wks</filename> file in the
  6266. <filename>scripts/lib/image/canned-wks</filename>
  6267. directory and then by changing the lines that specify
  6268. the target disk from which to boot.
  6269. <literallayout class='monospaced'>
  6270. $ cp /home/scottrif/poky/scripts/lib/wic/canned-wks/directdisk-gpt.wks \
  6271. /home/scottrif/poky/scripts/lib/wic/canned-wks/directdisksdb-gpt.wks
  6272. </literallayout>
  6273. Next, the example modifies the
  6274. <filename>directdisksdb-gpt.wks</filename> file and
  6275. changes all instances of
  6276. "<filename>--ondisk sda</filename>" to
  6277. "<filename>--ondisk sdb</filename>".
  6278. The example changes the following two lines and leaves
  6279. the remaining lines untouched:
  6280. <literallayout class='monospaced'>
  6281. part /boot --source bootimg-pcbios --ondisk sdb --label boot --active --align 1024
  6282. part / --source rootfs --ondisk sdb --fstype=ext4 --label platform --align 1024 --use-uuid
  6283. </literallayout>
  6284. Once the lines are changed, the example generates the
  6285. <filename>directdisksdb-gpt</filename> image.
  6286. The command points the process at the
  6287. <filename>core-image-minimal</filename> artifacts for
  6288. the Next Unit of Computing (nuc)
  6289. <ulink url='&YOCTO_DOCS_REF_URL;#var-MACHINE'><filename>MACHINE</filename></ulink>
  6290. the <filename>local.conf</filename>.
  6291. <literallayout class='monospaced'>
  6292. $ wic create directdisksdb-gpt -e core-image-minimal
  6293. INFO: Building wic-tools...
  6294. .
  6295. .
  6296. .
  6297. Initialising tasks: 100% |#######################################| Time: 0:00:01
  6298. NOTE: Executing SetScene Tasks
  6299. NOTE: Executing RunQueue Tasks
  6300. NOTE: Tasks Summary: Attempted 1161 tasks of which 1157 didn't need to be rerun and all succeeded.
  6301. INFO: Creating image(s)...
  6302. INFO: The new image(s) can be found here:
  6303. ./directdisksdb-gpt-201710090938-sdb.direct
  6304. The following build artifacts were used to create the image(s):
  6305. ROOTFS_DIR: /home/scottrif/poky/build/tmp.wic.hk3wl6zn/rootfs_copy
  6306. BOOTIMG_DIR: /home/scottrif/poky/build/tmp/work/qemux86-poky-linux/core-image-minimal/1.0-r0/recipe-sysroot/usr/share
  6307. KERNEL_DIR: /home/scottrif/poky/build/tmp/deploy/images/qemux86
  6308. NATIVE_SYSROOT: /home/scottrif/poky/build/tmp/work/i586-poky-linux/wic-tools/1.0-r0/recipe-sysroot-native
  6309. INFO: The image(s) were created using OE kickstart file:
  6310. /home/scottrif/poky/scripts/lib/wic/canned-wks/directdisksdb-gpt.wks
  6311. </literallayout>
  6312. Continuing with the example, you can now directly
  6313. <filename>dd</filename> the image to a USB stick, or
  6314. whatever media for which you built your image,
  6315. and boot the resulting media:
  6316. <literallayout class='monospaced'>
  6317. $ sudo dd if=directdisksdb-gpt-201710090938-sdb.direct of=/dev/sdb
  6318. 140966+0 records in
  6319. 140966+0 records out
  6320. 72174592 bytes (72 MB, 69 MiB) copied, 78.0282 s, 925 kB/s
  6321. $ sudo eject /dev/sdb
  6322. </literallayout>
  6323. </para>
  6324. </section>
  6325. <section id='using-a-modified-kickstart-file-and-running-in-raw-mode'>
  6326. <title>Using a Modified Kickstart File and Running in Raw Mode</title>
  6327. <para>
  6328. This next example manually specifies each build artifact
  6329. (runs in Raw Mode) and uses a modified kickstart file.
  6330. The example also uses the <filename>-o</filename> option
  6331. to cause Wic to create the output
  6332. somewhere other than the default output directory,
  6333. which is the current directory:
  6334. <literallayout class='monospaced'>
  6335. $ wic create /home/scottrif/my_yocto/test.wks -o /home/scottrif/testwic \
  6336. --rootfs-dir /home/scottrif/poky/build/tmp/work/qemux86-poky-linux/core-image-minimal/1.0-r0/rootfs \
  6337. --bootimg-dir /home/scottrif/poky/build/tmp/work/qemux86-poky-linux/core-image-minimal/1.0-r0/recipe-sysroot/usr/share \
  6338. --kernel-dir /home/scottrif/poky/build/tmp/deploy/images/qemux86 \
  6339. --native-sysroot /home/scottrif/poky/build/tmp/work/i586-poky-linux/wic-tools/1.0-r0/recipe-sysroot-native
  6340. INFO: Creating image(s)...
  6341. INFO: The new image(s) can be found here:
  6342. /home/scottrif/testwic/test-201710091445-sdb.direct
  6343. The following build artifacts were used to create the image(s):
  6344. ROOTFS_DIR: /home/scottrif/testwic/tmp.wic.x4wipbmb/rootfs_copy
  6345. BOOTIMG_DIR: /home/scottrif/poky/build/tmp/work/qemux86-poky-linux/core-image-minimal/1.0-r0/recipe-sysroot/usr/share
  6346. KERNEL_DIR: /home/scottrif/poky/build/tmp/deploy/images/qemux86
  6347. NATIVE_SYSROOT: /home/scottrif/poky/build/tmp/work/i586-poky-linux/wic-tools/1.0-r0/recipe-sysroot-native
  6348. INFO: The image(s) were created using OE kickstart file:
  6349. /home/scottrif/my_yocto/test.wks
  6350. </literallayout>
  6351. For this example,
  6352. <ulink url='&YOCTO_DOCS_REF_URL;#var-MACHINE'><filename>MACHINE</filename></ulink>
  6353. did not have to be specified in the
  6354. <filename>local.conf</filename> file since the
  6355. artifact is manually specified.
  6356. </para>
  6357. </section>
  6358. <section id='using-wic-to-manipulate-an-image'>
  6359. <title>Using Wic to Manipulate an Image</title>
  6360. <para>
  6361. Wic image manipulation allows you to shorten turnaround
  6362. time during image development.
  6363. For example, you can use Wic to delete the kernel partition
  6364. of a Wic image and then insert a newly built kernel.
  6365. This saves you time from having to rebuild the entire image
  6366. each time you modify the kernel.
  6367. <note>
  6368. In order to use Wic to manipulate a Wic image as in
  6369. this example, your development machine must have the
  6370. <filename>mtools</filename> package installed.
  6371. </note>
  6372. </para>
  6373. <para>
  6374. The following example examines the contents of the Wic
  6375. image, deletes the existing kernel, and then inserts a
  6376. new kernel:
  6377. <orderedlist>
  6378. <listitem><para>
  6379. <emphasis>List the Partitions:</emphasis>
  6380. Use the <filename>wic ls</filename> command to list
  6381. all the partitions in the Wic image:
  6382. <literallayout class='monospaced'>
  6383. $ wic ls tmp/deploy/images/qemux86/core-image-minimal-qemux86.wic
  6384. Num Start End Size Fstype
  6385. 1 1048576 25041919 23993344 fat16
  6386. 2 25165824 72157183 46991360 ext4
  6387. </literallayout>
  6388. The previous output shows two partitions in the
  6389. <filename>core-image-minimal-qemux86.wic</filename>
  6390. image.
  6391. </para></listitem>
  6392. <listitem><para>
  6393. <emphasis>Examine a Particular Partition:</emphasis>
  6394. Use the <filename>wic ls</filename> command again
  6395. but in a different form to examine a particular
  6396. partition.
  6397. <note>
  6398. You can get command usage on any Wic command
  6399. using the following form:
  6400. <literallayout class='monospaced'>
  6401. $ wic help <replaceable>command</replaceable>
  6402. </literallayout>
  6403. For example, the following command shows you
  6404. the various ways to use the
  6405. <filename>wic ls</filename> command:
  6406. <literallayout class='monospaced'>
  6407. $ wic help ls
  6408. </literallayout>
  6409. </note>
  6410. The following command shows what is in Partition
  6411. one:
  6412. <literallayout class='monospaced'>
  6413. $ wic ls tmp/deploy/images/qemux86/core-image-minimal-qemux86.wic:1
  6414. Volume in drive : is boot
  6415. Volume Serial Number is E894-1809
  6416. Directory for ::/
  6417. libcom32 c32 186500 2017-10-09 16:06
  6418. libutil c32 24148 2017-10-09 16:06
  6419. syslinux cfg 220 2017-10-09 16:06
  6420. vesamenu c32 27104 2017-10-09 16:06
  6421. vmlinuz 6904608 2017-10-09 16:06
  6422. 5 files 7 142 580 bytes
  6423. 16 582 656 bytes free
  6424. </literallayout>
  6425. The previous output shows five files, with the
  6426. <filename>vmlinuz</filename> being the kernel.
  6427. <note>
  6428. If you see the following error, you need to
  6429. update or create a
  6430. <filename>~/.mtoolsrc</filename> file and
  6431. be sure to have the line “mtools_skip_check=1“
  6432. in the file.
  6433. Then, run the Wic command again:
  6434. <literallayout class='monospaced'>
  6435. ERROR: _exec_cmd: /usr/bin/mdir -i /tmp/wic-parttfokuwra ::/ returned '1' instead of 0
  6436. output: Total number of sectors (47824) not a multiple of sectors per track (32)!
  6437. Add mtools_skip_check=1 to your .mtoolsrc file to skip this test
  6438. </literallayout>
  6439. </note>
  6440. </para></listitem>
  6441. <listitem><para>
  6442. <emphasis>Remove the Old Kernel:</emphasis>
  6443. Use the <filename>wic rm</filename> command to
  6444. remove the <filename>vmlinuz</filename> file
  6445. (kernel):
  6446. <literallayout class='monospaced'>
  6447. $ wic rm tmp/deploy/images/qemux86/core-image-minimal-qemux86.wic:1/vmlinuz
  6448. </literallayout>
  6449. </para></listitem>
  6450. <listitem><para>
  6451. <emphasis>Add In the New Kernel:</emphasis>
  6452. Use the <filename>wic cp</filename> command to
  6453. add the updated kernel to the Wic image.
  6454. Depending on how you built your kernel, it could
  6455. be in different places.
  6456. If you used <filename>devtool</filename> and
  6457. an SDK to build your kernel, it resides in the
  6458. <filename>tmp/work</filename> directory of the
  6459. extensible SDK.
  6460. If you used <filename>make</filename> to build the
  6461. kernel, the kernel will be in the
  6462. <filename>workspace/sources</filename> area.
  6463. </para>
  6464. <para>The following example assumes
  6465. <filename>devtool</filename> was used to build
  6466. the kernel:
  6467. <literallayout class='monospaced'>
  6468. 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 \
  6469. ~/poky/build/tmp/deploy/images/qemux86/core-image-minimal-qemux86.wic:1/vmlinuz
  6470. </literallayout>
  6471. Once the new kernel is added back into the image,
  6472. you can use the <filename>dd</filename>
  6473. command or
  6474. <link linkend='flashing-images-using-bmaptool'><filename>bmaptool</filename></link>
  6475. to flash your wic image onto an SD card
  6476. or USB stick and test your target.
  6477. <note>
  6478. Using <filename>bmaptool</filename> is
  6479. generally 10 to 20 times faster than using
  6480. <filename>dd</filename>.
  6481. </note>
  6482. </para></listitem>
  6483. </orderedlist>
  6484. </para>
  6485. </section>
  6486. </section>
  6487. </section>
  6488. <section id='building-an-initramfs-image'>
  6489. <title>Building an Initial RAM Filesystem (initramfs) Image</title>
  6490. <para>
  6491. An initial RAM filesystem (initramfs) image provides a temporary
  6492. root filesystem used for early system initialization (e.g.
  6493. loading of modules needed to locate and mount the "real" root
  6494. filesystem).
  6495. <note>
  6496. The initramfs image is the successor of initial RAM disk
  6497. (initrd).
  6498. It is a "copy in and out" (cpio) archive of the initial
  6499. filesystem that gets loaded into memory during the Linux
  6500. startup process.
  6501. Because Linux uses the contents of the archive during
  6502. initialization, the initramfs image needs to contain all of the
  6503. device drivers and tools needed to mount the final root
  6504. filesystem.
  6505. </note>
  6506. </para>
  6507. <para>
  6508. Follow these steps to create an initramfs image:
  6509. <orderedlist>
  6510. <listitem><para>
  6511. <emphasis>Create the initramfs Image Recipe:</emphasis>
  6512. You can reference the
  6513. <filename>core-image-minimal-initramfs.bb</filename>
  6514. recipe found in the <filename>meta/recipes-core</filename>
  6515. directory of the
  6516. <ulink url='&YOCTO_DOCS_REF_URL;#source-directory'>Source Directory</ulink>
  6517. as an example from which to work.
  6518. </para></listitem>
  6519. <listitem><para>
  6520. <emphasis>Decide if You Need to Bundle the initramfs Image
  6521. Into the Kernel Image:</emphasis>
  6522. If you want the initramfs image that is built to be
  6523. bundled in with the kernel image, set the
  6524. <ulink url='&YOCTO_DOCS_REF_URL;#var-INITRAMFS_IMAGE_BUNDLE'><filename>INITRAMFS_IMAGE_BUNDLE</filename></ulink>
  6525. variable to "1" in your <filename>local.conf</filename>
  6526. configuration file and set the
  6527. <ulink url='&YOCTO_DOCS_REF_URL;#var-INITRAMFS_IMAGE'><filename>INITRAMFS_IMAGE</filename></ulink>
  6528. variable in the recipe that builds the kernel image.
  6529. <note><title>Tip</title>
  6530. It is recommended that you do bundle the initramfs
  6531. image with the kernel image to avoid circular
  6532. dependencies between the kernel recipe and the
  6533. initramfs recipe should the initramfs image
  6534. include kernel modules.
  6535. </note>
  6536. Setting the <filename>INITRAMFS_IMAGE_BUNDLE</filename>
  6537. flag causes the initramfs image to be unpacked
  6538. into the <filename>${B}/usr/</filename> directory.
  6539. The unpacked initramfs image is then passed to the kernel's
  6540. <filename>Makefile</filename> using the
  6541. <ulink url='&YOCTO_DOCS_REF_URL;#var-CONFIG_INITRAMFS_SOURCE'><filename>CONFIG_INITRAMFS_SOURCE</filename></ulink>
  6542. variable, allowing the initramfs image to be built into
  6543. the kernel normally.
  6544. <note>
  6545. If you choose to not bundle the initramfs image with
  6546. the kernel image, you are essentially using an
  6547. <ulink url='https://en.wikipedia.org/wiki/Initrd'>Initial RAM Disk (initrd)</ulink>.
  6548. Creating an initrd is handled primarily through the
  6549. <ulink url='&YOCTO_DOCS_REF_URL;#var-INITRD_IMAGE'><filename>INITRD_IMAGE</filename></ulink>,
  6550. <filename>INITRD_LIVE</filename>, and
  6551. <filename>INITRD_IMAGE_LIVE</filename> variables.
  6552. For more information, see the
  6553. <ulink url='&YOCTO_GIT_URL;/cgit/cgit.cgi/poky/tree/meta/classes/image-live.bbclass'><filename>image-live.bbclass</filename></ulink>
  6554. file.
  6555. </note>
  6556. </para></listitem>
  6557. <!--
  6558. Some notes from Cal:
  6559. A non-bundled initramfs is essentially an initrd, which I am discovering
  6560. to be rather confusingly supported in OE at the moment.
  6561. Its primarily handled through INITRD_IMAGE(_LIVE/_VM) and INITRD(_LIVE/_VM)
  6562. variables. INITRD_IMAGE* is the primary image target, which gets added to
  6563. INITRD*, which is a list of cpio filesystems. You can add more cpio
  6564. filesystems to the INITRD variable to add more to the initrd. For
  6565. instance, meta-intel adds intel-microcode via the following:
  6566. INITRD_LIVE_prepend = "${@bb.utils.contains('MACHINE_FEATURES', 'intel-ucode', '${DEPLOY_DIR_IMAGE}/microcode.cpio ', '', d)}"
  6567. If 'intel-ucode' is in MACHINE_FEATURES, this resolves to:
  6568. INITRD_LIVE_prepend = "${DEPLOY_DIR_IMAGE}/microcode.cpio "
  6569. Unfortunately you need the full path, and its up to you to sort out
  6570. dependencies as well. For instance, we have the following:
  6571. MACHINE_ESSENTIAL_EXTRA_RDEPENDS_append = "${@bb.utils.contains('MACHINE_FEATURES', 'intel-ucode', ' intel-microcode', '', d)}"
  6572. which resolves to:
  6573. MACHINE_ESSENTIAL_EXTRA_RDEPENDS_append = "intel-microcode"
  6574. However, the above is only true with the "live" IMAGE_FSTYPE. Wic is
  6575. another beast entirely, with current wic kickstart files not supporting
  6576. initrds, and only partial support in the source plugins. That being said,
  6577. I know the generic bootfs work Ed is working on will help immensely in this
  6578. aspect. He or Saul can provide more details here.
  6579. Anyhow, its rather fractured and confusing and could probably use a
  6580. rework honestly. I don't know how feasible it is to document all the
  6581. details and corner cases of this area.
  6582. -->
  6583. <listitem><para>
  6584. <emphasis>Optionally Add Items to the initramfs Image
  6585. Through the initramfs Image Recipe:</emphasis>
  6586. If you add items to the initramfs image by way of its
  6587. recipe, you should use
  6588. <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_INSTALL'><filename>PACKAGE_INSTALL</filename></ulink>
  6589. rather than
  6590. <ulink url='&YOCTO_DOCS_REF_URL;#var-IMAGE_INSTALL'><filename>IMAGE_INSTALL</filename></ulink>.
  6591. <filename>PACKAGE_INSTALL</filename> gives more direct
  6592. control of what is added to the image as compared to
  6593. the defaults you might not necessarily want that are
  6594. set by the
  6595. <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-image'><filename>image</filename></ulink>
  6596. or
  6597. <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-core-image'><filename>core-image</filename></ulink>
  6598. classes.
  6599. </para></listitem>
  6600. <listitem><para>
  6601. <emphasis>Build the Kernel Image and the initramfs
  6602. Image:</emphasis>
  6603. Build your kernel image using BitBake.
  6604. Because the initramfs image recipe is a dependency of the
  6605. kernel image, the initramfs image is built as well and
  6606. bundled with the kernel image if you used the
  6607. <ulink url='&YOCTO_DOCS_REF_URL;#var-INITRAMFS_IMAGE_BUNDLE'><filename>INITRAMFS_IMAGE_BUNDLE</filename></ulink>
  6608. variable described earlier.
  6609. </para></listitem>
  6610. </orderedlist>
  6611. </para>
  6612. </section>
  6613. <section id='flashing-images-using-bmaptool'>
  6614. <title>Flashing Images Using <filename>bmaptool</filename></title>
  6615. <para>
  6616. A fast and easy way to flash an image to a bootable device
  6617. is to use Bmaptool, which is integrated into the OpenEmbedded
  6618. build system.
  6619. Bmaptool is a generic tool that creates a file's block map (bmap)
  6620. and then uses that map to copy the file.
  6621. As compared to traditional tools such as dd or cp, Bmaptool
  6622. can copy (or flash) large files like raw system image files
  6623. much faster.
  6624. <note><title>Notes</title>
  6625. <itemizedlist>
  6626. <listitem><para>
  6627. If you are using Ubuntu or Debian distributions, you
  6628. can install the <filename>bmap-tools</filename> package
  6629. using the following command and then use the tool
  6630. without specifying <filename>PATH</filename> even from
  6631. the root account:
  6632. <literallayout class='monospaced'>
  6633. $ sudo apt-get install bmap-tools
  6634. </literallayout>
  6635. </para></listitem>
  6636. <listitem><para>
  6637. If you are unable to install the
  6638. <filename>bmap-tools</filename> package, you will
  6639. need to build Bmaptool before using it.
  6640. Use the following command:
  6641. <literallayout class='monospaced'>
  6642. $ bitbake bmap-tools-native
  6643. </literallayout>
  6644. </para></listitem>
  6645. </itemizedlist>
  6646. </note>
  6647. </para>
  6648. <para>
  6649. Following, is an example that shows how to flash a Wic image.
  6650. Realize that while this example uses a Wic image, you can use
  6651. Bmaptool to flash any type of image.
  6652. Use these steps to flash an image using Bmaptool:
  6653. <orderedlist>
  6654. <listitem><para>
  6655. <emphasis>Update your <filename>local.conf</filename> File:</emphasis>
  6656. You need to have the following set in your
  6657. <filename>local.conf</filename> file before building
  6658. your image:
  6659. <literallayout class='monospaced'>
  6660. IMAGE_FSTYPES += "wic wic.bmap"
  6661. </literallayout>
  6662. </para></listitem>
  6663. <listitem><para>
  6664. <emphasis>Get Your Image:</emphasis>
  6665. Either have your image ready (pre-built with the
  6666. <ulink url='&YOCTO_DOCS_REF_URL;#var-IMAGE_FSTYPES'><filename>IMAGE_FSTYPES</filename></ulink>
  6667. setting previously mentioned) or take the step to build
  6668. the image:
  6669. <literallayout class='monospaced'>
  6670. $ bitbake <replaceable>image</replaceable>
  6671. </literallayout>
  6672. </para></listitem>
  6673. <listitem><para>
  6674. <emphasis>Flash the Device:</emphasis>
  6675. Flash the device with the image by using Bmaptool
  6676. depending on your particular setup.
  6677. The following commands assume the image resides in the
  6678. Build Directory's <filename>deploy/images/</filename>
  6679. area:
  6680. <itemizedlist>
  6681. <listitem><para>
  6682. If you have write access to the media, use this
  6683. command form:
  6684. <literallayout class='monospaced'>
  6685. $ 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>
  6686. </literallayout>
  6687. </para></listitem>
  6688. <listitem><para>
  6689. If you do not have write access to the media, set
  6690. your permissions first and then use the same
  6691. command form:
  6692. <literallayout class='monospaced'>
  6693. $ sudo chmod 666 /dev/sd<replaceable>X</replaceable>
  6694. $ 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>
  6695. </literallayout>
  6696. </para></listitem>
  6697. </itemizedlist>
  6698. </para></listitem>
  6699. </orderedlist>
  6700. </para>
  6701. <para>
  6702. For help on the <filename>bmaptool</filename> command, use the
  6703. following command:
  6704. <literallayout class='monospaced'>
  6705. $ bmaptool --help
  6706. </literallayout>
  6707. </para>
  6708. </section>
  6709. <section id='making-images-more-secure'>
  6710. <title>Making Images More Secure</title>
  6711. <para>
  6712. Security is of increasing concern for embedded devices.
  6713. Consider the issues and problems discussed in just this
  6714. sampling of work found across the Internet:
  6715. <itemizedlist>
  6716. <listitem><para><emphasis>
  6717. "<ulink url='https://www.schneier.com/blog/archives/2014/01/security_risks_9.html'>Security Risks of Embedded Systems</ulink>"</emphasis>
  6718. by Bruce Schneier
  6719. </para></listitem>
  6720. <listitem><para><emphasis>
  6721. "<ulink url='http://internetcensus2012.bitbucket.org/paper.html'>Internet Census 2012</ulink>"</emphasis>
  6722. by Carna Botnet</para></listitem>
  6723. <listitem><para><emphasis>
  6724. "<ulink url='http://elinux.org/images/6/6f/Security-issues.pdf'>Security Issues for Embedded Devices</ulink>"</emphasis>
  6725. by Jake Edge
  6726. </para></listitem>
  6727. </itemizedlist>
  6728. </para>
  6729. <para>
  6730. When securing your image is of concern, there are steps, tools,
  6731. and variables that you can consider to help you reach the
  6732. security goals you need for your particular device.
  6733. Not all situations are identical when it comes to making an
  6734. image secure.
  6735. Consequently, this section provides some guidance and suggestions
  6736. for consideration when you want to make your image more secure.
  6737. <note>
  6738. Because the security requirements and risks are
  6739. different for every type of device, this section cannot
  6740. provide a complete reference on securing your custom OS.
  6741. It is strongly recommended that you also consult other sources
  6742. of information on embedded Linux system hardening and on
  6743. security.
  6744. </note>
  6745. </para>
  6746. <section id='general-considerations'>
  6747. <title>General Considerations</title>
  6748. <para>
  6749. General considerations exist that help you create more
  6750. secure images.
  6751. You should consider the following suggestions to help
  6752. make your device more secure:
  6753. <itemizedlist>
  6754. <listitem><para>
  6755. Scan additional code you are adding to the system
  6756. (e.g. application code) by using static analysis
  6757. tools.
  6758. Look for buffer overflows and other potential
  6759. security problems.
  6760. </para></listitem>
  6761. <listitem><para>
  6762. Pay particular attention to the security for
  6763. any web-based administration interface.
  6764. </para>
  6765. <para>Web interfaces typically need to perform
  6766. administrative functions and tend to need to run with
  6767. elevated privileges.
  6768. Thus, the consequences resulting from the interface's
  6769. security becoming compromised can be serious.
  6770. Look for common web vulnerabilities such as
  6771. cross-site-scripting (XSS), unvalidated inputs,
  6772. and so forth.</para>
  6773. <para>As with system passwords, the default credentials
  6774. for accessing a web-based interface should not be the
  6775. same across all devices.
  6776. This is particularly true if the interface is enabled
  6777. by default as it can be assumed that many end-users
  6778. will not change the credentials.
  6779. </para></listitem>
  6780. <listitem><para>
  6781. Ensure you can update the software on the device to
  6782. mitigate vulnerabilities discovered in the future.
  6783. This consideration especially applies when your
  6784. device is network-enabled.
  6785. </para></listitem>
  6786. <listitem><para>
  6787. Ensure you remove or disable debugging functionality
  6788. before producing the final image.
  6789. For information on how to do this, see the
  6790. "<link linkend='considerations-specific-to-the-openembedded-build-system'>Considerations Specific to the OpenEmbedded Build System</link>"
  6791. section.
  6792. </para></listitem>
  6793. <listitem><para>
  6794. Ensure you have no network services listening that
  6795. are not needed.
  6796. </para></listitem>
  6797. <listitem><para>
  6798. Remove any software from the image that is not needed.
  6799. </para></listitem>
  6800. <listitem><para>
  6801. Enable hardware support for secure boot functionality
  6802. when your device supports this functionality.
  6803. </para></listitem>
  6804. </itemizedlist>
  6805. </para>
  6806. </section>
  6807. <section id='security-flags'>
  6808. <title>Security Flags</title>
  6809. <para>
  6810. The Yocto Project has security flags that you can enable that
  6811. help make your build output more secure.
  6812. The security flags are in the
  6813. <filename>meta/conf/distro/include/security_flags.inc</filename>
  6814. file in your
  6815. <ulink url='&YOCTO_DOCS_REF_URL;#source-directory'>Source Directory</ulink>
  6816. (e.g. <filename>poky</filename>).
  6817. <note>
  6818. Depending on the recipe, certain security flags are enabled
  6819. and disabled by default.
  6820. </note>
  6821. </para>
  6822. <para>
  6823. <!--
  6824. The GCC/LD flags in <filename>security_flags.inc</filename>
  6825. enable more secure code generation.
  6826. By including the <filename>security_flags.inc</filename>
  6827. file, you enable flags to the compiler and linker that cause
  6828. them to generate more secure code.
  6829. <note>
  6830. The GCC/LD flags are enabled by default in the
  6831. <filename>poky-lsb</filename> distribution.
  6832. </note>
  6833. -->
  6834. Use the following line in your
  6835. <filename>local.conf</filename> file or in your custom
  6836. distribution configuration file to enable the security
  6837. compiler and linker flags for your build:
  6838. <literallayout class='monospaced'>
  6839. require conf/distro/include/security_flags.inc
  6840. </literallayout>
  6841. </para>
  6842. </section>
  6843. <section id='considerations-specific-to-the-openembedded-build-system'>
  6844. <title>Considerations Specific to the OpenEmbedded Build System</title>
  6845. <para>
  6846. You can take some steps that are specific to the
  6847. OpenEmbedded build system to make your images more secure:
  6848. <itemizedlist>
  6849. <listitem><para>
  6850. Ensure "debug-tweaks" is not one of your selected
  6851. <ulink url='&YOCTO_DOCS_REF_URL;#var-IMAGE_FEATURES'><filename>IMAGE_FEATURES</filename></ulink>.
  6852. When creating a new project, the default is to provide you
  6853. with an initial <filename>local.conf</filename> file that
  6854. enables this feature using the
  6855. <ulink url='&YOCTO_DOCS_REF_URL;#var-EXTRA_IMAGE_FEATURES'><filename>EXTRA_IMAGE_FEATURES</filename></ulink> variable with the line:
  6856. <literallayout class='monospaced'>
  6857. EXTRA_IMAGE_FEATURES = "debug-tweaks"
  6858. </literallayout>
  6859. To disable that feature, simply comment out that line in your
  6860. <filename>local.conf</filename> file, or
  6861. make sure <filename>IMAGE_FEATURES</filename> does not contain
  6862. "debug-tweaks" before producing your final image.
  6863. Among other things, leaving this in place sets the
  6864. root password as blank, which makes logging in for
  6865. debugging or inspection easy during
  6866. development but also means anyone can easily log in
  6867. during production.
  6868. </para></listitem>
  6869. <listitem><para>
  6870. It is possible to set a root password for the image
  6871. and also to set passwords for any extra users you might
  6872. add (e.g. administrative or service type users).
  6873. When you set up passwords for multiple images or
  6874. users, you should not duplicate passwords.
  6875. </para>
  6876. <para>
  6877. To set up passwords, use the
  6878. <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-extrausers'><filename>extrausers</filename></ulink>
  6879. class, which is the preferred method.
  6880. For an example on how to set up both root and user
  6881. passwords, see the
  6882. "<ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-extrausers'><filename>extrausers.bbclass</filename></ulink>"
  6883. section.
  6884. <note>
  6885. When adding extra user accounts or setting a
  6886. root password, be cautious about setting the
  6887. same password on every device.
  6888. If you do this, and the password you have set
  6889. is exposed, then every device is now potentially
  6890. compromised.
  6891. If you need this access but want to ensure
  6892. security, consider setting a different,
  6893. random password for each device.
  6894. Typically, you do this as a separate step after
  6895. you deploy the image onto the device.
  6896. </note>
  6897. </para></listitem>
  6898. <listitem><para>
  6899. Consider enabling a Mandatory Access Control (MAC)
  6900. framework such as SMACK or SELinux and tuning it
  6901. appropriately for your device's usage.
  6902. You can find more information in the
  6903. <ulink url='http://git.yoctoproject.org/cgit/cgit.cgi/meta-selinux/'><filename>meta-selinux</filename></ulink>
  6904. layer.
  6905. </para></listitem>
  6906. </itemizedlist>
  6907. </para>
  6908. <para>
  6909. </para>
  6910. </section>
  6911. <section id='tools-for-hardening-your-image'>
  6912. <title>Tools for Hardening Your Image</title>
  6913. <para>
  6914. The Yocto Project provides tools for making your image
  6915. more secure.
  6916. You can find these tools in the
  6917. <filename>meta-security</filename> layer of the
  6918. <ulink url='&YOCTO_GIT_URL;/cgit/cgit.cgi'>Yocto Project Source Repositories</ulink>.
  6919. </para>
  6920. </section>
  6921. </section>
  6922. <section id='creating-your-own-distribution'>
  6923. <title>Creating Your Own Distribution</title>
  6924. <para>
  6925. When you build an image using the Yocto Project and
  6926. do not alter any distribution
  6927. <ulink url='&YOCTO_DOCS_REF_URL;#metadata'>Metadata</ulink>,
  6928. you are creating a Poky distribution.
  6929. If you wish to gain more control over package alternative
  6930. selections, compile-time options, and other low-level
  6931. configurations, you can create your own distribution.
  6932. </para>
  6933. <para>
  6934. To create your own distribution, the basic steps consist of
  6935. creating your own distribution layer, creating your own
  6936. distribution configuration file, and then adding any needed
  6937. code and Metadata to the layer.
  6938. The following steps provide some more detail:
  6939. <itemizedlist>
  6940. <listitem><para><emphasis>Create a layer for your new distro:</emphasis>
  6941. Create your distribution layer so that you can keep your
  6942. Metadata and code for the distribution separate.
  6943. It is strongly recommended that you create and use your own
  6944. layer for configuration and code.
  6945. Using your own layer as compared to just placing
  6946. configurations in a <filename>local.conf</filename>
  6947. configuration file makes it easier to reproduce the same
  6948. build configuration when using multiple build machines.
  6949. See the
  6950. "<link linkend='creating-a-general-layer-using-the-bitbake-layers-script'>Creating a General Layer Using the <filename>bitbake-layers</filename> Script</link>"
  6951. section for information on how to quickly set up a layer.
  6952. </para></listitem>
  6953. <listitem><para><emphasis>Create the distribution configuration file:</emphasis>
  6954. The distribution configuration file needs to be created in
  6955. the <filename>conf/distro</filename> directory of your
  6956. layer.
  6957. You need to name it using your distribution name
  6958. (e.g. <filename>mydistro.conf</filename>).
  6959. <note>
  6960. The
  6961. <ulink url='&YOCTO_DOCS_REF_URL;#var-DISTRO'><filename>DISTRO</filename></ulink>
  6962. variable in your
  6963. <filename>local.conf</filename> file determines the
  6964. name of your distribution.
  6965. </note></para>
  6966. <para>You can split out parts of your configuration file
  6967. into include files and then "require" them from within
  6968. your distribution configuration file.
  6969. Be sure to place the include files in the
  6970. <filename>conf/distro/include</filename> directory of
  6971. your layer.
  6972. A common example usage of include files would be to
  6973. separate out the selection of desired version and revisions
  6974. for individual recipes.
  6975. </para>
  6976. <para>Your configuration file needs to set the following
  6977. required variables:
  6978. <literallayout class='monospaced'>
  6979. <ulink url='&YOCTO_DOCS_REF_URL;#var-DISTRO_NAME'><filename>DISTRO_NAME</filename></ulink>
  6980. <ulink url='&YOCTO_DOCS_REF_URL;#var-DISTRO_VERSION'><filename>DISTRO_VERSION</filename></ulink>
  6981. </literallayout>
  6982. These following variables are optional and you typically
  6983. set them from the distribution configuration file:
  6984. <literallayout class='monospaced'>
  6985. <ulink url='&YOCTO_DOCS_REF_URL;#var-DISTRO_FEATURES'><filename>DISTRO_FEATURES</filename></ulink>
  6986. <ulink url='&YOCTO_DOCS_REF_URL;#var-DISTRO_EXTRA_RDEPENDS'><filename>DISTRO_EXTRA_RDEPENDS</filename></ulink>
  6987. <ulink url='&YOCTO_DOCS_REF_URL;#var-DISTRO_EXTRA_RRECOMMENDS'><filename>DISTRO_EXTRA_RRECOMMENDS</filename></ulink>
  6988. <ulink url='&YOCTO_DOCS_REF_URL;#var-TCLIBC'><filename>TCLIBC</filename></ulink>
  6989. </literallayout>
  6990. <tip>
  6991. If you want to base your distribution configuration file
  6992. on the very basic configuration from OE-Core, you
  6993. can use
  6994. <filename>conf/distro/defaultsetup.conf</filename> as
  6995. a reference and just include variables that differ
  6996. as compared to <filename>defaultsetup.conf</filename>.
  6997. Alternatively, you can create a distribution
  6998. configuration file from scratch using the
  6999. <filename>defaultsetup.conf</filename> file
  7000. or configuration files from other distributions
  7001. such as Poky or Angstrom as references.
  7002. </tip></para></listitem>
  7003. <listitem><para><emphasis>Provide miscellaneous variables:</emphasis>
  7004. Be sure to define any other variables for which you want to
  7005. create a default or enforce as part of the distribution
  7006. configuration.
  7007. You can include nearly any variable from the
  7008. <filename>local.conf</filename> file.
  7009. The variables you use are not limited to the list in the
  7010. previous bulleted item.</para></listitem>
  7011. <listitem><para><emphasis>Point to Your distribution configuration file:</emphasis>
  7012. In your <filename>local.conf</filename> file in the
  7013. <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink>,
  7014. set your
  7015. <ulink url='&YOCTO_DOCS_REF_URL;#var-DISTRO'><filename>DISTRO</filename></ulink>
  7016. variable to point to your distribution's configuration file.
  7017. For example, if your distribution's configuration file is
  7018. named <filename>mydistro.conf</filename>, then you point
  7019. to it as follows:
  7020. <literallayout class='monospaced'>
  7021. DISTRO = "mydistro"
  7022. </literallayout></para></listitem>
  7023. <listitem><para><emphasis>Add more to the layer if necessary:</emphasis>
  7024. Use your layer to hold other information needed for the
  7025. distribution:
  7026. <itemizedlist>
  7027. <listitem><para>Add recipes for installing
  7028. distro-specific configuration files that are not
  7029. already installed by another recipe.
  7030. If you have distro-specific configuration files
  7031. that are included by an existing recipe, you should
  7032. add an append file (<filename>.bbappend</filename>)
  7033. for those.
  7034. For general information and recommendations
  7035. on how to add recipes to your layer, see the
  7036. "<link linkend='creating-your-own-layer'>Creating Your Own Layer</link>"
  7037. and
  7038. "<link linkend='best-practices-to-follow-when-creating-layers'>Following Best Practices When Creating Layers</link>"
  7039. sections.</para></listitem>
  7040. <listitem><para>Add any image recipes that are specific
  7041. to your distribution.</para></listitem>
  7042. <listitem><para>Add a <filename>psplash</filename>
  7043. append file for a branded splash screen.
  7044. For information on append files, see the
  7045. "<link linkend='using-bbappend-files'>Using .bbappend Files in Your Layer</link>"
  7046. section.</para></listitem>
  7047. <listitem><para>Add any other append files to make
  7048. custom changes that are specific to individual
  7049. recipes.</para></listitem>
  7050. </itemizedlist></para></listitem>
  7051. </itemizedlist>
  7052. </para>
  7053. </section>
  7054. <section id='creating-a-custom-template-configuration-directory'>
  7055. <title>Creating a Custom Template Configuration Directory</title>
  7056. <para>
  7057. If you are producing your own customized version
  7058. of the build system for use by other users, you might
  7059. want to customize the message shown by the setup script or
  7060. you might want to change the template configuration files (i.e.
  7061. <filename>local.conf</filename> and
  7062. <filename>bblayers.conf</filename>) that are created in
  7063. a new build directory.
  7064. </para>
  7065. <para>
  7066. The OpenEmbedded build system uses the environment variable
  7067. <filename>TEMPLATECONF</filename> to locate the directory
  7068. from which it gathers configuration information that ultimately
  7069. ends up in the
  7070. <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink>
  7071. <filename>conf</filename> directory.
  7072. By default, <filename>TEMPLATECONF</filename> is set as
  7073. follows in the <filename>poky</filename> repository:
  7074. <literallayout class='monospaced'>
  7075. TEMPLATECONF=${TEMPLATECONF:-meta-poky/conf}
  7076. </literallayout>
  7077. This is the directory used by the build system to find templates
  7078. from which to build some key configuration files.
  7079. If you look at this directory, you will see the
  7080. <filename>bblayers.conf.sample</filename>,
  7081. <filename>local.conf.sample</filename>, and
  7082. <filename>conf-notes.txt</filename> files.
  7083. The build system uses these files to form the respective
  7084. <filename>bblayers.conf</filename> file,
  7085. <filename>local.conf</filename> file, and display the list of
  7086. BitBake targets when running the setup script.
  7087. </para>
  7088. <para>
  7089. To override these default configuration files with
  7090. configurations you want used within every new
  7091. Build Directory, simply set the
  7092. <filename>TEMPLATECONF</filename> variable to your directory.
  7093. The <filename>TEMPLATECONF</filename> variable is set in the
  7094. <filename>.templateconf</filename> file, which is in the
  7095. top-level
  7096. <ulink url='&YOCTO_DOCS_REF_URL;#source-directory'>Source Directory</ulink>
  7097. folder (e.g. <filename>poky</filename>).
  7098. Edit the <filename>.templateconf</filename> so that it can locate
  7099. your directory.
  7100. </para>
  7101. <para>
  7102. Best practices dictate that you should keep your
  7103. template configuration directory in your custom distribution layer.
  7104. For example, suppose you have a layer named
  7105. <filename>meta-mylayer</filename> located in your home directory
  7106. and you want your template configuration directory named
  7107. <filename>myconf</filename>.
  7108. Changing the <filename>.templateconf</filename> as follows
  7109. causes the OpenEmbedded build system to look in your directory
  7110. and base its configuration files on the
  7111. <filename>*.sample</filename> configuration files it finds.
  7112. The final configuration files (i.e.
  7113. <filename>local.conf</filename> and
  7114. <filename>bblayers.conf</filename> ultimately still end up in
  7115. your Build Directory, but they are based on your
  7116. <filename>*.sample</filename> files.
  7117. <literallayout class='monospaced'>
  7118. TEMPLATECONF=${TEMPLATECONF:-meta-mylayer/myconf}
  7119. </literallayout>
  7120. </para>
  7121. <para>
  7122. Aside from the <filename>*.sample</filename> configuration files,
  7123. the <filename>conf-notes.txt</filename> also resides in the
  7124. default <filename>meta-poky/conf</filename> directory.
  7125. The script that sets up the build environment
  7126. (i.e.
  7127. <ulink url="&YOCTO_DOCS_REF_URL;#structure-core-script"><filename>&OE_INIT_FILE;</filename></ulink>)
  7128. uses this file to display BitBake targets as part of the script
  7129. output.
  7130. Customizing this <filename>conf-notes.txt</filename> file is a
  7131. good way to make sure your list of custom targets appears
  7132. as part of the script's output.
  7133. </para>
  7134. <para>
  7135. Here is the default list of targets displayed as a result of
  7136. running either of the setup scripts:
  7137. <literallayout class='monospaced'>
  7138. You can now run 'bitbake &lt;target&gt;'
  7139. Common targets are:
  7140. core-image-minimal
  7141. core-image-sato
  7142. meta-toolchain
  7143. meta-ide-support
  7144. </literallayout>
  7145. </para>
  7146. <para>
  7147. Changing the listed common targets is as easy as editing your
  7148. version of <filename>conf-notes.txt</filename> in your
  7149. custom template configuration directory and making sure you
  7150. have <filename>TEMPLATECONF</filename> set to your directory.
  7151. </para>
  7152. </section>
  7153. <section id='dev-saving-memory-during-a-build'>
  7154. <title>Conserving Disk Space During Builds</title>
  7155. <para>
  7156. To help conserve disk space during builds, you can add the
  7157. following statement to your project's
  7158. <filename>local.conf</filename> configuration file found in the
  7159. <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink>:
  7160. <literallayout class='monospaced'>
  7161. INHERIT += "rm_work"
  7162. </literallayout>
  7163. Adding this statement deletes the work directory used for building
  7164. a recipe once the recipe is built.
  7165. For more information on "rm_work", see the
  7166. <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-rm-work'><filename>rm_work</filename></ulink>
  7167. class in the Yocto Project Reference Manual.
  7168. </para>
  7169. </section>
  7170. <section id='building-a-tiny-system'>
  7171. <title>Building a Tiny System</title>
  7172. <para>
  7173. Very small distributions have some significant advantages such
  7174. as requiring less on-die or in-package memory (cheaper), better
  7175. performance through efficient cache usage, lower power requirements
  7176. due to less memory, faster boot times, and reduced development
  7177. overhead.
  7178. Some real-world examples where a very small distribution gives
  7179. you distinct advantages are digital cameras, medical devices,
  7180. and small headless systems.
  7181. </para>
  7182. <para>
  7183. This section presents information that shows you how you can
  7184. trim your distribution to even smaller sizes than the
  7185. <filename>poky-tiny</filename> distribution, which is around
  7186. 5 Mbytes, that can be built out-of-the-box using the Yocto Project.
  7187. </para>
  7188. <section id='tiny-system-overview'>
  7189. <title>Overview</title>
  7190. <para>
  7191. The following list presents the overall steps you need to
  7192. consider and perform to create distributions with smaller
  7193. root filesystems, achieve faster boot times, maintain your critical
  7194. functionality, and avoid initial RAM disks:
  7195. <itemizedlist>
  7196. <listitem><para>
  7197. <link linkend='goals-and-guiding-principles'>Determine your goals and guiding principles.</link>
  7198. </para></listitem>
  7199. <listitem><para>
  7200. <link linkend='understand-what-gives-your-image-size'>Understand what contributes to your image size.</link>
  7201. </para></listitem>
  7202. <listitem><para>
  7203. <link linkend='trim-the-root-filesystem'>Reduce the size of the root filesystem.</link>
  7204. </para></listitem>
  7205. <listitem><para>
  7206. <link linkend='trim-the-kernel'>Reduce the size of the kernel.</link>
  7207. </para></listitem>
  7208. <listitem><para>
  7209. <link linkend='remove-package-management-requirements'>Eliminate packaging requirements.</link>
  7210. </para></listitem>
  7211. <listitem><para>
  7212. <link linkend='look-for-other-ways-to-minimize-size'>Look for other ways to minimize size.</link>
  7213. </para></listitem>
  7214. <listitem><para>
  7215. <link linkend='iterate-on-the-process'>Iterate on the process.</link>
  7216. </para></listitem>
  7217. </itemizedlist>
  7218. </para>
  7219. </section>
  7220. <section id='goals-and-guiding-principles'>
  7221. <title>Goals and Guiding Principles</title>
  7222. <para>
  7223. Before you can reach your destination, you need to know
  7224. where you are going.
  7225. Here is an example list that you can use as a guide when
  7226. creating very small distributions:
  7227. <itemizedlist>
  7228. <listitem><para>Determine how much space you need
  7229. (e.g. a kernel that is 1 Mbyte or less and
  7230. a root filesystem that is 3 Mbytes or less).
  7231. </para></listitem>
  7232. <listitem><para>Find the areas that are currently
  7233. taking 90% of the space and concentrate on reducing
  7234. those areas.
  7235. </para></listitem>
  7236. <listitem><para>Do not create any difficult "hacks"
  7237. to achieve your goals.</para></listitem>
  7238. <listitem><para>Leverage the device-specific
  7239. options.</para></listitem>
  7240. <listitem><para>Work in a separate layer so that you
  7241. keep changes isolated.
  7242. For information on how to create layers, see
  7243. the "<link linkend='understanding-and-creating-layers'>Understanding and Creating Layers</link>" section.
  7244. </para></listitem>
  7245. </itemizedlist>
  7246. </para>
  7247. </section>
  7248. <section id='understand-what-gives-your-image-size'>
  7249. <title>Understand What Contributes to Your Image Size</title>
  7250. <para>
  7251. It is easiest to have something to start with when creating
  7252. your own distribution.
  7253. You can use the Yocto Project out-of-the-box to create the
  7254. <filename>poky-tiny</filename> distribution.
  7255. Ultimately, you will want to make changes in your own
  7256. distribution that are likely modeled after
  7257. <filename>poky-tiny</filename>.
  7258. <note>
  7259. To use <filename>poky-tiny</filename> in your build,
  7260. set the
  7261. <ulink url='&YOCTO_DOCS_REF_URL;#var-DISTRO'><filename>DISTRO</filename></ulink>
  7262. variable in your
  7263. <filename>local.conf</filename> file to "poky-tiny"
  7264. as described in the
  7265. "<link linkend='creating-your-own-distribution'>Creating Your Own Distribution</link>"
  7266. section.
  7267. </note>
  7268. </para>
  7269. <para>
  7270. Understanding some memory concepts will help you reduce the
  7271. system size.
  7272. Memory consists of static, dynamic, and temporary memory.
  7273. Static memory is the TEXT (code), DATA (initialized data
  7274. in the code), and BSS (uninitialized data) sections.
  7275. Dynamic memory represents memory that is allocated at runtime:
  7276. stacks, hash tables, and so forth.
  7277. Temporary memory is recovered after the boot process.
  7278. This memory consists of memory used for decompressing
  7279. the kernel and for the <filename>__init__</filename>
  7280. functions.
  7281. </para>
  7282. <para>
  7283. To help you see where you currently are with kernel and root
  7284. filesystem sizes, you can use two tools found in the
  7285. <ulink url='&YOCTO_DOCS_REF_URL;#source-directory'>Source Directory</ulink> in
  7286. the <filename>scripts/tiny/</filename> directory:
  7287. <itemizedlist>
  7288. <listitem><para><filename>ksize.py</filename>: Reports
  7289. component sizes for the kernel build objects.
  7290. </para></listitem>
  7291. <listitem><para><filename>dirsize.py</filename>: Reports
  7292. component sizes for the root filesystem.</para></listitem>
  7293. </itemizedlist>
  7294. This next tool and command help you organize configuration
  7295. fragments and view file dependencies in a human-readable form:
  7296. <itemizedlist>
  7297. <listitem><para><filename>merge_config.sh</filename>:
  7298. Helps you manage configuration files and fragments
  7299. within the kernel.
  7300. With this tool, you can merge individual configuration
  7301. fragments together.
  7302. The tool allows you to make overrides and warns you
  7303. of any missing configuration options.
  7304. The tool is ideal for allowing you to iterate on
  7305. configurations, create minimal configurations, and
  7306. create configuration files for different machines
  7307. without having to duplicate your process.</para>
  7308. <para>The <filename>merge_config.sh</filename> script is
  7309. part of the Linux Yocto kernel Git repositories
  7310. (i.e. <filename>linux-yocto-3.14</filename>,
  7311. <filename>linux-yocto-3.10</filename>,
  7312. <filename>linux-yocto-3.8</filename>, and so forth)
  7313. in the
  7314. <filename>scripts/kconfig</filename> directory.</para>
  7315. <para>For more information on configuration fragments,
  7316. see the
  7317. "<ulink url='&YOCTO_DOCS_KERNEL_DEV_URL;#creating-config-fragments'>Creating Configuration Fragments</ulink>"
  7318. section in the Yocto Project Linux Kernel Development
  7319. Manual.
  7320. </para></listitem>
  7321. <listitem><para><filename>bitbake -u taskexp -g <replaceable>bitbake_target</replaceable></filename>:
  7322. Using the BitBake command with these options brings up
  7323. a Dependency Explorer from which you can view file
  7324. dependencies.
  7325. Understanding these dependencies allows you to make
  7326. informed decisions when cutting out various pieces of the
  7327. kernel and root filesystem.</para></listitem>
  7328. </itemizedlist>
  7329. </para>
  7330. </section>
  7331. <section id='trim-the-root-filesystem'>
  7332. <title>Trim the Root Filesystem</title>
  7333. <para>
  7334. The root filesystem is made up of packages for booting,
  7335. libraries, and applications.
  7336. To change things, you can configure how the packaging happens,
  7337. which changes the way you build them.
  7338. You can also modify the filesystem itself or select a different
  7339. filesystem.
  7340. </para>
  7341. <para>
  7342. First, find out what is hogging your root filesystem by running the
  7343. <filename>dirsize.py</filename> script from your root directory:
  7344. <literallayout class='monospaced'>
  7345. $ cd <replaceable>root-directory-of-image</replaceable>
  7346. $ dirsize.py 100000 > dirsize-100k.log
  7347. $ cat dirsize-100k.log
  7348. </literallayout>
  7349. You can apply a filter to the script to ignore files under
  7350. a certain size.
  7351. The previous example filters out any files below 100 Kbytes.
  7352. The sizes reported by the tool are uncompressed, and thus
  7353. will be smaller by a relatively constant factor in a
  7354. compressed root filesystem.
  7355. When you examine your log file, you can focus on areas of the
  7356. root filesystem that take up large amounts of memory.
  7357. </para>
  7358. <para>
  7359. You need to be sure that what you eliminate does not cripple
  7360. the functionality you need.
  7361. One way to see how packages relate to each other is by using
  7362. the Dependency Explorer UI with the BitBake command:
  7363. <literallayout class='monospaced'>
  7364. $ cd <replaceable>image-directory</replaceable>
  7365. $ bitbake -u taskexp -g <replaceable>image</replaceable>
  7366. </literallayout>
  7367. Use the interface to select potential packages you wish to
  7368. eliminate and see their dependency relationships.
  7369. </para>
  7370. <para>
  7371. When deciding how to reduce the size, get rid of packages that
  7372. result in minimal impact on the feature set.
  7373. For example, you might not need a VGA display.
  7374. Or, you might be able to get by with <filename>devtmpfs</filename>
  7375. and <filename>mdev</filename> instead of
  7376. <filename>udev</filename>.
  7377. </para>
  7378. <para>
  7379. Use your <filename>local.conf</filename> file to make changes.
  7380. For example, to eliminate <filename>udev</filename> and
  7381. <filename>glib</filename>, set the following in the
  7382. local configuration file:
  7383. <literallayout class='monospaced'>
  7384. VIRTUAL-RUNTIME_dev_manager = ""
  7385. </literallayout>
  7386. </para>
  7387. <para>
  7388. Finally, you should consider exactly the type of root
  7389. filesystem you need to meet your needs while also reducing
  7390. its size.
  7391. For example, consider <filename>cramfs</filename>,
  7392. <filename>squashfs</filename>, <filename>ubifs</filename>,
  7393. <filename>ext2</filename>, or an <filename>initramfs</filename>
  7394. using <filename>initramfs</filename>.
  7395. Be aware that <filename>ext3</filename> requires a 1 Mbyte
  7396. journal.
  7397. If you are okay with running read-only, you do not need this
  7398. journal.
  7399. </para>
  7400. <note>
  7401. After each round of elimination, you need to rebuild your
  7402. system and then use the tools to see the effects of your
  7403. reductions.
  7404. </note>
  7405. </section>
  7406. <section id='trim-the-kernel'>
  7407. <title>Trim the Kernel</title>
  7408. <para>
  7409. The kernel is built by including policies for hardware-independent
  7410. aspects.
  7411. What subsystems do you enable?
  7412. For what architecture are you building?
  7413. Which drivers do you build by default?
  7414. <note>You can modify the kernel source if you want to help
  7415. with boot time.
  7416. </note>
  7417. </para>
  7418. <para>
  7419. Run the <filename>ksize.py</filename> script from the top-level
  7420. Linux build directory to get an idea of what is making up
  7421. the kernel:
  7422. <literallayout class='monospaced'>
  7423. $ cd <replaceable>top-level-linux-build-directory</replaceable>
  7424. $ ksize.py > ksize.log
  7425. $ cat ksize.log
  7426. </literallayout>
  7427. When you examine the log, you will see how much space is
  7428. taken up with the built-in <filename>.o</filename> files for
  7429. drivers, networking, core kernel files, filesystem, sound,
  7430. and so forth.
  7431. The sizes reported by the tool are uncompressed, and thus
  7432. will be smaller by a relatively constant factor in a compressed
  7433. kernel image.
  7434. Look to reduce the areas that are large and taking up around
  7435. the "90% rule."
  7436. </para>
  7437. <para>
  7438. To examine, or drill down, into any particular area, use the
  7439. <filename>-d</filename> option with the script:
  7440. <literallayout class='monospaced'>
  7441. $ ksize.py -d > ksize.log
  7442. </literallayout>
  7443. Using this option breaks out the individual file information
  7444. for each area of the kernel (e.g. drivers, networking, and
  7445. so forth).
  7446. </para>
  7447. <para>
  7448. Use your log file to see what you can eliminate from the kernel
  7449. based on features you can let go.
  7450. For example, if you are not going to need sound, you do not
  7451. need any drivers that support sound.
  7452. </para>
  7453. <para>
  7454. After figuring out what to eliminate, you need to reconfigure
  7455. the kernel to reflect those changes during the next build.
  7456. You could run <filename>menuconfig</filename> and make all your
  7457. changes at once.
  7458. However, that makes it difficult to see the effects of your
  7459. individual eliminations and also makes it difficult to replicate
  7460. the changes for perhaps another target device.
  7461. A better method is to start with no configurations using
  7462. <filename>allnoconfig</filename>, create configuration
  7463. fragments for individual changes, and then manage the
  7464. fragments into a single configuration file using
  7465. <filename>merge_config.sh</filename>.
  7466. The tool makes it easy for you to iterate using the
  7467. configuration change and build cycle.
  7468. </para>
  7469. <para>
  7470. Each time you make configuration changes, you need to rebuild
  7471. the kernel and check to see what impact your changes had on
  7472. the overall size.
  7473. </para>
  7474. </section>
  7475. <section id='remove-package-management-requirements'>
  7476. <title>Remove Package Management Requirements</title>
  7477. <para>
  7478. Packaging requirements add size to the image.
  7479. One way to reduce the size of the image is to remove all the
  7480. packaging requirements from the image.
  7481. This reduction includes both removing the package manager
  7482. and its unique dependencies as well as removing the package
  7483. management data itself.
  7484. </para>
  7485. <para>
  7486. To eliminate all the packaging requirements for an image,
  7487. be sure that "package-management" is not part of your
  7488. <ulink url='&YOCTO_DOCS_REF_URL;#var-IMAGE_FEATURES'><filename>IMAGE_FEATURES</filename></ulink>
  7489. statement for the image.
  7490. When you remove this feature, you are removing the package
  7491. manager as well as its dependencies from the root filesystem.
  7492. </para>
  7493. </section>
  7494. <section id='look-for-other-ways-to-minimize-size'>
  7495. <title>Look for Other Ways to Minimize Size</title>
  7496. <para>
  7497. Depending on your particular circumstances, other areas that you
  7498. can trim likely exist.
  7499. The key to finding these areas is through tools and methods
  7500. described here combined with experimentation and iteration.
  7501. Here are a couple of areas to experiment with:
  7502. <itemizedlist>
  7503. <listitem><para><filename>glibc</filename>:
  7504. In general, follow this process:
  7505. <orderedlist>
  7506. <listitem><para>Remove <filename>glibc</filename>
  7507. features from
  7508. <ulink url='&YOCTO_DOCS_REF_URL;#var-DISTRO_FEATURES'><filename>DISTRO_FEATURES</filename></ulink>
  7509. that you think you do not need.</para></listitem>
  7510. <listitem><para>Build your distribution.
  7511. </para></listitem>
  7512. <listitem><para>If the build fails due to missing
  7513. symbols in a package, determine if you can
  7514. reconfigure the package to not need those
  7515. features.
  7516. For example, change the configuration to not
  7517. support wide character support as is done for
  7518. <filename>ncurses</filename>.
  7519. Or, if support for those characters is needed,
  7520. determine what <filename>glibc</filename>
  7521. features provide the support and restore the
  7522. configuration.
  7523. </para></listitem>
  7524. <listitem><para>Rebuild and repeat the process.
  7525. </para></listitem>
  7526. </orderedlist></para></listitem>
  7527. <listitem><para><filename>busybox</filename>:
  7528. For BusyBox, use a process similar as described for
  7529. <filename>glibc</filename>.
  7530. A difference is you will need to boot the resulting
  7531. system to see if you are able to do everything you
  7532. expect from the running system.
  7533. You need to be sure to integrate configuration fragments
  7534. into Busybox because BusyBox handles its own core
  7535. features and then allows you to add configuration
  7536. fragments on top.
  7537. </para></listitem>
  7538. </itemizedlist>
  7539. </para>
  7540. </section>
  7541. <section id='iterate-on-the-process'>
  7542. <title>Iterate on the Process</title>
  7543. <para>
  7544. If you have not reached your goals on system size, you need
  7545. to iterate on the process.
  7546. The process is the same.
  7547. Use the tools and see just what is taking up 90% of the root
  7548. filesystem and the kernel.
  7549. Decide what you can eliminate without limiting your device
  7550. beyond what you need.
  7551. </para>
  7552. <para>
  7553. Depending on your system, a good place to look might be
  7554. Busybox, which provides a stripped down
  7555. version of Unix tools in a single, executable file.
  7556. You might be able to drop virtual terminal services or perhaps
  7557. ipv6.
  7558. </para>
  7559. </section>
  7560. </section>
  7561. <section id='building-images-for-more-than-one-machine'>
  7562. <title>Building Images for More than One Machine</title>
  7563. <para>
  7564. A common scenario developers face is creating images for several
  7565. different machines that use the same software environment.
  7566. In this situation, it is tempting to set the
  7567. tunings and optimization flags for each build specifically for
  7568. the targeted hardware (i.e. "maxing out" the tunings).
  7569. Doing so can considerably add to build times and package feed
  7570. maintenance collectively for the machines.
  7571. For example, selecting tunes that are extremely specific to a
  7572. CPU core used in a system might enable some micro optimizations
  7573. in GCC for that particular system but would otherwise not gain
  7574. you much of a performance difference across the other systems
  7575. as compared to using a more general tuning across all the builds
  7576. (e.g. setting
  7577. <ulink url='&YOCTO_DOCS_REF_URL;#var-DEFAULTTUNE'><filename>DEFAULTTUNE</filename></ulink>
  7578. specifically for each machine's build).
  7579. Rather than "max out" each build's tunings, you can take steps that
  7580. cause the OpenEmbedded build system to reuse software across the
  7581. various machines where it makes sense.
  7582. </para>
  7583. <para>
  7584. If build speed and package feed maintenance are considerations,
  7585. you should consider the points in this section that can help you
  7586. optimize your tunings to best consider build times and package
  7587. feed maintenance.
  7588. <itemizedlist>
  7589. <listitem><para><emphasis>Share the Build Directory:</emphasis>
  7590. If at all possible, share the
  7591. <ulink url='&YOCTO_DOCS_REF_URL;#var-TMPDIR'><filename>TMPDIR</filename></ulink>
  7592. across builds.
  7593. The Yocto Project supports switching between different
  7594. <ulink url='&YOCTO_DOCS_REF_URL;#var-MACHINE'><filename>MACHINE</filename></ulink>
  7595. values in the same <filename>TMPDIR</filename>.
  7596. This practice is well supported and regularly used by
  7597. developers when building for multiple machines.
  7598. When you use the same <filename>TMPDIR</filename> for
  7599. multiple machine builds, the OpenEmbedded build system can
  7600. reuse the existing native and often cross-recipes for
  7601. multiple machines.
  7602. Thus, build time decreases.
  7603. <note>
  7604. If
  7605. <ulink url='&YOCTO_DOCS_REF_URL;#var-DISTRO'><filename>DISTRO</filename></ulink>
  7606. settings change or fundamental configuration settings
  7607. such as the filesystem layout, you need to work with
  7608. a clean <filename>TMPDIR</filename>.
  7609. Sharing <filename>TMPDIR</filename> under these
  7610. circumstances might work but since it is not
  7611. guaranteed, you should use a clean
  7612. <filename>TMPDIR</filename>.
  7613. </note>
  7614. </para></listitem>
  7615. <listitem><para><emphasis>Enable the Appropriate Package Architecture:</emphasis>
  7616. By default, the OpenEmbedded build system enables three
  7617. levels of package architectures: "all", "tune" or "package",
  7618. and "machine".
  7619. Any given recipe usually selects one of these package
  7620. architectures (types) for its output.
  7621. Depending for what a given recipe creates packages, making
  7622. sure you enable the appropriate package architecture can
  7623. directly impact the build time.</para>
  7624. <para>A recipe that just generates scripts can enable
  7625. "all" architecture because there are no binaries to build.
  7626. To specifically enable "all" architecture, be sure your
  7627. recipe inherits the
  7628. <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-allarch'><filename>allarch</filename></ulink>
  7629. class.
  7630. This class is useful for "all" architectures because it
  7631. configures many variables so packages can be used across
  7632. multiple architectures.</para>
  7633. <para>If your recipe needs to generate packages that are
  7634. machine-specific or when one of the build or runtime
  7635. dependencies is already machine-architecture dependent,
  7636. which makes your recipe also machine-architecture dependent,
  7637. make sure your recipe enables the "machine" package
  7638. architecture through the
  7639. <ulink url='&YOCTO_DOCS_REF_URL;#var-MACHINE_ARCH'><filename>MACHINE_ARCH</filename></ulink>
  7640. variable:
  7641. <literallayout class='monospaced'>
  7642. PACKAGE_ARCH = "${MACHINE_ARCH}"
  7643. </literallayout>
  7644. When you do not specifically enable a package
  7645. architecture through the
  7646. <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_ARCH'><filename>PACKAGE_ARCH</filename></ulink>,
  7647. The OpenEmbedded build system defaults to the
  7648. <ulink url='&YOCTO_DOCS_REF_URL;#var-TUNE_PKGARCH'><filename>TUNE_PKGARCH</filename></ulink>
  7649. setting:
  7650. <literallayout class='monospaced'>
  7651. PACKAGE_ARCH = "${TUNE_PKGARCH}"
  7652. </literallayout>
  7653. </para></listitem>
  7654. <listitem><para><emphasis>Choose a Generic Tuning File if Possible:</emphasis>
  7655. Some tunes are more generic and can run on multiple targets
  7656. (e.g. an <filename>armv5</filename> set of packages could
  7657. run on <filename>armv6</filename> and
  7658. <filename>armv7</filename> processors in most cases).
  7659. Similarly, <filename>i486</filename> binaries could work
  7660. on <filename>i586</filename> and higher processors.
  7661. You should realize, however, that advances on newer
  7662. processor versions would not be used.</para>
  7663. <para>If you select the same tune for several different
  7664. machines, the OpenEmbedded build system reuses software
  7665. previously built, thus speeding up the overall build time.
  7666. Realize that even though a new sysroot for each machine is
  7667. generated, the software is not recompiled and only one
  7668. package feed exists.
  7669. </para></listitem>
  7670. <listitem><para><emphasis>Manage Granular Level Packaging:</emphasis>
  7671. Sometimes cases exist where injecting another level
  7672. of package architecture beyond the three higher levels
  7673. noted earlier can be useful.
  7674. For example, consider the <filename>emgd</filename>
  7675. graphics stack in the
  7676. <filename>meta-intel</filename> layer.
  7677. In this layer, a subset of software exists that is
  7678. compiled against something different from the rest of the
  7679. generic packages.
  7680. You can examine the key code in the
  7681. <ulink url='http://git.yoctoproject.org/cgit/cgit.cgi'>Source Repositories</ulink>
  7682. "daisy" branch in
  7683. <filename>classes/emgd-gl.bbclass</filename>.
  7684. For a specific set of packages, the code redefines
  7685. <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_ARCH'><filename>PACKAGE_ARCH</filename></ulink>.
  7686. <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_EXTRA_ARCHS'><filename>PACKAGE_EXTRA_ARCHS</filename></ulink>
  7687. is then appended with this extra tune name in
  7688. <filename>meta-intel-emgd.inc</filename>.
  7689. The result is that when searching for packages, the
  7690. build system uses a four-level search and the packages
  7691. in this new level are preferred as compared to the standard
  7692. tune.
  7693. The overall result is that the build system reuses most
  7694. software from the common tune except for specific cases
  7695. as needed.
  7696. </para></listitem>
  7697. <listitem><para><emphasis>Use Tools to Debug Issues:</emphasis>
  7698. Sometimes you can run into situations where software is
  7699. being rebuilt when you think it should not be.
  7700. For example, the OpenEmbedded build system might not be
  7701. using shared state between machines when you think it
  7702. should be.
  7703. These types of situations are usually due to references
  7704. to machine-specific variables such as
  7705. <ulink url='&YOCTO_DOCS_REF_URL;#var-MACHINE'><filename>MACHINE</filename></ulink>,
  7706. <ulink url='&YOCTO_DOCS_REF_URL;#var-SERIAL_CONSOLE'><filename>SERIAL_CONSOLE</filename></ulink>,
  7707. <ulink url='&YOCTO_DOCS_REF_URL;#var-XSERVER'><filename>XSERVER</filename></ulink>,
  7708. <ulink url='&YOCTO_DOCS_REF_URL;#var-MACHINE_FEATURES'><filename>MACHINE_FEATURES</filename></ulink>,
  7709. and so forth in code that is supposed to only be
  7710. tune-specific or when the recipe depends
  7711. (<ulink url='&YOCTO_DOCS_REF_URL;#var-DEPENDS'><filename>DEPENDS</filename></ulink>,
  7712. <ulink url='&YOCTO_DOCS_REF_URL;#var-RDEPENDS'><filename>RDEPENDS</filename></ulink>,
  7713. <ulink url='&YOCTO_DOCS_REF_URL;#var-RRECOMMENDS'><filename>RRECOMMENDS</filename></ulink>,
  7714. <ulink url='&YOCTO_DOCS_REF_URL;#var-RSUGGESTS'><filename>RSUGGESTS</filename></ulink>,
  7715. and so forth) on some other recipe that already has
  7716. <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_ARCH'><filename>PACKAGE_ARCH</filename></ulink>
  7717. defined as "${MACHINE_ARCH}".
  7718. <note>
  7719. Patches to fix any issues identified are most welcome
  7720. as these issues occasionally do occur.
  7721. </note></para>
  7722. <para>For such cases, you can use some tools to help you
  7723. sort out the situation:
  7724. <itemizedlist>
  7725. <listitem><para><emphasis><filename>sstate-diff-machines.sh</filename>:</emphasis>
  7726. You can find this tool in the
  7727. <filename>scripts</filename> directory of the
  7728. Source Repositories.
  7729. See the comments in the script for information on
  7730. how to use the tool.
  7731. </para></listitem>
  7732. <listitem><para><emphasis>BitBake's "-S printdiff" Option:</emphasis>
  7733. Using this option causes BitBake to try to
  7734. establish the closest signature match it can
  7735. (e.g. in the shared state cache) and then run
  7736. <filename>bitbake-diffsigs</filename> over the
  7737. matches to determine the stamps and delta where
  7738. these two stamp trees diverge.
  7739. </para></listitem>
  7740. </itemizedlist>
  7741. </para></listitem>
  7742. </itemizedlist>
  7743. </para>
  7744. </section>
  7745. <section id='working-with-packages'>
  7746. <title>Working with Packages</title>
  7747. <para>
  7748. This section describes a few tasks that involve packages:
  7749. <itemizedlist>
  7750. <listitem><para>
  7751. <link linkend='excluding-packages-from-an-image'>Excluding packages from an image</link>
  7752. </para></listitem>
  7753. <listitem><para>
  7754. <link linkend='incrementing-a-binary-package-version'>Incrementing a binary package version</link>
  7755. </para></listitem>
  7756. <listitem><para>
  7757. <link linkend='handling-optional-module-packaging'>Handling optional module packaging</link>
  7758. </para></listitem>
  7759. <listitem><para>
  7760. <link linkend='using-runtime-package-management'>Using Runtime Package Management</link>
  7761. </para></listitem>
  7762. <listitem><para>
  7763. <link linkend='testing-packages-with-ptest'>Setting up and running package test (ptest)</link>
  7764. </para></listitem>
  7765. </itemizedlist>
  7766. </para>
  7767. <section id='excluding-packages-from-an-image'>
  7768. <title>Excluding Packages from an Image</title>
  7769. <para>
  7770. You might find it necessary to prevent specific packages
  7771. from being installed into an image.
  7772. If so, you can use several variables to direct the build
  7773. system to essentially ignore installing recommended packages
  7774. or to not install a package at all.
  7775. </para>
  7776. <para>
  7777. The following list introduces variables you can use to
  7778. prevent packages from being installed into your image.
  7779. Each of these variables only works with IPK and RPM
  7780. package types.
  7781. Support for Debian packages does not exist.
  7782. Also, you can use these variables from your
  7783. <filename>local.conf</filename> file or attach them to a
  7784. specific image recipe by using a recipe name override.
  7785. For more detail on the variables, see the descriptions in the
  7786. Yocto Project Reference Manual's glossary chapter.
  7787. <itemizedlist>
  7788. <listitem><para><ulink url='&YOCTO_DOCS_REF_URL;#var-BAD_RECOMMENDATIONS'><filename>BAD_RECOMMENDATIONS</filename></ulink>:
  7789. Use this variable to specify "recommended-only"
  7790. packages that you do not want installed.
  7791. </para></listitem>
  7792. <listitem><para><ulink url='&YOCTO_DOCS_REF_URL;#var-NO_RECOMMENDATIONS'><filename>NO_RECOMMENDATIONS</filename></ulink>:
  7793. Use this variable to prevent all "recommended-only"
  7794. packages from being installed.
  7795. </para></listitem>
  7796. <listitem><para><ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_EXCLUDE'><filename>PACKAGE_EXCLUDE</filename></ulink>:
  7797. Use this variable to prevent specific packages from
  7798. being installed regardless of whether they are
  7799. "recommended-only" or not.
  7800. You need to realize that the build process could
  7801. fail with an error when you
  7802. prevent the installation of a package whose presence
  7803. is required by an installed package.
  7804. </para></listitem>
  7805. </itemizedlist>
  7806. </para>
  7807. </section>
  7808. <section id='incrementing-a-binary-package-version'>
  7809. <title>Incrementing a Package Version</title>
  7810. <para>
  7811. This section provides some background on how binary package
  7812. versioning is accomplished and presents some of the services,
  7813. variables, and terminology involved.
  7814. </para>
  7815. <para>
  7816. In order to understand binary package versioning, you need
  7817. to consider the following:
  7818. <itemizedlist>
  7819. <listitem><para>
  7820. Binary Package: The binary package that is eventually
  7821. built and installed into an image.
  7822. </para></listitem>
  7823. <listitem><para>
  7824. Binary Package Version: The binary package version
  7825. is composed of two components - a version and a
  7826. revision.
  7827. <note>
  7828. Technically, a third component, the "epoch" (i.e.
  7829. <ulink url='&YOCTO_DOCS_REF_URL;#var-PE'><filename>PE</filename></ulink>)
  7830. is involved but this discussion for the most part
  7831. ignores <filename>PE</filename>.
  7832. </note>
  7833. The version and revision are taken from the
  7834. <ulink url='&YOCTO_DOCS_REF_URL;#var-PV'><filename>PV</filename></ulink>
  7835. and
  7836. <ulink url='&YOCTO_DOCS_REF_URL;#var-PR'><filename>PR</filename></ulink>
  7837. variables, respectively.
  7838. </para></listitem>
  7839. <listitem><para>
  7840. <filename>PV</filename>: The recipe version.
  7841. <filename>PV</filename> represents the version of the
  7842. software being packaged.
  7843. Do not confuse <filename>PV</filename> with the
  7844. binary package version.
  7845. </para></listitem>
  7846. <listitem><para>
  7847. <filename>PR</filename>: The recipe revision.
  7848. </para></listitem>
  7849. <listitem><para>
  7850. <ulink url='&YOCTO_DOCS_REF_URL;#var-SRCPV'><filename>SRCPV</filename></ulink>:
  7851. The OpenEmbedded build system uses this string
  7852. to help define the value of <filename>PV</filename>
  7853. when the source code revision needs to be included
  7854. in it.
  7855. </para></listitem>
  7856. <listitem><para>
  7857. <ulink url='https://wiki.yoctoproject.org/wiki/PR_Service'>PR Service</ulink>:
  7858. A network-based service that helps automate keeping
  7859. package feeds compatible with existing package
  7860. manager applications such as RPM, APT, and OPKG.
  7861. </para></listitem>
  7862. </itemizedlist>
  7863. </para>
  7864. <para>
  7865. Whenever the binary package content changes, the binary package
  7866. version must change.
  7867. Changing the binary package version is accomplished by changing
  7868. or "bumping" the <filename>PR</filename> and/or
  7869. <filename>PV</filename> values.
  7870. Increasing these values occurs one of two ways:
  7871. <itemizedlist>
  7872. <listitem><para>Automatically using a Package Revision
  7873. Service (PR Service).
  7874. </para></listitem>
  7875. <listitem><para>Manually incrementing the
  7876. <filename>PR</filename> and/or
  7877. <filename>PV</filename> variables.
  7878. </para></listitem>
  7879. </itemizedlist>
  7880. </para>
  7881. <para>
  7882. Given a primary challenge of any build system and its users
  7883. is how to maintain a package feed that is compatible with
  7884. existing package manager applications such as RPM, APT, and
  7885. OPKG, using an automated system is much preferred over a
  7886. manual system.
  7887. In either system, the main requirement is that binary package
  7888. version numbering increases in a linear fashion and that a
  7889. number of version components exist that support that linear
  7890. progression.
  7891. For information on how to ensure package revisioning remains
  7892. linear, see the
  7893. "<link linkend='automatically-incrementing-a-binary-package-revision-number'>Automatically Incrementing a Binary Package Revision Number</link>"
  7894. section.
  7895. </para>
  7896. <para>
  7897. The following three sections provide related information on the
  7898. PR Service, the manual method for "bumping"
  7899. <filename>PR</filename> and/or <filename>PV</filename>, and
  7900. on how to ensure binary package revisioning remains linear.
  7901. </para>
  7902. <section id='working-with-a-pr-service'>
  7903. <title>Working With a PR Service</title>
  7904. <para>
  7905. As mentioned, attempting to maintain revision numbers in the
  7906. <ulink url='&YOCTO_DOCS_REF_URL;#metadata'>Metadata</ulink>
  7907. is error prone, inaccurate, and causes problems for people
  7908. submitting recipes.
  7909. Conversely, the PR Service automatically generates
  7910. increasing numbers, particularly the revision field,
  7911. which removes the human element.
  7912. <note>
  7913. For additional information on using a PR Service, you
  7914. can see the
  7915. <ulink url='&YOCTO_WIKI_URL;/wiki/PR_Service'>PR Service</ulink>
  7916. wiki page.
  7917. </note>
  7918. </para>
  7919. <para>
  7920. The Yocto Project uses variables in order of
  7921. decreasing priority to facilitate revision numbering (i.e.
  7922. <ulink url='&YOCTO_DOCS_REF_URL;#var-PE'><filename>PE</filename></ulink>,
  7923. <ulink url='&YOCTO_DOCS_REF_URL;#var-PV'><filename>PV</filename></ulink>, and
  7924. <ulink url='&YOCTO_DOCS_REF_URL;#var-PR'><filename>PR</filename></ulink>
  7925. for epoch, version, and revision, respectively).
  7926. The values are highly dependent on the policies and
  7927. procedures of a given distribution and package feed.
  7928. </para>
  7929. <para>
  7930. Because the OpenEmbedded build system uses
  7931. "<ulink url='&YOCTO_DOCS_OM_URL;#overview-checksums'>signatures</ulink>",
  7932. which are unique to a given build, the build system
  7933. knows when to rebuild packages.
  7934. All the inputs into a given task are represented by a
  7935. signature, which can trigger a rebuild when different.
  7936. Thus, the build system itself does not rely on the
  7937. <filename>PR</filename>, <filename>PV</filename>, and
  7938. <filename>PE</filename> numbers to trigger a rebuild.
  7939. The signatures, however, can be used to generate
  7940. these values.
  7941. </para>
  7942. <para>
  7943. The PR Service works with both
  7944. <filename>OEBasic</filename> and
  7945. <filename>OEBasicHash</filename> generators.
  7946. The value of <filename>PR</filename> bumps when the
  7947. checksum changes and the different generator mechanisms
  7948. change signatures under different circumstances.
  7949. </para>
  7950. <para>
  7951. As implemented, the build system includes values from
  7952. the PR Service into the <filename>PR</filename> field as
  7953. an addition using the form "<filename>.x</filename>" so
  7954. <filename>r0</filename> becomes <filename>r0.1</filename>,
  7955. <filename>r0.2</filename> and so forth.
  7956. This scheme allows existing <filename>PR</filename> values
  7957. to be used for whatever reasons, which include manual
  7958. <filename>PR</filename> bumps, should it be necessary.
  7959. </para>
  7960. <para>
  7961. By default, the PR Service is not enabled or running.
  7962. Thus, the packages generated are just "self consistent".
  7963. The build system adds and removes packages and
  7964. there are no guarantees about upgrade paths but images
  7965. will be consistent and correct with the latest changes.
  7966. </para>
  7967. <para>
  7968. The simplest form for a PR Service is for it to exist
  7969. for a single host development system that builds the
  7970. package feed (building system).
  7971. For this scenario, you can enable a local PR Service by
  7972. setting
  7973. <ulink url='&YOCTO_DOCS_REF_URL;#var-PRSERV_HOST'><filename>PRSERV_HOST</filename></ulink>
  7974. in your <filename>local.conf</filename> file in the
  7975. <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink>:
  7976. <literallayout class='monospaced'>
  7977. PRSERV_HOST = "localhost:0"
  7978. </literallayout>
  7979. Once the service is started, packages will automatically
  7980. get increasing <filename>PR</filename> values and
  7981. BitBake takes care of starting and stopping the server.
  7982. </para>
  7983. <para>
  7984. If you have a more complex setup where multiple host
  7985. development systems work against a common, shared package
  7986. feed, you have a single PR Service running and it is
  7987. connected to each building system.
  7988. For this scenario, you need to start the PR Service using
  7989. the <filename>bitbake-prserv</filename> command:
  7990. <literallayout class='monospaced'>
  7991. bitbake-prserv --host <replaceable>ip</replaceable> --port <replaceable>port</replaceable> --start
  7992. </literallayout>
  7993. In addition to hand-starting the service, you need to
  7994. update the <filename>local.conf</filename> file of each
  7995. building system as described earlier so each system
  7996. points to the server and port.
  7997. </para>
  7998. <para>
  7999. It is also recommended you use build history, which adds
  8000. some sanity checks to binary package versions, in
  8001. conjunction with the server that is running the PR Service.
  8002. To enable build history, add the following to each building
  8003. system's <filename>local.conf</filename> file:
  8004. <literallayout class='monospaced'>
  8005. # It is recommended to activate "buildhistory" for testing the PR service
  8006. INHERIT += "buildhistory"
  8007. BUILDHISTORY_COMMIT = "1"
  8008. </literallayout>
  8009. For information on build history, see the
  8010. "<link linkend='maintaining-build-output-quality'>Maintaining Build Output Quality</link>"
  8011. section.
  8012. </para>
  8013. <note>
  8014. <para>
  8015. The OpenEmbedded build system does not maintain
  8016. <filename>PR</filename> information as part of the
  8017. shared state (sstate) packages.
  8018. If you maintain an sstate feed, its expected that either
  8019. all your building systems that contribute to the sstate
  8020. feed use a shared PR Service, or you do not run a PR
  8021. Service on any of your building systems.
  8022. Having some systems use a PR Service while others do
  8023. not leads to obvious problems.
  8024. </para>
  8025. <para>
  8026. For more information on shared state, see the
  8027. "<ulink url='&YOCTO_DOCS_OM_URL;#shared-state-cache'>Shared State Cache</ulink>"
  8028. section in the Yocto Project Overview and Concepts
  8029. Manual.
  8030. </para>
  8031. </note>
  8032. </section>
  8033. <section id='manually-bumping-pr'>
  8034. <title>Manually Bumping PR</title>
  8035. <para>
  8036. The alternative to setting up a PR Service is to manually
  8037. "bump" the
  8038. <ulink url='&YOCTO_DOCS_REF_URL;#var-PR'><filename>PR</filename></ulink>
  8039. variable.
  8040. </para>
  8041. <para>
  8042. If a committed change results in changing the package
  8043. output, then the value of the PR variable needs to be
  8044. increased (or "bumped") as part of that commit.
  8045. For new recipes you should add the <filename>PR</filename>
  8046. variable and set its initial value equal to "r0", which is
  8047. the default.
  8048. Even though the default value is "r0", the practice of
  8049. adding it to a new recipe makes it harder to forget to bump
  8050. the variable when you make changes to the recipe in future.
  8051. </para>
  8052. <para>
  8053. If you are sharing a common <filename>.inc</filename> file
  8054. with multiple recipes, you can also use the
  8055. <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-INC_PR'>INC_PR</ulink></filename>
  8056. variable to ensure that the recipes sharing the
  8057. <filename>.inc</filename> file are rebuilt when the
  8058. <filename>.inc</filename> file itself is changed.
  8059. The <filename>.inc</filename> file must set
  8060. <filename>INC_PR</filename> (initially to "r0"), and all
  8061. recipes referring to it should set <filename>PR</filename>
  8062. to "${INC_PR}.0" initially, incrementing the last number
  8063. when the recipe is changed.
  8064. If the <filename>.inc</filename> file is changed then its
  8065. <filename>INC_PR</filename> should be incremented.
  8066. </para>
  8067. <para>
  8068. When upgrading the version of a binary package, assuming the
  8069. <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-PV'>PV</ulink></filename>
  8070. changes, the <filename>PR</filename> variable should be
  8071. reset to "r0" (or "${INC_PR}.0" if you are using
  8072. <filename>INC_PR</filename>).
  8073. </para>
  8074. <para>
  8075. Usually, version increases occur only to binary packages.
  8076. However, if for some reason <filename>PV</filename> changes
  8077. but does not increase, you can increase the
  8078. <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-PE'>PE</ulink></filename>
  8079. variable (Package Epoch).
  8080. The <filename>PE</filename> variable defaults to "0".
  8081. </para>
  8082. <para>
  8083. Binary package version numbering strives to follow the
  8084. <ulink url='http://www.debian.org/doc/debian-policy/ch-controlfields.html'>
  8085. Debian Version Field Policy Guidelines</ulink>.
  8086. These guidelines define how versions are compared and what
  8087. "increasing" a version means.
  8088. </para>
  8089. </section>
  8090. <section id='automatically-incrementing-a-binary-package-revision-number'>
  8091. <title>Automatically Incrementing a Package Version Number</title>
  8092. <para>
  8093. When fetching a repository, BitBake uses the
  8094. <ulink url='&YOCTO_DOCS_REF_URL;#var-SRCREV'><filename>SRCREV</filename></ulink>
  8095. variable to determine the specific source code revision
  8096. from which to build.
  8097. You set the <filename>SRCREV</filename> variable to
  8098. <ulink url='&YOCTO_DOCS_REF_URL;#var-AUTOREV'><filename>AUTOREV</filename></ulink>
  8099. to cause the OpenEmbedded build system to automatically use the
  8100. latest revision of the software:
  8101. <literallayout class='monospaced'>
  8102. SRCREV = "${AUTOREV}"
  8103. </literallayout>
  8104. </para>
  8105. <para>
  8106. Furthermore, you need to reference <filename>SRCPV</filename>
  8107. in <filename>PV</filename> in order to automatically update
  8108. the version whenever the revision of the source code
  8109. changes.
  8110. Here is an example:
  8111. <literallayout class='monospaced'>
  8112. PV = "1.0+git${SRCPV}"
  8113. </literallayout>
  8114. The OpenEmbedded build system substitutes
  8115. <filename>SRCPV</filename> with the following:
  8116. <literallayout class='monospaced'>
  8117. AUTOINC+<replaceable>source_code_revision</replaceable>
  8118. </literallayout>
  8119. The build system replaces the <filename>AUTOINC</filename> with
  8120. a number.
  8121. The number used depends on the state of the PR Service:
  8122. <itemizedlist>
  8123. <listitem><para>
  8124. If PR Service is enabled, the build system increments
  8125. the number, which is similar to the behavior of
  8126. <ulink url='&YOCTO_DOCS_REF_URL;#var-PR'><filename>PR</filename></ulink>.
  8127. This behavior results in linearly increasing package
  8128. versions, which is desirable.
  8129. Here is an example:
  8130. <literallayout class='monospaced'>
  8131. hello-world-git_0.0+git0+b6558dd387-r0.0_armv7a-neon.ipk
  8132. hello-world-git_0.0+git1+dd2f5c3565-r0.0_armv7a-neon.ipk
  8133. </literallayout>
  8134. </para></listitem>
  8135. <listitem><para>
  8136. If PR Service is not enabled, the build system
  8137. replaces the <filename>AUTOINC</filename>
  8138. placeholder with zero (i.e. "0").
  8139. This results in changing the package version since
  8140. the source revision is included.
  8141. However, package versions are not increased linearly.
  8142. Here is an example:
  8143. <literallayout class='monospaced'>
  8144. hello-world-git_0.0+git0+b6558dd387-r0.0_armv7a-neon.ipk
  8145. hello-world-git_0.0+git0+dd2f5c3565-r0.0_armv7a-neon.ipk
  8146. </literallayout>
  8147. </para></listitem>
  8148. </itemizedlist>
  8149. </para>
  8150. <para>
  8151. In summary, the OpenEmbedded build system does not track the
  8152. history of binary package versions for this purpose.
  8153. <filename>AUTOINC</filename>, in this case, is comparable to
  8154. <filename>PR</filename>.
  8155. If PR server is not enabled, <filename>AUTOINC</filename>
  8156. in the package version is simply replaced by "0".
  8157. If PR server is enabled, the build system keeps track of the
  8158. package versions and bumps the number when the package
  8159. revision changes.
  8160. </para>
  8161. </section>
  8162. </section>
  8163. <section id='handling-optional-module-packaging'>
  8164. <title>Handling Optional Module Packaging</title>
  8165. <para>
  8166. Many pieces of software split functionality into optional
  8167. modules (or plug-ins) and the plug-ins that are built
  8168. might depend on configuration options.
  8169. To avoid having to duplicate the logic that determines what
  8170. modules are available in your recipe or to avoid having
  8171. to package each module by hand, the OpenEmbedded build system
  8172. provides functionality to handle module packaging dynamically.
  8173. </para>
  8174. <para>
  8175. To handle optional module packaging, you need to do two things:
  8176. <itemizedlist>
  8177. <listitem><para>Ensure the module packaging is actually
  8178. done.</para></listitem>
  8179. <listitem><para>Ensure that any dependencies on optional
  8180. modules from other recipes are satisfied by your recipe.
  8181. </para></listitem>
  8182. </itemizedlist>
  8183. </para>
  8184. <section id='making-sure-the-packaging-is-done'>
  8185. <title>Making Sure the Packaging is Done</title>
  8186. <para>
  8187. To ensure the module packaging actually gets done, you use
  8188. the <filename>do_split_packages</filename> function within
  8189. the <filename>populate_packages</filename> Python function
  8190. in your recipe.
  8191. The <filename>do_split_packages</filename> function
  8192. searches for a pattern of files or directories under a
  8193. specified path and creates a package for each one it finds
  8194. by appending to the
  8195. <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGES'><filename>PACKAGES</filename></ulink>
  8196. variable and setting the appropriate values for
  8197. <filename>FILES_packagename</filename>,
  8198. <filename>RDEPENDS_packagename</filename>,
  8199. <filename>DESCRIPTION_packagename</filename>, and so forth.
  8200. Here is an example from the <filename>lighttpd</filename>
  8201. recipe:
  8202. <literallayout class='monospaced'>
  8203. python populate_packages_prepend () {
  8204. lighttpd_libdir = d.expand('${libdir}')
  8205. do_split_packages(d, lighttpd_libdir, '^mod_(.*)\.so$',
  8206. 'lighttpd-module-%s', 'Lighttpd module for %s',
  8207. extra_depends='')
  8208. }
  8209. </literallayout>
  8210. The previous example specifies a number of things in the
  8211. call to <filename>do_split_packages</filename>.
  8212. <itemizedlist>
  8213. <listitem><para>A directory within the files installed
  8214. by your recipe through <filename>do_install</filename>
  8215. in which to search.</para></listitem>
  8216. <listitem><para>A regular expression used to match module
  8217. files in that directory.
  8218. In the example, note the parentheses () that mark
  8219. the part of the expression from which the module
  8220. name should be derived.</para></listitem>
  8221. <listitem><para>A pattern to use for the package names.
  8222. </para></listitem>
  8223. <listitem><para>A description for each package.
  8224. </para></listitem>
  8225. <listitem><para>An empty string for
  8226. <filename>extra_depends</filename>, which disables
  8227. the default dependency on the main
  8228. <filename>lighttpd</filename> package.
  8229. Thus, if a file in <filename>${libdir}</filename>
  8230. called <filename>mod_alias.so</filename> is found,
  8231. a package called <filename>lighttpd-module-alias</filename>
  8232. is created for it and the
  8233. <ulink url='&YOCTO_DOCS_REF_URL;#var-DESCRIPTION'><filename>DESCRIPTION</filename></ulink>
  8234. is set to "Lighttpd module for alias".</para></listitem>
  8235. </itemizedlist>
  8236. </para>
  8237. <para>
  8238. Often, packaging modules is as simple as the previous
  8239. example.
  8240. However, more advanced options exist that you can use
  8241. within <filename>do_split_packages</filename> to modify its
  8242. behavior.
  8243. And, if you need to, you can add more logic by specifying
  8244. a hook function that is called for each package.
  8245. It is also perfectly acceptable to call
  8246. <filename>do_split_packages</filename> multiple times if
  8247. you have more than one set of modules to package.
  8248. </para>
  8249. <para>
  8250. For more examples that show how to use
  8251. <filename>do_split_packages</filename>, see the
  8252. <filename>connman.inc</filename> file in the
  8253. <filename>meta/recipes-connectivity/connman/</filename>
  8254. directory of the <filename>poky</filename>
  8255. <ulink url='&YOCTO_DOCS_OM_URL;#yocto-project-repositories'>source repository</ulink>.
  8256. You can also find examples in
  8257. <filename>meta/classes/kernel.bbclass</filename>.
  8258. </para>
  8259. <para>
  8260. Following is a reference that shows
  8261. <filename>do_split_packages</filename> mandatory and
  8262. optional arguments:
  8263. <literallayout class='monospaced'>
  8264. Mandatory arguments
  8265. root
  8266. The path in which to search
  8267. file_regex
  8268. Regular expression to match searched files.
  8269. Use parentheses () to mark the part of this
  8270. expression that should be used to derive the
  8271. module name (to be substituted where %s is
  8272. used in other function arguments as noted below)
  8273. output_pattern
  8274. Pattern to use for the package names. Must
  8275. include %s.
  8276. description
  8277. Description to set for each package. Must
  8278. include %s.
  8279. Optional arguments
  8280. postinst
  8281. Postinstall script to use for all packages
  8282. (as a string)
  8283. recursive
  8284. True to perform a recursive search - default
  8285. False
  8286. hook
  8287. A hook function to be called for every match.
  8288. The function will be called with the following
  8289. arguments (in the order listed):
  8290. f
  8291. Full path to the file/directory match
  8292. pkg
  8293. The package name
  8294. file_regex
  8295. As above
  8296. output_pattern
  8297. As above
  8298. modulename
  8299. The module name derived using file_regex
  8300. extra_depends
  8301. Extra runtime dependencies (RDEPENDS) to be
  8302. set for all packages. The default value of None
  8303. causes a dependency on the main package
  8304. (${PN}) - if you do not want this, pass empty
  8305. string '' for this parameter.
  8306. aux_files_pattern
  8307. Extra item(s) to be added to FILES for each
  8308. package. Can be a single string item or a list
  8309. of strings for multiple items. Must include %s.
  8310. postrm
  8311. postrm script to use for all packages (as a
  8312. string)
  8313. allow_dirs
  8314. True to allow directories to be matched -
  8315. default False
  8316. prepend
  8317. If True, prepend created packages to PACKAGES
  8318. instead of the default False which appends them
  8319. match_path
  8320. match file_regex on the whole relative path to
  8321. the root rather than just the file name
  8322. aux_files_pattern_verbatim
  8323. Extra item(s) to be added to FILES for each
  8324. package, using the actual derived module name
  8325. rather than converting it to something legal
  8326. for a package name. Can be a single string item
  8327. or a list of strings for multiple items. Must
  8328. include %s.
  8329. allow_links
  8330. True to allow symlinks to be matched - default
  8331. False
  8332. summary
  8333. Summary to set for each package. Must include %s;
  8334. defaults to description if not set.
  8335. </literallayout>
  8336. </para>
  8337. </section>
  8338. <section id='satisfying-dependencies'>
  8339. <title>Satisfying Dependencies</title>
  8340. <para>
  8341. The second part for handling optional module packaging
  8342. is to ensure that any dependencies on optional modules
  8343. from other recipes are satisfied by your recipe.
  8344. You can be sure these dependencies are satisfied by
  8345. using the
  8346. <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGES_DYNAMIC'><filename>PACKAGES_DYNAMIC</filename></ulink> variable.
  8347. Here is an example that continues with the
  8348. <filename>lighttpd</filename> recipe shown earlier:
  8349. <literallayout class='monospaced'>
  8350. PACKAGES_DYNAMIC = "lighttpd-module-.*"
  8351. </literallayout>
  8352. The name specified in the regular expression can of
  8353. course be anything.
  8354. In this example, it is <filename>lighttpd-module-</filename>
  8355. and is specified as the prefix to ensure that any
  8356. <ulink url='&YOCTO_DOCS_REF_URL;#var-RDEPENDS'><filename>RDEPENDS</filename></ulink>
  8357. and <ulink url='&YOCTO_DOCS_REF_URL;#var-RRECOMMENDS'><filename>RRECOMMENDS</filename></ulink>
  8358. on a package name starting with the prefix are satisfied
  8359. during build time.
  8360. If you are using <filename>do_split_packages</filename>
  8361. as described in the previous section, the value you put in
  8362. <filename>PACKAGES_DYNAMIC</filename> should correspond to
  8363. the name pattern specified in the call to
  8364. <filename>do_split_packages</filename>.
  8365. </para>
  8366. </section>
  8367. </section>
  8368. <section id='using-runtime-package-management'>
  8369. <title>Using Runtime Package Management</title>
  8370. <para>
  8371. During a build, BitBake always transforms a recipe into one or
  8372. more packages.
  8373. For example, BitBake takes the <filename>bash</filename> recipe
  8374. and produces a number of packages (e.g.
  8375. <filename>bash</filename>, <filename>bash-bashbug</filename>,
  8376. <filename>bash-completion</filename>,
  8377. <filename>bash-completion-dbg</filename>,
  8378. <filename>bash-completion-dev</filename>,
  8379. <filename>bash-completion-extra</filename>,
  8380. <filename>bash-dbg</filename>, and so forth).
  8381. Not all generated packages are included in an image.
  8382. </para>
  8383. <para>
  8384. In several situations, you might need to update, add, remove,
  8385. or query the packages on a target device at runtime
  8386. (i.e. without having to generate a new image).
  8387. Examples of such situations include:
  8388. <itemizedlist>
  8389. <listitem><para>
  8390. You want to provide in-the-field updates to deployed
  8391. devices (e.g. security updates).
  8392. </para></listitem>
  8393. <listitem><para>
  8394. You want to have a fast turn-around development cycle
  8395. for one or more applications that run on your device.
  8396. </para></listitem>
  8397. <listitem><para>
  8398. You want to temporarily install the "debug" packages
  8399. of various applications on your device so that
  8400. debugging can be greatly improved by allowing
  8401. access to symbols and source debugging.
  8402. </para></listitem>
  8403. <listitem><para>
  8404. You want to deploy a more minimal package selection of
  8405. your device but allow in-the-field updates to add a
  8406. larger selection for customization.
  8407. </para></listitem>
  8408. </itemizedlist>
  8409. </para>
  8410. <para>
  8411. In all these situations, you have something similar to a more
  8412. traditional Linux distribution in that in-field devices
  8413. are able to receive pre-compiled packages from a server for
  8414. installation or update.
  8415. Being able to install these packages on a running,
  8416. in-field device is what is termed "runtime package
  8417. management".
  8418. </para>
  8419. <para>
  8420. In order to use runtime package management, you
  8421. need a host or server machine that serves up the pre-compiled
  8422. packages plus the required metadata.
  8423. You also need package manipulation tools on the target.
  8424. The build machine is a likely candidate to act as the server.
  8425. However, that machine does not necessarily have to be the
  8426. package server.
  8427. The build machine could push its artifacts to another machine
  8428. that acts as the server (e.g. Internet-facing).
  8429. In fact, doing so is advantageous for a production
  8430. environment as getting the packages away from the
  8431. development system's build directory prevents accidental
  8432. overwrites.
  8433. </para>
  8434. <para>
  8435. A simple build that targets just one device produces
  8436. more than one package database.
  8437. In other words, the packages produced by a build are separated
  8438. out into a couple of different package groupings based on
  8439. criteria such as the target's CPU architecture, the target
  8440. board, or the C library used on the target.
  8441. For example, a build targeting the <filename>qemux86</filename>
  8442. device produces the following three package databases:
  8443. <filename>noarch</filename>, <filename>i586</filename>, and
  8444. <filename>qemux86</filename>.
  8445. If you wanted your <filename>qemux86</filename> device to be
  8446. aware of all the packages that were available to it,
  8447. you would need to point it to each of these databases
  8448. individually.
  8449. In a similar way, a traditional Linux distribution usually is
  8450. configured to be aware of a number of software repositories
  8451. from which it retrieves packages.
  8452. </para>
  8453. <para>
  8454. Using runtime package management is completely optional and
  8455. not required for a successful build or deployment in any
  8456. way.
  8457. But if you want to make use of runtime package management,
  8458. you need to do a couple things above and beyond the basics.
  8459. The remainder of this section describes what you need to do.
  8460. </para>
  8461. <section id='runtime-package-management-build'>
  8462. <title>Build Considerations</title>
  8463. <para>
  8464. This section describes build considerations of which you
  8465. need to be aware in order to provide support for runtime
  8466. package management.
  8467. </para>
  8468. <para>
  8469. When BitBake generates packages, it needs to know
  8470. what format or formats to use.
  8471. In your configuration, you use the
  8472. <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_CLASSES'><filename>PACKAGE_CLASSES</filename></ulink>
  8473. variable to specify the format:
  8474. <orderedlist>
  8475. <listitem><para>
  8476. Open the <filename>local.conf</filename> file
  8477. inside your
  8478. <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink>
  8479. (e.g. <filename>~/poky/build/conf/local.conf</filename>).
  8480. </para></listitem>
  8481. <listitem><para>
  8482. Select the desired package format as follows:
  8483. <literallayout class='monospaced'>
  8484. PACKAGE_CLASSES ?= “package_<replaceable>packageformat</replaceable>”
  8485. </literallayout>
  8486. where <replaceable>packageformat</replaceable>
  8487. can be "ipk", "rpm", "deb", or "tar" which are the
  8488. supported package formats.
  8489. <note>
  8490. Because the Yocto Project supports four
  8491. different package formats, you can set the
  8492. variable with more than one argument.
  8493. However, the OpenEmbedded build system only
  8494. uses the first argument when creating an image
  8495. or Software Development Kit (SDK).
  8496. </note>
  8497. </para></listitem>
  8498. </orderedlist>
  8499. </para>
  8500. <para>
  8501. If you would like your image to start off with a basic
  8502. package database containing the packages in your current
  8503. build as well as to have the relevant tools available on the
  8504. target for runtime package management, you can include
  8505. "package-management" in the
  8506. <ulink url='&YOCTO_DOCS_REF_URL;#var-IMAGE_FEATURES'><filename>IMAGE_FEATURES</filename></ulink>
  8507. variable.
  8508. Including "package-management" in this configuration
  8509. variable ensures that when the image is assembled for your
  8510. target, the image includes the currently-known package
  8511. databases as well as the target-specific tools required
  8512. for runtime package management to be performed on the
  8513. target.
  8514. However, this is not strictly necessary.
  8515. You could start your image off without any databases
  8516. but only include the required on-target package
  8517. tool(s).
  8518. As an example, you could include "opkg" in your
  8519. <ulink url='&YOCTO_DOCS_REF_URL;#var-IMAGE_INSTALL'><filename>IMAGE_INSTALL</filename></ulink>
  8520. variable if you are using the IPK package format.
  8521. You can then initialize your target's package database(s)
  8522. later once your image is up and running.
  8523. </para>
  8524. <para>
  8525. Whenever you perform any sort of build step that can
  8526. potentially generate a package or modify existing
  8527. package, it is always a good idea to re-generate the
  8528. package index after the build by using the following
  8529. command:
  8530. <literallayout class='monospaced'>
  8531. $ bitbake package-index
  8532. </literallayout>
  8533. It might be tempting to build the package and the
  8534. package index at the same time with a command such as
  8535. the following:
  8536. <literallayout class='monospaced'>
  8537. $ bitbake <replaceable>some-package</replaceable> package-index
  8538. </literallayout>
  8539. Do not do this as BitBake does not schedule the package
  8540. index for after the completion of the package you are
  8541. building.
  8542. Consequently, you cannot be sure of the package index
  8543. including information for the package you just built.
  8544. Thus, be sure to run the package update step separately
  8545. after building any packages.
  8546. </para>
  8547. <para>
  8548. You can use the
  8549. <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_FEED_ARCHS'><filename>PACKAGE_FEED_ARCHS</filename></ulink>,
  8550. <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_FEED_BASE_PATHS'><filename>PACKAGE_FEED_BASE_PATHS</filename></ulink>,
  8551. and
  8552. <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_FEED_URIS'><filename>PACKAGE_FEED_URIS</filename></ulink>
  8553. variables to pre-configure target images to use a package
  8554. feed.
  8555. If you do not define these variables, then manual steps
  8556. as described in the subsequent sections are necessary to
  8557. configure the target.
  8558. You should set these variables before building the image
  8559. in order to produce a correctly configured image.
  8560. </para>
  8561. <para>
  8562. When your build is complete, your packages reside in the
  8563. <filename>${TMPDIR}/deploy/<replaceable>packageformat</replaceable></filename>
  8564. directory.
  8565. For example, if
  8566. <filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-TMPDIR'><filename>TMPDIR</filename></ulink><filename>}</filename>
  8567. is <filename>tmp</filename> and your selected package type
  8568. is RPM, then your RPM packages are available in
  8569. <filename>tmp/deploy/rpm</filename>.
  8570. </para>
  8571. </section>
  8572. <section id='runtime-package-management-server'>
  8573. <title>Host or Server Machine Setup</title>
  8574. <para>
  8575. Although other protocols are possible, a server using HTTP
  8576. typically serves packages.
  8577. If you want to use HTTP, then set up and configure a
  8578. web server such as Apache 2, lighttpd, or
  8579. SimpleHTTPServer on the machine serving the packages.
  8580. </para>
  8581. <para>
  8582. To keep things simple, this section describes how to set
  8583. up a SimpleHTTPServer web server to share package feeds
  8584. from the developer's machine.
  8585. Although this server might not be the best for a production
  8586. environment, the setup is simple and straight forward.
  8587. Should you want to use a different server more suited for
  8588. production (e.g. Apache 2, Lighttpd, or Nginx), take the
  8589. appropriate steps to do so.
  8590. </para>
  8591. <para>
  8592. From within the build directory where you have built an
  8593. image based on your packaging choice (i.e. the
  8594. <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_CLASSES'><filename>PACKAGE_CLASSES</filename></ulink>
  8595. setting), simply start the server.
  8596. The following example assumes a build directory of
  8597. <filename>~/poky/build/tmp/deploy/rpm</filename> and a
  8598. <filename>PACKAGE_CLASSES</filename> setting of
  8599. "package_rpm":
  8600. <literallayout class='monospaced'>
  8601. $ cd ~/poky/build/tmp/deploy/rpm
  8602. $ python -m SimpleHTTPServer
  8603. </literallayout>
  8604. </para>
  8605. </section>
  8606. <section id='runtime-package-management-target'>
  8607. <title>Target Setup</title>
  8608. <para>
  8609. Setting up the target differs depending on the
  8610. package management system.
  8611. This section provides information for RPM, IPK, and DEB.
  8612. </para>
  8613. <section id='runtime-package-management-target-rpm'>
  8614. <title>Using RPM</title>
  8615. <para>
  8616. The
  8617. <ulink url='https://en.wikipedia.org/wiki/DNF_(software)'>Dandified Packaging Tool</ulink>
  8618. (DNF) performs runtime package management of RPM
  8619. packages.
  8620. In order to use DNF for runtime package management,
  8621. you must perform an initial setup on the target
  8622. machine for cases where the
  8623. <filename>PACKAGE_FEED_*</filename> variables were not
  8624. set as part of the image that is running on the
  8625. target.
  8626. This means if you built your image and did not not use
  8627. these variables as part of the build and your image is
  8628. now running on the target, you need to perform the
  8629. steps in this section if you want to use runtime
  8630. package management.
  8631. <note>
  8632. For information on the
  8633. <filename>PACKAGE_FEED_*</filename> variables, see
  8634. <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_FEED_ARCHS'><filename>PACKAGE_FEED_ARCHS</filename></ulink>,
  8635. <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_FEED_BASE_PATHS'><filename>PACKAGE_FEED_BASE_PATHS</filename></ulink>,
  8636. and
  8637. <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_FEED_URIS'><filename>PACKAGE_FEED_URIS</filename></ulink>
  8638. in the Yocto Project Reference Manual variables
  8639. glossary.
  8640. </note>
  8641. </para>
  8642. <para>
  8643. On the target, you must inform DNF that package
  8644. databases are available.
  8645. You do this by creating a file named
  8646. <filename>/etc/yum.repos.d/oe-packages.repo</filename>
  8647. and defining the <filename>oe-packages</filename>.
  8648. </para>
  8649. <para>
  8650. As an example, assume the target is able to use the
  8651. following package databases:
  8652. <filename>all</filename>, <filename>i586</filename>,
  8653. and <filename>qemux86</filename> from a server named
  8654. <filename>my.server</filename>.
  8655. The specifics for setting up the web server are up to
  8656. you.
  8657. The critical requirement is that the URIs in the
  8658. target repository configuration point to the
  8659. correct remote location for the feeds.
  8660. <note><title>Tip</title>
  8661. For development purposes, you can point the web
  8662. server to the build system's
  8663. <filename>deploy</filename> directory.
  8664. However, for production use, it is better to copy
  8665. the package directories to a location outside of
  8666. the build area and use that location.
  8667. Doing so avoids situations where the build system
  8668. overwrites or changes the
  8669. <filename>deploy</filename> directory.
  8670. </note>
  8671. </para>
  8672. <para>
  8673. When telling DNF where to look for the package
  8674. databases, you must declare individual locations
  8675. per architecture or a single location used for all
  8676. architectures.
  8677. You cannot do both:
  8678. <itemizedlist>
  8679. <listitem><para>
  8680. <emphasis>Create an Explicit List of Architectures:</emphasis>
  8681. Define individual base URLs to identify where
  8682. each package database is located:
  8683. <literallayout class='monospaced'>
  8684. [oe-packages]
  8685. baseurl=http://my.server/rpm/i586 http://my.server/rpm/qemux86 http://my.server/rpm/all
  8686. </literallayout>
  8687. This example informs DNF about individual
  8688. package databases for all three architectures.
  8689. </para></listitem>
  8690. <listitem><para>
  8691. <emphasis>Create a Single (Full) Package Index:</emphasis>
  8692. Define a single base URL that identifies where
  8693. a full package database is located:
  8694. <literallayout class='monospaced'>
  8695. [oe-packages]
  8696. baseurl=http://my.server/rpm
  8697. </literallayout>
  8698. This example informs DNF about a single package
  8699. database that contains all the package index
  8700. information for all supported architectures.
  8701. </para></listitem>
  8702. </itemizedlist>
  8703. </para>
  8704. <para>
  8705. Once you have informed DNF where to find the package
  8706. databases, you need to fetch them:
  8707. <literallayout class='monospaced'>
  8708. # dnf makecache
  8709. </literallayout>
  8710. DNF is now able to find, install, and upgrade packages
  8711. from the specified repository or repositories.
  8712. <note>
  8713. See the
  8714. <ulink url='http://dnf.readthedocs.io/en/latest/'>DNF documentation</ulink>
  8715. for additional information.
  8716. </note>
  8717. </para>
  8718. </section>
  8719. <section id='runtime-package-management-target-ipk'>
  8720. <title>Using IPK</title>
  8721. <para>
  8722. The <filename>opkg</filename> application performs
  8723. runtime package management of IPK packages.
  8724. You must perform an initial setup for
  8725. <filename>opkg</filename> on the target machine
  8726. if the
  8727. <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_FEED_ARCHS'><filename>PACKAGE_FEED_ARCHS</filename></ulink>,
  8728. <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_FEED_BASE_PATHS'><filename>PACKAGE_FEED_BASE_PATHS</filename></ulink>, and
  8729. <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_FEED_URIS'><filename>PACKAGE_FEED_URIS</filename></ulink>
  8730. variables have not been set or the target image was
  8731. built before the variables were set.
  8732. </para>
  8733. <para>
  8734. The <filename>opkg</filename> application uses
  8735. configuration files to find available package
  8736. databases.
  8737. Thus, you need to create a configuration file inside
  8738. the <filename>/etc/opkg/</filename> direction, which
  8739. informs <filename>opkg</filename> of any repository
  8740. you want to use.
  8741. </para>
  8742. <para>
  8743. As an example, suppose you are serving packages from a
  8744. <filename>ipk/</filename> directory containing the
  8745. <filename>i586</filename>,
  8746. <filename>all</filename>, and
  8747. <filename>qemux86</filename> databases through an
  8748. HTTP server named <filename>my.server</filename>.
  8749. On the target, create a configuration file
  8750. (e.g. <filename>my_repo.conf</filename>) inside the
  8751. <filename>/etc/opkg/</filename> directory containing
  8752. the following:
  8753. <literallayout class='monospaced'>
  8754. src/gz all http://my.server/ipk/all
  8755. src/gz i586 http://my.server/ipk/i586
  8756. src/gz qemux86 http://my.server/ipk/qemux86
  8757. </literallayout>
  8758. Next, instruct <filename>opkg</filename> to fetch
  8759. the repository information:
  8760. <literallayout class='monospaced'>
  8761. # opkg update
  8762. </literallayout>
  8763. The <filename>opkg</filename> application is now able
  8764. to find, install, and upgrade packages from the
  8765. specified repository.
  8766. </para>
  8767. </section>
  8768. <section id='runtime-package-management-target-deb'>
  8769. <title>Using DEB</title>
  8770. <para>
  8771. The <filename>apt</filename> application performs
  8772. runtime package management of DEB packages.
  8773. This application uses a source list file to find
  8774. available package databases.
  8775. You must perform an initial setup for
  8776. <filename>apt</filename> on the target machine
  8777. if the
  8778. <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_FEED_ARCHS'><filename>PACKAGE_FEED_ARCHS</filename></ulink>,
  8779. <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_FEED_BASE_PATHS'><filename>PACKAGE_FEED_BASE_PATHS</filename></ulink>, and
  8780. <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_FEED_URIS'><filename>PACKAGE_FEED_URIS</filename></ulink>
  8781. variables have not been set or the target image was
  8782. built before the variables were set.
  8783. </para>
  8784. <para>
  8785. To inform <filename>apt</filename> of the repository
  8786. you want to use, you might create a list file (e.g.
  8787. <filename>my_repo.list</filename>) inside the
  8788. <filename>/etc/apt/sources.list.d/</filename>
  8789. directory.
  8790. As an example, suppose you are serving packages from a
  8791. <filename>deb/</filename> directory containing the
  8792. <filename>i586</filename>,
  8793. <filename>all</filename>, and
  8794. <filename>qemux86</filename> databases through an
  8795. HTTP server named <filename>my.server</filename>.
  8796. The list file should contain:
  8797. <literallayout class='monospaced'>
  8798. deb http://my.server/deb/all ./
  8799. deb http://my.server/deb/i586 ./
  8800. deb http://my.server/deb/qemux86 ./
  8801. </literallayout>
  8802. Next, instruct the <filename>apt</filename>
  8803. application to fetch the repository information:
  8804. <literallayout class='monospaced'>
  8805. # apt-get update
  8806. </literallayout>
  8807. After this step, <filename>apt</filename> is able
  8808. to find, install, and upgrade packages from the
  8809. specified repository.
  8810. </para>
  8811. </section>
  8812. </section>
  8813. </section>
  8814. <section id='generating-and-using-signed-packages'>
  8815. <title>Generating and Using Signed Packages</title>
  8816. <para>
  8817. In order to add security to RPM packages used during a build,
  8818. you can take steps to securely sign them.
  8819. Once a signature is verified, the OpenEmbedded build system
  8820. can use the package in the build.
  8821. If security fails for a signed package, the build system
  8822. aborts the build.
  8823. </para>
  8824. <para>
  8825. This section describes how to sign RPM packages during a build
  8826. and how to use signed package feeds (repositories) when
  8827. doing a build.
  8828. </para>
  8829. <section id='signing-rpm-packages'>
  8830. <title>Signing RPM Packages</title>
  8831. <para>
  8832. To enable signing RPM packages, you must set up the
  8833. following configurations in either your
  8834. <filename>local.config</filename> or
  8835. <filename>distro.config</filename> file:
  8836. <literallayout class='monospaced'>
  8837. # Inherit sign_rpm.bbclass to enable signing functionality
  8838. INHERIT += " sign_rpm"
  8839. # Define the GPG key that will be used for signing.
  8840. RPM_GPG_NAME = "<replaceable>key_name</replaceable>"
  8841. # Provide passphrase for the key
  8842. RPM_GPG_PASSPHRASE = "<replaceable>passphrase</replaceable>"
  8843. </literallayout>
  8844. <note>
  8845. Be sure to supply appropriate values for both
  8846. <replaceable>key_name</replaceable> and
  8847. <replaceable>passphrase</replaceable>
  8848. </note>
  8849. Aside from the
  8850. <filename>RPM_GPG_NAME</filename> and
  8851. <filename>RPM_GPG_PASSPHRASE</filename> variables in the
  8852. previous example, two optional variables related to signing
  8853. exist:
  8854. <itemizedlist>
  8855. <listitem><para>
  8856. <emphasis><filename>GPG_BIN</filename>:</emphasis>
  8857. Specifies a <filename>gpg</filename> binary/wrapper
  8858. that is executed when the package is signed.
  8859. </para></listitem>
  8860. <listitem><para>
  8861. <emphasis><filename>GPG_PATH</filename>:</emphasis>
  8862. Specifies the <filename>gpg</filename> home
  8863. directory used when the package is signed.
  8864. </para></listitem>
  8865. </itemizedlist>
  8866. </para>
  8867. </section>
  8868. <section id='processing-package-feeds'>
  8869. <title>Processing Package Feeds</title>
  8870. <para>
  8871. In addition to being able to sign RPM packages, you can
  8872. also enable signed package feeds for IPK and RPM packages.
  8873. </para>
  8874. <para>
  8875. The steps you need to take to enable signed package feed
  8876. use are similar to the steps used to sign RPM packages.
  8877. You must define the following in your
  8878. <filename>local.config</filename> or
  8879. <filename>distro.config</filename> file:
  8880. <literallayout class='monospaced'>
  8881. INHERIT += "sign_package_feed"
  8882. PACKAGE_FEED_GPG_NAME = "<replaceable>key_name</replaceable>"
  8883. PACKAGE_FEED_GPG_PASSPHRASE_FILE = "<replaceable>path_to_file_containing_passphrase</replaceable>"
  8884. </literallayout>
  8885. For signed package feeds, the passphrase must exist in a
  8886. separate file, which is pointed to by the
  8887. <filename>PACKAGE_FEED_GPG_PASSPHRASE_FILE</filename>
  8888. variable.
  8889. Regarding security, keeping a plain text passphrase out of
  8890. the configuration is more secure.
  8891. </para>
  8892. <para>
  8893. Aside from the
  8894. <filename>PACKAGE_FEED_GPG_NAME</filename> and
  8895. <filename>PACKAGE_FEED_GPG_PASSPHRASE_FILE</filename>
  8896. variables, three optional variables related to signed
  8897. package feeds exist:
  8898. <itemizedlist>
  8899. <listitem><para>
  8900. <emphasis><filename>GPG_BIN</filename>:</emphasis>
  8901. Specifies a <filename>gpg</filename> binary/wrapper
  8902. that is executed when the package is signed.
  8903. </para></listitem>
  8904. <listitem><para>
  8905. <emphasis><filename>GPG_PATH</filename>:</emphasis>
  8906. Specifies the <filename>gpg</filename> home
  8907. directory used when the package is signed.
  8908. </para></listitem>
  8909. <listitem><para>
  8910. <emphasis><filename>PACKAGE_FEED_GPG_SIGNATURE_TYPE</filename>:</emphasis>
  8911. Specifies the type of <filename>gpg</filename>
  8912. signature.
  8913. This variable applies only to RPM and IPK package
  8914. feeds.
  8915. Allowable values for the
  8916. <filename>PACKAGE_FEED_GPG_SIGNATURE_TYPE</filename>
  8917. are "ASC", which is the default and specifies ascii
  8918. armored, and "BIN", which specifies binary.
  8919. </para></listitem>
  8920. </itemizedlist>
  8921. </para>
  8922. </section>
  8923. </section>
  8924. <section id='testing-packages-with-ptest'>
  8925. <title>Testing Packages With ptest</title>
  8926. <para>
  8927. A Package Test (ptest) runs tests against packages built
  8928. by the OpenEmbedded build system on the target machine.
  8929. A ptest contains at least two items: the actual test, and
  8930. a shell script (<filename>run-ptest</filename>) that starts
  8931. the test.
  8932. The shell script that starts the test must not contain
  8933. the actual test - the script only starts the test.
  8934. On the other hand, the test can be anything from a simple
  8935. shell script that runs a binary and checks the output to
  8936. an elaborate system of test binaries and data files.
  8937. </para>
  8938. <para>
  8939. The test generates output in the format used by
  8940. Automake:
  8941. <literallayout class='monospaced'>
  8942. <replaceable>result</replaceable>: <replaceable>testname</replaceable>
  8943. </literallayout>
  8944. where the result can be <filename>PASS</filename>,
  8945. <filename>FAIL</filename>, or <filename>SKIP</filename>,
  8946. and the testname can be any identifying string.
  8947. </para>
  8948. <para>
  8949. For a list of Yocto Project recipes that are already
  8950. enabled with ptest, see the
  8951. <ulink url='https://wiki.yoctoproject.org/wiki/Ptest'>Ptest</ulink>
  8952. wiki page.
  8953. <note>
  8954. A recipe is "ptest-enabled" if it inherits the
  8955. <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-ptest'><filename>ptest</filename></ulink>
  8956. class.
  8957. </note>
  8958. </para>
  8959. <section id='adding-ptest-to-your-build'>
  8960. <title>Adding ptest to Your Build</title>
  8961. <para>
  8962. To add package testing to your build, add the
  8963. <ulink url='&YOCTO_DOCS_REF_URL;#var-DISTRO_FEATURES'><filename>DISTRO_FEATURES</filename></ulink>
  8964. and <ulink url='&YOCTO_DOCS_REF_URL;#var-EXTRA_IMAGE_FEATURES'><filename>EXTRA_IMAGE_FEATURES</filename></ulink>
  8965. variables to your <filename>local.conf</filename> file,
  8966. which is found in the
  8967. <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink>:
  8968. <literallayout class='monospaced'>
  8969. DISTRO_FEATURES_append = " ptest"
  8970. EXTRA_IMAGE_FEATURES += "ptest-pkgs"
  8971. </literallayout>
  8972. Once your build is complete, the ptest files are installed
  8973. into the
  8974. <filename>/usr/lib/<replaceable>package</replaceable>/ptest</filename>
  8975. directory within the image, where
  8976. <filename><replaceable>package</replaceable></filename>
  8977. is the name of the package.
  8978. </para>
  8979. </section>
  8980. <section id='running-ptest'>
  8981. <title>Running ptest</title>
  8982. <para>
  8983. The <filename>ptest-runner</filename> package installs a
  8984. shell script that loops through all installed ptest test
  8985. suites and runs them in sequence.
  8986. Consequently, you might want to add this package to
  8987. your image.
  8988. </para>
  8989. </section>
  8990. <section id='getting-your-package-ready'>
  8991. <title>Getting Your Package Ready</title>
  8992. <para>
  8993. In order to enable a recipe to run installed ptests
  8994. on target hardware,
  8995. you need to prepare the recipes that build the packages
  8996. you want to test.
  8997. Here is what you have to do for each recipe:
  8998. <itemizedlist>
  8999. <listitem><para><emphasis>Be sure the recipe
  9000. inherits the
  9001. <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-ptest'><filename>ptest</filename></ulink>
  9002. class:</emphasis>
  9003. Include the following line in each recipe:
  9004. <literallayout class='monospaced'>
  9005. inherit ptest
  9006. </literallayout>
  9007. </para></listitem>
  9008. <listitem><para><emphasis>Create <filename>run-ptest</filename>:</emphasis>
  9009. This script starts your test.
  9010. Locate the script where you will refer to it
  9011. using
  9012. <ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'><filename>SRC_URI</filename></ulink>.
  9013. Here is an example that starts a test for
  9014. <filename>dbus</filename>:
  9015. <literallayout class='monospaced'>
  9016. #!/bin/sh
  9017. cd test
  9018. make -k runtest-TESTS
  9019. </literallayout>
  9020. </para></listitem>
  9021. <listitem><para><emphasis>Ensure dependencies are
  9022. met:</emphasis>
  9023. If the test adds build or runtime dependencies
  9024. that normally do not exist for the package
  9025. (such as requiring "make" to run the test suite),
  9026. use the
  9027. <ulink url='&YOCTO_DOCS_REF_URL;#var-DEPENDS'><filename>DEPENDS</filename></ulink>
  9028. and
  9029. <ulink url='&YOCTO_DOCS_REF_URL;#var-RDEPENDS'><filename>RDEPENDS</filename></ulink>
  9030. variables in your recipe in order for the package
  9031. to meet the dependencies.
  9032. Here is an example where the package has a runtime
  9033. dependency on "make":
  9034. <literallayout class='monospaced'>
  9035. RDEPENDS_${PN}-ptest += "make"
  9036. </literallayout>
  9037. </para></listitem>
  9038. <listitem><para><emphasis>Add a function to build the
  9039. test suite:</emphasis>
  9040. Not many packages support cross-compilation of
  9041. their test suites.
  9042. Consequently, you usually need to add a
  9043. cross-compilation function to the package.
  9044. </para>
  9045. <para>Many packages based on Automake compile and
  9046. run the test suite by using a single command
  9047. such as <filename>make check</filename>.
  9048. However, the host <filename>make check</filename>
  9049. builds and runs on the same computer, while
  9050. cross-compiling requires that the package is built
  9051. on the host but executed for the target
  9052. architecture (though often, as in the case for
  9053. ptest, the execution occurs on the host).
  9054. The built version of Automake that ships with the
  9055. Yocto Project includes a patch that separates
  9056. building and execution.
  9057. Consequently, packages that use the unaltered,
  9058. patched version of <filename>make check</filename>
  9059. automatically cross-compiles.</para>
  9060. <para>Regardless, you still must add a
  9061. <filename>do_compile_ptest</filename> function to
  9062. build the test suite.
  9063. Add a function similar to the following to your
  9064. recipe:
  9065. <literallayout class='monospaced'>
  9066. do_compile_ptest() {
  9067. oe_runmake buildtest-TESTS
  9068. }
  9069. </literallayout>
  9070. </para></listitem>
  9071. <listitem><para><emphasis>Ensure special configurations
  9072. are set:</emphasis>
  9073. If the package requires special configurations
  9074. prior to compiling the test code, you must
  9075. insert a <filename>do_configure_ptest</filename>
  9076. function into the recipe.
  9077. </para></listitem>
  9078. <listitem><para><emphasis>Install the test
  9079. suite:</emphasis>
  9080. The <filename>ptest</filename> class
  9081. automatically copies the file
  9082. <filename>run-ptest</filename> to the target and
  9083. then runs make <filename>install-ptest</filename>
  9084. to run the tests.
  9085. If this is not enough, you need to create a
  9086. <filename>do_install_ptest</filename> function and
  9087. make sure it gets called after the
  9088. "make install-ptest" completes.
  9089. </para></listitem>
  9090. </itemizedlist>
  9091. </para>
  9092. </section>
  9093. </section>
  9094. </section>
  9095. <section id='efficiently-fetching-source-files-during-a-build'>
  9096. <title>Efficiently Fetching Source Files During a Build</title>
  9097. <para>
  9098. The OpenEmbedded build system works with source files located
  9099. through the
  9100. <ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'><filename>SRC_URI</filename></ulink>
  9101. variable.
  9102. When you build something using BitBake, a big part of the operation
  9103. is locating and downloading all the source tarballs.
  9104. For images, downloading all the source for various packages can
  9105. take a significant amount of time.
  9106. </para>
  9107. <para>
  9108. This section shows you how you can use mirrors to speed up
  9109. fetching source files and how you can pre-fetch files all of which
  9110. leads to more efficient use of resources and time.
  9111. </para>
  9112. <section id='setting-up-effective-mirrors'>
  9113. <title>Setting up Effective Mirrors</title>
  9114. <para>
  9115. A good deal that goes into a Yocto Project
  9116. build is simply downloading all of the source tarballs.
  9117. Maybe you have been working with another build system
  9118. (OpenEmbedded or Angstrom) for which you have built up a
  9119. sizable directory of source tarballs.
  9120. Or, perhaps someone else has such a directory for which you
  9121. have read access.
  9122. If so, you can save time by adding statements to your
  9123. configuration file so that the build process checks local
  9124. directories first for existing tarballs before checking the
  9125. Internet.
  9126. </para>
  9127. <para>
  9128. Here is an efficient way to set it up in your
  9129. <filename>local.conf</filename> file:
  9130. <literallayout class='monospaced'>
  9131. SOURCE_MIRROR_URL ?= "file:///home/you/your-download-dir/"
  9132. INHERIT += "own-mirrors"
  9133. BB_GENERATE_MIRROR_TARBALLS = "1"
  9134. # BB_NO_NETWORK = "1"
  9135. </literallayout>
  9136. </para>
  9137. <para>
  9138. In the previous example, the
  9139. <ulink url='&YOCTO_DOCS_REF_URL;#var-BB_GENERATE_MIRROR_TARBALLS'><filename>BB_GENERATE_MIRROR_TARBALLS</filename></ulink>
  9140. variable causes the OpenEmbedded build system to generate
  9141. tarballs of the Git repositories and store them in the
  9142. <ulink url='&YOCTO_DOCS_REF_URL;#var-DL_DIR'><filename>DL_DIR</filename></ulink>
  9143. directory.
  9144. Due to performance reasons, generating and storing these
  9145. tarballs is not the build system's default behavior.
  9146. </para>
  9147. <para>
  9148. You can also use the
  9149. <ulink url='&YOCTO_DOCS_REF_URL;#var-PREMIRRORS'><filename>PREMIRRORS</filename></ulink>
  9150. variable.
  9151. For an example, see the variable's glossary entry in the
  9152. Yocto Project Reference Manual.
  9153. </para>
  9154. </section>
  9155. <section id='getting-source-files-and-suppressing-the-build'>
  9156. <title>Getting Source Files and Suppressing the Build</title>
  9157. <para>
  9158. Another technique you can use to ready yourself for a
  9159. successive string of build operations, is to pre-fetch
  9160. all the source files without actually starting a build.
  9161. This technique lets you work through any download issues
  9162. and ultimately gathers all the source files into your
  9163. download directory
  9164. <ulink url='&YOCTO_DOCS_REF_URL;#structure-build-downloads'><filename>build/downloads</filename></ulink>,
  9165. which is located with
  9166. <ulink url='&YOCTO_DOCS_REF_URL;#var-DL_DIR'><filename>DL_DIR</filename></ulink>.
  9167. </para>
  9168. <para>
  9169. Use the following BitBake command form to fetch all the
  9170. necessary sources without starting the build:
  9171. <literallayout class='monospaced'>
  9172. $ bitbake -c <replaceable>target</replaceable> runall="fetch"
  9173. </literallayout>
  9174. This variation of the BitBake command guarantees that you
  9175. have all the sources for that BitBake target should you
  9176. disconnect from the Internet and want to do the build
  9177. later offline.
  9178. </para>
  9179. </section>
  9180. </section>
  9181. <section id="building-software-from-an-external-source">
  9182. <title>Building Software from an External Source</title>
  9183. <para>
  9184. By default, the OpenEmbedded build system uses the
  9185. <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink>
  9186. when building source code.
  9187. The build process involves fetching the source files, unpacking
  9188. them, and then patching them if necessary before the build takes
  9189. place.
  9190. </para>
  9191. <para>
  9192. Situations exist where you might want to build software from source
  9193. files that are external to and thus outside of the
  9194. OpenEmbedded build system.
  9195. For example, suppose you have a project that includes a new BSP with
  9196. a heavily customized kernel.
  9197. And, you want to minimize exposing the build system to the
  9198. development team so that they can focus on their project and
  9199. maintain everyone's workflow as much as possible.
  9200. In this case, you want a kernel source directory on the development
  9201. machine where the development occurs.
  9202. You want the recipe's
  9203. <ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'><filename>SRC_URI</filename></ulink>
  9204. variable to point to the external directory and use it as is, not
  9205. copy it.
  9206. </para>
  9207. <para>
  9208. To build from software that comes from an external source, all you
  9209. need to do is inherit the
  9210. <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-externalsrc'><filename>externalsrc</filename></ulink>
  9211. class and then set the
  9212. <ulink url='&YOCTO_DOCS_REF_URL;#var-EXTERNALSRC'><filename>EXTERNALSRC</filename></ulink>
  9213. variable to point to your external source code.
  9214. Here are the statements to put in your
  9215. <filename>local.conf</filename> file:
  9216. <literallayout class='monospaced'>
  9217. INHERIT += "externalsrc"
  9218. EXTERNALSRC_pn-<replaceable>myrecipe</replaceable> = "<replaceable>path-to-your-source-tree</replaceable>"
  9219. </literallayout>
  9220. </para>
  9221. <para>
  9222. This next example shows how to accomplish the same thing by setting
  9223. <filename>EXTERNALSRC</filename> in the recipe itself or in the
  9224. recipe's append file:
  9225. <literallayout class='monospaced'>
  9226. EXTERNALSRC = "<replaceable>path</replaceable>"
  9227. EXTERNALSRC_BUILD = "<replaceable>path</replaceable>"
  9228. </literallayout>
  9229. <note>
  9230. In order for these settings to take effect, you must globally
  9231. or locally inherit the
  9232. <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-externalsrc'><filename>externalsrc</filename></ulink>
  9233. class.
  9234. </note>
  9235. </para>
  9236. <para>
  9237. By default, <filename>externalsrc.bbclass</filename> builds
  9238. the source code in a directory separate from the external source
  9239. directory as specified by
  9240. <ulink url='&YOCTO_DOCS_REF_URL;#var-EXTERNALSRC'><filename>EXTERNALSRC</filename></ulink>.
  9241. If you need to have the source built in the same directory in
  9242. which it resides, or some other nominated directory, you can set
  9243. <ulink url='&YOCTO_DOCS_REF_URL;#var-EXTERNALSRC_BUILD'><filename>EXTERNALSRC_BUILD</filename></ulink>
  9244. to point to that directory:
  9245. <literallayout class='monospaced'>
  9246. EXTERNALSRC_BUILD_pn-<replaceable>myrecipe</replaceable> = "<replaceable>path-to-your-source-tree</replaceable>"
  9247. </literallayout>
  9248. </para>
  9249. </section>
  9250. <section id="selecting-an-initialization-manager">
  9251. <title>Selecting an Initialization Manager</title>
  9252. <para>
  9253. By default, the Yocto Project uses SysVinit as the initialization
  9254. manager.
  9255. However, support also exists for systemd,
  9256. which is a full replacement for init with
  9257. parallel starting of services, reduced shell overhead and other
  9258. features that are used by many distributions.
  9259. </para>
  9260. <para>
  9261. If you want to use SysVinit, you do
  9262. not have to do anything.
  9263. But, if you want to use systemd, you must
  9264. take some steps as described in the following sections.
  9265. </para>
  9266. <section id='using-systemd-exclusively'>
  9267. <title>Using systemd Exclusively</title>
  9268. <para>
  9269. Set the these variables in your distribution configuration
  9270. file as follows:
  9271. <literallayout class='monospaced'>
  9272. DISTRO_FEATURES_append = " systemd"
  9273. VIRTUAL-RUNTIME_init_manager = "systemd"
  9274. </literallayout>
  9275. You can also prevent the SysVinit
  9276. distribution feature from
  9277. being automatically enabled as follows:
  9278. <literallayout class='monospaced'>
  9279. DISTRO_FEATURES_BACKFILL_CONSIDERED = "sysvinit"
  9280. </literallayout>
  9281. Doing so removes any redundant SysVinit scripts.
  9282. </para>
  9283. <para>
  9284. To remove initscripts from your image altogether,
  9285. set this variable also:
  9286. <literallayout class='monospaced'>
  9287. VIRTUAL-RUNTIME_initscripts = ""
  9288. </literallayout>
  9289. </para>
  9290. <para>
  9291. For information on the backfill variable, see
  9292. <ulink url='&YOCTO_DOCS_REF_URL;#var-DISTRO_FEATURES_BACKFILL_CONSIDERED'><filename>DISTRO_FEATURES_BACKFILL_CONSIDERED</filename></ulink>.
  9293. </para>
  9294. </section>
  9295. <section id='using-systemd-for-the-main-image-and-using-sysvinit-for-the-rescue-image'>
  9296. <title>Using systemd for the Main Image and Using SysVinit for the Rescue Image</title>
  9297. <para>
  9298. Set these variables in your distribution configuration
  9299. file as follows:
  9300. <literallayout class='monospaced'>
  9301. DISTRO_FEATURES_append = " systemd"
  9302. VIRTUAL-RUNTIME_init_manager = "systemd"
  9303. </literallayout>
  9304. Doing so causes your main image to use the
  9305. <filename>packagegroup-core-boot.bb</filename> recipe and
  9306. systemd.
  9307. The rescue/minimal image cannot use this package group.
  9308. However, it can install SysVinit
  9309. and the appropriate packages will have support for both
  9310. systemd and SysVinit.
  9311. </para>
  9312. </section>
  9313. </section>
  9314. <section id="selecting-dev-manager">
  9315. <title>Selecting a Device Manager</title>
  9316. <para>
  9317. The Yocto Project provides multiple ways to manage the device
  9318. manager (<filename>/dev</filename>):
  9319. <itemizedlist>
  9320. <listitem><para><emphasis>Persistent and Pre-Populated<filename>/dev</filename>:</emphasis>
  9321. For this case, the <filename>/dev</filename> directory
  9322. is persistent and the required device nodes are created
  9323. during the build.
  9324. </para></listitem>
  9325. <listitem><para><emphasis>Use <filename>devtmpfs</filename> with a Device Manager:</emphasis>
  9326. For this case, the <filename>/dev</filename> directory
  9327. is provided by the kernel as an in-memory file system and
  9328. is automatically populated by the kernel at runtime.
  9329. Additional configuration of device nodes is done in user
  9330. space by a device manager like
  9331. <filename>udev</filename> or
  9332. <filename>busybox-mdev</filename>.
  9333. </para></listitem>
  9334. </itemizedlist>
  9335. </para>
  9336. <section id="static-dev-management">
  9337. <title>Using Persistent and Pre-Populated<filename>/dev</filename></title>
  9338. <para>
  9339. To use the static method for device population, you need to
  9340. set the
  9341. <ulink url='&YOCTO_DOCS_REF_URL;#var-USE_DEVFS'><filename>USE_DEVFS</filename></ulink>
  9342. variable to "0" as follows:
  9343. <literallayout class='monospaced'>
  9344. USE_DEVFS = "0"
  9345. </literallayout>
  9346. </para>
  9347. <para>
  9348. The content of the resulting <filename>/dev</filename>
  9349. directory is defined in a Device Table file.
  9350. The
  9351. <ulink url='&YOCTO_DOCS_REF_URL;#var-IMAGE_DEVICE_TABLES'><filename>IMAGE_DEVICE_TABLES</filename></ulink>
  9352. variable defines the Device Table to use and should be set
  9353. in the machine or distro configuration file.
  9354. Alternatively, you can set this variable in your
  9355. <filename>local.conf</filename> configuration file.
  9356. </para>
  9357. <para>
  9358. If you do not define the
  9359. <filename>IMAGE_DEVICE_TABLES</filename> variable, the default
  9360. <filename>device_table-minimal.txt</filename> is used:
  9361. <literallayout class='monospaced'>
  9362. IMAGE_DEVICE_TABLES = "device_table-mymachine.txt"
  9363. </literallayout>
  9364. </para>
  9365. <para>
  9366. The population is handled by the <filename>makedevs</filename>
  9367. utility during image creation:
  9368. </para>
  9369. </section>
  9370. <section id="devtmpfs-dev-management">
  9371. <title>Using <filename>devtmpfs</filename> and a Device Manager</title>
  9372. <para>
  9373. To use the dynamic method for device population, you need to
  9374. use (or be sure to set) the
  9375. <ulink url='&YOCTO_DOCS_REF_URL;#var-USE_DEVFS'><filename>USE_DEVFS</filename></ulink>
  9376. variable to "1", which is the default:
  9377. <literallayout class='monospaced'>
  9378. USE_DEVFS = "1"
  9379. </literallayout>
  9380. With this setting, the resulting <filename>/dev</filename>
  9381. directory is populated by the kernel using
  9382. <filename>devtmpfs</filename>.
  9383. Make sure the corresponding kernel configuration variable
  9384. <filename>CONFIG_DEVTMPFS</filename> is set when building
  9385. you build a Linux kernel.
  9386. </para>
  9387. <para>
  9388. All devices created by <filename>devtmpfs</filename> will be
  9389. owned by <filename>root</filename> and have permissions
  9390. <filename>0600</filename>.
  9391. </para>
  9392. <para>
  9393. To have more control over the device nodes, you can use a
  9394. device manager like <filename>udev</filename> or
  9395. <filename>busybox-mdev</filename>.
  9396. You choose the device manager by defining the
  9397. <filename>VIRTUAL-RUNTIME_dev_manager</filename> variable
  9398. in your machine or distro configuration file.
  9399. Alternatively, you can set this variable in your
  9400. <filename>local.conf</filename> configuration file:
  9401. <literallayout class='monospaced'>
  9402. VIRTUAL-RUNTIME_dev_manager = "udev"
  9403. # Some alternative values
  9404. # VIRTUAL-RUNTIME_dev_manager = "busybox-mdev"
  9405. # VIRTUAL-RUNTIME_dev_manager = "systemd"
  9406. </literallayout>
  9407. </para>
  9408. </section>
  9409. </section>
  9410. <section id="platdev-appdev-srcrev">
  9411. <title>Using an External SCM</title>
  9412. <para>
  9413. If you're working on a recipe that pulls from an external Source
  9414. Code Manager (SCM), it is possible to have the OpenEmbedded build
  9415. system notice new recipe changes added to the SCM and then build
  9416. the resulting packages that depend on the new recipes by using
  9417. the latest versions.
  9418. This only works for SCMs from which it is possible to get a
  9419. sensible revision number for changes.
  9420. Currently, you can do this with Apache Subversion (SVN), Git, and
  9421. Bazaar (BZR) repositories.
  9422. </para>
  9423. <para>
  9424. To enable this behavior, the
  9425. <ulink url='&YOCTO_DOCS_REF_URL;#var-PV'><filename>PV</filename></ulink>
  9426. of the recipe needs to reference
  9427. <ulink url='&YOCTO_DOCS_REF_URL;#var-SRCPV'><filename>SRCPV</filename></ulink>.
  9428. Here is an example:
  9429. <literallayout class='monospaced'>
  9430. PV = "1.2.3+git${SRCPV}"
  9431. </literallayout>
  9432. Then, you can add the following to your
  9433. <filename>local.conf</filename>:
  9434. <literallayout class='monospaced'>
  9435. SRCREV_pn-<replaceable>PN</replaceable> = "${AUTOREV}"
  9436. </literallayout>
  9437. <ulink url='&YOCTO_DOCS_REF_URL;#var-PN'><filename>PN</filename></ulink>
  9438. is the name of the recipe for which you want to enable automatic source
  9439. revision updating.
  9440. </para>
  9441. <para>
  9442. If you do not want to update your local configuration file, you can
  9443. add the following directly to the recipe to finish enabling
  9444. the feature:
  9445. <literallayout class='monospaced'>
  9446. SRCREV = "${AUTOREV}"
  9447. </literallayout>
  9448. </para>
  9449. <para>
  9450. The Yocto Project provides a distribution named
  9451. <filename>poky-bleeding</filename>, whose configuration
  9452. file contains the line:
  9453. <literallayout class='monospaced'>
  9454. require conf/distro/include/poky-floating-revisions.inc
  9455. </literallayout>
  9456. This line pulls in the listed include file that contains
  9457. numerous lines of exactly that form:
  9458. <literallayout class='monospaced'>
  9459. #SRCREV_pn-opkg-native ?= "${AUTOREV}"
  9460. #SRCREV_pn-opkg-sdk ?= "${AUTOREV}"
  9461. #SRCREV_pn-opkg ?= "${AUTOREV}"
  9462. #SRCREV_pn-opkg-utils-native ?= "${AUTOREV}"
  9463. #SRCREV_pn-opkg-utils ?= "${AUTOREV}"
  9464. SRCREV_pn-gconf-dbus ?= "${AUTOREV}"
  9465. SRCREV_pn-matchbox-common ?= "${AUTOREV}"
  9466. SRCREV_pn-matchbox-config-gtk ?= "${AUTOREV}"
  9467. SRCREV_pn-matchbox-desktop ?= "${AUTOREV}"
  9468. SRCREV_pn-matchbox-keyboard ?= "${AUTOREV}"
  9469. SRCREV_pn-matchbox-panel-2 ?= "${AUTOREV}"
  9470. SRCREV_pn-matchbox-themes-extra ?= "${AUTOREV}"
  9471. SRCREV_pn-matchbox-terminal ?= "${AUTOREV}"
  9472. SRCREV_pn-matchbox-wm ?= "${AUTOREV}"
  9473. SRCREV_pn-settings-daemon ?= "${AUTOREV}"
  9474. SRCREV_pn-screenshot ?= "${AUTOREV}"
  9475. .
  9476. .
  9477. .
  9478. </literallayout>
  9479. These lines allow you to experiment with building a
  9480. distribution that tracks the latest development source
  9481. for numerous packages.
  9482. <note><title>Caution</title>
  9483. The <filename>poky-bleeding</filename> distribution
  9484. is not tested on a regular basis.
  9485. Keep this in mind if you use it.
  9486. </note>
  9487. </para>
  9488. </section>
  9489. <section id='creating-a-read-only-root-filesystem'>
  9490. <title>Creating a Read-Only Root Filesystem</title>
  9491. <para>
  9492. Suppose, for security reasons, you need to disable
  9493. your target device's root filesystem's write permissions
  9494. (i.e. you need a read-only root filesystem).
  9495. Or, perhaps you are running the device's operating system
  9496. from a read-only storage device.
  9497. For either case, you can customize your image for
  9498. that behavior.
  9499. </para>
  9500. <note>
  9501. Supporting a read-only root filesystem requires that the system and
  9502. applications do not try to write to the root filesystem.
  9503. You must configure all parts of the target system to write
  9504. elsewhere, or to gracefully fail in the event of attempting to
  9505. write to the root filesystem.
  9506. </note>
  9507. <section id='creating-the-root-filesystem'>
  9508. <title>Creating the Root Filesystem</title>
  9509. <para>
  9510. To create the read-only root filesystem, simply add the
  9511. "read-only-rootfs" feature to your image.
  9512. Using either of the following statements in your
  9513. image recipe or from within the
  9514. <filename>local.conf</filename> file found in the
  9515. <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink>
  9516. causes the build system to create a read-only root filesystem:
  9517. <literallayout class='monospaced'>
  9518. IMAGE_FEATURES = "read-only-rootfs"
  9519. </literallayout>
  9520. or
  9521. <literallayout class='monospaced'>
  9522. EXTRA_IMAGE_FEATURES += "read-only-rootfs"
  9523. </literallayout>
  9524. </para>
  9525. <para>
  9526. For more information on how to use these variables, see the
  9527. "<link linkend='usingpoky-extend-customimage-imagefeatures'>Customizing Images Using Custom <filename>IMAGE_FEATURES</filename> and <filename>EXTRA_IMAGE_FEATURES</filename></link>"
  9528. section.
  9529. For information on the variables, see
  9530. <ulink url='&YOCTO_DOCS_REF_URL;#var-IMAGE_FEATURES'><filename>IMAGE_FEATURES</filename></ulink>
  9531. and <ulink url='&YOCTO_DOCS_REF_URL;#var-EXTRA_IMAGE_FEATURES'><filename>EXTRA_IMAGE_FEATURES</filename></ulink>.
  9532. </para>
  9533. </section>
  9534. <section id='post-installation-scripts'>
  9535. <title>Post-Installation Scripts</title>
  9536. <para>
  9537. It is very important that you make sure all
  9538. post-Installation (<filename>pkg_postinst</filename>) scripts
  9539. for packages that are installed into the image can be run
  9540. at the time when the root filesystem is created during the
  9541. build on the host system.
  9542. These scripts cannot attempt to run during first-boot on the
  9543. target device.
  9544. With the "read-only-rootfs" feature enabled,
  9545. the build system checks during root filesystem creation to make
  9546. sure all post-installation scripts succeed.
  9547. If any of these scripts still need to be run after the root
  9548. filesystem is created, the build immediately fails.
  9549. These build-time checks ensure that the build fails
  9550. rather than the target device fails later during its
  9551. initial boot operation.
  9552. </para>
  9553. <para>
  9554. Most of the common post-installation scripts generated by the
  9555. build system for the out-of-the-box Yocto Project are engineered
  9556. so that they can run during root filesystem creation
  9557. (e.g. post-installation scripts for caching fonts).
  9558. However, if you create and add custom scripts, you need
  9559. to be sure they can be run during this file system creation.
  9560. </para>
  9561. <para>
  9562. Here are some common problems that prevent
  9563. post-installation scripts from running during root filesystem
  9564. creation:
  9565. <itemizedlist>
  9566. <listitem><para>
  9567. <emphasis>Not using $D in front of absolute
  9568. paths:</emphasis>
  9569. The build system defines
  9570. <filename>$</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-D'><filename>D</filename></ulink>
  9571. when the root filesystem is created.
  9572. Furthermore, <filename>$D</filename> is blank when the
  9573. script is run on the target device.
  9574. This implies two purposes for <filename>$D</filename>:
  9575. ensuring paths are valid in both the host and target
  9576. environments, and checking to determine which
  9577. environment is being used as a method for taking
  9578. appropriate actions.
  9579. </para></listitem>
  9580. <listitem><para>
  9581. <emphasis>Attempting to run processes that are
  9582. specific to or dependent on the target
  9583. architecture:</emphasis>
  9584. You can work around these attempts by using native
  9585. tools, which run on the host system,
  9586. to accomplish the same tasks, or
  9587. by alternatively running the processes under QEMU,
  9588. which has the <filename>qemu_run_binary</filename>
  9589. function.
  9590. For more information, see the
  9591. <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-qemu'><filename>qemu</filename></ulink>
  9592. class.</para></listitem>
  9593. </itemizedlist>
  9594. </para>
  9595. </section>
  9596. <section id='areas-with-write-access'>
  9597. <title>Areas With Write Access</title>
  9598. <para>
  9599. With the "read-only-rootfs" feature enabled,
  9600. any attempt by the target to write to the root filesystem at
  9601. runtime fails.
  9602. Consequently, you must make sure that you configure processes
  9603. and applications that attempt these types of writes do so
  9604. to directories with write access (e.g.
  9605. <filename>/tmp</filename> or <filename>/var/run</filename>).
  9606. </para>
  9607. </section>
  9608. </section>
  9609. <section id='maintaining-build-output-quality'>
  9610. <title>Maintaining Build Output Quality</title>
  9611. <para>
  9612. Many factors can influence the quality of a build.
  9613. For example, if you upgrade a recipe to use a new version of an
  9614. upstream software package or you experiment with some new
  9615. configuration options, subtle changes can occur that you might
  9616. not detect until later.
  9617. Consider the case where your recipe is using a newer version of
  9618. an upstream package.
  9619. In this case, a new version of a piece of software might
  9620. introduce an optional dependency on another library, which is
  9621. auto-detected.
  9622. If that library has already been built when the software is
  9623. building, the software will link to the built library and that
  9624. library will be pulled into your image along with the new
  9625. software even if you did not want the library.
  9626. </para>
  9627. <para>
  9628. The
  9629. <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-buildhistory'><filename>buildhistory</filename></ulink>
  9630. class exists to help you maintain the quality of your build
  9631. output.
  9632. You can use the class to highlight unexpected and possibly
  9633. unwanted changes in the build output.
  9634. When you enable build history, it records information about the
  9635. contents of each package and image and then commits that
  9636. information to a local Git repository where you can examine
  9637. the information.
  9638. </para>
  9639. <para>
  9640. The remainder of this section describes the following:
  9641. <itemizedlist>
  9642. <listitem><para>
  9643. How you can enable and disable build history
  9644. </para></listitem>
  9645. <listitem><para>
  9646. How to understand what the build history contains
  9647. </para></listitem>
  9648. <listitem><para>
  9649. How to limit the information used for build history
  9650. </para></listitem>
  9651. <listitem><para>
  9652. How to examine the build history from both a
  9653. command-line and web interface
  9654. </para></listitem>
  9655. </itemizedlist>
  9656. </para>
  9657. <section id='enabling-and-disabling-build-history'>
  9658. <title>Enabling and Disabling Build History</title>
  9659. <para>
  9660. Build history is disabled by default.
  9661. To enable it, add the following <filename>INHERIT</filename>
  9662. statement and set the
  9663. <ulink url='&YOCTO_DOCS_REF_URL;#var-BUILDHISTORY_COMMIT'><filename>BUILDHISTORY_COMMIT</filename></ulink>
  9664. variable to "1" at the end of your
  9665. <filename>conf/local.conf</filename> file found in the
  9666. <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink>:
  9667. <literallayout class='monospaced'>
  9668. INHERIT += "buildhistory"
  9669. BUILDHISTORY_COMMIT = "1"
  9670. </literallayout>
  9671. Enabling build history as previously described causes the
  9672. OpenEmbedded build system to collect build output information
  9673. and commit it as a single commit to a local
  9674. <ulink url='&YOCTO_DOCS_OM_URL;#git'>Git</ulink>
  9675. repository.
  9676. <note>
  9677. Enabling build history increases your build times slightly,
  9678. particularly for images, and increases the amount of disk
  9679. space used during the build.
  9680. </note>
  9681. </para>
  9682. <para>
  9683. You can disable build history by removing the previous
  9684. statements from your <filename>conf/local.conf</filename>
  9685. file.
  9686. </para>
  9687. </section>
  9688. <section id='understanding-what-the-build-history-contains'>
  9689. <title>Understanding What the Build History Contains</title>
  9690. <para>
  9691. Build history information is kept in
  9692. <filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-TOPDIR'><filename>TOPDIR</filename></ulink><filename>}/buildhistory</filename>
  9693. in the Build Directory as defined by the
  9694. <ulink url='&YOCTO_DOCS_REF_URL;#var-BUILDHISTORY_DIR'><filename>BUILDHISTORY_DIR</filename></ulink>
  9695. variable.
  9696. The following is an example abbreviated listing:
  9697. <imagedata fileref="figures/buildhistory.png" align="center" width="6in" depth="4in" />
  9698. </para>
  9699. <para>
  9700. At the top level, a <filename>metadata-revs</filename>
  9701. file exists that lists the revisions of the repositories for
  9702. the enabled layers when the build was produced.
  9703. The rest of the data splits into separate
  9704. <filename>packages</filename>, <filename>images</filename>
  9705. and <filename>sdk</filename> directories, the contents of
  9706. which are described as follows.
  9707. </para>
  9708. <section id='build-history-package-information'>
  9709. <title>Build History Package Information</title>
  9710. <para>
  9711. The history for each package contains a text file that has
  9712. name-value pairs with information about the package.
  9713. For example,
  9714. <filename>buildhistory/packages/i586-poky-linux/busybox/busybox/latest</filename>
  9715. contains the following:
  9716. <literallayout class='monospaced'>
  9717. PV = 1.22.1
  9718. PR = r32
  9719. RPROVIDES =
  9720. RDEPENDS = glibc (>= 2.20) update-alternatives-opkg
  9721. RRECOMMENDS = busybox-syslog busybox-udhcpc update-rc.d
  9722. PKGSIZE = 540168
  9723. FILES = /usr/bin/* /usr/sbin/* /usr/lib/busybox/* /usr/lib/lib*.so.* \
  9724. /etc /com /var /bin/* /sbin/* /lib/*.so.* /lib/udev/rules.d \
  9725. /usr/lib/udev/rules.d /usr/share/busybox /usr/lib/busybox/* \
  9726. /usr/share/pixmaps /usr/share/applications /usr/share/idl \
  9727. /usr/share/omf /usr/share/sounds /usr/lib/bonobo/servers
  9728. FILELIST = /bin/busybox /bin/busybox.nosuid /bin/busybox.suid /bin/sh \
  9729. /etc/busybox.links.nosuid /etc/busybox.links.suid
  9730. </literallayout>
  9731. Most of these name-value pairs correspond to variables
  9732. used to produce the package.
  9733. The exceptions are <filename>FILELIST</filename>, which
  9734. is the actual list of files in the package, and
  9735. <filename>PKGSIZE</filename>, which is the total size of
  9736. files in the package in bytes.
  9737. </para>
  9738. <para>
  9739. A file also exists that corresponds to the recipe from
  9740. which the package came (e.g.
  9741. <filename>buildhistory/packages/i586-poky-linux/busybox/latest</filename>):
  9742. <literallayout class='monospaced'>
  9743. PV = 1.22.1
  9744. PR = r32
  9745. DEPENDS = initscripts kern-tools-native update-rc.d-native \
  9746. virtual/i586-poky-linux-compilerlibs virtual/i586-poky-linux-gcc \
  9747. virtual/libc virtual/update-alternatives
  9748. PACKAGES = busybox-ptest busybox-httpd busybox-udhcpd busybox-udhcpc \
  9749. busybox-syslog busybox-mdev busybox-hwclock busybox-dbg \
  9750. busybox-staticdev busybox-dev busybox-doc busybox-locale busybox
  9751. </literallayout>
  9752. </para>
  9753. <para>
  9754. Finally, for those recipes fetched from a version control
  9755. system (e.g., Git), a file exists that lists source
  9756. revisions that are specified in the recipe and lists
  9757. the actual revisions used during the build.
  9758. Listed and actual revisions might differ when
  9759. <ulink url='&YOCTO_DOCS_REF_URL;#var-SRCREV'><filename>SRCREV</filename></ulink>
  9760. is set to
  9761. ${<ulink url='&YOCTO_DOCS_REF_URL;#var-AUTOREV'><filename>AUTOREV</filename></ulink>}.
  9762. Here is an example assuming
  9763. <filename>buildhistory/packages/qemux86-poky-linux/linux-yocto/latest_srcrev</filename>):
  9764. <literallayout class='monospaced'>
  9765. # SRCREV_machine = "38cd560d5022ed2dbd1ab0dca9642e47c98a0aa1"
  9766. SRCREV_machine = "38cd560d5022ed2dbd1ab0dca9642e47c98a0aa1"
  9767. # SRCREV_meta = "a227f20eff056e511d504b2e490f3774ab260d6f"
  9768. SRCREV_meta = "a227f20eff056e511d504b2e490f3774ab260d6f"
  9769. </literallayout>
  9770. You can use the
  9771. <filename>buildhistory-collect-srcrevs</filename>
  9772. command with the <filename>-a</filename> option to
  9773. collect the stored <filename>SRCREV</filename> values
  9774. from build history and report them in a format suitable for
  9775. use in global configuration (e.g.,
  9776. <filename>local.conf</filename> or a distro include file)
  9777. to override floating <filename>AUTOREV</filename> values
  9778. to a fixed set of revisions.
  9779. Here is some example output from this command:
  9780. <literallayout class='monospaced'>
  9781. $ buildhistory-collect-srcrevs -a
  9782. # i586-poky-linux
  9783. SRCREV_pn-glibc = "b8079dd0d360648e4e8de48656c5c38972621072"
  9784. SRCREV_pn-glibc-initial = "b8079dd0d360648e4e8de48656c5c38972621072"
  9785. SRCREV_pn-opkg-utils = "53274f087565fd45d8452c5367997ba6a682a37a"
  9786. SRCREV_pn-kmod = "fd56638aed3fe147015bfa10ed4a5f7491303cb4"
  9787. # x86_64-linux
  9788. SRCREV_pn-gtk-doc-stub-native = "1dea266593edb766d6d898c79451ef193eb17cfa"
  9789. SRCREV_pn-dtc-native = "65cc4d2748a2c2e6f27f1cf39e07a5dbabd80ebf"
  9790. SRCREV_pn-update-rc.d-native = "eca680ddf28d024954895f59a241a622dd575c11"
  9791. SRCREV_glibc_pn-cross-localedef-native = "b8079dd0d360648e4e8de48656c5c38972621072"
  9792. SRCREV_localedef_pn-cross-localedef-native = "c833367348d39dad7ba018990bfdaffaec8e9ed3"
  9793. SRCREV_pn-prelink-native = "faa069deec99bf61418d0bab831c83d7c1b797ca"
  9794. SRCREV_pn-opkg-utils-native = "53274f087565fd45d8452c5367997ba6a682a37a"
  9795. SRCREV_pn-kern-tools-native = "23345b8846fe4bd167efdf1bd8a1224b2ba9a5ff"
  9796. SRCREV_pn-kmod-native = "fd56638aed3fe147015bfa10ed4a5f7491303cb4"
  9797. # qemux86-poky-linux
  9798. SRCREV_machine_pn-linux-yocto = "38cd560d5022ed2dbd1ab0dca9642e47c98a0aa1"
  9799. SRCREV_meta_pn-linux-yocto = "a227f20eff056e511d504b2e490f3774ab260d6f"
  9800. # all-poky-linux
  9801. SRCREV_pn-update-rc.d = "eca680ddf28d024954895f59a241a622dd575c11"
  9802. </literallayout>
  9803. <note>
  9804. Here are some notes on using the
  9805. <filename>buildhistory-collect-srcrevs</filename>
  9806. command:
  9807. <itemizedlist>
  9808. <listitem><para>
  9809. By default, only values where the
  9810. <filename>SRCREV</filename> was not hardcoded
  9811. (usually when <filename>AUTOREV</filename>
  9812. is used) are reported.
  9813. Use the <filename>-a</filename> option to
  9814. see all <filename>SRCREV</filename> values.
  9815. </para></listitem>
  9816. <listitem><para>
  9817. The output statements might not have any effect
  9818. if overrides are applied elsewhere in the
  9819. build system configuration.
  9820. Use the <filename>-f</filename> option to add
  9821. the <filename>forcevariable</filename> override
  9822. to each output line if you need to work around
  9823. this restriction.
  9824. </para></listitem>
  9825. <listitem><para>
  9826. The script does apply special handling when
  9827. building for multiple machines.
  9828. However, the script does place a comment before
  9829. each set of values that specifies which
  9830. triplet to which they belong as previously
  9831. shown (e.g.,
  9832. <filename>i586-poky-linux</filename>).
  9833. </para></listitem>
  9834. </itemizedlist>
  9835. </note>
  9836. </para>
  9837. </section>
  9838. <section id='build-history-image-information'>
  9839. <title>Build History Image Information</title>
  9840. <para>
  9841. The files produced for each image are as follows:
  9842. <itemizedlist>
  9843. <listitem><para>
  9844. <filename>image-files:</filename>
  9845. A directory containing selected files from the root
  9846. filesystem.
  9847. The files are defined by
  9848. <ulink url='&YOCTO_DOCS_REF_URL;#var-BUILDHISTORY_IMAGE_FILES'><filename>BUILDHISTORY_IMAGE_FILES</filename></ulink>.
  9849. </para></listitem>
  9850. <listitem><para>
  9851. <filename>build-id.txt:</filename>
  9852. Human-readable information about the build
  9853. configuration and metadata source revisions.
  9854. This file contains the full build header as printed
  9855. by BitBake.
  9856. </para></listitem>
  9857. <listitem><para>
  9858. <filename>*.dot:</filename>
  9859. Dependency graphs for the image that are
  9860. compatible with <filename>graphviz</filename>.
  9861. </para></listitem>
  9862. <listitem><para>
  9863. <filename>files-in-image.txt:</filename>
  9864. A list of files in the image with permissions,
  9865. owner, group, size, and symlink information.
  9866. </para></listitem>
  9867. <listitem><para>
  9868. <filename>image-info.txt:</filename>
  9869. A text file containing name-value pairs with
  9870. information about the image.
  9871. See the following listing example for more
  9872. information.
  9873. </para></listitem>
  9874. <listitem><para>
  9875. <filename>installed-package-names.txt:</filename>
  9876. A list of installed packages by name only.
  9877. </para></listitem>
  9878. <listitem><para>
  9879. <filename>installed-package-sizes.txt:</filename>
  9880. A list of installed packages ordered by size.
  9881. </para></listitem>
  9882. <listitem><para>
  9883. <filename>installed-packages.txt:</filename>
  9884. A list of installed packages with full package
  9885. filenames.
  9886. </para></listitem>
  9887. </itemizedlist>
  9888. <note>
  9889. Installed package information is able to be gathered
  9890. and produced even if package management is disabled
  9891. for the final image.
  9892. </note>
  9893. </para>
  9894. <para>
  9895. Here is an example of <filename>image-info.txt</filename>:
  9896. <literallayout class='monospaced'>
  9897. DISTRO = poky
  9898. DISTRO_VERSION = 1.7
  9899. USER_CLASSES = buildstats image-mklibs image-prelink
  9900. IMAGE_CLASSES = image_types
  9901. IMAGE_FEATURES = debug-tweaks
  9902. IMAGE_LINGUAS =
  9903. IMAGE_INSTALL = packagegroup-core-boot run-postinsts
  9904. BAD_RECOMMENDATIONS =
  9905. NO_RECOMMENDATIONS =
  9906. PACKAGE_EXCLUDE =
  9907. ROOTFS_POSTPROCESS_COMMAND = write_package_manifest; license_create_manifest; \
  9908. write_image_manifest ; buildhistory_list_installed_image ; \
  9909. buildhistory_get_image_installed ; ssh_allow_empty_password; \
  9910. postinst_enable_logging; rootfs_update_timestamp ; ssh_disable_dns_lookup ;
  9911. IMAGE_POSTPROCESS_COMMAND = buildhistory_get_imageinfo ;
  9912. IMAGESIZE = 6900
  9913. </literallayout>
  9914. Other than <filename>IMAGESIZE</filename>, which is the
  9915. total size of the files in the image in Kbytes, the
  9916. name-value pairs are variables that may have influenced the
  9917. content of the image.
  9918. This information is often useful when you are trying to
  9919. determine why a change in the package or file
  9920. listings has occurred.
  9921. </para>
  9922. </section>
  9923. <section id='using-build-history-to-gather-image-information-only'>
  9924. <title>Using Build History to Gather Image Information Only</title>
  9925. <para>
  9926. As you can see, build history produces image information,
  9927. including dependency graphs, so you can see why something
  9928. was pulled into the image.
  9929. If you are just interested in this information and not
  9930. interested in collecting specific package or SDK
  9931. information, you can enable writing only image information
  9932. without any history by adding the following to your
  9933. <filename>conf/local.conf</filename> file found in the
  9934. <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink>:
  9935. <literallayout class='monospaced'>
  9936. INHERIT += "buildhistory"
  9937. BUILDHISTORY_COMMIT = "0"
  9938. BUILDHISTORY_FEATURES = "image"
  9939. </literallayout>
  9940. Here, you set the
  9941. <ulink url='&YOCTO_DOCS_REF_URL;#var-BUILDHISTORY_FEATURES'><filename>BUILDHISTORY_FEATURES</filename></ulink>
  9942. variable to use the image feature only.
  9943. </para>
  9944. </section>
  9945. <section id='build-history-sdk-information'>
  9946. <title>Build History SDK Information</title>
  9947. <para>
  9948. Build history collects similar information on the contents
  9949. of SDKs
  9950. (e.g. <filename>bitbake -c populate_sdk imagename</filename>)
  9951. as compared to information it collects for images.
  9952. Furthermore, this information differs depending on whether
  9953. an extensible or standard SDK is being produced.
  9954. </para>
  9955. <para>
  9956. The following list shows the files produced for SDKs:
  9957. <itemizedlist>
  9958. <listitem><para>
  9959. <filename>files-in-sdk.txt:</filename>
  9960. A list of files in the SDK with permissions,
  9961. owner, group, size, and symlink information.
  9962. This list includes both the host and target parts
  9963. of the SDK.
  9964. </para></listitem>
  9965. <listitem><para>
  9966. <filename>sdk-info.txt:</filename>
  9967. A text file containing name-value pairs with
  9968. information about the SDK.
  9969. See the following listing example for more
  9970. information.
  9971. </para></listitem>
  9972. <listitem><para>
  9973. <filename>sstate-task-sizes.txt:</filename>
  9974. A text file containing name-value pairs with
  9975. information about task group sizes
  9976. (e.g. <filename>do_populate_sysroot</filename>
  9977. tasks have a total size).
  9978. The <filename>sstate-task-sizes.txt</filename> file
  9979. exists only when an extensible SDK is created.
  9980. </para></listitem>
  9981. <listitem><para>
  9982. <filename>sstate-package-sizes.txt:</filename>
  9983. A text file containing name-value pairs with
  9984. information for the shared-state packages and
  9985. sizes in the SDK.
  9986. The <filename>sstate-package-sizes.txt</filename>
  9987. file exists only when an extensible SDK is created.
  9988. </para></listitem>
  9989. <listitem><para>
  9990. <filename>sdk-files:</filename>
  9991. A folder that contains copies of the files
  9992. mentioned in
  9993. <filename>BUILDHISTORY_SDK_FILES</filename> if the
  9994. files are present in the output.
  9995. Additionally, the default value of
  9996. <filename>BUILDHISTORY_SDK_FILES</filename> is
  9997. specific to the extensible SDK although you can
  9998. set it differently if you would like to pull in
  9999. specific files from the standard SDK.</para>
  10000. <para>The default files are
  10001. <filename>conf/local.conf</filename>,
  10002. <filename>conf/bblayers.conf</filename>,
  10003. <filename>conf/auto.conf</filename>,
  10004. <filename>conf/locked-sigs.inc</filename>, and
  10005. <filename>conf/devtool.conf</filename>.
  10006. Thus, for an extensible SDK, these files get
  10007. copied into the <filename>sdk-files</filename>
  10008. directory.
  10009. </para></listitem>
  10010. <listitem><para>
  10011. The following information appears under
  10012. each of the <filename>host</filename>
  10013. and <filename>target</filename> directories
  10014. for the portions of the SDK that run on the host
  10015. and on the target, respectively:
  10016. <note>
  10017. The following files for the most part are empty
  10018. when producing an extensible SDK because this
  10019. type of SDK is not constructed from packages
  10020. as is the standard SDK.
  10021. </note>
  10022. <itemizedlist>
  10023. <listitem><para>
  10024. <filename>depends.dot:</filename>
  10025. Dependency graph for the SDK that is
  10026. compatible with
  10027. <filename>graphviz</filename>.
  10028. </para></listitem>
  10029. <listitem><para>
  10030. <filename>installed-package-names.txt:</filename>
  10031. A list of installed packages by name only.
  10032. </para></listitem>
  10033. <listitem><para>
  10034. <filename>installed-package-sizes.txt:</filename>
  10035. A list of installed packages ordered by size.
  10036. </para></listitem>
  10037. <listitem><para>
  10038. <filename>installed-packages.txt:</filename>
  10039. A list of installed packages with full
  10040. package filenames.
  10041. </para></listitem>
  10042. </itemizedlist>
  10043. </para></listitem>
  10044. </itemizedlist>
  10045. </para>
  10046. <para>
  10047. Here is an example of <filename>sdk-info.txt</filename>:
  10048. <literallayout class='monospaced'>
  10049. DISTRO = poky
  10050. DISTRO_VERSION = 1.3+snapshot-20130327
  10051. SDK_NAME = poky-glibc-i686-arm
  10052. SDK_VERSION = 1.3+snapshot
  10053. SDKMACHINE =
  10054. SDKIMAGE_FEATURES = dev-pkgs dbg-pkgs
  10055. BAD_RECOMMENDATIONS =
  10056. SDKSIZE = 352712
  10057. </literallayout>
  10058. Other than <filename>SDKSIZE</filename>, which is the
  10059. total size of the files in the SDK in Kbytes, the
  10060. name-value pairs are variables that might have influenced
  10061. the content of the SDK.
  10062. This information is often useful when you are trying to
  10063. determine why a change in the package or file listings
  10064. has occurred.
  10065. </para>
  10066. </section>
  10067. <section id='examining-build-history-information'>
  10068. <title>Examining Build History Information</title>
  10069. <para>
  10070. You can examine build history output from the command
  10071. line or from a web interface.
  10072. </para>
  10073. <para>
  10074. To see any changes that have occurred (assuming you have
  10075. <ulink url='&YOCTO_DOCS_REF_URL;#var-BUILDHISTORY_COMMIT'><filename>BUILDHISTORY_COMMIT</filename></ulink><filename>&nbsp;= "1"</filename>),
  10076. you can simply use any Git command that allows you to
  10077. view the history of a repository.
  10078. Here is one method:
  10079. <literallayout class='monospaced'>
  10080. $ git log -p
  10081. </literallayout>
  10082. You need to realize, however, that this method does show
  10083. changes that are not significant (e.g. a package's size
  10084. changing by a few bytes).
  10085. </para>
  10086. <para>
  10087. A command-line tool called
  10088. <filename>buildhistory-diff</filename> does exist, though,
  10089. that queries the Git repository and prints just the
  10090. differences that might be significant in human-readable
  10091. form.
  10092. Here is an example:
  10093. <literallayout class='monospaced'>
  10094. $ ~/poky/poky/scripts/buildhistory-diff . HEAD^
  10095. Changes to images/qemux86_64/glibc/core-image-minimal (files-in-image.txt):
  10096. /etc/anotherpkg.conf was added
  10097. /sbin/anotherpkg was added
  10098. * (installed-package-names.txt):
  10099. * anotherpkg was added
  10100. Changes to images/qemux86_64/glibc/core-image-minimal (installed-package-names.txt):
  10101. anotherpkg was added
  10102. packages/qemux86_64-poky-linux/v86d: PACKAGES: added "v86d-extras"
  10103. * PR changed from "r0" to "r1"
  10104. * PV changed from "0.1.10" to "0.1.12"
  10105. packages/qemux86_64-poky-linux/v86d/v86d: PKGSIZE changed from 110579 to 144381 (+30%)
  10106. * PR changed from "r0" to "r1"
  10107. * PV changed from "0.1.10" to "0.1.12"
  10108. </literallayout>
  10109. <note>
  10110. The <filename>buildhistory-diff</filename> tool
  10111. requires the <filename>GitPython</filename> package.
  10112. Be sure to install it using Pip3 as follows:
  10113. <literallayout class='monospaced'>
  10114. $ pip3 install GitPython --user
  10115. </literallayout>
  10116. Alternatively, you can install
  10117. <filename>python3-git</filename> using the appropriate
  10118. distribution package manager (e.g.
  10119. <filename>apt-get</filename>, <filename>dnf</filename>,
  10120. or <filename>zipper</filename>).
  10121. </note>
  10122. </para>
  10123. <para>
  10124. To see changes to the build history using a web interface,
  10125. follow the instruction in the <filename>README</filename>
  10126. file here.
  10127. <ulink url='http://git.yoctoproject.org/cgit/cgit.cgi/buildhistory-web/'></ulink>.
  10128. </para>
  10129. <para>
  10130. Here is a sample screenshot of the interface:
  10131. <imagedata fileref="figures/buildhistory-web.png" align="center" scalefit="1" width="130%" contentdepth="130%" />
  10132. </para>
  10133. </section>
  10134. </section>
  10135. </section>
  10136. <section id="performing-automated-runtime-testing">
  10137. <title>Performing Automated Runtime Testing</title>
  10138. <para>
  10139. The OpenEmbedded build system makes available a series of automated
  10140. tests for images to verify runtime functionality.
  10141. You can run these tests on either QEMU or actual target hardware.
  10142. Tests are written in Python making use of the
  10143. <filename>unittest</filename> module, and the majority of them
  10144. run commands on the target system over SSH.
  10145. This section describes how you set up the environment to use these
  10146. tests, run available tests, and write and add your own tests.
  10147. </para>
  10148. <para>
  10149. For information on the test and QA infrastructure available
  10150. within the Yocto Project, see the
  10151. "<ulink url='&YOCTO_DOCS_REF_URL;#testing-and-quality-assurance'>Testing and Quality Assurance</ulink>"
  10152. section in the Yocto Project Reference Manual.
  10153. </para>
  10154. <section id='enabling-tests'>
  10155. <title>Enabling Tests</title>
  10156. <para>
  10157. Depending on whether you are planning to run tests using
  10158. QEMU or on the hardware, you have to take
  10159. different steps to enable the tests.
  10160. See the following subsections for information on how to
  10161. enable both types of tests.
  10162. </para>
  10163. <section id='qemu-image-enabling-tests'>
  10164. <title>Enabling Runtime Tests on QEMU</title>
  10165. <para>
  10166. In order to run tests, you need to do the following:
  10167. <itemizedlist>
  10168. <listitem><para><emphasis>Set up to avoid interaction
  10169. with <filename>sudo</filename> for networking:</emphasis>
  10170. To accomplish this, you must do one of the
  10171. following:
  10172. <itemizedlist>
  10173. <listitem><para>Add
  10174. <filename>NOPASSWD</filename> for your user
  10175. in <filename>/etc/sudoers</filename> either for
  10176. all commands or just for
  10177. <filename>runqemu-ifup</filename>.
  10178. You must provide the full path as that can
  10179. change if you are using multiple clones of the
  10180. source repository.
  10181. <note>
  10182. On some distributions, you also need to
  10183. comment out "Defaults requiretty" in
  10184. <filename>/etc/sudoers</filename>.
  10185. </note></para></listitem>
  10186. <listitem><para>Manually configure a tap interface
  10187. for your system.</para></listitem>
  10188. <listitem><para>Run as root the script in
  10189. <filename>scripts/runqemu-gen-tapdevs</filename>,
  10190. which should generate a list of tap devices.
  10191. This is the option typically chosen for
  10192. Autobuilder-type environments.
  10193. </para></listitem>
  10194. </itemizedlist></para></listitem>
  10195. <listitem><para><emphasis>Set the
  10196. <filename>DISPLAY</filename> variable:</emphasis>
  10197. You need to set this variable so that you have an X
  10198. server available (e.g. start
  10199. <filename>vncserver</filename> for a headless machine).
  10200. </para></listitem>
  10201. <listitem><para><emphasis>Be sure your host's firewall
  10202. accepts incoming connections from
  10203. 192.168.7.0/24:</emphasis>
  10204. Some of the tests (in particular DNF tests) start
  10205. an HTTP server on a random high number port,
  10206. which is used to serve files to the target.
  10207. The DNF module serves
  10208. <filename>${WORKDIR}/oe-rootfs-repo</filename>
  10209. so it can run DNF channel commands.
  10210. That means your host's firewall
  10211. must accept incoming connections from 192.168.7.0/24,
  10212. which is the default IP range used for tap devices
  10213. by <filename>runqemu</filename>.</para></listitem>
  10214. <listitem><para><emphasis>Be sure your host has the
  10215. correct packages installed:</emphasis>
  10216. Depending your host's distribution, you need
  10217. to have the following packages installed:
  10218. <itemizedlist>
  10219. <listitem><para>Ubuntu and Debian:
  10220. <filename>sysstat</filename> and
  10221. <filename>iproute2</filename>
  10222. </para></listitem>
  10223. <listitem><para>OpenSUSE:
  10224. <filename>sysstat</filename> and
  10225. <filename>iproute2</filename>
  10226. </para></listitem>
  10227. <listitem><para>Fedora:
  10228. <filename>sysstat</filename> and
  10229. <filename>iproute</filename>
  10230. </para></listitem>
  10231. <listitem><para>CentOS:
  10232. <filename>sysstat</filename> and
  10233. <filename>iproute</filename>
  10234. </para></listitem>
  10235. </itemizedlist>
  10236. </para></listitem>
  10237. </itemizedlist>
  10238. </para>
  10239. <para>
  10240. Once you start running the tests, the following happens:
  10241. <orderedlist>
  10242. <listitem><para>A copy of the root filesystem is written
  10243. to <filename>${WORKDIR}/testimage</filename>.
  10244. </para></listitem>
  10245. <listitem><para>The image is booted under QEMU using the
  10246. standard <filename>runqemu</filename> script.
  10247. </para></listitem>
  10248. <listitem><para>A default timeout of 500 seconds occurs
  10249. to allow for the boot process to reach the login prompt.
  10250. You can change the timeout period by setting
  10251. <ulink url='&YOCTO_DOCS_REF_URL;#var-TEST_QEMUBOOT_TIMEOUT'><filename>TEST_QEMUBOOT_TIMEOUT</filename></ulink>
  10252. in the <filename>local.conf</filename> file.
  10253. </para></listitem>
  10254. <listitem><para>Once the boot process is reached and the
  10255. login prompt appears, the tests run.
  10256. The full boot log is written to
  10257. <filename>${WORKDIR}/testimage/qemu_boot_log</filename>.
  10258. </para></listitem>
  10259. <listitem><para>Each test module loads in the order found
  10260. in <filename>TEST_SUITES</filename>.
  10261. You can find the full output of the commands run over
  10262. SSH in
  10263. <filename>${WORKDIR}/testimgage/ssh_target_log</filename>.
  10264. </para></listitem>
  10265. <listitem><para>If no failures occur, the task running the
  10266. tests ends successfully.
  10267. You can find the output from the
  10268. <filename>unittest</filename> in the task log at
  10269. <filename>${WORKDIR}/temp/log.do_testimage</filename>.
  10270. </para></listitem>
  10271. </orderedlist>
  10272. </para>
  10273. </section>
  10274. <section id='hardware-image-enabling-tests'>
  10275. <title>Enabling Runtime Tests on Hardware</title>
  10276. <para>
  10277. The OpenEmbedded build system can run tests on real
  10278. hardware, and for certain devices it can also deploy
  10279. the image to be tested onto the device beforehand.
  10280. </para>
  10281. <para>
  10282. For automated deployment, a "master image" is installed
  10283. onto the hardware once as part of setup.
  10284. Then, each time tests are to be run, the following
  10285. occurs:
  10286. <orderedlist>
  10287. <listitem><para>The master image is booted into and
  10288. used to write the image to be tested to
  10289. a second partition.
  10290. </para></listitem>
  10291. <listitem><para>The device is then rebooted using an
  10292. external script that you need to provide.
  10293. </para></listitem>
  10294. <listitem><para>The device boots into the image to be
  10295. tested.
  10296. </para></listitem>
  10297. </orderedlist>
  10298. </para>
  10299. <para>
  10300. When running tests (independent of whether the image
  10301. has been deployed automatically or not), the device is
  10302. expected to be connected to a network on a
  10303. pre-determined IP address.
  10304. You can either use static IP addresses written into
  10305. the image, or set the image to use DHCP and have your
  10306. DHCP server on the test network assign a known IP address
  10307. based on the MAC address of the device.
  10308. </para>
  10309. <para>
  10310. In order to run tests on hardware, you need to set
  10311. <filename>TEST_TARGET</filename> to an appropriate value.
  10312. For QEMU, you do not have to change anything, the default
  10313. value is "QemuTarget".
  10314. For running tests on hardware, the following options exist:
  10315. <itemizedlist>
  10316. <listitem><para><emphasis>"SimpleRemoteTarget":</emphasis>
  10317. Choose "SimpleRemoteTarget" if you are going to
  10318. run tests on a target system that is already
  10319. running the image to be tested and is available
  10320. on the network.
  10321. You can use "SimpleRemoteTarget" in conjunction
  10322. with either real hardware or an image running
  10323. within a separately started QEMU or any
  10324. other virtual machine manager.
  10325. </para></listitem>
  10326. <listitem><para><emphasis>"Systemd-bootTarget":</emphasis>
  10327. Choose "Systemd-bootTarget" if your hardware is
  10328. an EFI-based machine with
  10329. <filename>systemd-boot</filename> as bootloader and
  10330. <filename>core-image-testmaster</filename>
  10331. (or something similar) is installed.
  10332. Also, your hardware under test must be in a
  10333. DHCP-enabled network that gives it the same IP
  10334. address for each reboot.</para>
  10335. <para>If you choose "Systemd-bootTarget", there are
  10336. additional requirements and considerations.
  10337. See the
  10338. "<link linkend='selecting-systemd-boottarget'>Selecting Systemd-bootTarget</link>"
  10339. section, which follows, for more information.
  10340. </para></listitem>
  10341. <listitem><para><emphasis>"BeagleBoneTarget":</emphasis>
  10342. Choose "BeagleBoneTarget" if you are deploying
  10343. images and running tests on the BeagleBone
  10344. "Black" or original "White" hardware.
  10345. For information on how to use these tests, see the
  10346. comments at the top of the BeagleBoneTarget
  10347. <filename>meta-yocto-bsp/lib/oeqa/controllers/beaglebonetarget.py</filename>
  10348. file.
  10349. </para></listitem>
  10350. <listitem><para><emphasis>"EdgeRouterTarget":</emphasis>
  10351. Choose "EdgeRouterTarget" is you are deploying
  10352. images and running tests on the Ubiquiti Networks
  10353. EdgeRouter Lite.
  10354. For information on how to use these tests, see the
  10355. comments at the top of the EdgeRouterTarget
  10356. <filename>meta-yocto-bsp/lib/oeqa/controllers/edgeroutertarget.py</filename>
  10357. file.
  10358. </para></listitem>
  10359. <listitem><para><emphasis>"GrubTarget":</emphasis>
  10360. Choose the "supports deploying images and running
  10361. tests on any generic PC that boots using GRUB.
  10362. For information on how to use these tests, see the
  10363. comments at the top of the GrubTarget
  10364. <filename>meta-yocto-bsp/lib/oeqa/controllers/grubtarget.py</filename>
  10365. file.
  10366. </para></listitem>
  10367. <listitem><para><emphasis>"<replaceable>your-target</replaceable>":</emphasis>
  10368. Create your own custom target if you want to run
  10369. tests when you are deploying images and running
  10370. tests on a custom machine within your BSP layer.
  10371. To do this, you need to add a Python unit that
  10372. defines the target class under
  10373. <filename>lib/oeqa/controllers/</filename> within
  10374. your layer.
  10375. You must also provide an empty
  10376. <filename>__init__.py</filename>.
  10377. For examples, see files in
  10378. <filename>meta-yocto-bsp/lib/oeqa/controllers/</filename>.
  10379. </para></listitem>
  10380. </itemizedlist>
  10381. </para>
  10382. </section>
  10383. <section id='selecting-systemd-boottarget'>
  10384. <title>Selecting Systemd-bootTarget</title>
  10385. <para>
  10386. If you did not set <filename>TEST_TARGET</filename> to
  10387. "Systemd-bootTarget", then you do not need any information
  10388. in this section.
  10389. You can skip down to the
  10390. "<link linkend='qemu-image-running-tests'>Running Tests</link>"
  10391. section.
  10392. </para>
  10393. <para>
  10394. If you did set <filename>TEST_TARGET</filename> to
  10395. "Systemd-bootTarget", you also need to perform a one-time
  10396. setup of your master image by doing the following:
  10397. <orderedlist>
  10398. <listitem><para><emphasis>Set <filename>EFI_PROVIDER</filename>:</emphasis>
  10399. Be sure that <filename>EFI_PROVIDER</filename>
  10400. is as follows:
  10401. <literallayout class='monospaced'>
  10402. EFI_PROVIDER = "systemd-boot"
  10403. </literallayout>
  10404. </para></listitem>
  10405. <listitem><para><emphasis>Build the master image:</emphasis>
  10406. Build the <filename>core-image-testmaster</filename>
  10407. image.
  10408. The <filename>core-image-testmaster</filename>
  10409. recipe is provided as an example for a
  10410. "master" image and you can customize the image
  10411. recipe as you would any other recipe.
  10412. </para>
  10413. <para>Here are the image recipe requirements:
  10414. <itemizedlist>
  10415. <listitem><para>Inherits
  10416. <filename>core-image</filename>
  10417. so that kernel modules are installed.
  10418. </para></listitem>
  10419. <listitem><para>Installs normal linux utilities
  10420. not busybox ones (e.g.
  10421. <filename>bash</filename>,
  10422. <filename>coreutils</filename>,
  10423. <filename>tar</filename>,
  10424. <filename>gzip</filename>, and
  10425. <filename>kmod</filename>).
  10426. </para></listitem>
  10427. <listitem><para>Uses a custom
  10428. Initial RAM Disk (initramfs) image with a
  10429. custom installer.
  10430. A normal image that you can install usually
  10431. creates a single rootfs partition.
  10432. This image uses another installer that
  10433. creates a specific partition layout.
  10434. Not all Board Support Packages (BSPs)
  10435. can use an installer.
  10436. For such cases, you need to manually create
  10437. the following partition layout on the
  10438. target:
  10439. <itemizedlist>
  10440. <listitem><para>First partition mounted
  10441. under <filename>/boot</filename>,
  10442. labeled "boot".
  10443. </para></listitem>
  10444. <listitem><para>The main rootfs
  10445. partition where this image gets
  10446. installed, which is mounted under
  10447. <filename>/</filename>.
  10448. </para></listitem>
  10449. <listitem><para>Another partition
  10450. labeled "testrootfs" where test
  10451. images get deployed.
  10452. </para></listitem>
  10453. </itemizedlist>
  10454. </para></listitem>
  10455. </itemizedlist>
  10456. </para></listitem>
  10457. <listitem><para><emphasis>Install image:</emphasis>
  10458. Install the image that you just built on the target
  10459. system.
  10460. </para></listitem>
  10461. </orderedlist>
  10462. </para>
  10463. <para>
  10464. The final thing you need to do when setting
  10465. <filename>TEST_TARGET</filename> to "Systemd-bootTarget" is
  10466. to set up the test image:
  10467. <orderedlist>
  10468. <listitem><para><emphasis>Set up your <filename>local.conf</filename> file:</emphasis>
  10469. Make sure you have the following statements in
  10470. your <filename>local.conf</filename> file:
  10471. <literallayout class='monospaced'>
  10472. IMAGE_FSTYPES += "tar.gz"
  10473. INHERIT += "testimage"
  10474. TEST_TARGET = "Systemd-bootTarget"
  10475. TEST_TARGET_IP = "192.168.2.3"
  10476. </literallayout>
  10477. </para></listitem>
  10478. <listitem><para><emphasis>Build your test image:</emphasis>
  10479. Use BitBake to build the image:
  10480. <literallayout class='monospaced'>
  10481. $ bitbake core-image-sato
  10482. </literallayout>
  10483. </para></listitem>
  10484. </orderedlist>
  10485. </para>
  10486. </section>
  10487. <section id='power-control'>
  10488. <title>Power Control</title>
  10489. <para>
  10490. For most hardware targets other than SimpleRemoteTarget,
  10491. you can control power:
  10492. <itemizedlist>
  10493. <listitem><para>
  10494. You can use
  10495. <filename>TEST_POWERCONTROL_CMD</filename>
  10496. together with
  10497. <filename>TEST_POWERCONTROL_EXTRA_ARGS</filename>
  10498. as a command that runs on the host and does power
  10499. cycling.
  10500. The test code passes one argument to that command:
  10501. off, on or cycle (off then on).
  10502. Here is an example that could appear in your
  10503. <filename>local.conf</filename> file:
  10504. <literallayout class='monospaced'>
  10505. TEST_POWERCONTROL_CMD = "powercontrol.exp test 10.11.12.1 nuc1"
  10506. </literallayout>
  10507. In this example, the expect script does the
  10508. following:
  10509. <literallayout class='monospaced'>
  10510. ssh test@10.11.12.1 "pyctl nuc1 <replaceable>arg</replaceable>"
  10511. </literallayout>
  10512. It then runs a Python script that controls power
  10513. for a label called <filename>nuc1</filename>.
  10514. <note>
  10515. You need to customize
  10516. <filename>TEST_POWERCONTROL_CMD</filename>
  10517. and
  10518. <filename>TEST_POWERCONTROL_EXTRA_ARGS</filename>
  10519. for your own setup.
  10520. The one requirement is that it accepts
  10521. "on", "off", and "cycle" as the last argument.
  10522. </note>
  10523. </para></listitem>
  10524. <listitem><para>
  10525. When no command is defined, it connects to the
  10526. device over SSH and uses the classic reboot command
  10527. to reboot the device.
  10528. Classic reboot is fine as long as the machine
  10529. actually reboots (i.e. the SSH test has not
  10530. failed).
  10531. It is useful for scenarios where you have a simple
  10532. setup, typically with a single board, and where
  10533. some manual interaction is okay from time to time.
  10534. </para></listitem>
  10535. </itemizedlist>
  10536. If you have no hardware to automatically perform power
  10537. control but still wish to experiment with automated
  10538. hardware testing, you can use the dialog-power-control
  10539. script that shows a dialog prompting you to perform the
  10540. required power action.
  10541. This script requires either KDialog or Zenity to be
  10542. installed.
  10543. To use this script, set the
  10544. <ulink url='&YOCTO_DOCS_REF_URL;#var-TEST_POWERCONTROL_CMD'><filename>TEST_POWERCONTROL_CMD</filename></ulink>
  10545. variable as follows:
  10546. <literallayout class='monospaced'>
  10547. TEST_POWERCONTROL_CMD = "${COREBASE}/scripts/contrib/dialog-power-control"
  10548. </literallayout>
  10549. </para>
  10550. </section>
  10551. <section id='serial-console-connection'>
  10552. <title>Serial Console Connection</title>
  10553. <para>
  10554. For test target classes requiring a serial console
  10555. to interact with the bootloader (e.g. BeagleBoneTarget,
  10556. EdgeRouterTarget, and GrubTarget), you need to
  10557. specify a command to use to connect to the serial console
  10558. of the target machine by using the
  10559. <ulink url='&YOCTO_DOCS_REF_URL;#var-TEST_SERIALCONTROL_CMD'><filename>TEST_SERIALCONTROL_CMD</filename></ulink>
  10560. variable and optionally the
  10561. <ulink url='&YOCTO_DOCS_REF_URL;#var-TEST_SERIALCONTROL_EXTRA_ARGS'><filename>TEST_SERIALCONTROL_EXTRA_ARGS</filename></ulink>
  10562. variable.
  10563. </para>
  10564. <para>
  10565. These cases could be a serial terminal program if the
  10566. machine is connected to a local serial port, or a
  10567. <filename>telnet</filename> or
  10568. <filename>ssh</filename> command connecting to a remote
  10569. console server.
  10570. Regardless of the case, the command simply needs to
  10571. connect to the serial console and forward that connection
  10572. to standard input and output as any normal terminal
  10573. program does.
  10574. For example, to use the picocom terminal program on
  10575. serial device <filename>/dev/ttyUSB0</filename>
  10576. at 115200bps, you would set the variable as follows:
  10577. <literallayout class='monospaced'>
  10578. TEST_SERIALCONTROL_CMD = "picocom /dev/ttyUSB0 -b 115200"
  10579. </literallayout>
  10580. For local devices where the serial port device disappears
  10581. when the device reboots, an additional "serdevtry" wrapper
  10582. script is provided.
  10583. To use this wrapper, simply prefix the terminal command
  10584. with
  10585. <filename>${COREBASE}/scripts/contrib/serdevtry</filename>:
  10586. <literallayout class='monospaced'>
  10587. TEST_SERIALCONTROL_CMD = "${COREBASE}/scripts/contrib/serdevtry picocom -b
  10588. 115200 /dev/ttyUSB0"
  10589. </literallayout>
  10590. </para>
  10591. </section>
  10592. </section>
  10593. <section id="qemu-image-running-tests">
  10594. <title>Running Tests</title>
  10595. <para>
  10596. You can start the tests automatically or manually:
  10597. <itemizedlist>
  10598. <listitem><para><emphasis>Automatically running tests:</emphasis>
  10599. To run the tests automatically after the
  10600. OpenEmbedded build system successfully creates an image,
  10601. first set the
  10602. <ulink url='&YOCTO_DOCS_REF_URL;#var-TEST_IMAGE'><filename>TEST_IMAGE</filename></ulink>
  10603. variable to "1" in your <filename>local.conf</filename>
  10604. file in the
  10605. <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink>:
  10606. <literallayout class='monospaced'>
  10607. TEST_IMAGE = "1"
  10608. </literallayout>
  10609. Next, build your image.
  10610. If the image successfully builds, the tests will be
  10611. run:
  10612. <literallayout class='monospaced'>
  10613. bitbake core-image-sato
  10614. </literallayout></para></listitem>
  10615. <listitem><para><emphasis>Manually running tests:</emphasis>
  10616. To manually run the tests, first globally inherit the
  10617. <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-testimage*'><filename>testimage</filename></ulink>
  10618. class by editing your <filename>local.conf</filename>
  10619. file:
  10620. <literallayout class='monospaced'>
  10621. INHERIT += "testimage"
  10622. </literallayout>
  10623. Next, use BitBake to run the tests:
  10624. <literallayout class='monospaced'>
  10625. bitbake -c testimage <replaceable>image</replaceable>
  10626. </literallayout></para></listitem>
  10627. </itemizedlist>
  10628. </para>
  10629. <para>
  10630. All test files reside in
  10631. <filename>meta/lib/oeqa/runtime</filename> in the
  10632. <ulink url='&YOCTO_DOCS_REF_URL;#source-directory'>Source Directory</ulink>.
  10633. A test name maps directly to a Python module.
  10634. Each test module may contain a number of individual tests.
  10635. Tests are usually grouped together by the area
  10636. tested (e.g tests for systemd reside in
  10637. <filename>meta/lib/oeqa/runtime/systemd.py</filename>).
  10638. </para>
  10639. <para>
  10640. You can add tests to any layer provided you place them in the
  10641. proper area and you extend
  10642. <ulink url='&YOCTO_DOCS_REF_URL;#var-BBPATH'><filename>BBPATH</filename></ulink>
  10643. in the <filename>local.conf</filename> file as normal.
  10644. Be sure that tests reside in
  10645. <filename><replaceable>layer</replaceable>/lib/oeqa/runtime</filename>.
  10646. <note>
  10647. Be sure that module names do not collide with module names
  10648. used in the default set of test modules in
  10649. <filename>meta/lib/oeqa/runtime</filename>.
  10650. </note>
  10651. </para>
  10652. <para>
  10653. You can change the set of tests run by appending or overriding
  10654. <ulink url='&YOCTO_DOCS_REF_URL;#var-TEST_SUITES'><filename>TEST_SUITES</filename></ulink>
  10655. variable in <filename>local.conf</filename>.
  10656. Each name in <filename>TEST_SUITES</filename> represents a
  10657. required test for the image.
  10658. Test modules named within <filename>TEST_SUITES</filename>
  10659. cannot be skipped even if a test is not suitable for an image
  10660. (e.g. running the RPM tests on an image without
  10661. <filename>rpm</filename>).
  10662. Appending "auto" to <filename>TEST_SUITES</filename> causes the
  10663. build system to try to run all tests that are suitable for the
  10664. image (i.e. each test module may elect to skip itself).
  10665. </para>
  10666. <para>
  10667. The order you list tests in <filename>TEST_SUITES</filename>
  10668. is important and influences test dependencies.
  10669. Consequently, tests that depend on other tests should be added
  10670. after the test on which they depend.
  10671. For example, since the <filename>ssh</filename> test
  10672. depends on the
  10673. <filename>ping</filename> test, "ssh" needs to come after
  10674. "ping" in the list.
  10675. The test class provides no re-ordering or dependency handling.
  10676. <note>
  10677. Each module can have multiple classes with multiple test
  10678. methods.
  10679. And, Python <filename>unittest</filename> rules apply.
  10680. </note>
  10681. </para>
  10682. <para>
  10683. Here are some things to keep in mind when running tests:
  10684. <itemizedlist>
  10685. <listitem><para>The default tests for the image are defined
  10686. as:
  10687. <literallayout class='monospaced'>
  10688. DEFAULT_TEST_SUITES_pn-<replaceable>image</replaceable> = "ping ssh df connman syslog xorg scp vnc date rpm dnf dmesg"
  10689. </literallayout></para></listitem>
  10690. <listitem><para>Add your own test to the list of the
  10691. by using the following:
  10692. <literallayout class='monospaced'>
  10693. TEST_SUITES_append = " mytest"
  10694. </literallayout></para></listitem>
  10695. <listitem><para>Run a specific list of tests as follows:
  10696. <literallayout class='monospaced'>
  10697. TEST_SUITES = "test1 test2 test3"
  10698. </literallayout>
  10699. Remember, order is important.
  10700. Be sure to place a test that is dependent on another test
  10701. later in the order.</para></listitem>
  10702. </itemizedlist>
  10703. </para>
  10704. </section>
  10705. <section id="exporting-tests">
  10706. <title>Exporting Tests</title>
  10707. <para>
  10708. You can export tests so that they can run independently of
  10709. the build system.
  10710. Exporting tests is required if you want to be able to hand
  10711. the test execution off to a scheduler.
  10712. You can only export tests that are defined in
  10713. <ulink url='&YOCTO_DOCS_REF_URL;#var-TEST_SUITES'><filename>TEST_SUITES</filename></ulink>.
  10714. </para>
  10715. <para>
  10716. If your image is already built, make sure the following are set
  10717. in your <filename>local.conf</filename> file:
  10718. <literallayout class='monospaced'>
  10719. INHERIT +="testexport"
  10720. TEST_TARGET_IP = "<replaceable>IP-address-for-the-test-target</replaceable>"
  10721. TEST_SERVER_IP = "<replaceable>IP-address-for-the-test-server</replaceable>"
  10722. </literallayout>
  10723. You can then export the tests with the following BitBake
  10724. command form:
  10725. <literallayout class='monospaced'>
  10726. $ bitbake <replaceable>image</replaceable> -c testexport
  10727. </literallayout>
  10728. Exporting the tests places them in the
  10729. <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink>
  10730. in
  10731. <filename>tmp/testexport/</filename><replaceable>image</replaceable>,
  10732. which is controlled by the
  10733. <filename>TEST_EXPORT_DIR</filename> variable.
  10734. </para>
  10735. <para>
  10736. You can now run the tests outside of the build environment:
  10737. <literallayout class='monospaced'>
  10738. $ cd tmp/testexport/<replaceable>image</replaceable>
  10739. $ ./runexported.py testdata.json
  10740. </literallayout>
  10741. </para>
  10742. <para>
  10743. Here is a complete example that shows IP addresses and uses
  10744. the <filename>core-image-sato</filename> image:
  10745. <literallayout class='monospaced'>
  10746. INHERIT +="testexport"
  10747. TEST_TARGET_IP = "192.168.7.2"
  10748. TEST_SERVER_IP = "192.168.7.1"
  10749. </literallayout>
  10750. Use BitBake to export the tests:
  10751. <literallayout class='monospaced'>
  10752. $ bitbake core-image-sato -c testexport
  10753. </literallayout>
  10754. Run the tests outside of the build environment using the
  10755. following:
  10756. <literallayout class='monospaced'>
  10757. $ cd tmp/testexport/core-image-sato
  10758. $ ./runexported.py testdata.json
  10759. </literallayout>
  10760. </para>
  10761. </section>
  10762. <section id="qemu-image-writing-new-tests">
  10763. <title>Writing New Tests</title>
  10764. <para>
  10765. As mentioned previously, all new test files need to be in the
  10766. proper place for the build system to find them.
  10767. New tests for additional functionality outside of the core
  10768. should be added to the layer that adds the functionality, in
  10769. <filename><replaceable>layer</replaceable>/lib/oeqa/runtime</filename>
  10770. (as long as
  10771. <ulink url='&YOCTO_DOCS_REF_URL;#var-BBPATH'><filename>BBPATH</filename></ulink>
  10772. is extended in the layer's
  10773. <filename>layer.conf</filename> file as normal).
  10774. Just remember the following:
  10775. <itemizedlist>
  10776. <listitem><para>Filenames need to map directly to test
  10777. (module) names.
  10778. </para></listitem>
  10779. <listitem><para>Do not use module names that
  10780. collide with existing core tests.
  10781. </para></listitem>
  10782. <listitem><para>Minimally, an empty
  10783. <filename>__init__.py</filename> file must exist
  10784. in the runtime directory.
  10785. </para></listitem>
  10786. </itemizedlist>
  10787. </para>
  10788. <para>
  10789. To create a new test, start by copying an existing module
  10790. (e.g. <filename>syslog.py</filename> or
  10791. <filename>gcc.py</filename> are good ones to use).
  10792. Test modules can use code from
  10793. <filename>meta/lib/oeqa/utils</filename>, which are helper
  10794. classes.
  10795. </para>
  10796. <note>
  10797. Structure shell commands such that you rely on them and they
  10798. return a single code for success.
  10799. Be aware that sometimes you will need to parse the output.
  10800. See the <filename>df.py</filename> and
  10801. <filename>date.py</filename> modules for examples.
  10802. </note>
  10803. <para>
  10804. You will notice that all test classes inherit
  10805. <filename>oeRuntimeTest</filename>, which is found in
  10806. <filename>meta/lib/oetest.py</filename>.
  10807. This base class offers some helper attributes, which are
  10808. described in the following sections:
  10809. </para>
  10810. <section id='qemu-image-writing-tests-class-methods'>
  10811. <title>Class Methods</title>
  10812. <para>
  10813. Class methods are as follows:
  10814. <itemizedlist>
  10815. <listitem><para><emphasis><filename>hasPackage(pkg)</filename>:</emphasis>
  10816. Returns "True" if <filename>pkg</filename> is in the
  10817. installed package list of the image, which is based
  10818. on the manifest file that is generated during the
  10819. <filename>do_rootfs</filename> task.
  10820. </para></listitem>
  10821. <listitem><para><emphasis><filename>hasFeature(feature)</filename>:</emphasis>
  10822. Returns "True" if the feature is in
  10823. <ulink url='&YOCTO_DOCS_REF_URL;#var-IMAGE_FEATURES'><filename>IMAGE_FEATURES</filename></ulink>
  10824. or
  10825. <ulink url='&YOCTO_DOCS_REF_URL;#var-DISTRO_FEATURES'><filename>DISTRO_FEATURES</filename></ulink>.
  10826. </para></listitem>
  10827. </itemizedlist>
  10828. </para>
  10829. </section>
  10830. <section id='qemu-image-writing-tests-class-attributes'>
  10831. <title>Class Attributes</title>
  10832. <para>
  10833. Class attributes are as follows:
  10834. <itemizedlist>
  10835. <listitem><para><emphasis><filename>pscmd</filename>:</emphasis>
  10836. Equals "ps -ef" if <filename>procps</filename> is
  10837. installed in the image.
  10838. Otherwise, <filename>pscmd</filename> equals
  10839. "ps" (busybox).
  10840. </para></listitem>
  10841. <listitem><para><emphasis><filename>tc</filename>:</emphasis>
  10842. The called test context, which gives access to the
  10843. following attributes:
  10844. <itemizedlist>
  10845. <listitem><para><emphasis><filename>d</filename>:</emphasis>
  10846. The BitBake datastore, which allows you to
  10847. use stuff such as
  10848. <filename>oeRuntimeTest.tc.d.getVar("VIRTUAL-RUNTIME_init_manager")</filename>.
  10849. </para></listitem>
  10850. <listitem><para><emphasis><filename>testslist</filename> and <filename>testsrequired</filename>:</emphasis>
  10851. Used internally.
  10852. The tests do not need these.
  10853. </para></listitem>
  10854. <listitem><para><emphasis><filename>filesdir</filename>:</emphasis>
  10855. The absolute path to
  10856. <filename>meta/lib/oeqa/runtime/files</filename>,
  10857. which contains helper files for tests meant
  10858. for copying on the target such as small
  10859. files written in C for compilation.
  10860. </para></listitem>
  10861. <listitem><para><emphasis><filename>target</filename>:</emphasis>
  10862. The target controller object used to deploy
  10863. and start an image on a particular target
  10864. (e.g. QemuTarget, SimpleRemote, and
  10865. Systemd-bootTarget).
  10866. Tests usually use the following:
  10867. <itemizedlist>
  10868. <listitem><para><emphasis><filename>ip</filename>:</emphasis>
  10869. The target's IP address.
  10870. </para></listitem>
  10871. <listitem><para><emphasis><filename>server_ip</filename>:</emphasis>
  10872. The host's IP address, which is
  10873. usually used by the DNF test
  10874. suite.
  10875. </para></listitem>
  10876. <listitem><para><emphasis><filename>run(cmd, timeout=None)</filename>:</emphasis>
  10877. The single, most used method.
  10878. This command is a wrapper for:
  10879. <filename>ssh root@host "cmd"</filename>.
  10880. The command returns a tuple:
  10881. (status, output), which are what
  10882. their names imply - the return code
  10883. of "cmd" and whatever output
  10884. it produces.
  10885. The optional timeout argument
  10886. represents the number of seconds the
  10887. test should wait for "cmd" to
  10888. return.
  10889. If the argument is "None", the
  10890. test uses the default instance's
  10891. timeout period, which is 300
  10892. seconds.
  10893. If the argument is "0", the test
  10894. runs until the command returns.
  10895. </para></listitem>
  10896. <listitem><para><emphasis><filename>copy_to(localpath, remotepath)</filename>:</emphasis>
  10897. <filename>scp localpath root@ip:remotepath</filename>.
  10898. </para></listitem>
  10899. <listitem><para><emphasis><filename>copy_from(remotepath, localpath)</filename>:</emphasis>
  10900. <filename>scp root@host:remotepath localpath</filename>.
  10901. </para></listitem>
  10902. </itemizedlist></para></listitem>
  10903. </itemizedlist></para></listitem>
  10904. </itemizedlist>
  10905. </para>
  10906. </section>
  10907. <section id='qemu-image-writing-tests-instance-attributes'>
  10908. <title>Instance Attributes</title>
  10909. <para>
  10910. A single instance attribute exists, which is
  10911. <filename>target</filename>.
  10912. The <filename>target</filename> instance attribute is
  10913. identical to the class attribute of the same name, which
  10914. is described in the previous section.
  10915. This attribute exists as both an instance and class
  10916. attribute so tests can use
  10917. <filename>self.target.run(cmd)</filename> in instance
  10918. methods instead of
  10919. <filename>oeRuntimeTest.tc.target.run(cmd)</filename>.
  10920. </para>
  10921. </section>
  10922. </section>
  10923. <section id='installing-packages-in-the-dut-without-the-package-manager'>
  10924. <title>Installing Packages in the DUT Without the Package Manager</title>
  10925. <para>
  10926. When a test requires a package built by BitBake, it is possible
  10927. to install that package.
  10928. Installing the package does not require a package manager be
  10929. installed in the device under test (DUT).
  10930. It does, however, require an SSH connection and the target must
  10931. be using the <filename>sshcontrol</filename> class.
  10932. <note>
  10933. This method uses <filename>scp</filename> to copy files
  10934. from the host to the target, which causes permissions and
  10935. special attributes to be lost.
  10936. </note>
  10937. </para>
  10938. <para>
  10939. A JSON file is used to define the packages needed by a test.
  10940. This file must be in the same path as the file used to define
  10941. the tests.
  10942. Furthermore, the filename must map directly to the test
  10943. module name with a <filename>.json</filename> extension.
  10944. </para>
  10945. <para>
  10946. The JSON file must include an object with the test name as
  10947. keys of an object or an array.
  10948. This object (or array of objects) uses the following data:
  10949. <itemizedlist>
  10950. <listitem><para>"pkg" - A mandatory string that is the
  10951. name of the package to be installed.
  10952. </para></listitem>
  10953. <listitem><para>"rm" - An optional boolean, which defaults
  10954. to "false", that specifies to remove the package after
  10955. the test.
  10956. </para></listitem>
  10957. <listitem><para>"extract" - An optional boolean, which
  10958. defaults to "false", that specifies if the package must
  10959. be extracted from the package format.
  10960. When set to "true", the package is not automatically
  10961. installed into the DUT.
  10962. </para></listitem>
  10963. </itemizedlist>
  10964. </para>
  10965. <para>
  10966. Following is an example JSON file that handles test "foo"
  10967. installing package "bar" and test "foobar" installing
  10968. packages "foo" and "bar".
  10969. Once the test is complete, the packages are removed from the
  10970. DUT.
  10971. <literallayout class='monospaced'>
  10972. {
  10973. "foo": {
  10974. "pkg": "bar"
  10975. },
  10976. "foobar": [
  10977. {
  10978. "pkg": "foo",
  10979. "rm": true
  10980. },
  10981. {
  10982. "pkg": "bar",
  10983. "rm": true
  10984. }
  10985. ]
  10986. }
  10987. </literallayout>
  10988. </para>
  10989. </section>
  10990. </section>
  10991. <section id='usingpoky-debugging-tools-and-techniques'>
  10992. <title>Debugging Tools and Techniques</title>
  10993. <para>
  10994. The exact method for debugging build failures depends on the nature
  10995. of the problem and on the system's area from which the bug
  10996. originates.
  10997. Standard debugging practices such as comparison against the last
  10998. known working version with examination of the changes and the
  10999. re-application of steps to identify the one causing the problem are
  11000. valid for the Yocto Project just as they are for any other system.
  11001. Even though it is impossible to detail every possible potential
  11002. failure, this section provides some general tips to aid in
  11003. debugging given a variety of situations.
  11004. <note><title>Tip</title>
  11005. A useful feature for debugging is the error reporting tool.
  11006. Configuring the Yocto Project to use this tool causes the
  11007. OpenEmbedded build system to produce error reporting commands as
  11008. part of the console output.
  11009. You can enter the commands after the build completes to log
  11010. error information into a common database, that can help you
  11011. figure out what might be going wrong.
  11012. For information on how to enable and use this feature, see the
  11013. "<link linkend='using-the-error-reporting-tool'>Using the Error Reporting Tool</link>"
  11014. section.
  11015. </note>
  11016. </para>
  11017. <para>
  11018. The following list shows the debugging topics in the remainder of
  11019. this section:
  11020. <itemizedlist>
  11021. <listitem><para>
  11022. "<link linkend='dev-debugging-viewing-logs-from-failed-tasks'>Viewing Logs from Failed Tasks</link>"
  11023. describes how to find and view logs from tasks that
  11024. failed during the build process.
  11025. </para></listitem>
  11026. <listitem><para>
  11027. "<link linkend='dev-debugging-viewing-variable-values'>Viewing Variable Values</link>"
  11028. describes how to use the BitBake <filename>-e</filename>
  11029. option to examine variable values after a recipe has been
  11030. parsed.
  11031. </para></listitem>
  11032. <listitem><para>
  11033. "<link linkend='viewing-package-information-with-oe-pkgdata-util'>Viewing Package Information with <filename>oe-pkgdata-util</filename></link>"
  11034. describes how to use the
  11035. <filename>oe-pkgdata-util</filename> utility to query
  11036. <ulink url='&YOCTO_DOCS_REF_URL;#var-PKGDATA_DIR'><filename>PKGDATA_DIR</filename></ulink>
  11037. and display package-related information for built
  11038. packages.
  11039. </para></listitem>
  11040. <listitem><para>
  11041. "<link linkend='dev-viewing-dependencies-between-recipes-and-tasks'>Viewing Dependencies Between Recipes and Tasks</link>"
  11042. describes how to use the BitBake <filename>-g</filename>
  11043. option to display recipe dependency information used
  11044. during the build.
  11045. </para></listitem>
  11046. <listitem><para>
  11047. "<link linkend='dev-viewing-task-variable-dependencies'>Viewing Task Variable Dependencies</link>"
  11048. describes how to use the
  11049. <filename>bitbake-dumpsig</filename> command in
  11050. conjunction with key subdirectories in the
  11051. <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink>
  11052. to determine variable dependencies.
  11053. </para></listitem>
  11054. <listitem><para>
  11055. "<link linkend='dev-debugging-taskrunning'>Running Specific Tasks</link>"
  11056. describes how to use several BitBake options (e.g.
  11057. <filename>-c</filename>, <filename>-C</filename>, and
  11058. <filename>-f</filename>) to run specific tasks in the
  11059. build chain.
  11060. It can be useful to run tasks "out-of-order" when trying
  11061. isolate build issues.
  11062. </para></listitem>
  11063. <listitem><para>
  11064. "<link linkend='dev-debugging-bitbake'>General BitBake Problems</link>"
  11065. describes how to use BitBake's <filename>-D</filename>
  11066. debug output option to reveal more about what BitBake is
  11067. doing during the build.
  11068. </para></listitem>
  11069. <listitem><para>
  11070. "<link linkend='dev-debugging-buildfile'>Building with No Dependencies</link>"
  11071. describes how to use the BitBake <filename>-b</filename>
  11072. option to build a recipe while ignoring dependencies.
  11073. </para></listitem>
  11074. <listitem><para>
  11075. "<link linkend='recipe-logging-mechanisms'>Recipe Logging Mechanisms</link>"
  11076. describes how to use the many recipe logging functions
  11077. to produce debugging output and report errors and warnings.
  11078. </para></listitem>
  11079. <listitem><para>
  11080. "<link linkend='debugging-parallel-make-races'>Debugging Parallel Make Races</link>"
  11081. describes how to debug situations where the build consists
  11082. of several parts that are run simultaneously and when the
  11083. output or result of one part is not ready for use with a
  11084. different part of the build that depends on that output.
  11085. </para></listitem>
  11086. <listitem><para>
  11087. "<link linkend='platdev-gdb-remotedebug'>Debugging With the GNU Project Debugger (GDB) Remotely</link>"
  11088. describes how to use GDB to allow you to examine running
  11089. programs, which can help you fix problems.
  11090. </para></listitem>
  11091. <listitem><para>
  11092. "<link linkend='debugging-with-the-gnu-project-debugger-gdb-on-the-target'>Debugging with the GNU Project Debugger (GDB) on the Target</link>"
  11093. describes how to use GDB directly on target hardware for
  11094. debugging.
  11095. </para></listitem>
  11096. <listitem><para>
  11097. "<link linkend='dev-other-debugging-others'>Other Debugging Tips</link>"
  11098. describes miscellaneous debugging tips that can be useful.
  11099. </para></listitem>
  11100. </itemizedlist>
  11101. </para>
  11102. <para>
  11103. For debugging information within the popular
  11104. <trademark class='trade'>Eclipse</trademark> IDE, see the
  11105. "<ulink url='&YOCTO_DOCS_SDK_URL;#adt-eclipse'>Working within Eclipse</ulink>"
  11106. section in the Yocto Project Application Development and the
  11107. Extensible Software Development Kit (eSDK) manual.
  11108. </para>
  11109. <section id='dev-debugging-viewing-logs-from-failed-tasks'>
  11110. <title>Viewing Logs from Failed Tasks</title>
  11111. <para>
  11112. You can find the log for a task in the file
  11113. <filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-WORKDIR'><filename>WORKDIR</filename></ulink><filename>}/temp/log.do_</filename><replaceable>taskname</replaceable>.
  11114. For example, the log for the
  11115. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-compile'><filename>do_compile</filename></ulink>
  11116. task of the QEMU minimal image for the x86 machine
  11117. (<filename>qemux86</filename>) might be in
  11118. <filename>tmp/work/qemux86-poky-linux/core-image-minimal/1.0-r0/temp/log.do_compile</filename>.
  11119. To see the commands
  11120. <ulink url='&YOCTO_DOCS_REF_URL;#bitbake-term'>BitBake</ulink>
  11121. ran to generate a log, look at the corresponding
  11122. <filename>run.do_</filename><replaceable>taskname</replaceable>
  11123. file in the same directory.
  11124. </para>
  11125. <para>
  11126. <filename>log.do_</filename><replaceable>taskname</replaceable>
  11127. and
  11128. <filename>run.do_</filename><replaceable>taskname</replaceable>
  11129. are actually symbolic links to
  11130. <filename>log.do_</filename><replaceable>taskname</replaceable><filename>.</filename><replaceable>pid</replaceable>
  11131. and
  11132. <filename>log.run_</filename><replaceable>taskname</replaceable><filename>.</filename><replaceable>pid</replaceable>,
  11133. where <replaceable>pid</replaceable> is the PID the task had
  11134. when it ran.
  11135. The symlinks always point to the files corresponding to the most
  11136. recent run.
  11137. </para>
  11138. </section>
  11139. <section id='dev-debugging-viewing-variable-values'>
  11140. <title>Viewing Variable Values</title>
  11141. <para>
  11142. BitBake's <filename>-e</filename> option is used to display
  11143. variable values after parsing.
  11144. The following command displays the variable values after the
  11145. configuration files (i.e. <filename>local.conf</filename>,
  11146. <filename>bblayers.conf</filename>,
  11147. <filename>bitbake.conf</filename> and so forth) have been
  11148. parsed:
  11149. <literallayout class='monospaced'>
  11150. $ bitbake -e
  11151. </literallayout>
  11152. The following command displays variable values after a specific
  11153. recipe has been parsed.
  11154. The variables include those from the configuration as well:
  11155. <literallayout class='monospaced'>
  11156. $ bitbake -e recipename
  11157. </literallayout>
  11158. <note><para>
  11159. Each recipe has its own private set of variables
  11160. (datastore).
  11161. Internally, after parsing the configuration, a copy of the
  11162. resulting datastore is made prior to parsing each recipe.
  11163. This copying implies that variables set in one recipe will
  11164. not be visible to other recipes.</para>
  11165. <para>Likewise, each task within a recipe gets a private
  11166. datastore based on the recipe datastore, which means that
  11167. variables set within one task will not be visible to
  11168. other tasks.</para>
  11169. </note>
  11170. </para>
  11171. <para>
  11172. In the output of <filename>bitbake -e</filename>, each
  11173. variable is preceded by a description of how the variable
  11174. got its value, including temporary values that were later
  11175. overriden.
  11176. This description also includes variable flags (varflags) set on
  11177. the variable.
  11178. The output can be very helpful during debugging.
  11179. </para>
  11180. <para>
  11181. Variables that are exported to the environment are preceded by
  11182. <filename>export</filename> in the output of
  11183. <filename>bitbake -e</filename>.
  11184. See the following example:
  11185. <literallayout class='monospaced'>
  11186. export CC="i586-poky-linux-gcc -m32 -march=i586 --sysroot=/home/ulf/poky/build/tmp/sysroots/qemux86"
  11187. </literallayout>
  11188. </para>
  11189. <para>
  11190. In addition to variable values, the output of the
  11191. <filename>bitbake -e</filename> and
  11192. <filename>bitbake -e</filename>&nbsp;<replaceable>recipe</replaceable>
  11193. commands includes the following information:
  11194. <itemizedlist>
  11195. <listitem><para>
  11196. The output starts with a tree listing all configuration
  11197. files and classes included globally, recursively listing
  11198. the files they include or inherit in turn.
  11199. Much of the behavior of the OpenEmbedded build system
  11200. (including the behavior of the
  11201. <ulink url='&YOCTO_DOCS_REF_URL;#normal-recipe-build-tasks'>normal recipe build tasks</ulink>)
  11202. is implemented in the
  11203. <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-base'><filename>base</filename></ulink>
  11204. class and the classes it inherits, rather than being
  11205. built into BitBake itself.
  11206. </para></listitem>
  11207. <listitem><para>
  11208. After the variable values, all functions appear in the
  11209. output.
  11210. For shell functions, variables referenced within the
  11211. function body are expanded.
  11212. If a function has been modified using overrides or
  11213. using override-style operators like
  11214. <filename>_append</filename> and
  11215. <filename>_prepend</filename>, then the final assembled
  11216. function body appears in the output.
  11217. </para></listitem>
  11218. </itemizedlist>
  11219. </para>
  11220. </section>
  11221. <section id='viewing-package-information-with-oe-pkgdata-util'>
  11222. <title>Viewing Package Information with <filename>oe-pkgdata-util</filename></title>
  11223. <para>
  11224. You can use the <filename>oe-pkgdata-util</filename>
  11225. command-line utility to query
  11226. <ulink url='&YOCTO_DOCS_REF_URL;#var-PKGDATA_DIR'><filename>PKGDATA_DIR</filename></ulink>
  11227. and display various package-related information.
  11228. When you use the utility, you must use it to view information
  11229. on packages that have already been built.
  11230. </para>
  11231. <para>
  11232. Following are a few of the available
  11233. <filename>oe-pkgdata-util</filename> subcommands.
  11234. <note>
  11235. You can use the standard * and ? globbing wildcards as part
  11236. of package names and paths.
  11237. </note>
  11238. <itemizedlist>
  11239. <listitem><para>
  11240. <filename>oe-pkgdata-util list-pkgs [</filename><replaceable>pattern</replaceable><filename>]</filename>:
  11241. Lists all packages that have been built, optionally
  11242. limiting the match to packages that match
  11243. <replaceable>pattern</replaceable>.
  11244. </para></listitem>
  11245. <listitem><para>
  11246. <filename>oe-pkgdata-util list-pkg-files&nbsp;</filename><replaceable>package</replaceable><filename>&nbsp;...</filename>:
  11247. Lists the files and directories contained in the given
  11248. packages.
  11249. <note>
  11250. <para>
  11251. A different way to view the contents of a package is
  11252. to look at the
  11253. <filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-WORKDIR'><filename>WORKDIR</filename></ulink><filename>}/packages-split</filename>
  11254. directory of the recipe that generates the
  11255. package.
  11256. This directory is created by the
  11257. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-package'><filename>do_package</filename></ulink>
  11258. task and has one subdirectory for each package the
  11259. recipe generates, which contains the files stored in
  11260. that package.</para>
  11261. <para>
  11262. If you want to inspect the
  11263. <filename>${WORKDIR}/packages-split</filename>
  11264. directory, make sure that
  11265. <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-rm-work'><filename>rm_work</filename></ulink>
  11266. is not enabled when you build the recipe.
  11267. </para>
  11268. </note>
  11269. </para></listitem>
  11270. <listitem><para>
  11271. <filename>oe-pkgdata-util find-path&nbsp;</filename><replaceable>path</replaceable><filename>&nbsp;...</filename>:
  11272. Lists the names of the packages that contain the given
  11273. paths.
  11274. For example, the following tells us that
  11275. <filename>/usr/share/man/man1/make.1</filename>
  11276. is contained in the <filename>make-doc</filename>
  11277. package:
  11278. <literallayout class='monospaced'>
  11279. $ oe-pkgdata-util find-path /usr/share/man/man1/make.1
  11280. make-doc: /usr/share/man/man1/make.1
  11281. </literallayout>
  11282. </para></listitem>
  11283. <listitem><para>
  11284. <filename>oe-pkgdata-util lookup-recipe&nbsp;</filename><replaceable>package</replaceable><filename>&nbsp;...</filename>:
  11285. Lists the name of the recipes that
  11286. produce the given packages.
  11287. </para></listitem>
  11288. </itemizedlist>
  11289. </para>
  11290. <para>
  11291. For more information on the <filename>oe-pkgdata-util</filename>
  11292. command, use the help facility:
  11293. <literallayout class='monospaced'>
  11294. $ oe-pkgdata-util &dash;&dash;help
  11295. $ oe-pkgdata-util <replaceable>subcommand</replaceable> --help
  11296. </literallayout>
  11297. </para>
  11298. </section>
  11299. <section id='dev-viewing-dependencies-between-recipes-and-tasks'>
  11300. <title>Viewing Dependencies Between Recipes and Tasks</title>
  11301. <para>
  11302. Sometimes it can be hard to see why BitBake wants to build other
  11303. recipes before the one you have specified.
  11304. Dependency information can help you understand why a recipe is
  11305. built.
  11306. </para>
  11307. <para>
  11308. To generate dependency information for a recipe, run the
  11309. following command:
  11310. <literallayout class='monospaced'>
  11311. $ bitbake -g <replaceable>recipename</replaceable>
  11312. </literallayout>
  11313. This command writes the following files in the current
  11314. directory:
  11315. <itemizedlist>
  11316. <listitem><para>
  11317. <filename>pn-buildlist</filename>: A list of
  11318. recipes/targets involved in building
  11319. <replaceable>recipename</replaceable>.
  11320. "Involved" here means that at least one task from the
  11321. recipe needs to run when building
  11322. <replaceable>recipename</replaceable> from scratch.
  11323. Targets that are in
  11324. <ulink url='&YOCTO_DOCS_REF_URL;#var-ASSUME_PROVIDED'><filename>ASSUME_PROVIDED</filename></ulink>
  11325. are not listed.
  11326. </para></listitem>
  11327. <listitem><para>
  11328. <filename>task-depends.dot</filename>: A graph showing
  11329. dependencies between tasks.
  11330. </para></listitem>
  11331. </itemizedlist>
  11332. </para>
  11333. <para>
  11334. The graphs are in
  11335. <ulink url='https://en.wikipedia.org/wiki/DOT_%28graph_description_language%29'>DOT</ulink>
  11336. format and can be converted to images (e.g. using the
  11337. <filename>dot</filename> tool from
  11338. <ulink url='http://www.graphviz.org/'>Graphviz</ulink>).
  11339. <note><title>Notes</title>
  11340. <itemizedlist>
  11341. <listitem><para>
  11342. DOT files use a plain text format.
  11343. The graphs generated using the
  11344. <filename>bitbake -g</filename> command are often so
  11345. large as to be difficult to read without special
  11346. pruning (e.g. with Bitbake's
  11347. <filename>-I</filename> option) and processing.
  11348. Despite the form and size of the graphs, the
  11349. corresponding <filename>.dot</filename> files can
  11350. still be possible to read and provide useful
  11351. information.
  11352. </para>
  11353. <para>As an example, the
  11354. <filename>task-depends.dot</filename> file contains
  11355. lines such as the following:
  11356. <literallayout class='monospaced'>
  11357. "libxslt.do_configure" -> "libxml2.do_populate_sysroot"
  11358. </literallayout>
  11359. The above example line reveals that the
  11360. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-configure'><filename>do_configure</filename></ulink>
  11361. task in <filename>libxslt</filename> depends on the
  11362. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-populate_sysroot'><filename>do_populate_sysroot</filename></ulink>
  11363. task in <filename>libxml2</filename>, which is a
  11364. normal
  11365. <ulink url='&YOCTO_DOCS_REF_URL;#var-DEPENDS'><filename>DEPENDS</filename></ulink>
  11366. dependency between the two recipes.
  11367. </para></listitem>
  11368. <listitem><para>
  11369. For an example of how <filename>.dot</filename>
  11370. files can be processed, see the
  11371. <filename>scripts/contrib/graph-tool</filename>
  11372. Python script, which finds and displays paths
  11373. between graph nodes.
  11374. </para></listitem>
  11375. </itemizedlist>
  11376. </note>
  11377. </para>
  11378. <para>
  11379. You can use a different method to view dependency information
  11380. by using the following command:
  11381. <literallayout class='monospaced'>
  11382. $ bitbake -g -u taskexp <replaceable>recipename</replaceable>
  11383. </literallayout>
  11384. This command displays a GUI window from which you can view
  11385. build-time and runtime dependencies for the recipes involved in
  11386. building <replaceable>recipename</replaceable>.
  11387. </para>
  11388. </section>
  11389. <section id='dev-viewing-task-variable-dependencies'>
  11390. <title>Viewing Task Variable Dependencies</title>
  11391. <para>
  11392. As mentioned in the
  11393. "<ulink url='&YOCTO_DOCS_BB_URL;#checksums'>Checksums (Signatures)</ulink>"
  11394. section of the BitBake User Manual, BitBake tries to
  11395. automatically determine what variables a task depends on so
  11396. that it can rerun the task if any values of the variables
  11397. change.
  11398. This determination is usually reliable.
  11399. However, if you do things like construct variable names at
  11400. runtime, then you might have to manually declare dependencies
  11401. on those variables using <filename>vardeps</filename> as
  11402. described in the
  11403. "<ulink url='&YOCTO_DOCS_BB_URL;#variable-flags'>Variable Flags</ulink>"
  11404. section of the BitBake User Manual.
  11405. </para>
  11406. <para>
  11407. If you are unsure whether a variable dependency is being
  11408. picked up automatically for a given task, you can list the
  11409. variable dependencies BitBake has determined by doing the
  11410. following:
  11411. <orderedlist>
  11412. <listitem><para>
  11413. Build the recipe containing the task:
  11414. <literallayout class='monospaced'>
  11415. $ bitbake <replaceable>recipename</replaceable>
  11416. </literallayout>
  11417. </para></listitem>
  11418. <listitem><para>
  11419. Inside the
  11420. <ulink url='&YOCTO_DOCS_REF_URL;#var-STAMPS_DIR'><filename>STAMPS_DIR</filename></ulink>
  11421. directory, find the signature data
  11422. (<filename>sigdata</filename>) file that corresponds
  11423. to the task.
  11424. The <filename>sigdata</filename> files contain a pickled
  11425. Python database of all the metadata that went into
  11426. creating the input checksum for the task.
  11427. As an example, for the
  11428. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-fetch'><filename>do_fetch</filename></ulink>
  11429. task of the <filename>db</filename> recipe, the
  11430. <filename>sigdata</filename> file might be found in the
  11431. following location:
  11432. <literallayout class='monospaced'>
  11433. ${BUILDDIR}/tmp/stamps/i586-poky-linux/db/6.0.30-r1.do_fetch.sigdata.7c048c18222b16ff0bcee2000ef648b1
  11434. </literallayout>
  11435. For tasks that are accelerated through the shared state
  11436. (<ulink url='&YOCTO_DOCS_OM_URL;#shared-state-cache'>sstate</ulink>)
  11437. cache, an additional <filename>siginfo</filename> file
  11438. is written into
  11439. <ulink url='&YOCTO_DOCS_REF_URL;#var-SSTATE_DIR'><filename>SSTATE_DIR</filename></ulink>
  11440. along with the cached task output.
  11441. The <filename>siginfo</filename> files contain exactly
  11442. the same information as <filename>sigdata</filename>
  11443. files.
  11444. </para></listitem>
  11445. <listitem><para>
  11446. Run <filename>bitbake-dumpsig</filename> on the
  11447. <filename>sigdata</filename> or
  11448. <filename>siginfo</filename> file.
  11449. Here is an example:
  11450. <literallayout class='monospaced'>
  11451. $ bitbake-dumpsig ${BUILDDIR}/tmp/stamps/i586-poky-linux/db/6.0.30-r1.do_fetch.sigdata.7c048c18222b16ff0bcee2000ef648b1
  11452. </literallayout>
  11453. In the output of the above command, you will find a
  11454. line like the following, which lists all the (inferred)
  11455. variable dependencies for the task.
  11456. This list also includes indirect dependencies from
  11457. variables depending on other variables, recursively.
  11458. <literallayout class='monospaced'>
  11459. Task dependencies: ['PV', 'SRCREV', 'SRC_URI', 'SRC_URI[md5sum]', 'SRC_URI[sha256sum]', 'base_do_fetch']
  11460. </literallayout>
  11461. <note>
  11462. Functions (e.g. <filename>base_do_fetch</filename>)
  11463. also count as variable dependencies.
  11464. These functions in turn depend on the variables they
  11465. reference.
  11466. </note>
  11467. The output of <filename>bitbake-dumpsig</filename> also
  11468. includes the value each variable had, a list of
  11469. dependencies for each variable, and
  11470. <ulink url='&YOCTO_DOCS_BB_URL;#var-BB_HASHBASE_WHITELIST'><filename>BB_HASHBASE_WHITELIST</filename></ulink>
  11471. information.
  11472. </para></listitem>
  11473. </orderedlist>
  11474. </para>
  11475. <para>
  11476. There is also a <filename>bitbake-diffsigs</filename> command
  11477. for comparing two <filename>siginfo</filename> or
  11478. <filename>sigdata</filename> files.
  11479. This command can be helpful when trying to figure out what
  11480. changed between two versions of a task.
  11481. If you call <filename>bitbake-diffsigs</filename> with just one
  11482. file, the command behaves like
  11483. <filename>bitbake-dumpsig</filename>.
  11484. </para>
  11485. <para>
  11486. You can also use BitBake to dump out the signature construction
  11487. information without executing tasks by using either of the
  11488. following BitBake command-line options:
  11489. <literallayout class='monospaced'>
  11490. &dash;&dash;dump-signatures=<replaceable>SIGNATURE_HANDLER</replaceable>
  11491. -S <replaceable>SIGNATURE_HANDLER</replaceable>
  11492. </literallayout>
  11493. <note>
  11494. Two common values for
  11495. <replaceable>SIGNATURE_HANDLER</replaceable> are "none" and
  11496. "printdiff", which dump only the signature or compare the
  11497. dumped signature with the cached one, respectively.
  11498. </note>
  11499. Using BitBake with either of these options causes BitBake to
  11500. dump out <filename>sigdata</filename> files in the
  11501. <filename>stamps</filename> directory for every task it would
  11502. have executed instead of building the specified target package.
  11503. </para>
  11504. </section>
  11505. <section id='dev-debugging-taskrunning'>
  11506. <title>Running Specific Tasks</title>
  11507. <para>
  11508. Any given recipe consists of a set of tasks.
  11509. The standard BitBake behavior in most cases is:
  11510. <filename>do_fetch</filename>,
  11511. <filename>do_unpack</filename>,
  11512. <filename>do_patch</filename>,
  11513. <filename>do_configure</filename>,
  11514. <filename>do_compile</filename>,
  11515. <filename>do_install</filename>,
  11516. <filename>do_package</filename>,
  11517. <filename>do_package_write_*</filename>, and
  11518. <filename>do_build</filename>.
  11519. The default task is <filename>do_build</filename> and any tasks
  11520. on which it depends build first.
  11521. Some tasks, such as <filename>do_devshell</filename>, are not
  11522. part of the default build chain.
  11523. If you wish to run a task that is not part of the default build
  11524. chain, you can use the <filename>-c</filename> option in
  11525. BitBake.
  11526. Here is an example:
  11527. <literallayout class='monospaced'>
  11528. $ bitbake matchbox-desktop -c devshell
  11529. </literallayout>
  11530. </para>
  11531. <para>
  11532. The <filename>-c</filename> option respects task dependencies,
  11533. which means that all other tasks (including tasks from other
  11534. recipes) that the specified task depends on will be run before
  11535. the task.
  11536. Even when you manually specify a task to run with
  11537. <filename>-c</filename>, BitBake will only run the task if it
  11538. considers it "out of date".
  11539. See the
  11540. "<ulink url='&YOCTO_DOCS_OM_URL;#stamp-files-and-the-rerunning-of-tasks'>Stamp Files and the Rerunning of Tasks</ulink>"
  11541. section in the Yocto Project Overview and Concepts Manual for
  11542. how BitBake determines whether a task is "out of date".
  11543. </para>
  11544. <para>
  11545. If you want to force an up-to-date task to be rerun (e.g.
  11546. because you made manual modifications to the recipe's
  11547. <ulink linkend='&YOCTO_DOCS_REF_URL;#var-WORKDIR'><filename>WORKDIR</filename></ulink>
  11548. that you want to try out), then you can use the
  11549. <filename>-f</filename> option.
  11550. <note>
  11551. The reason <filename>-f</filename> is never required when
  11552. running the
  11553. <ulink linkend='&YOCTO_DOCS_REF_URL;#ref-tasks-devshell'><filename>do_devshell</filename></ulink>
  11554. task is because the
  11555. <filename>[</filename><ulink url='&YOCTO_DOCS_BB_URL;#variable-flags'><filename>nostamp</filename></ulink><filename>]</filename>
  11556. variable flag is already set for the task.
  11557. </note>
  11558. The following example shows one way you can use the
  11559. <filename>-f</filename> option:
  11560. <literallayout class='monospaced'>
  11561. $ bitbake matchbox-desktop
  11562. .
  11563. .
  11564. make some changes to the source code in the work directory
  11565. .
  11566. .
  11567. $ bitbake matchbox-desktop -c compile -f
  11568. $ bitbake matchbox-desktop
  11569. </literallayout>
  11570. </para>
  11571. <para>
  11572. This sequence first builds and then recompiles
  11573. <filename>matchbox-desktop</filename>.
  11574. The last command reruns all tasks (basically the packaging
  11575. tasks) after the compile.
  11576. BitBake recognizes that the <filename>do_compile</filename>
  11577. task was rerun and therefore understands that the other tasks
  11578. also need to be run again.
  11579. </para>
  11580. <para>
  11581. Another, shorter way to rerun a task and all
  11582. <ulink url='&YOCTO_DOCS_REF_URL;#normal-recipe-build-tasks'>normal recipe build tasks</ulink>
  11583. that depend on it is to use the <filename>-C</filename>
  11584. option.
  11585. <note>
  11586. This option is upper-cased and is separate from the
  11587. <filename>-c</filename> option, which is lower-cased.
  11588. </note>
  11589. Using this option invalidates the given task and then runs the
  11590. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-build'><filename>do_build</filename></ulink>
  11591. task, which is the default task if no task is given, and the
  11592. tasks on which it depends.
  11593. You could replace the final two commands in the previous example
  11594. with the following single command:
  11595. <literallayout class='monospaced'>
  11596. $ bitbake matchbox-desktop -C compile
  11597. </literallayout>
  11598. Internally, the <filename>-f</filename> and
  11599. <filename>-C</filename> options work by tainting (modifying) the
  11600. input checksum of the specified task.
  11601. This tainting indirectly causes the task and its
  11602. dependent tasks to be rerun through the normal task dependency
  11603. mechanisms.
  11604. <note>
  11605. BitBake explicitly keeps track of which tasks have been
  11606. tainted in this fashion, and will print warnings such as the
  11607. following for builds involving such tasks:
  11608. <literallayout class='monospaced'>
  11609. WARNING: /home/ulf/poky/meta/recipes-sato/matchbox-desktop/matchbox-desktop_2.1.bb.do_compile is tainted from a forced run
  11610. </literallayout>
  11611. The purpose of the warning is to let you know that the work
  11612. directory and build output might not be in the clean state
  11613. they would be in for a "normal" build, depending on what
  11614. actions you took.
  11615. To get rid of such warnings, you can remove the work
  11616. directory and rebuild the recipe, as follows:
  11617. <literallayout class='monospaced'>
  11618. $ bitbake matchbox-desktop -c clean
  11619. $ bitbake matchbox-desktop
  11620. </literallayout>
  11621. </note>
  11622. </para>
  11623. <para>
  11624. You can view a list of tasks in a given package by running the
  11625. <filename>do_listtasks</filename> task as follows:
  11626. <literallayout class='monospaced'>
  11627. $ bitbake matchbox-desktop -c listtasks
  11628. </literallayout>
  11629. The results appear as output to the console and are also in the
  11630. file <filename>${WORKDIR}/temp/log.do_listtasks</filename>.
  11631. </para>
  11632. </section>
  11633. <section id='dev-debugging-bitbake'>
  11634. <title>General BitBake Problems</title>
  11635. <para>
  11636. You can see debug output from BitBake by using the
  11637. <filename>-D</filename> option.
  11638. The debug output gives more information about what BitBake
  11639. is doing and the reason behind it.
  11640. Each <filename>-D</filename> option you use increases the
  11641. logging level.
  11642. The most common usage is <filename>-DDD</filename>.
  11643. </para>
  11644. <para>
  11645. The output from
  11646. <filename>bitbake -DDD -v</filename> <replaceable>targetname</replaceable>
  11647. can reveal why BitBake chose a certain version of a package or
  11648. why BitBake picked a certain provider.
  11649. This command could also help you in a situation where you think
  11650. BitBake did something unexpected.
  11651. </para>
  11652. </section>
  11653. <section id='dev-debugging-buildfile'>
  11654. <title>Building with No Dependencies</title>
  11655. <para>
  11656. To build a specific recipe (<filename>.bb</filename> file),
  11657. you can use the following command form:
  11658. <literallayout class='monospaced'>
  11659. $ bitbake -b <replaceable>somepath</replaceable>/<replaceable>somerecipe</replaceable>.bb
  11660. </literallayout>
  11661. This command form does not check for dependencies.
  11662. Consequently, you should use it only when you know existing
  11663. dependencies have been met.
  11664. <note>
  11665. You can also specify fragments of the filename.
  11666. In this case, BitBake checks for a unique match.
  11667. </note>
  11668. </para>
  11669. </section>
  11670. <section id='recipe-logging-mechanisms'>
  11671. <title>Recipe Logging Mechanisms</title>
  11672. <para>
  11673. The Yocto Project provides several logging functions for
  11674. producing debugging output and reporting errors and warnings.
  11675. For Python functions, the following logging functions exist.
  11676. All of these functions log to
  11677. <filename>${T}/log.do_</filename><replaceable>task</replaceable>,
  11678. and can also log to standard output (stdout) with the right
  11679. settings:
  11680. <itemizedlist>
  11681. <listitem><para>
  11682. <filename>bb.plain(</filename><replaceable>msg</replaceable><filename>)</filename>:
  11683. Writes <replaceable>msg</replaceable> as is to the
  11684. log while also logging to stdout.
  11685. </para></listitem>
  11686. <listitem><para>
  11687. <filename>bb.note(</filename><replaceable>msg</replaceable><filename>)</filename>:
  11688. Writes "NOTE: <replaceable>msg</replaceable>" to the
  11689. log.
  11690. Also logs to stdout if BitBake is called with "-v".
  11691. </para></listitem>
  11692. <listitem><para>
  11693. <filename>bb.debug(</filename><replaceable>level</replaceable><filename>,&nbsp;</filename><replaceable>msg</replaceable><filename>)</filename>:
  11694. Writes "DEBUG: <replaceable>msg</replaceable>" to the
  11695. log.
  11696. Also logs to stdout if the log level is greater than or
  11697. equal to <replaceable>level</replaceable>.
  11698. See the
  11699. "<ulink url='&YOCTO_DOCS_BB_URL;#usage-and-syntax'>-D</ulink>"
  11700. option in the BitBake User Manual for more information.
  11701. </para></listitem>
  11702. <listitem><para>
  11703. <filename>bb.warn(</filename><replaceable>msg</replaceable><filename>)</filename>:
  11704. Writes "WARNING: <replaceable>msg</replaceable>" to the
  11705. log while also logging to stdout.
  11706. </para></listitem>
  11707. <listitem><para>
  11708. <filename>bb.error(</filename><replaceable>msg</replaceable><filename>)</filename>:
  11709. Writes "ERROR: <replaceable>msg</replaceable>" to the
  11710. log while also logging to standard out (stdout).
  11711. <note>
  11712. Calling this function does not cause the task to fail.
  11713. </note>
  11714. </para></listitem>
  11715. <listitem><para>
  11716. <filename>bb.fatal(</filename><replaceable>msg</replaceable><filename>)</filename>:
  11717. This logging function is similar to
  11718. <filename>bb.error(</filename><replaceable>msg</replaceable><filename>)</filename>
  11719. but also causes the calling task to fail.
  11720. <note>
  11721. <filename>bb.fatal()</filename> raises an exception,
  11722. which means you do not need to put a "return"
  11723. statement after the function.
  11724. </note>
  11725. </para></listitem>
  11726. </itemizedlist>
  11727. </para>
  11728. <para>
  11729. The same logging functions are also available in shell
  11730. functions, under the names
  11731. <filename>bbplain</filename>, <filename>bbnote</filename>,
  11732. <filename>bbdebug</filename>, <filename>bbwarn</filename>,
  11733. <filename>bberror</filename>, and <filename>bbfatal</filename>.
  11734. The
  11735. <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-logging'><filename>logging</filename></ulink>
  11736. class implements these functions.
  11737. See that class in the
  11738. <filename>meta/classes</filename> folder of the
  11739. <ulink url='&YOCTO_DOCS_REF_URL;#source-directory'>Source Directory</ulink>
  11740. for information.
  11741. </para>
  11742. <section id='logging-with-python'>
  11743. <title>Logging With Python</title>
  11744. <para>
  11745. When creating recipes using Python and inserting code that
  11746. handles build logs, keep in mind the goal is to have
  11747. informative logs while keeping the console as "silent" as
  11748. possible.
  11749. Also, if you want status messages in the log, use the
  11750. "debug" loglevel.
  11751. </para>
  11752. <para>
  11753. Following is an example written in Python.
  11754. The code handles logging for a function that determines the
  11755. number of tasks needed to be run.
  11756. See the
  11757. "<ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-listtasks'><filename>do_listtasks</filename></ulink>"
  11758. section for additional information:
  11759. <literallayout class='monospaced'>
  11760. python do_listtasks() {
  11761. bb.debug(2, "Starting to figure out the task list")
  11762. if noteworthy_condition:
  11763. bb.note("There are 47 tasks to run")
  11764. bb.debug(2, "Got to point xyz")
  11765. if warning_trigger:
  11766. bb.warn("Detected warning_trigger, this might be a problem later.")
  11767. if recoverable_error:
  11768. bb.error("Hit recoverable_error, you really need to fix this!")
  11769. if fatal_error:
  11770. bb.fatal("fatal_error detected, unable to print the task list")
  11771. bb.plain("The tasks present are abc")
  11772. bb.debug(2, "Finished figuring out the tasklist")
  11773. }
  11774. </literallayout>
  11775. </para>
  11776. </section>
  11777. <section id='logging-with-bash'>
  11778. <title>Logging With Bash</title>
  11779. <para>
  11780. When creating recipes using Bash and inserting code that
  11781. handles build logs, you have the same goals - informative
  11782. with minimal console output.
  11783. The syntax you use for recipes written in Bash is similar
  11784. to that of recipes written in Python described in the
  11785. previous section.
  11786. </para>
  11787. <para>
  11788. Following is an example written in Bash.
  11789. The code logs the progress of the <filename>do_my_function</filename> function.
  11790. <literallayout class='monospaced'>
  11791. do_my_function() {
  11792. bbdebug 2 "Running do_my_function"
  11793. if [ exceptional_condition ]; then
  11794. bbnote "Hit exceptional_condition"
  11795. fi
  11796. bbdebug 2 "Got to point xyz"
  11797. if [ warning_trigger ]; then
  11798. bbwarn "Detected warning_trigger, this might cause a problem later."
  11799. fi
  11800. if [ recoverable_error ]; then
  11801. bberror "Hit recoverable_error, correcting"
  11802. fi
  11803. if [ fatal_error ]; then
  11804. bbfatal "fatal_error detected"
  11805. fi
  11806. bbdebug 2 "Completed do_my_function"
  11807. }
  11808. </literallayout>
  11809. </para>
  11810. </section>
  11811. </section>
  11812. <section id='debugging-parallel-make-races'>
  11813. <title>Debugging Parallel Make Races</title>
  11814. <para>
  11815. A parallel <filename>make</filename> race occurs when the build
  11816. consists of several parts that are run simultaneously and
  11817. a situation occurs when the output or result of one
  11818. part is not ready for use with a different part of the build
  11819. that depends on that output.
  11820. Parallel make races are annoying and can sometimes be difficult
  11821. to reproduce and fix.
  11822. However, some simple tips and tricks exist that can help
  11823. you debug and fix them.
  11824. This section presents a real-world example of an error
  11825. encountered on the Yocto Project autobuilder and the process
  11826. used to fix it.
  11827. <note>
  11828. If you cannot properly fix a <filename>make</filename> race
  11829. condition, you can work around it by clearing either the
  11830. <ulink url='&YOCTO_DOCS_REF_URL;#var-PARALLEL_MAKE'><filename>PARALLEL_MAKE</filename></ulink>
  11831. or
  11832. <ulink url='&YOCTO_DOCS_REF_URL;#var-PARALLEL_MAKEINST'><filename>PARALLEL_MAKEINST</filename></ulink>
  11833. variables.
  11834. </note>
  11835. </para>
  11836. <section id='the-failure'>
  11837. <title>The Failure</title>
  11838. <para>
  11839. For this example, assume that you are building an image that
  11840. depends on the "neard" package.
  11841. And, during the build, BitBake runs into problems and
  11842. creates the following output.
  11843. <note>
  11844. This example log file has longer lines artificially
  11845. broken to make the listing easier to read.
  11846. </note>
  11847. If you examine the output or the log file, you see the
  11848. failure during <filename>make</filename>:
  11849. <literallayout class='monospaced'>
  11850. | DEBUG: SITE files ['endian-little', 'bit-32', 'ix86-common', 'common-linux', 'common-glibc', 'i586-linux', 'common']
  11851. | DEBUG: Executing shell function do_compile
  11852. | NOTE: make -j 16
  11853. | make --no-print-directory all-am
  11854. | /bin/mkdir -p include/near
  11855. | /bin/mkdir -p include/near
  11856. | /bin/mkdir -p include/near
  11857. | ln -s /home/pokybuild/yocto-autobuilder/yocto-slave/nightly-x86/build/build/tmp/work/i586-poky-linux/neard/
  11858. 0.14-r0/neard-0.14/include/types.h include/near/types.h
  11859. | ln -s /home/pokybuild/yocto-autobuilder/yocto-slave/nightly-x86/build/build/tmp/work/i586-poky-linux/neard/
  11860. 0.14-r0/neard-0.14/include/log.h include/near/log.h
  11861. | ln -s /home/pokybuild/yocto-autobuilder/yocto-slave/nightly-x86/build/build/tmp/work/i586-poky-linux/neard/
  11862. 0.14-r0/neard-0.14/include/plugin.h include/near/plugin.h
  11863. | /bin/mkdir -p include/near
  11864. | /bin/mkdir -p include/near
  11865. | /bin/mkdir -p include/near
  11866. | ln -s /home/pokybuild/yocto-autobuilder/yocto-slave/nightly-x86/build/build/tmp/work/i586-poky-linux/neard/
  11867. 0.14-r0/neard-0.14/include/tag.h include/near/tag.h
  11868. | /bin/mkdir -p include/near
  11869. | ln -s /home/pokybuild/yocto-autobuilder/yocto-slave/nightly-x86/build/build/tmp/work/i586-poky-linux/neard/
  11870. 0.14-r0/neard-0.14/include/adapter.h include/near/adapter.h
  11871. | /bin/mkdir -p include/near
  11872. | ln -s /home/pokybuild/yocto-autobuilder/yocto-slave/nightly-x86/build/build/tmp/work/i586-poky-linux/neard/
  11873. 0.14-r0/neard-0.14/include/ndef.h include/near/ndef.h
  11874. | ln -s /home/pokybuild/yocto-autobuilder/yocto-slave/nightly-x86/build/build/tmp/work/i586-poky-linux/neard/
  11875. 0.14-r0/neard-0.14/include/tlv.h include/near/tlv.h
  11876. | /bin/mkdir -p include/near
  11877. | /bin/mkdir -p include/near
  11878. | ln -s /home/pokybuild/yocto-autobuilder/yocto-slave/nightly-x86/build/build/tmp/work/i586-poky-linux/neard/
  11879. 0.14-r0/neard-0.14/include/setting.h include/near/setting.h
  11880. | /bin/mkdir -p include/near
  11881. | /bin/mkdir -p include/near
  11882. | /bin/mkdir -p include/near
  11883. | ln -s /home/pokybuild/yocto-autobuilder/yocto-slave/nightly-x86/build/build/tmp/work/i586-poky-linux/neard/
  11884. 0.14-r0/neard-0.14/include/device.h include/near/device.h
  11885. | ln -s /home/pokybuild/yocto-autobuilder/yocto-slave/nightly-x86/build/build/tmp/work/i586-poky-linux/neard/
  11886. 0.14-r0/neard-0.14/include/nfc_copy.h include/near/nfc_copy.h
  11887. | ln -s /home/pokybuild/yocto-autobuilder/yocto-slave/nightly-x86/build/build/tmp/work/i586-poky-linux/neard/
  11888. 0.14-r0/neard-0.14/include/snep.h include/near/snep.h
  11889. | ln -s /home/pokybuild/yocto-autobuilder/yocto-slave/nightly-x86/build/build/tmp/work/i586-poky-linux/neard/
  11890. 0.14-r0/neard-0.14/include/version.h include/near/version.h
  11891. | ln -s /home/pokybuild/yocto-autobuilder/yocto-slave/nightly-x86/build/build/tmp/work/i586-poky-linux/neard/
  11892. 0.14-r0/neard-0.14/include/dbus.h include/near/dbus.h
  11893. | ./src/genbuiltin nfctype1 nfctype2 nfctype3 nfctype4 p2p > src/builtin.h
  11894. | i586-poky-linux-gcc -m32 -march=i586 --sysroot=/home/pokybuild/yocto-autobuilder/yocto-slave/nightly-x86/
  11895. build/build/tmp/sysroots/qemux86 -DHAVE_CONFIG_H -I. -I./include -I./src -I./gdbus -I/home/pokybuild/
  11896. yocto-autobuilder/yocto-slave/nightly-x86/build/build/tmp/sysroots/qemux86/usr/include/glib-2.0
  11897. -I/home/pokybuild/yocto-autobuilder/yocto-slave/nightly-x86/build/build/tmp/sysroots/qemux86/usr/
  11898. lib/glib-2.0/include -I/home/pokybuild/yocto-autobuilder/yocto-slave/nightly-x86/build/build/
  11899. tmp/sysroots/qemux86/usr/include/dbus-1.0 -I/home/pokybuild/yocto-autobuilder/yocto-slave/
  11900. nightly-x86/build/build/tmp/sysroots/qemux86/usr/lib/dbus-1.0/include -I/home/pokybuild/yocto-autobuilder/
  11901. yocto-slave/nightly-x86/build/build/tmp/sysroots/qemux86/usr/include/libnl3
  11902. -DNEAR_PLUGIN_BUILTIN -DPLUGINDIR=\""/usr/lib/near/plugins"\"
  11903. -DCONFIGDIR=\""/etc/neard\"" -O2 -pipe -g -feliminate-unused-debug-types -c
  11904. -o tools/snep-send.o tools/snep-send.c
  11905. | In file included from tools/snep-send.c:16:0:
  11906. | tools/../src/near.h:41:23: fatal error: near/dbus.h: No such file or directory
  11907. | #include &lt;near/dbus.h&gt;
  11908. | ^
  11909. | compilation terminated.
  11910. | make[1]: *** [tools/snep-send.o] Error 1
  11911. | make[1]: *** Waiting for unfinished jobs....
  11912. | make: *** [all] Error 2
  11913. | ERROR: oe_runmake failed
  11914. </literallayout>
  11915. </para>
  11916. </section>
  11917. <section id='reproducing-the-error'>
  11918. <title>Reproducing the Error</title>
  11919. <para>
  11920. Because race conditions are intermittent, they do not
  11921. manifest themselves every time you do the build.
  11922. In fact, most times the build will complete without problems
  11923. even though the potential race condition exists.
  11924. Thus, once the error surfaces, you need a way to reproduce
  11925. it.
  11926. </para>
  11927. <para>
  11928. In this example, compiling the "neard" package is causing
  11929. the problem.
  11930. So the first thing to do is build "neard" locally.
  11931. Before you start the build, set the
  11932. <ulink url='&YOCTO_DOCS_REF_URL;#var-PARALLEL_MAKE'><filename>PARALLEL_MAKE</filename></ulink>
  11933. variable in your <filename>local.conf</filename> file to
  11934. a high number (e.g. "-j 20").
  11935. Using a high value for <filename>PARALLEL_MAKE</filename>
  11936. increases the chances of the race condition showing up:
  11937. <literallayout class='monospaced'>
  11938. $ bitbake neard
  11939. </literallayout>
  11940. </para>
  11941. <para>
  11942. Once the local build for "neard" completes, start a
  11943. <filename>devshell</filename> build:
  11944. <literallayout class='monospaced'>
  11945. $ bitbake neard -c devshell
  11946. </literallayout>
  11947. For information on how to use a
  11948. <filename>devshell</filename>, see the
  11949. "<link linkend='platdev-appdev-devshell'>Using a Development Shell</link>"
  11950. section.
  11951. </para>
  11952. <para>
  11953. In the <filename>devshell</filename>, do the following:
  11954. <literallayout class='monospaced'>
  11955. $ make clean
  11956. $ make tools/snep-send.o
  11957. </literallayout>
  11958. The <filename>devshell</filename> commands cause the failure
  11959. to clearly be visible.
  11960. In this case, a missing dependency exists for the "neard"
  11961. Makefile target.
  11962. Here is some abbreviated, sample output with the
  11963. missing dependency clearly visible at the end:
  11964. <literallayout class='monospaced'>
  11965. i586-poky-linux-gcc -m32 -march=i586 --sysroot=/home/scott-lenovo/......
  11966. .
  11967. .
  11968. .
  11969. tools/snep-send.c
  11970. In file included from tools/snep-send.c:16:0:
  11971. tools/../src/near.h:41:23: fatal error: near/dbus.h: No such file or directory
  11972. #include &lt;near/dbus.h&gt;
  11973. ^
  11974. compilation terminated.
  11975. make: *** [tools/snep-send.o] Error 1
  11976. $
  11977. </literallayout>
  11978. </para>
  11979. </section>
  11980. <section id='creating-a-patch-for-the-fix'>
  11981. <title>Creating a Patch for the Fix</title>
  11982. <para>
  11983. Because there is a missing dependency for the Makefile
  11984. target, you need to patch the
  11985. <filename>Makefile.am</filename> file, which is generated
  11986. from <filename>Makefile.in</filename>.
  11987. You can use Quilt to create the patch:
  11988. <literallayout class='monospaced'>
  11989. $ quilt new parallelmake.patch
  11990. Patch patches/parallelmake.patch is now on top
  11991. $ quilt add Makefile.am
  11992. File Makefile.am added to patch patches/parallelmake.patch
  11993. </literallayout>
  11994. For more information on using Quilt, see the
  11995. "<link linkend='using-a-quilt-workflow'>Using Quilt in Your Workflow</link>"
  11996. section.
  11997. </para>
  11998. <para>
  11999. At this point you need to make the edits to
  12000. <filename>Makefile.am</filename> to add the missing
  12001. dependency.
  12002. For our example, you have to add the following line
  12003. to the file:
  12004. <literallayout class='monospaced'>
  12005. tools/snep-send.$(OBJEXT): include/near/dbus.h
  12006. </literallayout>
  12007. </para>
  12008. <para>
  12009. Once you have edited the file, use the
  12010. <filename>refresh</filename> command to create the patch:
  12011. <literallayout class='monospaced'>
  12012. $ quilt refresh
  12013. Refreshed patch patches/parallelmake.patch
  12014. </literallayout>
  12015. Once the patch file exists, you need to add it back to the
  12016. originating recipe folder.
  12017. Here is an example assuming a top-level
  12018. <ulink url='&YOCTO_DOCS_REF_URL;#source-directory'>Source Directory</ulink>
  12019. named <filename>poky</filename>:
  12020. <literallayout class='monospaced'>
  12021. $ cp patches/parallelmake.patch poky/meta/recipes-connectivity/neard/neard
  12022. </literallayout>
  12023. The final thing you need to do to implement the fix in the
  12024. build is to update the "neard" recipe (i.e.
  12025. <filename>neard-0.14.bb</filename>) so that the
  12026. <ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'><filename>SRC_URI</filename></ulink>
  12027. statement includes the patch file.
  12028. The recipe file is in the folder above the patch.
  12029. Here is what the edited <filename>SRC_URI</filename>
  12030. statement would look like:
  12031. <literallayout class='monospaced'>
  12032. SRC_URI = "${KERNELORG_MIRROR}/linux/network/nfc/${BPN}-${PV}.tar.xz \
  12033. file://neard.in \
  12034. file://neard.service.in \
  12035. file://parallelmake.patch \
  12036. "
  12037. </literallayout>
  12038. </para>
  12039. <para>
  12040. With the patch complete and moved to the correct folder and
  12041. the <filename>SRC_URI</filename> statement updated, you can
  12042. exit the <filename>devshell</filename>:
  12043. <literallayout class='monospaced'>
  12044. $ exit
  12045. </literallayout>
  12046. </para>
  12047. </section>
  12048. <section id='testing-the-build'>
  12049. <title>Testing the Build</title>
  12050. <para>
  12051. With everything in place, you can get back to trying the
  12052. build again locally:
  12053. <literallayout class='monospaced'>
  12054. $ bitbake neard
  12055. </literallayout>
  12056. This build should succeed.
  12057. </para>
  12058. <para>
  12059. Now you can open up a <filename>devshell</filename> again
  12060. and repeat the clean and make operations as follows:
  12061. <literallayout class='monospaced'>
  12062. $ bitbake neard -c devshell
  12063. $ make clean
  12064. $ make tools/snep-send.o
  12065. </literallayout>
  12066. The build should work without issue.
  12067. </para>
  12068. <para>
  12069. As with all solved problems, if they originated upstream,
  12070. you need to submit the fix for the recipe in OE-Core and
  12071. upstream so that the problem is taken care of at its
  12072. source.
  12073. See the
  12074. "<link linkend='how-to-submit-a-change'>Submitting a Change to the Yocto Project</link>"
  12075. section for more information.
  12076. </para>
  12077. </section>
  12078. </section>
  12079. <section id="platdev-gdb-remotedebug">
  12080. <title>Debugging With the GNU Project Debugger (GDB) Remotely</title>
  12081. <para>
  12082. GDB allows you to examine running programs, which in turn helps
  12083. you to understand and fix problems.
  12084. It also allows you to perform post-mortem style analysis of
  12085. program crashes.
  12086. GDB is available as a package within the Yocto Project and is
  12087. installed in SDK images by default.
  12088. See the
  12089. "<ulink url='&YOCTO_DOCS_REF_URL;#ref-images'>Images</ulink>"
  12090. chapter in the Yocto Project Reference Manual for a description of
  12091. these images.
  12092. You can find information on GDB at
  12093. <ulink url="http://sourceware.org/gdb/"/>.
  12094. <note><title>Tip</title>
  12095. For best results, install debug (<filename>-dbg</filename>)
  12096. packages for the applications you are going to debug.
  12097. Doing so makes extra debug symbols available that give you
  12098. more meaningful output.
  12099. </note>
  12100. </para>
  12101. <para>
  12102. Sometimes, due to memory or disk space constraints, it is not
  12103. possible to use GDB directly on the remote target to debug
  12104. applications.
  12105. These constraints arise because GDB needs to load the debugging
  12106. information and the binaries of the process being debugged.
  12107. Additionally, GDB needs to perform many computations to locate
  12108. information such as function names, variable names and values,
  12109. stack traces and so forth - even before starting the debugging
  12110. process.
  12111. These extra computations place more load on the target system
  12112. and can alter the characteristics of the program being debugged.
  12113. </para>
  12114. <para>
  12115. To help get past the previously mentioned constraints, you can
  12116. use gdbserver, which runs on the remote target and does not
  12117. load any debugging information from the debugged process.
  12118. Instead, a GDB instance processes the debugging information that
  12119. is run on a remote computer - the host GDB.
  12120. The host GDB then sends control commands to gdbserver to make
  12121. it stop or start the debugged program, as well as read or write
  12122. memory regions of that debugged program.
  12123. All the debugging information loaded and processed as well
  12124. as all the heavy debugging is done by the host GDB.
  12125. Offloading these processes gives the gdbserver running on the
  12126. target a chance to remain small and fast.
  12127. </para>
  12128. <para>
  12129. Because the host GDB is responsible for loading the debugging
  12130. information and for doing the necessary processing to make
  12131. actual debugging happen, you have to make sure the host can
  12132. access the unstripped binaries complete with their debugging
  12133. information and also be sure the target is compiled with no
  12134. optimizations.
  12135. The host GDB must also have local access to all the libraries
  12136. used by the debugged program.
  12137. Because gdbserver does not need any local debugging information,
  12138. the binaries on the remote target can remain stripped.
  12139. However, the binaries must also be compiled without optimization
  12140. so they match the host's binaries.
  12141. </para>
  12142. <para>
  12143. To remain consistent with GDB documentation and terminology,
  12144. the binary being debugged on the remote target machine is
  12145. referred to as the "inferior" binary.
  12146. For documentation on GDB see the
  12147. <ulink url="http://sourceware.org/gdb/documentation/">GDB site</ulink>.
  12148. </para>
  12149. <para>
  12150. The following steps show you how to debug using the GNU project
  12151. debugger.
  12152. <orderedlist>
  12153. <listitem><para>
  12154. <emphasis>Configure your build system to construct the
  12155. companion debug filesystem:</emphasis></para>
  12156. <para>In your <filename>local.conf</filename> file, set
  12157. the following:
  12158. <literallayout class='monospaced'>
  12159. IMAGE_GEN_DEBUGFS = "1"
  12160. IMAGE_FSTYPES_DEBUGFS = "tar.bz2"
  12161. </literallayout>
  12162. These options cause the OpenEmbedded build system
  12163. to generate a special companion filesystem fragment,
  12164. which contains the matching source and debug symbols to
  12165. your deployable filesystem.
  12166. The build system does this by looking at what is in the
  12167. deployed filesystem, and pulling the corresponding
  12168. <filename>-dbg</filename> packages.</para>
  12169. <para>The companion debug filesystem is not a complete
  12170. filesystem, but only contains the debug fragments.
  12171. This filesystem must be combined with the full filesystem
  12172. for debugging.
  12173. Subsequent steps in this procedure show how to combine
  12174. the partial filesystem with the full filesystem.
  12175. </para></listitem>
  12176. <listitem><para>
  12177. <emphasis>Configure the system to include gdbserver in
  12178. the target filesystem:</emphasis></para>
  12179. <para>Make the following addition in either your
  12180. <filename>local.conf</filename> file or in an image
  12181. recipe:
  12182. <literallayout class='monospaced'>
  12183. IMAGE_INSTALL_append = “ gdbserver"
  12184. </literallayout>
  12185. The change makes sure the <filename>gdbserver</filename>
  12186. package is included.
  12187. </para></listitem>
  12188. <listitem><para>
  12189. <emphasis>Build the environment:</emphasis></para>
  12190. <para>Use the following command to construct the image
  12191. and the companion Debug Filesystem:
  12192. <literallayout class='monospaced'>
  12193. $ bitbake <replaceable>image</replaceable>
  12194. </literallayout>
  12195. Build the cross GDB component and make it available
  12196. for debugging.
  12197. Build the SDK that matches the image.
  12198. Building the SDK is best for a production build
  12199. that can be used later for debugging, especially
  12200. during long term maintenance:
  12201. <literallayout class='monospaced'>
  12202. $ bitbake -c populate_sdk <replaceable>image</replaceable>
  12203. </literallayout></para>
  12204. <para>Alternatively, you can build the minimal
  12205. toolchain components that match the target.
  12206. Doing so creates a smaller than typical SDK and only
  12207. contains a minimal set of components with which to
  12208. build simple test applications, as well as run the
  12209. debugger:
  12210. <literallayout class='monospaced'>
  12211. $ bitbake meta-toolchain
  12212. </literallayout></para>
  12213. <para>A final method is to build Gdb itself within
  12214. the build system:
  12215. <literallayout class='monospaced'>
  12216. $ bitbake gdb-cross-<replaceable>architecture</replaceable>
  12217. </literallayout>
  12218. Doing so produces a temporary copy of
  12219. <filename>cross-gdb</filename> you can use for
  12220. debugging during development.
  12221. While this is the quickest approach, the two previous
  12222. methods in this step are better when considering
  12223. long-term maintenance strategies.
  12224. <note>
  12225. If you run
  12226. <filename>bitbake gdb-cross</filename>, the
  12227. OpenEmbedded build system suggests the actual
  12228. image (e.g. <filename>gdb-cross-i586</filename>).
  12229. The suggestion is usually the actual name you want
  12230. to use.
  12231. </note>
  12232. </para></listitem>
  12233. <listitem><para>
  12234. <emphasis>Set up the</emphasis>&nbsp;<filename>debugfs</filename></para>
  12235. <para>Run the following commands to set up the
  12236. <filename>debugfs</filename>:
  12237. <literallayout class='monospaced'>
  12238. $ mkdir debugfs
  12239. $ cd debugfs
  12240. $ tar xvfj <replaceable>build-dir</replaceable>/tmp-glibc/deploy/images/<replaceable>machine</replaceable>/<replaceable>image</replaceable>.rootfs.tar.bz2
  12241. $ tar xvfj <replaceable>build-dir</replaceable>/tmp-glibc/deploy/images/<replaceable>machine</replaceable>/<replaceable>image</replaceable>-dbg.rootfs.tar.bz2
  12242. </literallayout>
  12243. </para></listitem>
  12244. <listitem><para>
  12245. <emphasis>Set up GDB</emphasis></para>
  12246. <para>Install the SDK (if you built one) and then
  12247. source the correct environment file.
  12248. Sourcing the environment file puts the SDK in your
  12249. <filename>PATH</filename> environment variable.</para>
  12250. <para>If you are using the build system, Gdb is
  12251. located in
  12252. <replaceable>build-dir</replaceable>/tmp/sysroots/<replaceable>host</replaceable>/usr/bin/<replaceable>architecture</replaceable>/<replaceable>architecture</replaceable>-gdb
  12253. </para></listitem>
  12254. <listitem><para>
  12255. <emphasis>Boot the target:</emphasis></para>
  12256. <para>For information on how to run QEMU, see the
  12257. <ulink url='http://wiki.qemu.org/Documentation/GettingStartedDevelopers'>QEMU Documentation</ulink>.
  12258. <note>
  12259. Be sure to verify that your host can access the
  12260. target via TCP.
  12261. </note>
  12262. </para></listitem>
  12263. <listitem><para>
  12264. <emphasis>Debug a program:</emphasis></para>
  12265. <para>Debugging a program involves running gdbserver
  12266. on the target and then running Gdb on the host.
  12267. The example in this step debugs
  12268. <filename>gzip</filename>:
  12269. <literallayout class='monospaced'>
  12270. root@qemux86:~# gdbserver localhost:1234 /bin/gzip —help
  12271. </literallayout>
  12272. For additional gdbserver options, see the
  12273. <ulink url='https://www.gnu.org/software/gdb/documentation/'>GDB Server Documentation</ulink>.
  12274. </para>
  12275. <para>After running gdbserver on the target, you need
  12276. to run Gdb on the host and configure it and connect to
  12277. the target.
  12278. Use these commands:
  12279. <literallayout class='monospaced'>
  12280. $ cd <replaceable>directory-holding-the-debugfs-directory</replaceable>
  12281. $ <replaceable>arch</replaceable>-gdb
  12282. (gdb) set sysroot debugfs
  12283. (gdb) set substitute-path /usr/src/debug debugfs/usr/src/debug
  12284. (gdb) target remote <replaceable>IP-of-target</replaceable>:1234
  12285. </literallayout>
  12286. At this point, everything should automatically load
  12287. (i.e. matching binaries, symbols and headers).
  12288. <note>
  12289. The Gdb <filename>set</filename> commands in the
  12290. previous example can be placed into the users
  12291. <filename>~/.gdbinit</filename> file.
  12292. Upon starting, Gdb automatically runs whatever
  12293. commands are in that file.
  12294. </note>
  12295. </para></listitem>
  12296. <listitem><para>
  12297. <emphasis>Deploying without a full image
  12298. rebuild:</emphasis></para>
  12299. <para>In many cases, during development you want a
  12300. quick method to deploy a new binary to the target and
  12301. debug it, without waiting for a full image build.
  12302. </para>
  12303. <para>One approach to solving this situation is to
  12304. just build the component you want to debug.
  12305. Once you have built the component, copy the
  12306. executable directly to both the target and the
  12307. host <filename>debugfs</filename>.</para>
  12308. <para>If the binary is processed through the debug
  12309. splitting in OpenEmbedded, you should also
  12310. copy the debug items (i.e. <filename>.debug</filename>
  12311. contents and corresponding
  12312. <filename>/usr/src/debug</filename> files)
  12313. from the work directory.
  12314. Here is an example:
  12315. <literallayout class='monospaced'>
  12316. $ bitbake bash
  12317. $ bitbake -c devshell bash
  12318. $ cd ..
  12319. $ scp packages-split/bash/bin/bash <replaceable>target</replaceable>:/bin/bash
  12320. $ cp -a packages-split/bash-dbg/* <replaceable>path</replaceable>/debugfs
  12321. </literallayout>
  12322. </para></listitem>
  12323. </orderedlist>
  12324. </para>
  12325. </section>
  12326. <section id='debugging-with-the-gnu-project-debugger-gdb-on-the-target'>
  12327. <title>Debugging with the GNU Project Debugger (GDB) on the Target</title>
  12328. <para>
  12329. The previous section addressed using GDB remotely for debugging
  12330. purposes, which is the most usual case due to the inherent
  12331. hardware limitations on many embedded devices.
  12332. However, debugging in the target hardware itself is also
  12333. possible with more powerful devices.
  12334. This section describes what you need to do in order to support
  12335. using GDB to debug on the target hardware.
  12336. </para>
  12337. <para>
  12338. To support this kind of debugging, you need do the following:
  12339. <itemizedlist>
  12340. <listitem><para>
  12341. Ensure that GDB is on the target.
  12342. You can do this by adding "gdb" to
  12343. <ulink url='&YOCTO_DOCS_REF_URL;#var-IMAGE_INSTALL'><filename>IMAGE_INSTALL</filename></ulink>:
  12344. <literallayout class='monospaced'>
  12345. IMAGE_INSTALL_append = " gdb"
  12346. </literallayout>
  12347. Alternatively, you can add "tools-debug" to
  12348. <ulink url='&YOCTO_DOCS_REF_URL;#var-IMAGE_FEATURES'><filename>IMAGE_FEATURES</filename></ulink>:
  12349. <literallayout class='monospaced'>
  12350. IMAGE_FEATURES_append = " tools-debug"
  12351. </literallayout>
  12352. </para></listitem>
  12353. <listitem><para>
  12354. Ensure that debug symbols are present.
  12355. You can make sure these symbols are present by
  12356. installing <filename>-dbg</filename>:
  12357. <literallayout class='monospaced'>
  12358. IMAGE_INSTALL_append = " <replaceable>packagename</replaceable>-dbg"
  12359. </literallayout>
  12360. Alternatively, you can do the following to include all
  12361. the debug symbols:
  12362. <literallayout class='monospaced'>
  12363. IMAGE_FEATURES_append = " dbg-pkgs"
  12364. </literallayout>
  12365. </para></listitem>
  12366. </itemizedlist>
  12367. <note>
  12368. To improve the debug information accuracy, you can reduce
  12369. the level of optimization used by the compiler.
  12370. For example, when adding the following line to your
  12371. <filename>local.conf</filename> file, you will reduce
  12372. optimization from
  12373. <ulink url='&YOCTO_DOCS_REF_URL;#var-FULL_OPTIMIZATION'><filename>FULL_OPTIMIZATION</filename></ulink>
  12374. of "-O2" to
  12375. <ulink url='&YOCTO_DOCS_REF_URL;#var-DEBUG_OPTIMIZATION'><filename>DEBUG_OPTIMIZATION</filename></ulink>
  12376. of "-O -fno-omit-frame-pointer":
  12377. <literallayout class='monospaced'>
  12378. DEBUG_BUILD = "1"
  12379. </literallayout>
  12380. Consider that this will reduce the application's performance
  12381. and is recommended only for debugging purposes.
  12382. </note>
  12383. </para>
  12384. </section>
  12385. <section id='dev-other-debugging-others'>
  12386. <title>Other Debugging Tips</title>
  12387. <para>
  12388. Here are some other tips that you might find useful:
  12389. <itemizedlist>
  12390. <listitem><para>
  12391. When adding new packages, it is worth watching for
  12392. undesirable items making their way into compiler command
  12393. lines.
  12394. For example, you do not want references to local system
  12395. files like
  12396. <filename>/usr/lib/</filename> or
  12397. <filename>/usr/include/</filename>.
  12398. </para></listitem>
  12399. <listitem><para>
  12400. If you want to remove the <filename>psplash</filename>
  12401. boot splashscreen,
  12402. add <filename>psplash=false</filename> to the kernel
  12403. command line.
  12404. Doing so prevents <filename>psplash</filename> from
  12405. loading and thus allows you to see the console.
  12406. It is also possible to switch out of the splashscreen by
  12407. switching the virtual console (e.g. Fn+Left or Fn+Right
  12408. on a Zaurus).
  12409. </para></listitem>
  12410. <listitem><para>
  12411. Removing
  12412. <ulink url='&YOCTO_DOCS_REF_URL;#var-TMPDIR'><filename>TMPDIR</filename></ulink>
  12413. (usually <filename>tmp/</filename>, within the
  12414. <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink>)
  12415. can often fix temporary build issues.
  12416. Removing <filename>TMPDIR</filename> is usually a
  12417. relatively cheap operation, because task output will be
  12418. cached in
  12419. <ulink url='&YOCTO_DOCS_REF_URL;#var-SSTATE_DIR'><filename>SSTATE_DIR</filename></ulink>
  12420. (usually <filename>sstate-cache/</filename>, which is
  12421. also in the Build Directory).
  12422. <note>
  12423. Removing <filename>TMPDIR</filename> might be a
  12424. workaround rather than a fix.
  12425. Consequently, trying to determine the underlying
  12426. cause of an issue before removing the directory is
  12427. a good idea.
  12428. </note>
  12429. </para></listitem>
  12430. <listitem><para>
  12431. Understanding how a feature is used in practice within
  12432. existing recipes can be very helpful.
  12433. It is recommended that you configure some method that
  12434. allows you to quickly search through files.</para>
  12435. <para>Using GNU Grep, you can use the following shell
  12436. function to recursively search through common
  12437. recipe-related files, skipping binary files,
  12438. <filename>.git</filename> directories, and the
  12439. Build Directory (assuming its name starts with
  12440. "build"):
  12441. <literallayout class='monospaced'>
  12442. g() {
  12443. grep -Ir \
  12444. --exclude-dir=.git \
  12445. --exclude-dir='build*' \
  12446. --include='*.bb*' \
  12447. --include='*.inc*' \
  12448. --include='*.conf*' \
  12449. --include='*.py*' \
  12450. "$@"
  12451. }
  12452. </literallayout>
  12453. Following are some usage examples:
  12454. <literallayout class='monospaced'>
  12455. $ g FOO # Search recursively for "FOO"
  12456. $ g -i foo # Search recursively for "foo", ignoring case
  12457. $ g -w FOO # Search recursively for "FOO" as a word, ignoring e.g. "FOOBAR"
  12458. </literallayout>
  12459. If figuring out how some feature works requires a lot of
  12460. searching, it might indicate that the documentation
  12461. should be extended or improved.
  12462. In such cases, consider filing a documentation bug using
  12463. the Yocto Project implementation of
  12464. <ulink url='https://bugzilla.yoctoproject.org/'>Bugzilla</ulink>.
  12465. For information on how to submit a bug against
  12466. the Yocto Project, see the Yocto Project Bugzilla
  12467. <ulink url='&YOCTO_WIKI_URL;/wiki/Bugzilla_Configuration_and_Bug_Tracking'>wiki page</ulink>
  12468. and the
  12469. "<link linkend='submitting-a-defect-against-the-yocto-project'>Submitting a Defect Against the Yocto Project</link>"
  12470. section.
  12471. <note>
  12472. The manuals might not be the right place to document
  12473. variables that are purely internal and have a
  12474. limited scope (e.g. internal variables used to
  12475. implement a single <filename>.bbclass</filename>
  12476. file).
  12477. </note>
  12478. </para></listitem>
  12479. </itemizedlist>
  12480. </para>
  12481. </section>
  12482. </section>
  12483. <section id='maintaining-open-source-license-compliance-during-your-products-lifecycle'>
  12484. <title>Maintaining Open Source License Compliance During Your Product's Lifecycle</title>
  12485. <para>
  12486. One of the concerns for a development organization using open source
  12487. software is how to maintain compliance with various open source
  12488. licensing during the lifecycle of the product.
  12489. While this section does not provide legal advice or
  12490. comprehensively cover all scenarios, it does
  12491. present methods that you can use to
  12492. assist you in meeting the compliance requirements during a software
  12493. release.
  12494. </para>
  12495. <para>
  12496. With hundreds of different open source licenses that the Yocto
  12497. Project tracks, it is difficult to know the requirements of each
  12498. and every license.
  12499. However, the requirements of the major FLOSS licenses can begin
  12500. to be covered by
  12501. assuming that three main areas of concern exist:
  12502. <itemizedlist>
  12503. <listitem><para>Source code must be provided.</para></listitem>
  12504. <listitem><para>License text for the software must be
  12505. provided.</para></listitem>
  12506. <listitem><para>Compilation scripts and modifications to the
  12507. source code must be provided.
  12508. </para></listitem>
  12509. </itemizedlist>
  12510. There are other requirements beyond the scope of these
  12511. three and the methods described in this section
  12512. (e.g. the mechanism through which source code is distributed).
  12513. </para>
  12514. <para>
  12515. As different organizations have different methods of complying with
  12516. open source licensing, this section is not meant to imply that
  12517. there is only one single way to meet your compliance obligations,
  12518. but rather to describe one method of achieving compliance.
  12519. The remainder of this section describes methods supported to meet the
  12520. previously mentioned three requirements.
  12521. Once you take steps to meet these requirements,
  12522. and prior to releasing images, sources, and the build system,
  12523. you should audit all artifacts to ensure completeness.
  12524. <note>
  12525. The Yocto Project generates a license manifest during
  12526. image creation that is located
  12527. in <filename>${DEPLOY_DIR}/licenses/<replaceable>image_name-datestamp</replaceable></filename>
  12528. to assist with any audits.
  12529. </note>
  12530. </para>
  12531. <section id='providing-the-source-code'>
  12532. <title>Providing the Source Code</title>
  12533. <para>
  12534. Compliance activities should begin before you generate the
  12535. final image.
  12536. The first thing you should look at is the requirement that
  12537. tops the list for most compliance groups - providing
  12538. the source.
  12539. The Yocto Project has a few ways of meeting this
  12540. requirement.
  12541. </para>
  12542. <para>
  12543. One of the easiest ways to meet this requirement is
  12544. to provide the entire
  12545. <ulink url='&YOCTO_DOCS_REF_URL;#var-DL_DIR'><filename>DL_DIR</filename></ulink>
  12546. used by the build.
  12547. This method, however, has a few issues.
  12548. The most obvious is the size of the directory since it includes
  12549. all sources used in the build and not just the source used in
  12550. the released image.
  12551. It will include toolchain source, and other artifacts, which
  12552. you would not generally release.
  12553. However, the more serious issue for most companies is accidental
  12554. release of proprietary software.
  12555. The Yocto Project provides an
  12556. <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-archiver'><filename>archiver</filename></ulink>
  12557. class to help avoid some of these concerns.
  12558. </para>
  12559. <para>
  12560. Before you employ <filename>DL_DIR</filename> or the
  12561. <filename>archiver</filename> class, you need to decide how
  12562. you choose to provide source.
  12563. The source <filename>archiver</filename> class can generate
  12564. tarballs and SRPMs and can create them with various levels of
  12565. compliance in mind.
  12566. </para>
  12567. <para>
  12568. One way of doing this (but certainly not the only way) is to
  12569. release just the source as a tarball.
  12570. You can do this by adding the following to the
  12571. <filename>local.conf</filename> file found in the
  12572. <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink>:
  12573. <literallayout class='monospaced'>
  12574. INHERIT += "archiver"
  12575. ARCHIVER_MODE[src] = "original"
  12576. </literallayout>
  12577. During the creation of your image, the source from all
  12578. recipes that deploy packages to the image is placed within
  12579. subdirectories of
  12580. <filename>DEPLOY_DIR/sources</filename> based on the
  12581. <ulink url='&YOCTO_DOCS_REF_URL;#var-LICENSE'><filename>LICENSE</filename></ulink>
  12582. for each recipe.
  12583. Releasing the entire directory enables you to comply with
  12584. requirements concerning providing the unmodified source.
  12585. It is important to note that the size of the directory can
  12586. get large.
  12587. </para>
  12588. <para>
  12589. A way to help mitigate the size issue is to only release
  12590. tarballs for licenses that require the release of
  12591. source.
  12592. Let us assume you are only concerned with GPL code as
  12593. identified by running the following script:
  12594. <literallayout class='monospaced'>
  12595. # Script to archive a subset of packages matching specific license(s)
  12596. # Source and license files are copied into sub folders of package folder
  12597. # Must be run from build folder
  12598. #!/bin/bash
  12599. src_release_dir="source-release"
  12600. mkdir -p $src_release_dir
  12601. for a in tmp/deploy/sources/*; do
  12602. for d in $a/*; do
  12603. # Get package name from path
  12604. p=`basename $d`
  12605. p=${p%-*}
  12606. p=${p%-*}
  12607. # Only archive GPL packages (update *GPL* regex for your license check)
  12608. numfiles=`ls tmp/deploy/licenses/$p/*GPL* 2> /dev/null | wc -l`
  12609. if [ $numfiles -gt 1 ]; then
  12610. echo Archiving $p
  12611. mkdir -p $src_release_dir/$p/source
  12612. cp $d/* $src_release_dir/$p/source 2> /dev/null
  12613. mkdir -p $src_release_dir/$p/license
  12614. cp tmp/deploy/licenses/$p/* $src_release_dir/$p/license 2> /dev/null
  12615. fi
  12616. done
  12617. done </literallayout>
  12618. At this point, you could create a tarball from the
  12619. <filename>gpl_source_release</filename> directory and
  12620. provide that to the end user.
  12621. This method would be a step toward achieving compliance
  12622. with section 3a of GPLv2 and with section 6 of GPLv3.
  12623. </para>
  12624. </section>
  12625. <section id='providing-license-text'>
  12626. <title>Providing License Text</title>
  12627. <para>
  12628. One requirement that is often overlooked is inclusion
  12629. of license text.
  12630. This requirement also needs to be dealt with prior to
  12631. generating the final image.
  12632. Some licenses require the license text to accompany
  12633. the binary.
  12634. You can achieve this by adding the following to your
  12635. <filename>local.conf</filename> file:
  12636. <literallayout class='monospaced'>
  12637. COPY_LIC_MANIFEST = "1"
  12638. COPY_LIC_DIRS = "1"
  12639. LICENSE_CREATE_PACKAGE = "1"
  12640. </literallayout>
  12641. Adding these statements to the configuration file ensures
  12642. that the licenses collected during package generation
  12643. are included on your image.
  12644. <note>
  12645. <para>Setting all three variables to "1" results in the
  12646. image having two copies of the same license file.
  12647. One copy resides in
  12648. <filename>/usr/share/common-licenses</filename> and
  12649. the other resides in
  12650. <filename>/usr/share/license</filename>.</para>
  12651. <para>The reason for this behavior is because
  12652. <ulink url='&YOCTO_DOCS_REF_URL;#var-COPY_LIC_DIRS'><filename>COPY_LIC_DIRS</filename></ulink>
  12653. and
  12654. <ulink url='&YOCTO_DOCS_REF_URL;#var-COPY_LIC_MANIFEST'><filename>COPY_LIC_MANIFEST</filename></ulink>
  12655. add a copy of the license when the image is built but do
  12656. not offer a path for adding licenses for newly installed
  12657. packages to an image.
  12658. <ulink url='&YOCTO_DOCS_REF_URL;#var-LICENSE_CREATE_PACKAGE'><filename>LICENSE_CREATE_PACKAGE</filename></ulink>
  12659. adds a separate package and an upgrade path for adding
  12660. licenses to an image.</para>
  12661. </note>
  12662. </para>
  12663. <para>
  12664. As the source <filename>archiver</filename> class has already
  12665. archived the original
  12666. unmodified source that contains the license files,
  12667. you would have already met the requirements for inclusion
  12668. of the license information with source as defined by the GPL
  12669. and other open source licenses.
  12670. </para>
  12671. </section>
  12672. <section id='providing-compilation-scripts-and-source-code-modifications'>
  12673. <title>Providing Compilation Scripts and Source Code Modifications</title>
  12674. <para>
  12675. At this point, we have addressed all we need to
  12676. prior to generating the image.
  12677. The next two requirements are addressed during the final
  12678. packaging of the release.
  12679. </para>
  12680. <para>
  12681. By releasing the version of the OpenEmbedded build system
  12682. and the layers used during the build, you will be providing both
  12683. compilation scripts and the source code modifications in one
  12684. step.
  12685. </para>
  12686. <para>
  12687. If the deployment team has a
  12688. <ulink url='&YOCTO_DOCS_BSP_URL;#bsp-layers'>BSP layer</ulink>
  12689. and a distro layer, and those those layers are used to patch,
  12690. compile, package, or modify (in any way) any open source
  12691. software included in your released images, you
  12692. might be required to release those layers under section 3 of
  12693. GPLv2 or section 1 of GPLv3.
  12694. One way of doing that is with a clean
  12695. checkout of the version of the Yocto Project and layers used
  12696. during your build.
  12697. Here is an example:
  12698. <literallayout class='monospaced'>
  12699. # We built using the &DISTRO_NAME_NO_CAP; branch of the poky repo
  12700. $ git clone -b &DISTRO_NAME_NO_CAP; git://git.yoctoproject.org/poky
  12701. $ cd poky
  12702. # We built using the release_branch for our layers
  12703. $ git clone -b release_branch git://git.mycompany.com/meta-my-bsp-layer
  12704. $ git clone -b release_branch git://git.mycompany.com/meta-my-software-layer
  12705. # clean up the .git repos
  12706. $ find . -name ".git" -type d -exec rm -rf {} \;
  12707. </literallayout>
  12708. One thing a development organization might want to consider
  12709. for end-user convenience is to modify
  12710. <filename>meta-poky/conf/bblayers.conf.sample</filename> to
  12711. ensure that when the end user utilizes the released build
  12712. system to build an image, the development organization's
  12713. layers are included in the <filename>bblayers.conf</filename>
  12714. file automatically:
  12715. <literallayout class='monospaced'>
  12716. # LAYER_CONF_VERSION is increased each time build/conf/bblayers.conf
  12717. # changes incompatibly
  12718. LCONF_VERSION = "6"
  12719. BBPATH = "${TOPDIR}"
  12720. BBFILES ?= ""
  12721. BBLAYERS ?= " \
  12722. ##OEROOT##/meta \
  12723. ##OEROOT##/meta-poky \
  12724. ##OEROOT##/meta-yocto-bsp \
  12725. ##OEROOT##/meta-mylayer \
  12726. "
  12727. </literallayout>
  12728. Creating and providing an archive of the
  12729. <ulink url='&YOCTO_DOCS_REF_URL;#metadata'>Metadata</ulink>
  12730. layers (recipes, configuration files, and so forth)
  12731. enables you to meet your
  12732. requirements to include the scripts to control compilation
  12733. as well as any modifications to the original source.
  12734. </para>
  12735. </section>
  12736. </section>
  12737. <section id='using-the-error-reporting-tool'>
  12738. <title>Using the Error Reporting Tool</title>
  12739. <para>
  12740. The error reporting tool allows you to
  12741. submit errors encountered during builds to a central database.
  12742. Outside of the build environment, you can use a web interface to
  12743. browse errors, view statistics, and query for errors.
  12744. The tool works using a client-server system where the client
  12745. portion is integrated with the installed Yocto Project
  12746. <ulink url='&YOCTO_DOCS_REF_URL;#source-directory'>Source Directory</ulink>
  12747. (e.g. <filename>poky</filename>).
  12748. The server receives the information collected and saves it in a
  12749. database.
  12750. </para>
  12751. <para>
  12752. A live instance of the error reporting server exists at
  12753. <ulink url='http://errors.yoctoproject.org'></ulink>.
  12754. This server exists so that when you want to get help with
  12755. build failures, you can submit all of the information on the
  12756. failure easily and then point to the URL in your bug report
  12757. or send an email to the mailing list.
  12758. <note>
  12759. If you send error reports to this server, the reports become
  12760. publicly visible.
  12761. </note>
  12762. </para>
  12763. <section id='enabling-and-using-the-tool'>
  12764. <title>Enabling and Using the Tool</title>
  12765. <para>
  12766. By default, the error reporting tool is disabled.
  12767. You can enable it by inheriting the
  12768. <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-report-error'><filename>report-error</filename></ulink>
  12769. class by adding the following statement to the end of
  12770. your <filename>local.conf</filename> file in your
  12771. <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink>.
  12772. <literallayout class='monospaced'>
  12773. INHERIT += "report-error"
  12774. </literallayout>
  12775. </para>
  12776. <para>
  12777. By default, the error reporting feature stores information in
  12778. <filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-LOG_DIR'><filename>LOG_DIR</filename></ulink><filename>}/error-report</filename>.
  12779. However, you can specify a directory to use by adding the following
  12780. to your <filename>local.conf</filename> file:
  12781. <literallayout class='monospaced'>
  12782. ERR_REPORT_DIR = "path"
  12783. </literallayout>
  12784. Enabling error reporting causes the build process to collect
  12785. the errors and store them in a file as previously described.
  12786. When the build system encounters an error, it includes a
  12787. command as part of the console output.
  12788. You can run the command to send the error file to the server.
  12789. For example, the following command sends the errors to an
  12790. upstream server:
  12791. <literallayout class='monospaced'>
  12792. $ send-error-report /home/brandusa/project/poky/build/tmp/log/error-report/error_report_201403141617.txt
  12793. </literallayout>
  12794. In the previous example, the errors are sent to a public
  12795. database available at
  12796. <ulink url='http://errors.yoctoproject.org'></ulink>, which is
  12797. used by the entire community.
  12798. If you specify a particular server, you can send the errors
  12799. to a different database.
  12800. Use the following command for more information on available
  12801. options:
  12802. <literallayout class='monospaced'>
  12803. $ send-error-report --help
  12804. </literallayout>
  12805. </para>
  12806. <para>
  12807. When sending the error file, you are prompted to review the
  12808. data being sent as well as to provide a name and optional
  12809. email address.
  12810. Once you satisfy these prompts, the command returns a link
  12811. from the server that corresponds to your entry in the database.
  12812. For example, here is a typical link:
  12813. <literallayout class='monospaced'>
  12814. http://errors.yoctoproject.org/Errors/Details/9522/
  12815. </literallayout>
  12816. Following the link takes you to a web interface where you can
  12817. browse, query the errors, and view statistics.
  12818. </para>
  12819. </section>
  12820. <section id='disabling-the-tool'>
  12821. <title>Disabling the Tool</title>
  12822. <para>
  12823. To disable the error reporting feature, simply remove or comment
  12824. out the following statement from the end of your
  12825. <filename>local.conf</filename> file in your
  12826. <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink>.
  12827. <literallayout class='monospaced'>
  12828. INHERIT += "report-error"
  12829. </literallayout>
  12830. </para>
  12831. </section>
  12832. <section id='setting-up-your-own-error-reporting-server'>
  12833. <title>Setting Up Your Own Error Reporting Server</title>
  12834. <para>
  12835. If you want to set up your own error reporting server, you
  12836. can obtain the code from the Git repository at
  12837. <ulink url='http://git.yoctoproject.org/cgit/cgit.cgi/error-report-web/'></ulink>.
  12838. Instructions on how to set it up are in the README document.
  12839. </para>
  12840. </section>
  12841. </section>
  12842. </chapter>
  12843. <!--
  12844. vim: expandtab tw=80 ts=4
  12845. -->