dev-manual-common-tasks.xml 552 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634
  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. <link linkend='metadata'>Metadata</link> into multiple layers.
  18. Layers allow you to isolate different types of customizations from
  19. each other.
  20. You might find it tempting to keep everything in one layer when
  21. working on a single project.
  22. However, the more modular your Metadata, the easier
  23. it is to cope with future changes.
  24. </para>
  25. <para>
  26. To illustrate how layers are used to keep things modular, consider
  27. machine customizations.
  28. These types of customizations typically reside in a special layer,
  29. rather than a general layer, called a Board Support Package (BSP)
  30. Layer.
  31. Furthermore, the machine customizations should be isolated from
  32. recipes and Metadata that support a new GUI environment,
  33. for example.
  34. This situation gives you a couple of layers: one for the machine
  35. configurations, and one for the GUI environment.
  36. It is important to understand, however, that the BSP layer can
  37. still make machine-specific additions to recipes within the GUI
  38. environment layer without polluting the GUI layer itself
  39. with those machine-specific changes.
  40. You can accomplish this through a recipe that is a BitBake append
  41. (<filename>.bbappend</filename>) file, which is described later
  42. in this section.
  43. </para>
  44. <para>
  45. </para>
  46. <section id='yocto-project-layers'>
  47. <title>Layers</title>
  48. <para>
  49. The <link linkend='source-directory'>Source Directory</link>
  50. contains both general layers and BSP
  51. layers right out of the box.
  52. You can easily identify layers that ship with a
  53. Yocto Project release in the Source Directory by their
  54. folder names.
  55. Folders that represent layers typically have names that begin with
  56. the string <filename>meta-</filename>.
  57. <note>
  58. It is not a requirement that a layer name begin with the
  59. prefix <filename>meta-</filename>, but it is a commonly
  60. accepted standard in the Yocto Project community.
  61. </note>
  62. For example, when you set up the Source Directory structure,
  63. you will see several layers:
  64. <filename>meta</filename>,
  65. <filename>meta-skeleton</filename>,
  66. <filename>meta-selftest</filename>,
  67. <filename>meta-poky</filename>, and
  68. <filename>meta-yocto-bsp</filename>.
  69. Each of these folders represents a distinct layer.
  70. </para>
  71. <para>
  72. As another example, if you set up a local copy of the
  73. <filename>meta-intel</filename> Git repository
  74. and then explore the folder of that general layer,
  75. you will discover many Intel-specific BSP layers inside.
  76. For more information on BSP layers, see the
  77. "<ulink url='&YOCTO_DOCS_BSP_URL;#bsp-layers'>BSP Layers</ulink>"
  78. section in the Yocto Project Board Support Package (BSP)
  79. Developer's Guide.
  80. </para>
  81. </section>
  82. <section id='creating-your-own-layer'>
  83. <title>Creating Your Own Layer</title>
  84. <para>
  85. It is very easy to create your own layers to use with the
  86. OpenEmbedded build system.
  87. The Yocto Project ships with scripts that speed up creating
  88. general layers and BSP layers.
  89. This section describes the steps you perform by hand to create
  90. a layer so that you can better understand them.
  91. For information about the layer-creation scripts, see the
  92. "<ulink url='&YOCTO_DOCS_BSP_URL;#creating-a-new-bsp-layer-using-the-yocto-bsp-script'>Creating a New BSP Layer Using the yocto-bsp Script</ulink>"
  93. section in the Yocto Project Board Support Package (BSP)
  94. Developer's Guide and the
  95. "<link linkend='creating-a-general-layer-using-the-yocto-layer-script'>Creating a General Layer Using the yocto-layer Script</link>"
  96. section further down in this manual.
  97. </para>
  98. <para>
  99. Follow these general steps to create your layer:
  100. <orderedlist>
  101. <listitem><para><emphasis>Check Existing Layers:</emphasis>
  102. Before creating a new layer, you should be sure someone
  103. has not already created a layer containing the Metadata
  104. you need.
  105. You can see the
  106. <ulink url='http://layers.openembedded.org/layerindex/layers/'><filename>OpenEmbedded Metadata Index</filename></ulink>
  107. for a list of layers from the OpenEmbedded community
  108. that can be used in the Yocto Project.
  109. </para></listitem>
  110. <listitem><para><emphasis>Create a Directory:</emphasis>
  111. Create the directory for your layer.
  112. While not strictly required, prepend the name of the
  113. folder with the string <filename>meta-</filename>.
  114. For example:
  115. <literallayout class='monospaced'>
  116. meta-mylayer
  117. meta-GUI_xyz
  118. meta-mymachine
  119. </literallayout>
  120. </para></listitem>
  121. <listitem><para><emphasis>Create a Layer Configuration
  122. File:</emphasis>
  123. Inside your new layer folder, you need to create a
  124. <filename>conf/layer.conf</filename> file.
  125. It is easiest to take an existing layer configuration
  126. file and copy that to your layer's
  127. <filename>conf</filename> directory and then modify the
  128. file as needed.</para>
  129. <para>The
  130. <filename>meta-yocto-bsp/conf/layer.conf</filename> file
  131. demonstrates the required syntax:
  132. <literallayout class='monospaced'>
  133. # We have a conf and classes directory, add to BBPATH
  134. BBPATH .= ":${LAYERDIR}"
  135. # We have recipes-* directories, add to BBFILES
  136. BBFILES += "${LAYERDIR}/recipes-*/*/*.bb \
  137. ${LAYERDIR}/recipes-*/*/*.bbappend"
  138. BBFILE_COLLECTIONS += "yoctobsp"
  139. BBFILE_PATTERN_yoctobsp = "^${LAYERDIR}/"
  140. BBFILE_PRIORITY_yoctobsp = "5"
  141. LAYERVERSION_yoctobsp = "3"
  142. </literallayout></para>
  143. <para>Here is an explanation of the example:
  144. <itemizedlist>
  145. <listitem><para>The configuration and
  146. classes directory is appended to
  147. <ulink url='&YOCTO_DOCS_REF_URL;#var-BBPATH'><filename>BBPATH</filename></ulink>.
  148. <note>
  149. All non-distro layers, which include all BSP
  150. layers, are expected to append the layer
  151. directory to the
  152. <filename>BBPATH</filename>.
  153. On the other hand, distro layers, such as
  154. <filename>meta-poky</filename>, can choose
  155. to enforce their own precedence over
  156. <filename>BBPATH</filename>.
  157. For an example of that syntax, see the
  158. <filename>layer.conf</filename> file for
  159. the <filename>meta-poky</filename> layer.
  160. </note></para></listitem>
  161. <listitem><para>The recipes for the layers are
  162. appended to
  163. <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-BBFILES'>BBFILES</ulink></filename>.
  164. </para></listitem>
  165. <listitem><para>The
  166. <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-BBFILE_COLLECTIONS'>BBFILE_COLLECTIONS</ulink></filename>
  167. variable is then appended with the layer name.
  168. </para></listitem>
  169. <listitem><para>The
  170. <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-BBFILE_PATTERN'>BBFILE_PATTERN</ulink></filename>
  171. variable is set to a regular expression and is
  172. used to match files from
  173. <filename>BBFILES</filename> into a particular
  174. layer.
  175. In this case,
  176. <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-LAYERDIR'>LAYERDIR</ulink></filename>
  177. is used to make <filename>BBFILE_PATTERN</filename> match within the
  178. layer's path.</para></listitem>
  179. <listitem><para>The
  180. <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-BBFILE_PRIORITY'>BBFILE_PRIORITY</ulink></filename>
  181. variable then assigns a priority to the layer.
  182. Applying priorities is useful in situations
  183. where the same recipe might appear in multiple
  184. layers and allows you to choose the layer
  185. that takes precedence.</para></listitem>
  186. <listitem><para>The
  187. <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-LAYERVERSION'>LAYERVERSION</ulink></filename>
  188. variable optionally specifies the version of a
  189. layer as a single number.</para></listitem>
  190. </itemizedlist></para>
  191. <para>Note the use of the
  192. <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-LAYERDIR'>LAYERDIR</ulink></filename>
  193. variable, which expands to the directory of the current
  194. layer.</para>
  195. <para>Through the use of the <filename>BBPATH</filename>
  196. variable, BitBake locates class files
  197. (<filename>.bbclass</filename>),
  198. configuration files, and files that are included
  199. with <filename>include</filename> and
  200. <filename>require</filename> statements.
  201. For these cases, BitBake uses the first file that
  202. matches the name found in <filename>BBPATH</filename>.
  203. This is similar to the way the <filename>PATH</filename>
  204. variable is used for binaries.
  205. It is recommended, therefore, that you use unique
  206. class and configuration
  207. filenames in your custom layer.</para></listitem>
  208. <listitem><para><emphasis>Add Content:</emphasis> Depending
  209. on the type of layer, add the content.
  210. If the layer adds support for a machine, add the machine
  211. configuration in a <filename>conf/machine/</filename>
  212. file within the layer.
  213. If the layer adds distro policy, add the distro
  214. configuration in a <filename>conf/distro/</filename>
  215. file within the layer.
  216. If the layer introduces new recipes, put the recipes
  217. you need in <filename>recipes-*</filename>
  218. subdirectories within the layer.
  219. <note>In order to be compliant with the Yocto Project,
  220. a layer must contain a
  221. <ulink url='&YOCTO_DOCS_BSP_URL;#bsp-filelayout-readme'>README file.</ulink>
  222. </note></para></listitem>
  223. </orderedlist>
  224. </para>
  225. </section>
  226. <section id='best-practices-to-follow-when-creating-layers'>
  227. <title>Best Practices to Follow When Creating Layers</title>
  228. <para>
  229. To create layers that are easier to maintain and that will
  230. not impact builds for other machines, you should consider the
  231. information in the following sections.
  232. </para>
  233. <section id='avoid-overlaying-entire-recipes'>
  234. <title>Avoid "Overlaying" Entire Recipes</title>
  235. <para>
  236. Avoid "overlaying" entire recipes from other layers in your
  237. configuration.
  238. In other words, do not copy an entire recipe into your
  239. layer and then modify it.
  240. Rather, use an append file (<filename>.bbappend</filename>)
  241. to override
  242. only those parts of the original recipe you need to modify.
  243. </para>
  244. </section>
  245. <section id='avoid-duplicating-include-files'>
  246. <title>Avoid Duplicating Include Files</title>
  247. <para>
  248. Avoid duplicating include files.
  249. Use append files (<filename>.bbappend</filename>)
  250. for each recipe
  251. that uses an include file.
  252. Or, if you are introducing a new recipe that requires
  253. the included file, use the path relative to the original
  254. layer directory to refer to the file.
  255. For example, use
  256. <filename>require recipes-core/</filename><replaceable>package</replaceable><filename>/</filename><replaceable>file</replaceable><filename>.inc</filename>
  257. instead of <filename>require </filename><replaceable>file</replaceable><filename>.inc</filename>.
  258. If you're finding you have to overlay the include file,
  259. it could indicate a deficiency in the include file in
  260. the layer to which it originally belongs.
  261. If this is the case, you should try to address that
  262. deficiency instead of overlaying the include file.
  263. For example, you could address this by getting the
  264. maintainer of the include file to add a variable or
  265. variables to make it easy to override the parts needing
  266. to be overridden.
  267. </para>
  268. </section>
  269. <section id='structure-your-layers'>
  270. <title>Structure Your Layers</title>
  271. <para>
  272. Proper use of overrides within append files and placement
  273. of machine-specific files within your layer can ensure that
  274. a build is not using the wrong Metadata and negatively
  275. impacting a build for a different machine.
  276. Following are some examples:
  277. <itemizedlist>
  278. <listitem><para><emphasis>Modifying Variables to Support
  279. a Different Machine:</emphasis>
  280. Suppose you have a layer named
  281. <filename>meta-one</filename> that adds support
  282. for building machine "one".
  283. To do so, you use an append file named
  284. <filename>base-files.bbappend</filename> and
  285. create a dependency on "foo" by altering the
  286. <ulink url='&YOCTO_DOCS_REF_URL;#var-DEPENDS'><filename>DEPENDS</filename></ulink>
  287. variable:
  288. <literallayout class='monospaced'>
  289. DEPENDS = "foo"
  290. </literallayout>
  291. The dependency is created during any build that
  292. includes the layer
  293. <filename>meta-one</filename>.
  294. However, you might not want this dependency
  295. for all machines.
  296. For example, suppose you are building for
  297. machine "two" but your
  298. <filename>bblayers.conf</filename> file has the
  299. <filename>meta-one</filename> layer included.
  300. During the build, the
  301. <filename>base-files</filename> for machine
  302. "two" will also have the dependency on
  303. <filename>foo</filename>.</para>
  304. <para>To make sure your changes apply only when
  305. building machine "one", use a machine override
  306. with the <filename>DEPENDS</filename> statement:
  307. <literallayout class='monospaced'>
  308. DEPENDS_one = "foo"
  309. </literallayout>
  310. You should follow the same strategy when using
  311. <filename>_append</filename> and
  312. <filename>_prepend</filename> operations:
  313. <literallayout class='monospaced'>
  314. DEPENDS_append_one = " foo"
  315. DEPENDS_prepend_one = "foo "
  316. </literallayout>
  317. As an actual example, here's a line from the recipe
  318. for gnutls, which adds dependencies on
  319. "argp-standalone" when building with the musl C
  320. library:
  321. <literallayout class='monospaced'>
  322. DEPENDS_append_libc-musl = " argp-standalone"
  323. </literallayout>
  324. <note>
  325. Avoiding "+=" and "=+" and using
  326. machine-specific
  327. <filename>_append</filename>
  328. and <filename>_prepend</filename> operations
  329. is recommended as well.
  330. </note></para></listitem>
  331. <listitem><para><emphasis>Place Machine-Specific Files
  332. in Machine-Specific Locations:</emphasis>
  333. When you have a base recipe, such as
  334. <filename>base-files.bb</filename>, that
  335. contains a
  336. <ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'><filename>SRC_URI</filename></ulink>
  337. statement to a file, you can use an append file
  338. to cause the build to use your own version of
  339. the file.
  340. For example, an append file in your layer at
  341. <filename>meta-one/recipes-core/base-files/base-files.bbappend</filename>
  342. could extend
  343. <ulink url='&YOCTO_DOCS_REF_URL;#var-FILESPATH'><filename>FILESPATH</filename></ulink>
  344. using
  345. <ulink url='&YOCTO_DOCS_REF_URL;#var-FILESEXTRAPATHS'><filename>FILESEXTRAPATHS</filename></ulink>
  346. as follows:
  347. <literallayout class='monospaced'>
  348. FILESEXTRAPATHS_prepend := "${THISDIR}/${BPN}:"
  349. </literallayout>
  350. The build for machine "one" will pick up your
  351. machine-specific file as long as you have the
  352. file in
  353. <filename>meta-one/recipes-core/base-files/base-files/</filename>.
  354. However, if you are building for a different
  355. machine and the
  356. <filename>bblayers.conf</filename> file includes
  357. the <filename>meta-one</filename> layer and
  358. the location of your machine-specific file is
  359. the first location where that file is found
  360. according to <filename>FILESPATH</filename>,
  361. builds for all machines will also use that
  362. machine-specific file.</para>
  363. <para>You can make sure that a machine-specific
  364. file is used for a particular machine by putting
  365. the file in a subdirectory specific to the
  366. machine.
  367. For example, rather than placing the file in
  368. <filename>meta-one/recipes-core/base-files/base-files/</filename>
  369. as shown above, put it in
  370. <filename>meta-one/recipes-core/base-files/base-files/one/</filename>.
  371. Not only does this make sure the file is used
  372. only when building for machine "one", but the
  373. build process locates the file more quickly.</para>
  374. <para>In summary, you need to place all files
  375. referenced from <filename>SRC_URI</filename>
  376. in a machine-specific subdirectory within the
  377. layer in order to restrict those files to
  378. machine-specific builds.</para></listitem>
  379. </itemizedlist>
  380. </para>
  381. </section>
  382. <section id='other-recommendations'>
  383. <title>Other Recommendations</title>
  384. <para>
  385. We also recommend the following:
  386. <itemizedlist>
  387. <listitem><para>Store custom layers in a Git repository
  388. that uses the
  389. <filename>meta-<replaceable>layer_name</replaceable></filename> format.
  390. </para></listitem>
  391. <listitem><para>Clone the repository alongside other
  392. <filename>meta</filename> directories in the
  393. <link linkend='source-directory'>Source Directory</link>.
  394. </para></listitem>
  395. </itemizedlist>
  396. Following these recommendations keeps your Source Directory and
  397. its configuration entirely inside the Yocto Project's core
  398. base.
  399. </para>
  400. </section>
  401. </section>
  402. <section id='enabling-your-layer'>
  403. <title>Enabling Your Layer</title>
  404. <para>
  405. Before the OpenEmbedded build system can use your new layer,
  406. you need to enable it.
  407. To enable your layer, simply add your layer's path to the
  408. <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-BBLAYERS'>BBLAYERS</ulink></filename>
  409. variable in your <filename>conf/bblayers.conf</filename> file,
  410. which is found in the
  411. <link linkend='build-directory'>Build Directory</link>.
  412. The following example shows how to enable a layer named
  413. <filename>meta-mylayer</filename>:
  414. <literallayout class='monospaced'>
  415. LCONF_VERSION = "6"
  416. BBPATH = "${TOPDIR}"
  417. BBFILES ?= ""
  418. BBLAYERS ?= " \
  419. $HOME/poky/meta \
  420. $HOME/poky/meta-poky \
  421. $HOME/poky/meta-yocto-bsp \
  422. $HOME/poky/meta-mylayer \
  423. "
  424. </literallayout>
  425. </para>
  426. <para>
  427. BitBake parses each <filename>conf/layer.conf</filename> file
  428. as specified in the <filename>BBLAYERS</filename> variable
  429. within the <filename>conf/bblayers.conf</filename> file.
  430. During the processing of each
  431. <filename>conf/layer.conf</filename> file, BitBake adds the
  432. recipes, classes and configurations contained within the
  433. particular layer to the source directory.
  434. </para>
  435. </section>
  436. <section id='using-bbappend-files'>
  437. <title>Using .bbappend Files</title>
  438. <para>
  439. Recipes used to append Metadata to other recipes are called
  440. BitBake append files.
  441. BitBake append files use the <filename>.bbappend</filename> file
  442. type suffix, while the corresponding recipes to which Metadata
  443. is being appended use the <filename>.bb</filename> file type
  444. suffix.
  445. </para>
  446. <para>
  447. A <filename>.bbappend</filename> file allows your layer to make
  448. additions or changes to the content of another layer's recipe
  449. without having to copy the other recipe into your layer.
  450. Your <filename>.bbappend</filename> file resides in your layer,
  451. while the main <filename>.bb</filename> recipe file to
  452. which you are appending Metadata resides in a different layer.
  453. </para>
  454. <para>
  455. Append files must have the same root names as their corresponding
  456. recipes.
  457. For example, the append file
  458. <filename>someapp_&DISTRO;.bbappend</filename> must apply to
  459. <filename>someapp_&DISTRO;.bb</filename>.
  460. This means the original recipe and append file names are version
  461. number-specific.
  462. If the corresponding recipe is renamed to update to a newer
  463. version, the corresponding <filename>.bbappend</filename> file must
  464. be renamed (and possibly updated) as well.
  465. During the build process, BitBake displays an error on starting
  466. if it detects a <filename>.bbappend</filename> file that does
  467. not have a corresponding recipe with a matching name.
  468. See the
  469. <ulink url='&YOCTO_DOCS_REF_URL;#var-BB_DANGLINGAPPENDS_WARNONLY'><filename>BB_DANGLINGAPPENDS_WARNONLY</filename></ulink>
  470. variable for information on how to handle this error.
  471. </para>
  472. <para>
  473. Being able to append information to an existing recipe not only
  474. avoids duplication, but also automatically applies recipe
  475. changes in a different layer to your layer.
  476. If you were copying recipes, you would have to manually merge
  477. changes as they occur.
  478. </para>
  479. <para>
  480. As an example, consider the main formfactor recipe and a
  481. corresponding formfactor append file both from the
  482. <link linkend='source-directory'>Source Directory</link>.
  483. Here is the main formfactor recipe, which is named
  484. <filename>formfactor_0.0.bb</filename> and located in the
  485. "meta" layer at
  486. <filename>meta/recipes-bsp/formfactor</filename>:
  487. <literallayout class='monospaced'>
  488. SUMMARY = "Device formfactor information"
  489. SECTION = "base"
  490. LICENSE = "MIT"
  491. LIC_FILES_CHKSUM = "file://${COREBASE}/LICENSE;md5=4d92cd373abda3937c2bc47fbc49d690 \
  492. file://${COREBASE}/meta/COPYING.MIT;md5=3da9cfbcb788c80a0384361b4de20420"
  493. PR = "r45"
  494. SRC_URI = "file://config file://machconfig"
  495. S = "${WORKDIR}"
  496. PACKAGE_ARCH = "${MACHINE_ARCH}"
  497. INHIBIT_DEFAULT_DEPS = "1"
  498. do_install() {
  499. # Install file only if it has contents
  500. install -d ${D}${sysconfdir}/formfactor/
  501. install -m 0644 ${S}/config ${D}${sysconfdir}/formfactor/
  502. if [ -s "${S}/machconfig" ]; then
  503. install -m 0644 ${S}/machconfig ${D}${sysconfdir}/formfactor/
  504. fi
  505. }
  506. </literallayout>
  507. In the main recipe, note the
  508. <ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'><filename>SRC_URI</filename></ulink>
  509. variable, which tells the OpenEmbedded build system where to
  510. find files during the build.
  511. </para>
  512. <para>
  513. Following is the append file, which is named
  514. <filename>formfactor_0.0.bbappend</filename> and is from the
  515. Raspberry Pi BSP Layer named
  516. <filename>meta-raspberrypi</filename>.
  517. The file is in <filename>recipes-bsp/formfactor</filename>:
  518. <literallayout class='monospaced'>
  519. FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:"
  520. </literallayout>
  521. </para>
  522. <para>
  523. By default, the build system uses the
  524. <ulink url='&YOCTO_DOCS_REF_URL;#var-FILESPATH'><filename>FILESPATH</filename></ulink>
  525. variable to locate files.
  526. This append file extends the locations by setting the
  527. <ulink url='&YOCTO_DOCS_REF_URL;#var-FILESEXTRAPATHS'><filename>FILESEXTRAPATHS</filename></ulink>
  528. variable.
  529. Setting this variable in the <filename>.bbappend</filename>
  530. file is the most reliable and recommended method for adding
  531. directories to the search path used by the build system
  532. to find files.
  533. </para>
  534. <para>
  535. The statement in this example extends the directories to include
  536. <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>,
  537. which resolves to a directory named
  538. <filename>formfactor</filename> in the same directory
  539. in which the append file resides (i.e.
  540. <filename>meta-raspberrypi/recipes-bsp/formfactor/formfactor</filename>.
  541. This implies that you must have the supporting directory
  542. structure set up that will contain any files or patches you
  543. will be including from the layer.
  544. </para>
  545. <para>
  546. Using the immediate expansion assignment operator
  547. <filename>:=</filename> is important because of the reference to
  548. <filename>THISDIR</filename>.
  549. The trailing colon character is important as it ensures that
  550. items in the list remain colon-separated.
  551. <note>
  552. <para>
  553. BitBake automatically defines the
  554. <filename>THISDIR</filename> variable.
  555. You should never set this variable yourself.
  556. Using "_prepend" as part of the
  557. <filename>FILESEXTRAPATHS</filename> ensures your path
  558. will be searched prior to other paths in the final
  559. list.
  560. </para>
  561. <para>
  562. Also, not all append files add extra files.
  563. Many append files simply exist to add build options
  564. (e.g. <filename>systemd</filename>).
  565. For these cases, your append file would not even
  566. use the <filename>FILESEXTRAPATHS</filename> statement.
  567. </para>
  568. </note>
  569. </para>
  570. </section>
  571. <section id='prioritizing-your-layer'>
  572. <title>Prioritizing Your Layer</title>
  573. <para>
  574. Each layer is assigned a priority value.
  575. Priority values control which layer takes precedence if there
  576. are recipe files with the same name in multiple layers.
  577. For these cases, the recipe file from the layer with a higher
  578. priority number takes precedence.
  579. Priority values also affect the order in which multiple
  580. <filename>.bbappend</filename> files for the same recipe are
  581. applied.
  582. You can either specify the priority manually, or allow the
  583. build system to calculate it based on the layer's dependencies.
  584. </para>
  585. <para>
  586. To specify the layer's priority manually, use the
  587. <ulink url='&YOCTO_DOCS_REF_URL;#var-BBFILE_PRIORITY'><filename>BBFILE_PRIORITY</filename></ulink>
  588. variable.
  589. For example:
  590. <literallayout class='monospaced'>
  591. BBFILE_PRIORITY_mylayer = "1"
  592. </literallayout>
  593. </para>
  594. <note>
  595. <para>It is possible for a recipe with a lower version number
  596. <ulink url='&YOCTO_DOCS_REF_URL;#var-PV'><filename>PV</filename></ulink>
  597. in a layer that has a higher priority to take precedence.</para>
  598. <para>Also, the layer priority does not currently affect the
  599. precedence order of <filename>.conf</filename>
  600. or <filename>.bbclass</filename> files.
  601. Future versions of BitBake might address this.</para>
  602. </note>
  603. </section>
  604. <section id='managing-layers'>
  605. <title>Managing Layers</title>
  606. <para>
  607. You can use the BitBake layer management tool to provide a view
  608. into the structure of recipes across a multi-layer project.
  609. Being able to generate output that reports on configured layers
  610. with their paths and priorities and on
  611. <filename>.bbappend</filename> files and their applicable
  612. recipes can help to reveal potential problems.
  613. </para>
  614. <para>
  615. Use the following form when running the layer management tool.
  616. <literallayout class='monospaced'>
  617. $ bitbake-layers <replaceable>command</replaceable> [<replaceable>arguments</replaceable>]
  618. </literallayout>
  619. The following list describes the available commands:
  620. <itemizedlist>
  621. <listitem><para><filename><emphasis>help:</emphasis></filename>
  622. Displays general help or help on a specified command.
  623. </para></listitem>
  624. <listitem><para><filename><emphasis>show-layers:</emphasis></filename>
  625. Shows the current configured layers.
  626. </para></listitem>
  627. <listitem><para><filename><emphasis>show-recipes:</emphasis></filename>
  628. Lists available recipes and the layers that provide them.
  629. </para></listitem>
  630. <listitem><para><filename><emphasis>show-overlayed:</emphasis></filename>
  631. Lists overlayed recipes.
  632. A recipe is overlayed when a recipe with the same name
  633. exists in another layer that has a higher layer
  634. priority.
  635. </para></listitem>
  636. <listitem><para><filename><emphasis>show-appends:</emphasis></filename>
  637. Lists <filename>.bbappend</filename> files and the
  638. recipe files to which they apply.
  639. </para></listitem>
  640. <listitem><para><filename><emphasis>show-cross-depends:</emphasis></filename>
  641. Lists dependency relationships between recipes that
  642. cross layer boundaries.
  643. </para></listitem>
  644. <listitem><para><filename><emphasis>add-layer:</emphasis></filename>
  645. Adds a layer to <filename>bblayers.conf</filename>.
  646. </para></listitem>
  647. <listitem><para><filename><emphasis>remove-layer:</emphasis></filename>
  648. Removes a layer from <filename>bblayers.conf</filename>
  649. </para></listitem>
  650. <listitem><para><filename><emphasis>flatten:</emphasis></filename>
  651. Flattens the layer configuration into a separate output
  652. directory.
  653. Flattening your layer configuration builds a "flattened"
  654. directory that contains the contents of all layers,
  655. with any overlayed recipes removed and any
  656. <filename>.bbappend</filename> files appended to the
  657. corresponding recipes.
  658. You might have to perform some manual cleanup of the
  659. flattened layer as follows:
  660. <itemizedlist>
  661. <listitem><para>Non-recipe files (such as patches)
  662. are overwritten.
  663. The flatten command shows a warning for these
  664. files.
  665. </para></listitem>
  666. <listitem><para>Anything beyond the normal layer
  667. setup has been added to the
  668. <filename>layer.conf</filename> file.
  669. Only the lowest priority layer's
  670. <filename>layer.conf</filename> is used.
  671. </para></listitem>
  672. <listitem><para>Overridden and appended items from
  673. <filename>.bbappend</filename> files need to be
  674. cleaned up.
  675. The contents of each
  676. <filename>.bbappend</filename> end up in the
  677. flattened recipe.
  678. However, if there are appended or changed
  679. variable values, you need to tidy these up
  680. yourself.
  681. Consider the following example.
  682. Here, the <filename>bitbake-layers</filename>
  683. command adds the line
  684. <filename>#### bbappended ...</filename> so that
  685. you know where the following lines originate:
  686. <literallayout class='monospaced'>
  687. ...
  688. DESCRIPTION = "A useful utility"
  689. ...
  690. EXTRA_OECONF = "--enable-something"
  691. ...
  692. #### bbappended from meta-anotherlayer ####
  693. DESCRIPTION = "Customized utility"
  694. EXTRA_OECONF += "--enable-somethingelse"
  695. </literallayout>
  696. Ideally, you would tidy up these utilities as
  697. follows:
  698. <literallayout class='monospaced'>
  699. ...
  700. DESCRIPTION = "Customized utility"
  701. ...
  702. EXTRA_OECONF = "--enable-something --enable-somethingelse"
  703. ...
  704. </literallayout></para></listitem>
  705. </itemizedlist></para></listitem>
  706. </itemizedlist>
  707. </para>
  708. </section>
  709. <section id='creating-a-general-layer-using-the-yocto-layer-script'>
  710. <title>Creating a General Layer Using the yocto-layer Script</title>
  711. <para>
  712. The <filename>yocto-layer</filename> script simplifies
  713. creating a new general layer.
  714. <note>
  715. For information on BSP layers, see the
  716. "<ulink url='&YOCTO_DOCS_BSP_URL;#bsp-layers'>BSP Layers</ulink>"
  717. section in the Yocto Project Board Specific (BSP)
  718. Developer's Guide.
  719. </note>
  720. The default mode of the script's operation is to prompt you for
  721. information needed to generate the layer:
  722. <itemizedlist>
  723. <listitem><para>The layer priority.
  724. </para></listitem>
  725. <listitem><para>Whether or not to create a sample recipe.
  726. </para></listitem>
  727. <listitem><para>Whether or not to create a sample
  728. append file.
  729. </para></listitem>
  730. </itemizedlist>
  731. </para>
  732. <para>
  733. Use the <filename>yocto-layer create</filename> sub-command
  734. to create a new general layer.
  735. In its simplest form, you can create a layer as follows:
  736. <literallayout class='monospaced'>
  737. $ yocto-layer create mylayer
  738. </literallayout>
  739. The previous example creates a layer named
  740. <filename>meta-mylayer</filename> in the current directory.
  741. </para>
  742. <para>
  743. As the <filename>yocto-layer create</filename> command runs,
  744. default values for the prompts appear in brackets.
  745. Pressing enter without supplying anything for the prompts
  746. or pressing enter and providing an invalid response causes the
  747. script to accept the default value.
  748. Once the script completes, the new layer
  749. is created in the current working directory.
  750. The script names the layer by prepending
  751. <filename>meta-</filename> to the name you provide.
  752. </para>
  753. <para>
  754. Minimally, the script creates the following within the layer:
  755. <itemizedlist>
  756. <listitem><para><emphasis>The <filename>conf</filename>
  757. directory:</emphasis>
  758. This directory contains the layer's configuration file.
  759. The root name for the file is the same as the root name
  760. your provided for the layer (e.g.
  761. <filename><replaceable>layer</replaceable>.conf</filename>).
  762. </para></listitem>
  763. <listitem><para><emphasis>The
  764. <filename>COPYING.MIT</filename> file:</emphasis>
  765. The copyright and use notice for the software.
  766. </para></listitem>
  767. <listitem><para><emphasis>The <filename>README</filename>
  768. file:</emphasis>
  769. A file describing the contents of your new layer.
  770. </para></listitem>
  771. </itemizedlist>
  772. </para>
  773. <para>
  774. If you choose to generate a sample recipe file, the script
  775. prompts you for the name for the recipe and then creates it
  776. in <filename><replaceable>layer</replaceable>/recipes-example/example/</filename>.
  777. The script creates a <filename>.bb</filename> file and a
  778. directory, which contains a sample
  779. <filename>helloworld.c</filename> source file, along with
  780. a sample patch file.
  781. If you do not provide a recipe name, the script uses
  782. "example".
  783. </para>
  784. <para>
  785. If you choose to generate a sample append file, the script
  786. prompts you for the name for the file and then creates it
  787. in <filename><replaceable>layer</replaceable>/recipes-example-bbappend/example-bbappend/</filename>.
  788. The script creates a <filename>.bbappend</filename> file and a
  789. directory, which contains a sample patch file.
  790. If you do not provide a recipe name, the script uses
  791. "example".
  792. The script also prompts you for the version of the append file.
  793. The version should match the recipe to which the append file
  794. is associated.
  795. </para>
  796. <para>
  797. The easiest way to see how the <filename>yocto-layer</filename>
  798. script works is to experiment with the script.
  799. You can also read the usage information by entering the
  800. following:
  801. <literallayout class='monospaced'>
  802. $ yocto-layer help
  803. </literallayout>
  804. </para>
  805. <para>
  806. Once you create your general layer, you must add it to your
  807. <filename>bblayers.conf</filename> file.
  808. Here is an example where a layer named
  809. <filename>meta-mylayer</filename> is added:
  810. <literallayout class='monospaced'>
  811. BBLAYERS = ?" \
  812. /usr/local/src/yocto/meta \
  813. /usr/local/src/yocto/meta-poky \
  814. /usr/local/src/yocto/meta-yocto-bsp \
  815. /usr/local/src/yocto/meta-mylayer \
  816. "
  817. </literallayout>
  818. Adding the layer to this file enables the build system to
  819. locate the layer during the build.
  820. </para>
  821. </section>
  822. </section>
  823. <section id='usingpoky-extend-customimage'>
  824. <title>Customizing Images</title>
  825. <para>
  826. You can customize images to satisfy particular requirements.
  827. This section describes several methods and provides guidelines for each.
  828. </para>
  829. <section id='usingpoky-extend-customimage-localconf'>
  830. <title>Customizing Images Using <filename>local.conf</filename></title>
  831. <para>
  832. Probably the easiest way to customize an image is to add a
  833. package by way of the <filename>local.conf</filename>
  834. configuration file.
  835. Because it is limited to local use, this method generally only
  836. allows you to add packages and is not as flexible as creating
  837. your own customized image.
  838. When you add packages using local variables this way, you need
  839. to realize that these variable changes are in effect for every
  840. build and consequently affect all images, which might not
  841. be what you require.
  842. </para>
  843. <para>
  844. To add a package to your image using the local configuration
  845. file, use the
  846. <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-IMAGE_INSTALL'>IMAGE_INSTALL</ulink></filename>
  847. variable with the <filename>_append</filename> operator:
  848. <literallayout class='monospaced'>
  849. IMAGE_INSTALL_append = " strace"
  850. </literallayout>
  851. Use of the syntax is important - specifically, the space between
  852. the quote and the package name, which is
  853. <filename>strace</filename> in this example.
  854. This space is required since the <filename>_append</filename>
  855. operator does not add the space.
  856. </para>
  857. <para>
  858. Furthermore, you must use <filename>_append</filename> instead
  859. of the <filename>+=</filename> operator if you want to avoid
  860. ordering issues.
  861. The reason for this is because doing so unconditionally appends
  862. to the variable and avoids ordering problems due to the
  863. variable being set in image recipes and
  864. <filename>.bbclass</filename> files with operators like
  865. <filename>?=</filename>.
  866. Using <filename>_append</filename> ensures the operation takes
  867. affect.
  868. </para>
  869. <para>
  870. As shown in its simplest use,
  871. <filename>IMAGE_INSTALL_append</filename> affects all images.
  872. It is possible to extend the syntax so that the variable
  873. applies to a specific image only.
  874. Here is an example:
  875. <literallayout class='monospaced'>
  876. IMAGE_INSTALL_append_pn-core-image-minimal = " strace"
  877. </literallayout>
  878. This example adds <filename>strace</filename> to the
  879. <filename>core-image-minimal</filename> image only.
  880. </para>
  881. <para>
  882. You can add packages using a similar approach through the
  883. <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-CORE_IMAGE_EXTRA_INSTALL'>CORE_IMAGE_EXTRA_INSTALL</ulink></filename>
  884. variable.
  885. If you use this variable, only
  886. <filename>core-image-*</filename> images are affected.
  887. </para>
  888. </section>
  889. <section id='usingpoky-extend-customimage-imagefeatures'>
  890. <title>Customizing Images Using Custom <filename>IMAGE_FEATURES</filename> and
  891. <filename>EXTRA_IMAGE_FEATURES</filename></title>
  892. <para>
  893. Another method for customizing your image is to enable or
  894. disable high-level image features by using the
  895. <ulink url='&YOCTO_DOCS_REF_URL;#var-IMAGE_FEATURES'><filename>IMAGE_FEATURES</filename></ulink>
  896. and <ulink url='&YOCTO_DOCS_REF_URL;#var-EXTRA_IMAGE_FEATURES'><filename>EXTRA_IMAGE_FEATURES</filename></ulink>
  897. variables.
  898. Although the functions for both variables are nearly equivalent,
  899. best practices dictate using <filename>IMAGE_FEATURES</filename>
  900. from within a recipe and using
  901. <filename>EXTRA_IMAGE_FEATURES</filename> from within
  902. your <filename>local.conf</filename> file, which is found in the
  903. <link linkend='build-directory'>Build Directory</link>.
  904. </para>
  905. <para>
  906. To understand how these features work, the best reference is
  907. <filename>meta/classes/core-image.bbclass</filename>.
  908. This class lists out the available
  909. <ulink url='&YOCTO_DOCS_REF_URL;#var-IMAGE_FEATURES'><filename>IMAGE_FEATURES</filename></ulink>
  910. of which most map to package groups while some, such as
  911. <filename>debug-tweaks</filename> and
  912. <filename>read-only-rootfs</filename>, resolve as general
  913. configuration settings.
  914. </para>
  915. <para>
  916. In summary, the file looks at the contents of the
  917. <filename>IMAGE_FEATURES</filename> variable and then maps
  918. or configures the feature accordingly.
  919. Based on this information, the build system automatically
  920. adds the appropriate packages or configurations to the
  921. <ulink url='&YOCTO_DOCS_REF_URL;#var-IMAGE_INSTALL'><filename>IMAGE_INSTALL</filename></ulink>
  922. variable.
  923. Effectively, you are enabling extra features by extending the
  924. class or creating a custom class for use with specialized image
  925. <filename>.bb</filename> files.
  926. </para>
  927. <para>
  928. Use the <filename>EXTRA_IMAGE_FEATURES</filename> variable
  929. from within your local configuration file.
  930. Using a separate area from which to enable features with
  931. this variable helps you avoid overwriting the features in the
  932. image recipe that are enabled with
  933. <filename>IMAGE_FEATURES</filename>.
  934. The value of <filename>EXTRA_IMAGE_FEATURES</filename> is added
  935. to <filename>IMAGE_FEATURES</filename> within
  936. <filename>meta/conf/bitbake.conf</filename>.
  937. </para>
  938. <para>
  939. To illustrate how you can use these variables to modify your
  940. image, consider an example that selects the SSH server.
  941. The Yocto Project ships with two SSH servers you can use
  942. with your images: Dropbear and OpenSSH.
  943. Dropbear is a minimal SSH server appropriate for
  944. resource-constrained environments, while OpenSSH is a
  945. well-known standard SSH server implementation.
  946. By default, the <filename>core-image-sato</filename> image
  947. is configured to use Dropbear.
  948. The <filename>core-image-full-cmdline</filename> and
  949. <filename>core-image-lsb</filename> images both
  950. include OpenSSH.
  951. The <filename>core-image-minimal</filename> image does not
  952. contain an SSH server.
  953. </para>
  954. <para>
  955. You can customize your image and change these defaults.
  956. Edit the <filename>IMAGE_FEATURES</filename> variable
  957. in your recipe or use the
  958. <filename>EXTRA_IMAGE_FEATURES</filename> in your
  959. <filename>local.conf</filename> file so that it configures the
  960. image you are working with to include
  961. <filename>ssh-server-dropbear</filename> or
  962. <filename>ssh-server-openssh</filename>.
  963. </para>
  964. <note>
  965. See the
  966. "<ulink url='&YOCTO_DOCS_REF_URL;#ref-images'>Images</ulink>"
  967. section in the Yocto Project Reference Manual for a complete
  968. list of image features that ship with the Yocto Project.
  969. </note>
  970. </section>
  971. <section id='usingpoky-extend-customimage-custombb'>
  972. <title>Customizing Images Using Custom .bb Files</title>
  973. <para>
  974. You can also customize an image by creating a custom recipe
  975. that defines additional software as part of the image.
  976. The following example shows the form for the two lines you need:
  977. <literallayout class='monospaced'>
  978. IMAGE_INSTALL = "packagegroup-core-x11-base package1 package2"
  979. inherit core-image
  980. </literallayout>
  981. </para>
  982. <para>
  983. Defining the software using a custom recipe gives you total
  984. control over the contents of the image.
  985. It is important to use the correct names of packages in the
  986. <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-IMAGE_INSTALL'>IMAGE_INSTALL</ulink></filename>
  987. variable.
  988. You must use the OpenEmbedded notation and not the Debian notation for the names
  989. (e.g. <filename>glibc-dev</filename> instead of <filename>libc6-dev</filename>).
  990. </para>
  991. <para>
  992. The other method for creating a custom image is to base it on an existing image.
  993. For example, if you want to create an image based on <filename>core-image-sato</filename>
  994. but add the additional package <filename>strace</filename> to the image,
  995. copy the <filename>meta/recipes-sato/images/core-image-sato.bb</filename> to a
  996. new <filename>.bb</filename> and add the following line to the end of the copy:
  997. <literallayout class='monospaced'>
  998. IMAGE_INSTALL += "strace"
  999. </literallayout>
  1000. </para>
  1001. </section>
  1002. <section id='usingpoky-extend-customimage-customtasks'>
  1003. <title>Customizing Images Using Custom Package Groups</title>
  1004. <para>
  1005. For complex custom images, the best approach for customizing
  1006. an image is to create a custom package group recipe that is
  1007. used to build the image or images.
  1008. A good example of a package group recipe is
  1009. <filename>meta/recipes-core/packagegroups/packagegroup-base.bb</filename>.
  1010. </para>
  1011. <para>
  1012. If you examine that recipe, you see that the
  1013. <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGES'>PACKAGES</ulink></filename>
  1014. variable lists the package group packages to produce.
  1015. The <filename>inherit packagegroup</filename> statement
  1016. sets appropriate default values and automatically adds
  1017. <filename>-dev</filename>, <filename>-dbg</filename>, and
  1018. <filename>-ptest</filename> complementary packages for each
  1019. package specified in the <filename>PACKAGES</filename>
  1020. statement.
  1021. <note>
  1022. The <filename>inherit packages</filename> should be
  1023. located near the top of the recipe, certainly before
  1024. the <filename>PACKAGES</filename> statement.
  1025. </note>
  1026. </para>
  1027. <para>
  1028. For each package you specify in <filename>PACKAGES</filename>,
  1029. you can use
  1030. <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-RDEPENDS'>RDEPENDS</ulink></filename>
  1031. and
  1032. <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-RRECOMMENDS'>RRECOMMENDS</ulink></filename>
  1033. entries to provide a list of packages the parent task package
  1034. should contain.
  1035. You can see examples of these further down in the
  1036. <filename>packagegroup-base.bb</filename> recipe.
  1037. </para>
  1038. <para>
  1039. Here is a short, fabricated example showing the same basic
  1040. pieces:
  1041. <literallayout class='monospaced'>
  1042. DESCRIPTION = "My Custom Package Groups"
  1043. inherit packagegroup
  1044. PACKAGES = "\
  1045. packagegroup-custom-apps \
  1046. packagegroup-custom-tools \
  1047. "
  1048. RDEPENDS_packagegroup-custom-apps = "\
  1049. dropbear \
  1050. portmap \
  1051. psplash"
  1052. RDEPENDS_packagegroup-custom-tools = "\
  1053. oprofile \
  1054. oprofileui-server \
  1055. lttng-tools"
  1056. RRECOMMENDS_packagegroup-custom-tools = "\
  1057. kernel-module-oprofile"
  1058. </literallayout>
  1059. </para>
  1060. <para>
  1061. In the previous example, two package group packages are created with their dependencies and their
  1062. recommended package dependencies listed: <filename>packagegroup-custom-apps</filename>, and
  1063. <filename>packagegroup-custom-tools</filename>.
  1064. To build an image using these package group packages, you need to add
  1065. <filename>packagegroup-custom-apps</filename> and/or
  1066. <filename>packagegroup-custom-tools</filename> to
  1067. <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-IMAGE_INSTALL'>IMAGE_INSTALL</ulink></filename>.
  1068. For other forms of image dependencies see the other areas of this section.
  1069. </para>
  1070. </section>
  1071. <section id='usingpoky-extend-customimage-image-name'>
  1072. <title>Customizing an Image Hostname</title>
  1073. <para>
  1074. By default, the configured hostname (i.e.
  1075. <filename>/etc/hostname</filename>) in an image is the
  1076. same as the machine name.
  1077. For example, if
  1078. <ulink url='&YOCTO_DOCS_REF_URL;#var-MACHINE'><filename>MACHINE</filename></ulink>
  1079. equals "qemux86", the configured hostname written to
  1080. <filename>/etc/hostname</filename> is "qemux86".
  1081. </para>
  1082. <para>
  1083. You can customize this name by altering the value of the
  1084. "hostname" variable in the
  1085. <filename>base-files</filename> recipe using either
  1086. an append file or a configuration file.
  1087. Use the following in an append file:
  1088. <literallayout class='monospaced'>
  1089. hostname="myhostname"
  1090. </literallayout>
  1091. Use the following in a configuration file:
  1092. <literallayout class='monospaced'>
  1093. hostname_pn-base-files = "myhostname"
  1094. </literallayout>
  1095. </para>
  1096. <para>
  1097. Changing the default value of the variable "hostname" can be
  1098. useful in certain situations.
  1099. For example, suppose you need to do extensive testing on an
  1100. image and you would like to easily identify the image
  1101. under test from existing images with typical default
  1102. hostnames.
  1103. In this situation, you could change the default hostname to
  1104. "testme", which results in all the images using the name
  1105. "testme".
  1106. Once testing is complete and you do not need to rebuild the
  1107. image for test any longer, you can easily reset the default
  1108. hostname.
  1109. </para>
  1110. <para>
  1111. Another point of interest is that if you unset the variable,
  1112. the image will have no default hostname in the filesystem.
  1113. Here is an example that unsets the variable in a
  1114. configuration file:
  1115. <literallayout class='monospaced'>
  1116. hostname_pn-base-files = ""
  1117. </literallayout>
  1118. Having no default hostname in the filesystem is suitable for
  1119. environments that use dynamic hostnames such as virtual
  1120. machines.
  1121. </para>
  1122. </section>
  1123. </section>
  1124. <section id='new-recipe-writing-a-new-recipe'>
  1125. <title>Writing a New Recipe</title>
  1126. <para>
  1127. Recipes (<filename>.bb</filename> files) are fundamental components
  1128. in the Yocto Project environment.
  1129. Each software component built by the OpenEmbedded build system
  1130. requires a recipe to define the component.
  1131. This section describes how to create, write, and test a new
  1132. recipe.
  1133. <note>
  1134. For information on variables that are useful for recipes and
  1135. for information about recipe naming issues, see the
  1136. "<ulink url='&YOCTO_DOCS_REF_URL;#ref-varlocality-recipe-required'>Required</ulink>"
  1137. section of the Yocto Project Reference Manual.
  1138. </note>
  1139. </para>
  1140. <section id='new-recipe-overview'>
  1141. <title>Overview</title>
  1142. <para>
  1143. The following figure shows the basic process for creating a
  1144. new recipe.
  1145. The remainder of the section provides details for the steps.
  1146. <imagedata fileref="figures/recipe-workflow.png" width="6in" depth="7in" align="center" scalefit="1" />
  1147. </para>
  1148. </section>
  1149. <section id='new-recipe-locate-or-automatically-create-a-base-recipe'>
  1150. <title>Locate or Automatically Create a Base Recipe</title>
  1151. <para>
  1152. You can always write a recipe from scratch.
  1153. However, two choices exist that can help you quickly get a
  1154. start on a new recipe:
  1155. <itemizedlist>
  1156. <listitem><para><emphasis><filename>recipetool</filename>:</emphasis>
  1157. A tool provided by the Yocto Project that automates
  1158. creation of a base recipe based on the source
  1159. files.
  1160. </para></listitem>
  1161. <listitem><para><emphasis>Existing Recipes:</emphasis>
  1162. Location and modification of an existing recipe that is
  1163. similar in function to the recipe you need.
  1164. </para></listitem>
  1165. </itemizedlist>
  1166. </para>
  1167. <section id='new-recipe-creating-the-base-recipe-using-recipetool'>
  1168. <title>Creating the Base Recipe Using <filename>recipetool</filename></title>
  1169. <para>
  1170. <filename>recipetool</filename> automates creation of
  1171. a base recipe given a set of source code files.
  1172. As long as you can extract or point to the source files,
  1173. the tool will construct a recipe and automatically
  1174. configure all pre-build information into the recipe.
  1175. For example, suppose you have an application that builds
  1176. using Autotools.
  1177. Creating the base recipe using
  1178. <filename>recipetool</filename> results in a recipe
  1179. that has the pre-build dependencies, license requirements,
  1180. and checksums configured.
  1181. </para>
  1182. <para>
  1183. To run the tool, you just need to be in your
  1184. <link linkend='build-directory'>Build Directory</link>
  1185. and have sourced the build environment setup script
  1186. (i.e.
  1187. <ulink url='&YOCTO_DOCS_REF_URL;#structure-core-script'><filename>oe-init-build-env</filename></ulink>
  1188. or
  1189. <ulink url='&YOCTO_DOCS_REF_URL;#structure-memres-core-script'><filename>oe-init-build-env-memres</filename></ulink>).
  1190. Here is the basic <filename>recipetool</filename> syntax:
  1191. <note>
  1192. Running <filename>recipetool -h</filename> or
  1193. <filename>recipetool create -h</filename> produces the
  1194. Python-generated help, which presented differently
  1195. than what follows here.
  1196. </note>
  1197. <literallayout class='monospaced'>
  1198. recipetool -h
  1199. recipetool create [-h]
  1200. recipetool [-d] [-q] [--color auto | always | never ] create -o <replaceable>OUTFILE</replaceable> [-m] [-x <replaceable>EXTERNALSRC</replaceable>] <replaceable>source</replaceable>
  1201. -d Enables debug output.
  1202. -q Outputs only errors (quiet mode).
  1203. --color Colorizes the output automatically, always, or never.
  1204. -h Displays Python generated syntax for recipetool.
  1205. create Causes recipetool to create a base recipe. The create
  1206. command is further defined with these options:
  1207. -o <replaceable>OUTFILE</replaceable> Specifies the full path and filename for the generated
  1208. recipe.
  1209. -m Causes the recipe to be machine-specific rather than
  1210. architecture-specific (default).
  1211. -x <replaceable>EXTERNALSRC</replaceable> Fetches and extracts source files from <replaceable>source</replaceable>
  1212. and places them in <replaceable>EXTERNALSRC</replaceable>.
  1213. <replaceable>source</replaceable> must be a URL.
  1214. -h Displays Python-generated syntax for create.
  1215. <replaceable>source</replaceable> Specifies the source code on which to base the
  1216. recipe.
  1217. </literallayout>
  1218. </para>
  1219. <para>
  1220. Running <filename>recipetool create -o</filename>&nbsp;<replaceable>OUTFILE</replaceable>
  1221. creates the base recipe and locates it properly in the
  1222. layer that contains your source files.
  1223. Following are some syntax examples:
  1224. </para>
  1225. <para>
  1226. Use this syntax to generate a recipe based on <replaceable>source</replaceable>.
  1227. Once generated, the recipe resides in the existing source
  1228. code layer:
  1229. <literallayout class='monospaced'>
  1230. recipetool create -o <replaceable>OUTFILE</replaceable>&nbsp;<replaceable>source</replaceable>
  1231. </literallayout>
  1232. Use this syntax to generate a recipe using code that you
  1233. extract from <replaceable>source</replaceable>.
  1234. The extracted code is placed in its own layer defined
  1235. by <replaceable>EXTERNALSRC</replaceable>.
  1236. <literallayout class='monospaced'>
  1237. recipetool create -o <replaceable>OUTFILE</replaceable> -x <replaceable>EXTERNALSRC</replaceable> <replaceable>source</replaceable>
  1238. </literallayout>
  1239. Use this syntax to generate a recipe based on <replaceable>source</replaceable>.
  1240. The options direct <filename>recipetool</filename> to
  1241. run in "quiet mode" and to generate debugging information.
  1242. Once generated, the recipe resides in the existing source
  1243. code layer:
  1244. <literallayout class='monospaced'>
  1245. recipetool create -o <replaceable>OUTFILE</replaceable> <replaceable>source</replaceable>
  1246. </literallayout>
  1247. </para>
  1248. </section>
  1249. <section id='new-recipe-locating-and-using-a-similar-recipe'>
  1250. <title>Locating and Using a Similar Recipe</title>
  1251. <para>
  1252. Before writing a recipe from scratch, it is often useful to
  1253. discover whether someone else has already written one that
  1254. meets (or comes close to meeting) your needs.
  1255. The Yocto Project and OpenEmbedded communities maintain many
  1256. recipes that might be candidates for what you are doing.
  1257. You can find a good central index of these recipes in the
  1258. <ulink url='http://layers.openembedded.org'>OpenEmbedded metadata index</ulink>.
  1259. </para>
  1260. <para>
  1261. Working from an existing recipe or a skeleton recipe is the
  1262. best way to get started.
  1263. Here are some points on both methods:
  1264. <itemizedlist>
  1265. <listitem><para><emphasis>Locate and modify a recipe that
  1266. is close to what you want to do:</emphasis>
  1267. This method works when you are familiar with the
  1268. current recipe space.
  1269. The method does not work so well for those new to
  1270. the Yocto Project or writing recipes.</para>
  1271. <para>Some risks associated with this method are
  1272. using a recipe that has areas totally unrelated to
  1273. what you are trying to accomplish with your recipe,
  1274. not recognizing areas of the recipe that you might
  1275. have to add from scratch, and so forth.
  1276. All these risks stem from unfamiliarity with the
  1277. existing recipe space.</para></listitem>
  1278. <listitem><para><emphasis>Use and modify the following
  1279. skeleton recipe:</emphasis>
  1280. If for some reason you do not want to use
  1281. <filename>recipetool</filename> and you cannot
  1282. find an existing recipe that is close to meeting
  1283. your needs, you can use the following structure to
  1284. provide the fundamental areas of a new recipe.
  1285. <literallayout class='monospaced'>
  1286. DESCRIPTION = ""
  1287. HOMEPAGE = ""
  1288. LICENSE = ""
  1289. SECTION = ""
  1290. DEPENDS = ""
  1291. LIC_FILES_CHKSUM = ""
  1292. SRC_URI = ""
  1293. </literallayout>
  1294. </para></listitem>
  1295. </itemizedlist>
  1296. </para>
  1297. </section>
  1298. </section>
  1299. <section id='new-recipe-storing-and-naming-the-recipe'>
  1300. <title>Storing and Naming the Recipe</title>
  1301. <para>
  1302. Once you have your base recipe, you should put it in your
  1303. own layer and name it appropriately.
  1304. Locating it correctly ensures that the OpenEmbedded build
  1305. system can find it when you use BitBake to process the
  1306. recipe.
  1307. </para>
  1308. <itemizedlist>
  1309. <listitem><para><emphasis>Storing Your Recipe:</emphasis>
  1310. The OpenEmbedded build system locates your recipe
  1311. through the layer's <filename>conf/layer.conf</filename>
  1312. file and the
  1313. <ulink url='&YOCTO_DOCS_REF_URL;#var-BBFILES'><filename>BBFILES</filename></ulink>
  1314. variable.
  1315. This variable sets up a path from which the build system can
  1316. locate recipes.
  1317. Here is the typical use:
  1318. <literallayout class='monospaced'>
  1319. BBFILES += "${LAYERDIR}/recipes-*/*/*.bb \
  1320. ${LAYERDIR}/recipes-*/*/*.bbappend"
  1321. </literallayout>
  1322. Consequently, you need to be sure you locate your new recipe
  1323. inside your layer such that it can be found.</para>
  1324. <para>You can find more information on how layers are
  1325. structured in the
  1326. "<link linkend='understanding-and-creating-layers'>Understanding and Creating Layers</link>"
  1327. section.</para></listitem>
  1328. <listitem><para><emphasis>Naming Your Recipe:</emphasis>
  1329. When you name your recipe, you need to follow this naming
  1330. convention:
  1331. <literallayout class='monospaced'>
  1332. <replaceable>basename</replaceable>_<replaceable>version</replaceable>.bb
  1333. </literallayout>
  1334. Use lower-cased characters and do not include the reserved
  1335. suffixes <filename>-native</filename>,
  1336. <filename>-cross</filename>, <filename>-initial</filename>,
  1337. or <filename>-dev</filename> casually (i.e. do not use them
  1338. as part of your recipe name unless the string applies).
  1339. Here are some examples:
  1340. <literallayout class='monospaced'>
  1341. cups_1.7.0.bb
  1342. gawk_4.0.2.bb
  1343. irssi_0.8.16-rc1.bb
  1344. </literallayout></para></listitem>
  1345. </itemizedlist>
  1346. </section>
  1347. <section id='understanding-recipe-syntax'>
  1348. <title>Understanding Recipe Syntax</title>
  1349. <para>
  1350. Understanding recipe file syntax is important for
  1351. writing recipes.
  1352. The following list overviews the basic items that make up a
  1353. BitBake recipe file.
  1354. For more complete BitBake syntax descriptions, see the
  1355. "<ulink url='&YOCTO_DOCS_BB_URL;#bitbake-user-manual-metadata'>Syntax and Operators</ulink>"
  1356. chapter of the BitBake User Manual.
  1357. <itemizedlist>
  1358. <listitem><para><emphasis>Variable Assignments and Manipulations:</emphasis>
  1359. Variable assignments allow a value to be assigned to a
  1360. variable.
  1361. The assignment can be static text or might include
  1362. the contents of other variables.
  1363. In addition to the assignment, appending and prepending
  1364. operations are also supported.</para>
  1365. <para>The following example shows some of the ways
  1366. you can use variables in recipes:
  1367. <literallayout class='monospaced'>
  1368. S = "${WORKDIR}/postfix-${PV}"
  1369. CFLAGS += "-DNO_ASM"
  1370. SRC_URI_append = " file://fixup.patch"
  1371. </literallayout>
  1372. </para></listitem>
  1373. <listitem><para><emphasis>Functions:</emphasis>
  1374. Functions provide a series of actions to be performed.
  1375. You usually use functions to override the default
  1376. implementation of a task function or to complement
  1377. a default function (i.e. append or prepend to an
  1378. existing function).
  1379. Standard functions use <filename>sh</filename> shell
  1380. syntax, although access to OpenEmbedded variables and
  1381. internal methods are also available.</para>
  1382. <para>The following is an example function from the
  1383. <filename>sed</filename> recipe:
  1384. <literallayout class='monospaced'>
  1385. do_install () {
  1386. autotools_do_install
  1387. install -d ${D}${base_bindir}
  1388. mv ${D}${bindir}/sed ${D}${base_bindir}/sed
  1389. rmdir ${D}${bindir}/
  1390. }
  1391. </literallayout>
  1392. It is also possible to implement new functions that
  1393. are called between existing tasks as long as the
  1394. new functions are not replacing or complementing the
  1395. default functions.
  1396. You can implement functions in Python
  1397. instead of shell.
  1398. Both of these options are not seen in the majority of
  1399. recipes.</para></listitem>
  1400. <listitem><para><emphasis>Keywords:</emphasis>
  1401. BitBake recipes use only a few keywords.
  1402. You use keywords to include common
  1403. functions (<filename>inherit</filename>), load parts
  1404. of a recipe from other files
  1405. (<filename>include</filename> and
  1406. <filename>require</filename>) and export variables
  1407. to the environment (<filename>export</filename>).</para>
  1408. <para>The following example shows the use of some of
  1409. these keywords:
  1410. <literallayout class='monospaced'>
  1411. export POSTCONF = "${STAGING_BINDIR}/postconf"
  1412. inherit autoconf
  1413. require otherfile.inc
  1414. </literallayout>
  1415. </para></listitem>
  1416. <listitem><para><emphasis>Comments:</emphasis>
  1417. Any lines that begin with the hash character
  1418. (<filename>#</filename>) are treated as comment lines
  1419. and are ignored:
  1420. <literallayout class='monospaced'>
  1421. # This is a comment
  1422. </literallayout>
  1423. </para></listitem>
  1424. </itemizedlist>
  1425. </para>
  1426. <para>
  1427. This next list summarizes the most important and most commonly
  1428. used parts of the recipe syntax.
  1429. For more information on these parts of the syntax, you can
  1430. reference the
  1431. <ulink url='&YOCTO_DOCS_BB_URL;#bitbake-user-manual-metadata'>Syntax and Operators</ulink>
  1432. chapter in the BitBake User Manual.
  1433. <itemizedlist>
  1434. <listitem><para><emphasis>Line Continuation: <filename>\</filename></emphasis> -
  1435. Use the backward slash (<filename>\</filename>)
  1436. character to split a statement over multiple lines.
  1437. Place the slash character at the end of the line that
  1438. is to be continued on the next line:
  1439. <literallayout class='monospaced'>
  1440. VAR = "A really long \
  1441. line"
  1442. </literallayout>
  1443. <note>
  1444. You cannot have any characters including spaces
  1445. or tabs after the slash character.
  1446. </note>
  1447. </para></listitem>
  1448. <listitem><para><emphasis>Using Variables: <filename>${...}</filename></emphasis> -
  1449. Use the <filename>${<replaceable>VARNAME</replaceable>}</filename> syntax to
  1450. access the contents of a variable:
  1451. <literallayout class='monospaced'>
  1452. SRC_URI = "${SOURCEFORGE_MIRROR}/libpng/zlib-${PV}.tar.gz"
  1453. </literallayout>
  1454. </para></listitem>
  1455. <listitem><para><emphasis>Quote All Assignments: <filename>"<replaceable>value</replaceable>"</filename></emphasis> -
  1456. Use double quotes around the value in all variable
  1457. assignments.
  1458. <literallayout class='monospaced'>
  1459. VAR1 = "${OTHERVAR}"
  1460. VAR2 = "The version is ${PV}"
  1461. </literallayout>
  1462. </para></listitem>
  1463. <listitem><para><emphasis>Conditional Assignment: <filename>?=</filename></emphasis> -
  1464. Conditional assignment is used to assign a value to
  1465. a variable, but only when the variable is currently
  1466. unset.
  1467. Use the question mark followed by the equal sign
  1468. (<filename>?=</filename>) to make a "soft" assignment
  1469. used for conditional assignment.
  1470. Typically, "soft" assignments are used in the
  1471. <filename>local.conf</filename> file for variables
  1472. that are allowed to come through from the external
  1473. environment.
  1474. </para>
  1475. <para>Here is an example where
  1476. <filename>VAR1</filename> is set to "New value" if
  1477. it is currently empty.
  1478. However, if <filename>VAR1</filename> has already been
  1479. set, it remains unchanged:
  1480. <literallayout class='monospaced'>
  1481. VAR1 ?= "New value"
  1482. </literallayout>
  1483. In this next example, <filename>VAR1</filename>
  1484. is left with the value "Original value":
  1485. <literallayout class='monospaced'>
  1486. VAR1 = "Original value"
  1487. VAR1 ?= "New value"
  1488. </literallayout>
  1489. </para></listitem>
  1490. <listitem><para><emphasis>Appending: <filename>+=</filename></emphasis> -
  1491. Use the plus character followed by the equals sign
  1492. (<filename>+=</filename>) to append values to existing
  1493. variables.
  1494. <note>
  1495. This operator adds a space between the existing
  1496. content of the variable and the new content.
  1497. </note></para>
  1498. <para>Here is an example:
  1499. <literallayout class='monospaced'>
  1500. SRC_URI += "file://fix-makefile.patch"
  1501. </literallayout>
  1502. </para></listitem>
  1503. <listitem><para><emphasis>Prepending: <filename>=+</filename></emphasis> -
  1504. Use the equals sign followed by the plus character
  1505. (<filename>=+</filename>) to prepend values to existing
  1506. variables.
  1507. <note>
  1508. This operator adds a space between the new content
  1509. and the existing content of the variable.
  1510. </note></para>
  1511. <para>Here is an example:
  1512. <literallayout class='monospaced'>
  1513. VAR =+ "Starts"
  1514. </literallayout>
  1515. </para></listitem>
  1516. <listitem><para><emphasis>Appending: <filename>_append</filename></emphasis> -
  1517. Use the <filename>_append</filename> operator to
  1518. append values to existing variables.
  1519. This operator does not add any additional space.
  1520. Also, the operator is applied after all the
  1521. <filename>+=</filename>, and
  1522. <filename>=+</filename> operators have been applied and
  1523. after all <filename>=</filename> assignments have
  1524. occurred.
  1525. </para>
  1526. <para>The following example shows the space being
  1527. explicitly added to the start to ensure the appended
  1528. value is not merged with the existing value:
  1529. <literallayout class='monospaced'>
  1530. SRC_URI_append = " file://fix-makefile.patch"
  1531. </literallayout>
  1532. You can also use the <filename>_append</filename>
  1533. operator with overrides, which results in the actions
  1534. only being performed for the specified target or
  1535. machine:
  1536. <literallayout class='monospaced'>
  1537. SRC_URI_append_sh4 = " file://fix-makefile.patch"
  1538. </literallayout>
  1539. </para></listitem>
  1540. <listitem><para><emphasis>Prepending: <filename>_prepend</filename></emphasis> -
  1541. Use the <filename>_prepend</filename> operator to
  1542. prepend values to existing variables.
  1543. This operator does not add any additional space.
  1544. Also, the operator is applied after all the
  1545. <filename>+=</filename>, and
  1546. <filename>=+</filename> operators have been applied and
  1547. after all <filename>=</filename> assignments have
  1548. occurred.
  1549. </para>
  1550. <para>The following example shows the space being
  1551. explicitly added to the end to ensure the prepended
  1552. value is not merged with the existing value:
  1553. <literallayout class='monospaced'>
  1554. CFLAGS_prepend = "-I${S}/myincludes "
  1555. </literallayout>
  1556. You can also use the <filename>_prepend</filename>
  1557. operator with overrides, which results in the actions
  1558. only being performed for the specified target or
  1559. machine:
  1560. <literallayout class='monospaced'>
  1561. CFLAGS_prepend_sh4 = "-I${S}/myincludes "
  1562. </literallayout>
  1563. </para></listitem>
  1564. <listitem><para><emphasis>Overrides:</emphasis> -
  1565. You can use overrides to set a value conditionally,
  1566. typically based on how the recipe is being built.
  1567. For example, to set the
  1568. <ulink url='&YOCTO_DOCS_REF_URL;#var-KBRANCH'><filename>KBRANCH</filename></ulink>
  1569. variable's value to "standard/base" for any target
  1570. <ulink url='&YOCTO_DOCS_REF_URL;#var-MACHINE'><filename>MACHINE</filename></ulink>,
  1571. except for qemuarm where it should be set to
  1572. "standard/arm-versatile-926ejs", you would do the
  1573. following:
  1574. <literallayout class='monospaced'>
  1575. KBRANCH = "standard/base"
  1576. KBRANCH_qemuarm = "standard/arm-versatile-926ejs"
  1577. </literallayout>
  1578. Overrides are also used to separate alternate values
  1579. of a variable in other situations.
  1580. For example, when setting variables such as
  1581. <ulink url='&YOCTO_DOCS_REF_URL;#var-FILES'><filename>FILES</filename></ulink>
  1582. and
  1583. <ulink url='&YOCTO_DOCS_REF_URL;#var-RDEPENDS'><filename>RDEPENDS</filename></ulink>
  1584. that are specific to individual packages produced by
  1585. a recipe, you should always use an override that
  1586. specifies the name of the package.
  1587. </para></listitem>
  1588. <listitem><para><emphasis>Indentation:</emphasis>
  1589. Use spaces for indentation rather than than tabs.
  1590. For shell functions, both currently work.
  1591. However, it is a policy decision of the Yocto Project
  1592. to use tabs in shell functions.
  1593. Realize that some layers have a policy to use spaces
  1594. for all indentation.
  1595. </para></listitem>
  1596. <listitem><para><emphasis>Using Python for Complex Operations: <filename>${@<replaceable>python_code</replaceable>}</filename></emphasis> -
  1597. For more advanced processing, it is possible to use
  1598. Python code during variable assignments (e.g.
  1599. search and replacement on a variable).</para>
  1600. <para>You indicate Python code using the
  1601. <filename>${@<replaceable>python_code</replaceable>}</filename>
  1602. syntax for the variable assignment:
  1603. <literallayout class='monospaced'>
  1604. SRC_URI = "ftp://ftp.info-zip.org/pub/infozip/src/zip${@d.getVar('PV',1).replace('.', '')}.tgz
  1605. </literallayout>
  1606. </para></listitem>
  1607. <listitem><para><emphasis>Shell Function Syntax:</emphasis>
  1608. Write shell functions as if you were writing a shell
  1609. script when you describe a list of actions to take.
  1610. You should ensure that your script works with a generic
  1611. <filename>sh</filename> and that it does not require
  1612. any <filename>bash</filename> or other shell-specific
  1613. functionality.
  1614. The same considerations apply to various system
  1615. utilities (e.g. <filename>sed</filename>,
  1616. <filename>grep</filename>, <filename>awk</filename>,
  1617. and so forth) that you might wish to use.
  1618. If in doubt, you should check with multiple
  1619. implementations - including those from BusyBox.
  1620. </para></listitem>
  1621. </itemizedlist>
  1622. </para>
  1623. </section>
  1624. <section id='new-recipe-running-a-build-on-the-recipe'>
  1625. <title>Running a Build on the Recipe</title>
  1626. <para>
  1627. Creating a new recipe is usually an iterative process that
  1628. requires using BitBake to process the recipe multiple times in
  1629. order to progressively discover and add information to the
  1630. recipe file.
  1631. </para>
  1632. <para>
  1633. Assuming you have sourced a build environment setup script (i.e.
  1634. <ulink url='&YOCTO_DOCS_REF_URL;#structure-core-script'><filename>&OE_INIT_FILE;</filename></ulink>
  1635. or
  1636. <ulink url='&YOCTO_DOCS_REF_URL;#structure-memres-core-script'><filename>oe-init-build-env-memres</filename></ulink>)
  1637. and you are in the
  1638. <link linkend='build-directory'>Build Directory</link>,
  1639. use BitBake to process your recipe.
  1640. All you need to provide is the
  1641. <filename><replaceable>basename</replaceable></filename> of the recipe as described
  1642. in the previous section:
  1643. <literallayout class='monospaced'>
  1644. $ bitbake <replaceable>basename</replaceable>
  1645. </literallayout>
  1646. </para>
  1647. <para>
  1648. During the build, the OpenEmbedded build system creates a
  1649. temporary work directory for each recipe
  1650. (<filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-WORKDIR'><filename>WORKDIR</filename></ulink><filename>}</filename>)
  1651. where it keeps extracted source files, log files, intermediate
  1652. compilation and packaging files, and so forth.
  1653. </para>
  1654. <para>
  1655. The per-recipe temporary work directory is constructed as follows and
  1656. depends on several factors:
  1657. <literallayout class='monospaced'>
  1658. BASE_WORKDIR ?= "${TMPDIR}/work"
  1659. WORKDIR = "${BASE_WORKDIR}/${MULTIMACH_TARGET_SYS}/${PN}/${EXTENDPE}${PV}-${PR}"
  1660. </literallayout>
  1661. As an example, assume a Source Directory top-level folder named
  1662. <filename>poky</filename>, a default Build Directory at
  1663. <filename>poky/build</filename>, and a
  1664. <filename>qemux86-poky-linux</filename> machine target system.
  1665. Furthermore, suppose your recipe is named
  1666. <filename>foo_1.3.0.bb</filename>.
  1667. In this case, the work directory the build system uses to
  1668. build the package would be as follows:
  1669. <literallayout class='monospaced'>
  1670. poky/build/tmp/work/qemux86-poky-linux/foo/1.3.0-r0
  1671. </literallayout>
  1672. Inside this directory you can find sub-directories such as
  1673. <filename>image</filename>, <filename>packages-split</filename>,
  1674. and <filename>temp</filename>.
  1675. After the build, you can examine these to determine how well
  1676. the build went.
  1677. <note>
  1678. You can find log files for each task in the recipe's
  1679. <filename>temp</filename> directory (e.g.
  1680. <filename>poky/build/tmp/work/qemux86-poky-linux/foo/1.3.0-r0/temp</filename>).
  1681. Log files are named <filename>log.<replaceable>taskname</replaceable></filename>
  1682. (e.g. <filename>log.do_configure</filename>,
  1683. <filename>log.do_fetch</filename>, and
  1684. <filename>log.do_compile</filename>).
  1685. </note>
  1686. </para>
  1687. <para>
  1688. You can find more information about the build process in the
  1689. "<ulink url='&YOCTO_DOCS_REF_URL;#closer-look'>A Closer Look at the Yocto Project Development Environment</ulink>"
  1690. chapter of the Yocto Project Reference Manual.
  1691. </para>
  1692. <para>
  1693. You can also reference the following variables in the
  1694. Yocto Project Reference Manual's glossary for more information:
  1695. <itemizedlist>
  1696. <listitem><ulink url='&YOCTO_DOCS_REF_URL;#var-TMPDIR'><filename>TMPDIR</filename></ulink>:
  1697. The top-level build output directory</listitem>
  1698. <listitem><ulink url='&YOCTO_DOCS_REF_URL;#var-MULTIMACH_TARGET_SYS'><filename>MULTIMACH_TARGET_SYS</filename></ulink>:
  1699. The target system identifier</listitem>
  1700. <listitem><ulink url='&YOCTO_DOCS_REF_URL;#var-PN'><filename>PN</filename></ulink>:
  1701. The recipe name</listitem>
  1702. <listitem><ulink url='&YOCTO_DOCS_REF_URL;#var-EXTENDPE'><filename>EXTENDPE</filename></ulink>:
  1703. The epoch - (if
  1704. <ulink url='&YOCTO_DOCS_REF_URL;#var-PE'><filename>PE</filename></ulink>
  1705. is not specified, which is usually the case for most
  1706. recipes, then <filename>EXTENDPE</filename> is blank)</listitem>
  1707. <listitem><ulink url='&YOCTO_DOCS_REF_URL;#var-PV'><filename>PV</filename></ulink>:
  1708. The recipe version</listitem>
  1709. <listitem><ulink url='&YOCTO_DOCS_REF_URL;#var-PR'><filename>PR</filename></ulink>:
  1710. The recipe revision</listitem>
  1711. </itemizedlist>
  1712. </para>
  1713. </section>
  1714. <section id='new-recipe-fetching-code'>
  1715. <title>Fetching Code</title>
  1716. <para>
  1717. The first thing your recipe must do is specify how to fetch
  1718. the source files.
  1719. Fetching is controlled mainly through the
  1720. <ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'><filename>SRC_URI</filename></ulink>
  1721. variable.
  1722. Your recipe must have a <filename>SRC_URI</filename> variable
  1723. that points to where the source is located.
  1724. For a graphical representation of source locations, see the
  1725. "<ulink url='&YOCTO_DOCS_REF_URL;#sources-dev-environment'>Sources</ulink>"
  1726. section in the Yocto Project Reference Manual.
  1727. </para>
  1728. <para>
  1729. The
  1730. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-fetch'><filename>do_fetch</filename></ulink>
  1731. task uses the prefix of each entry in the
  1732. <filename>SRC_URI</filename> variable value to determine which
  1733. fetcher to use to get your source files.
  1734. It is the <filename>SRC_URI</filename> variable that triggers
  1735. the fetcher.
  1736. The
  1737. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-patch'><filename>do_patch</filename></ulink>
  1738. task uses the variable after source is fetched to apply
  1739. patches.
  1740. The OpenEmbedded build system uses
  1741. <ulink url='&YOCTO_DOCS_REF_URL;#var-FILESOVERRIDES'><filename>FILESOVERRIDES</filename></ulink>
  1742. for scanning directory locations for local files in
  1743. <filename>SRC_URI</filename>.
  1744. </para>
  1745. <para>
  1746. The <filename>SRC_URI</filename> variable in your recipe must
  1747. define each unique location for your source files.
  1748. It is good practice to not hard-code pathnames in an URL used
  1749. in <filename>SRC_URI</filename>.
  1750. Rather than hard-code these paths, use
  1751. <filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-PV'><filename>PV</filename></ulink><filename>}</filename>,
  1752. which causes the fetch process to use the version specified in
  1753. the recipe filename.
  1754. Specifying the version in this manner means that upgrading the
  1755. recipe to a future version is as simple as renaming the recipe
  1756. to match the new version.
  1757. </para>
  1758. <para>
  1759. Here is a simple example from the
  1760. <filename>meta/recipes-devtools/cdrtools/cdrtools-native_3.01a20.bb</filename>
  1761. recipe where the source comes from a single tarball.
  1762. Notice the use of the
  1763. <ulink url='&YOCTO_DOCS_REF_URL;#var-PV'><filename>PV</filename></ulink>
  1764. variable:
  1765. <literallayout class='monospaced'>
  1766. SRC_URI = "ftp://ftp.berlios.de/pub/cdrecord/alpha/cdrtools-${PV}.tar.bz2"
  1767. </literallayout>
  1768. </para>
  1769. <para>
  1770. Files mentioned in <filename>SRC_URI</filename> whose names end
  1771. in a typical archive extension (e.g. <filename>.tar</filename>,
  1772. <filename>.tar.gz</filename>, <filename>.tar.bz2</filename>,
  1773. <filename>.zip</filename>, and so forth), are automatically
  1774. extracted during the
  1775. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-unpack'><filename>do_unpack</filename></ulink>
  1776. task.
  1777. For another example that specifies these types of files, see
  1778. the
  1779. "<link linkend='new-recipe-autotooled-package'>Autotooled Package</link>"
  1780. section.
  1781. </para>
  1782. <para>
  1783. Another way of specifying source is from an SCM.
  1784. For Git repositories, you must specify
  1785. <ulink url='&YOCTO_DOCS_REF_URL;#var-SRCREV'><filename>SRCREV</filename></ulink>
  1786. and you should specify
  1787. <ulink url='&YOCTO_DOCS_REF_URL;#var-PV'><filename>PV</filename></ulink>
  1788. to include the revision with
  1789. <ulink url='&YOCTO_DOCS_REF_URL;#var-SRCPV'><filename>SRCPV</filename></ulink>.
  1790. Here is an example from the recipe
  1791. <filename>meta/recipes-kernel/blktrace/blktrace_git.bb</filename>:
  1792. <literallayout class='monospaced'>
  1793. SRCREV = "d6918c8832793b4205ed3bfede78c2f915c23385"
  1794. PR = "r6"
  1795. PV = "1.0.5+git${SRCPV}"
  1796. SRC_URI = "git://git.kernel.dk/blktrace.git \
  1797. file://ldflags.patch"
  1798. </literallayout>
  1799. </para>
  1800. <para>
  1801. If your <filename>SRC_URI</filename> statement includes
  1802. URLs pointing to individual files fetched from a remote server
  1803. other than a version control system, BitBake attempts to
  1804. verify the files against checksums defined in your recipe to
  1805. ensure they have not been tampered with or otherwise modified
  1806. since the recipe was written.
  1807. Two checksums are used:
  1808. <filename>SRC_URI[md5sum]</filename> and
  1809. <filename>SRC_URI[sha256sum]</filename>.
  1810. </para>
  1811. <para>
  1812. If your <filename>SRC_URI</filename> variable points to
  1813. more than a single URL (excluding SCM URLs), you need to
  1814. provide the <filename>md5</filename> and
  1815. <filename>sha256</filename> checksums for each URL.
  1816. For these cases, you provide a name for each URL as part of
  1817. the <filename>SRC_URI</filename> and then reference that name
  1818. in the subsequent checksum statements.
  1819. Here is an example:
  1820. <literallayout class='monospaced'>
  1821. SRC_URI = "${DEBIAN_MIRROR}/main/a/apmd/apmd_3.2.2.orig.tar.gz;name=tarball \
  1822. ${DEBIAN_MIRROR}/main/a/apmd/apmd_${PV}.diff.gz;name=patch
  1823. SRC_URI[tarball.md5sum] = "b1e6309e8331e0f4e6efd311c2d97fa8"
  1824. SRC_URI[tarball.sha256sum] = "7f7d9f60b7766b852881d40b8ff91d8e39fccb0d1d913102a5c75a2dbb52332d"
  1825. SRC_URI[patch.md5sum] = "57e1b689264ea80f78353519eece0c92"
  1826. SRC_URI[patch.sha256sum] = "7905ff96be93d725544d0040e425c42f9c05580db3c272f11cff75b9aa89d430"
  1827. </literallayout>
  1828. </para>
  1829. <para>
  1830. Proper values for <filename>md5</filename> and
  1831. <filename>sha256</filename> checksums might be available
  1832. with other signatures on the download page for the upstream
  1833. source (e.g. <filename>md5</filename>,
  1834. <filename>sha1</filename>, <filename>sha256</filename>,
  1835. <filename>GPG</filename>, and so forth).
  1836. Because the OpenEmbedded build system only deals with
  1837. <filename>sha256sum</filename> and <filename>md5sum</filename>,
  1838. you should verify all the signatures you find by hand.
  1839. </para>
  1840. <para>
  1841. If no <filename>SRC_URI</filename> checksums are specified
  1842. when you attempt to build the recipe, or you provide an
  1843. incorrect checksum, the build will produce an error for each
  1844. missing or incorrect checksum.
  1845. As part of the error message, the build system provides
  1846. the checksum string corresponding to the fetched file.
  1847. Once you have the correct checksums, you can copy and paste
  1848. them into your recipe and then run the build again to continue.
  1849. <note>
  1850. As mentioned, if the upstream source provides signatures
  1851. for verifying the downloaded source code, you should
  1852. verify those manually before setting the checksum values
  1853. in the recipe and continuing with the build.
  1854. </note>
  1855. </para>
  1856. <para>
  1857. This final example is a bit more complicated and is from the
  1858. <filename>meta/recipes-sato/rxvt-unicode/rxvt-unicode_9.20.bb</filename>
  1859. recipe.
  1860. The example's <filename>SRC_URI</filename> statement identifies
  1861. multiple files as the source files for the recipe: a tarball, a
  1862. patch file, a desktop file, and an icon.
  1863. <literallayout class='monospaced'>
  1864. SRC_URI = "http://dist.schmorp.de/rxvt-unicode/Attic/rxvt-unicode-${PV}.tar.bz2 \
  1865. file://xwc.patch \
  1866. file://rxvt.desktop \
  1867. file://rxvt.png"
  1868. </literallayout>
  1869. </para>
  1870. <para>
  1871. When you specify local files using the
  1872. <filename>file://</filename> URI protocol, the build system
  1873. fetches files from the local machine.
  1874. The path is relative to the
  1875. <ulink url='&YOCTO_DOCS_REF_URL;#var-FILESPATH'><filename>FILESPATH</filename></ulink>
  1876. variable and searches specific directories in a certain order:
  1877. <filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-BP'><filename>BP</filename></ulink><filename>}</filename>,
  1878. <filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-BPN'><filename>BPN</filename></ulink><filename>}</filename>,
  1879. and <filename>files</filename>.
  1880. The directories are assumed to be subdirectories of the
  1881. directory in which the recipe or append file resides.
  1882. For another example that specifies these types of files, see the
  1883. "<link linkend='new-recipe-single-c-file-package-hello-world'>Single .c File Package (Hello World!)</link>"
  1884. section.
  1885. </para>
  1886. <para>
  1887. The previous example also specifies a patch file.
  1888. Patch files are files whose names usually end in
  1889. <filename>.patch</filename> or <filename>.diff</filename> but
  1890. can end with compressed suffixes such as
  1891. <filename>diff.gz</filename> and
  1892. <filename>patch.bz2</filename>, for example.
  1893. The build system automatically applies patches as described
  1894. in the
  1895. "<link linkend='new-recipe-patching-code'>Patching Code</link>" section.
  1896. </para>
  1897. </section>
  1898. <section id='new-recipe-unpacking-code'>
  1899. <title>Unpacking Code</title>
  1900. <para>
  1901. During the build, the
  1902. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-unpack'><filename>do_unpack</filename></ulink>
  1903. task unpacks the source with
  1904. <filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-S'><filename>S</filename></ulink><filename>}</filename>
  1905. pointing to where it is unpacked.
  1906. </para>
  1907. <para>
  1908. If you are fetching your source files from an upstream source
  1909. archived tarball and the tarball's internal structure matches
  1910. the common convention of a top-level subdirectory named
  1911. <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>,
  1912. then you do not need to set <filename>S</filename>.
  1913. However, if <filename>SRC_URI</filename> specifies to fetch
  1914. source from an archive that does not use this convention,
  1915. or from an SCM like Git or Subversion, your recipe needs to
  1916. define <filename>S</filename>.
  1917. </para>
  1918. <para>
  1919. If processing your recipe using BitBake successfully unpacks
  1920. the source files, you need to be sure that the directory
  1921. pointed to by <filename>${S}</filename> matches the structure
  1922. of the source.
  1923. </para>
  1924. </section>
  1925. <section id='new-recipe-patching-code'>
  1926. <title>Patching Code</title>
  1927. <para>
  1928. Sometimes it is necessary to patch code after it has been
  1929. fetched.
  1930. Any files mentioned in <filename>SRC_URI</filename> whose
  1931. names end in <filename>.patch</filename> or
  1932. <filename>.diff</filename> or compressed versions of these
  1933. suffixes (e.g. <filename>diff.gz</filename> are treated as
  1934. patches.
  1935. The
  1936. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-patch'><filename>do_patch</filename></ulink>
  1937. task automatically applies these patches.
  1938. </para>
  1939. <para>
  1940. The build system should be able to apply patches with the "-p1"
  1941. option (i.e. one directory level in the path will be stripped
  1942. off).
  1943. If your patch needs to have more directory levels stripped off,
  1944. specify the number of levels using the "striplevel" option in
  1945. the <filename>SRC_URI</filename> entry for the patch.
  1946. Alternatively, if your patch needs to be applied in a specific
  1947. subdirectory that is not specified in the patch file, use the
  1948. "patchdir" option in the entry.
  1949. </para>
  1950. <para>
  1951. As with all local files referenced in
  1952. <ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'><filename>SRC_URI</filename></ulink>
  1953. using <filename>file://</filename>, you should place
  1954. patch files in a directory next to the recipe either
  1955. named the same as the base name of the recipe
  1956. (<ulink url='&YOCTO_DOCS_REF_URL;#var-BP'><filename>BP</filename></ulink>
  1957. and
  1958. <ulink url='&YOCTO_DOCS_REF_URL;#var-BPN'><filename>BPN</filename></ulink>)
  1959. or "files".
  1960. </para>
  1961. </section>
  1962. <section id='new-recipe-licensing'>
  1963. <title>Licensing</title>
  1964. <para>
  1965. Your recipe needs to have both the
  1966. <ulink url='&YOCTO_DOCS_REF_URL;#var-LICENSE'><filename>LICENSE</filename></ulink>
  1967. and
  1968. <ulink url='&YOCTO_DOCS_REF_URL;#var-LIC_FILES_CHKSUM'><filename>LIC_FILES_CHKSUM</filename></ulink>
  1969. variables:
  1970. <itemizedlist>
  1971. <listitem><para><emphasis><filename>LICENSE</filename>:</emphasis>
  1972. This variable specifies the license for the software.
  1973. If you do not know the license under which the software
  1974. you are building is distributed, you should go to the
  1975. source code and look for that information.
  1976. Typical files containing this information include
  1977. <filename>COPYING</filename>,
  1978. <filename>LICENSE</filename>, and
  1979. <filename>README</filename> files.
  1980. You could also find the information near the top of
  1981. a source file.
  1982. For example, given a piece of software licensed under
  1983. the GNU General Public License version 2, you would
  1984. set <filename>LICENSE</filename> as follows:
  1985. <literallayout class='monospaced'>
  1986. LICENSE = "GPLv2"
  1987. </literallayout></para>
  1988. <para>The licenses you specify within
  1989. <filename>LICENSE</filename> can have any name as long
  1990. as you do not use spaces, since spaces are used as
  1991. separators between license names.
  1992. For standard licenses, use the names of the files in
  1993. <filename>meta/files/common-licenses/</filename>
  1994. or the <filename>SPDXLICENSEMAP</filename> flag names
  1995. defined in <filename>meta/conf/licenses.conf</filename>.
  1996. </para></listitem>
  1997. <listitem><para><emphasis><filename>LIC_FILES_CHKSUM</filename>:</emphasis>
  1998. The OpenEmbedded build system uses this variable to
  1999. make sure the license text has not changed.
  2000. If it has, the build produces an error and it affords
  2001. you the chance to figure it out and correct the problem.
  2002. </para>
  2003. <para>You need to specify all applicable licensing
  2004. files for the software.
  2005. At the end of the configuration step, the build process
  2006. will compare the checksums of the files to be sure
  2007. the text has not changed.
  2008. Any differences result in an error with the message
  2009. containing the current checksum.
  2010. For more explanation and examples of how to set the
  2011. <filename>LIC_FILES_CHKSUM</filename> variable, see the
  2012. "<ulink url='&YOCTO_DOCS_REF_URL;#usingpoky-configuring-LIC_FILES_CHKSUM'>Tracking License Changes</ulink>"
  2013. section in the Yocto Project Reference Manual.</para>
  2014. <para>To determine the correct checksum string, you
  2015. can list the appropriate files in the
  2016. <filename>LIC_FILES_CHKSUM</filename> variable with
  2017. incorrect md5 strings, attempt to build the software,
  2018. and then note the resulting error messages that will
  2019. report the correct md5 strings.
  2020. See the
  2021. "<link linkend='new-recipe-fetching-code'>Fetching Code</link>"
  2022. section for additional information.
  2023. </para>
  2024. <para>
  2025. Here is an example that assumes the software has a
  2026. <filename>COPYING</filename> file:
  2027. <literallayout class='monospaced'>
  2028. LIC_FILES_CHKSUM = "file://COPYING;md5=xxx"
  2029. </literallayout>
  2030. When you try to build the software, the build system
  2031. will produce an error and give you the correct string
  2032. that you can substitute into the recipe file for a
  2033. subsequent build.
  2034. </para></listitem>
  2035. </itemizedlist>
  2036. </para>
  2037. <!--
  2038. <para>
  2039. For trying this out I created a new recipe named
  2040. <filename>htop_1.0.2.bb</filename> and put it in
  2041. <filename>poky/meta/recipes-extended/htop</filename>.
  2042. There are two license type statements in my very simple
  2043. recipe:
  2044. <literallayout class='monospaced'>
  2045. LICENSE = ""
  2046. LIC_FILES_CHKSUM = ""
  2047. SRC_URI[md5sum] = ""
  2048. SRC_URI[sha256sum] = ""
  2049. </literallayout>
  2050. Evidently, you need to run a <filename>bitbake -c cleanall htop</filename>.
  2051. Next, you delete or comment out the two <filename>SRC_URI</filename>
  2052. lines at the end and then attempt to build the software with
  2053. <filename>bitbake htop</filename>.
  2054. Doing so causes BitBake to report some errors and and give
  2055. you the actual strings you need for the last two
  2056. <filename>SRC_URI</filename> lines.
  2057. Prior to this, you have to dig around in the home page of the
  2058. source for <filename>htop</filename> and determine that the
  2059. software is released under GPLv2.
  2060. You can provide that in the <filename>LICENSE</filename>
  2061. statement.
  2062. Now you edit your recipe to have those two strings for
  2063. the <filename>SRC_URI</filename> statements:
  2064. <literallayout class='monospaced'>
  2065. LICENSE = "GPLv2"
  2066. LIC_FILES_CHKSUM = ""
  2067. SRC_URI = "${SOURCEFORGE_MIRROR}/htop/htop-${PV}.tar.gz"
  2068. SRC_URI[md5sum] = "0d01cca8df3349c74569cefebbd9919e"
  2069. SRC_URI[sha256sum] = "ee60657b044ece0df096c053060df7abf3cce3a568ab34d260049e6a37ccd8a1"
  2070. </literallayout>
  2071. At this point, you can build the software again using the
  2072. <filename>bitbake htop</filename> command.
  2073. There is just a set of errors now associated with the
  2074. empty <filename>LIC_FILES_CHKSUM</filename> variable now.
  2075. </para>
  2076. -->
  2077. </section>
  2078. <section id='new-recipe-configuring-the-recipe'>
  2079. <title>Configuring the Recipe</title>
  2080. <para>
  2081. Most software provides some means of setting build-time
  2082. configuration options before compilation.
  2083. Typically, setting these options is accomplished by running a
  2084. configure script with some options, or by modifying a build
  2085. configuration file.
  2086. <note>
  2087. As of Yocto Project Release 7.1, some of the core recipes
  2088. that package binary configuration scripts now disable the
  2089. scripts due to the scripts previously requiring error-prone
  2090. path substitution.
  2091. The OpenEmbedded build system uses
  2092. <filename>pkg-config</filename> now, which is much more
  2093. robust.
  2094. You can find a list of the <filename>*-config</filename>
  2095. scripts that are disabled list in the
  2096. "<ulink url='&YOCTO_DOCS_REF_URL;#migration-1.7-binary-configuration-scripts-disabled'>Binary Configuration Scripts Disabled</ulink>"
  2097. section in the Yocto Project Reference Manual.
  2098. </note>
  2099. </para>
  2100. <para>
  2101. A major part of build-time configuration is about checking for
  2102. build-time dependencies and possibly enabling optional
  2103. functionality as a result.
  2104. You need to specify any build-time dependencies for the
  2105. software you are building in your recipe's
  2106. <ulink url='&YOCTO_DOCS_REF_URL;#var-DEPENDS'><filename>DEPENDS</filename></ulink>
  2107. value, in terms of other recipes that satisfy those
  2108. dependencies.
  2109. You can often find build-time or runtime
  2110. dependencies described in the software's documentation.
  2111. </para>
  2112. <para>
  2113. The following list provides configuration items of note based
  2114. on how your software is built:
  2115. <itemizedlist>
  2116. <listitem><para><emphasis>Autotools:</emphasis>
  2117. If your source files have a
  2118. <filename>configure.ac</filename> file, then your
  2119. software is built using Autotools.
  2120. If this is the case, you just need to worry about
  2121. modifying the configuration.</para>
  2122. <para>When using Autotools, your recipe needs to inherit
  2123. the
  2124. <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-autotools'><filename>autotools</filename></ulink>
  2125. class and your recipe does not have to contain a
  2126. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-configure'><filename>do_configure</filename></ulink>
  2127. task.
  2128. However, you might still want to make some adjustments.
  2129. For example, you can set
  2130. <ulink url='&YOCTO_DOCS_REF_URL;#var-EXTRA_OECONF'><filename>EXTRA_OECONF</filename></ulink>
  2131. or
  2132. <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGECONFIG_CONFARGS'><filename>PACKAGECONFIG_CONFARGS</filename></ulink>
  2133. to pass any needed configure options that are specific
  2134. to the recipe.</para></listitem>
  2135. <listitem><para><emphasis>CMake:</emphasis>
  2136. If your source files have a
  2137. <filename>CMakeLists.txt</filename> file, then your
  2138. software is built using CMake.
  2139. If this is the case, you just need to worry about
  2140. modifying the configuration.</para>
  2141. <para>When you use CMake, your recipe needs to inherit
  2142. the
  2143. <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-cmake'><filename>cmake</filename></ulink>
  2144. class and your recipe does not have to contain a
  2145. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-configure'><filename>do_configure</filename></ulink>
  2146. task.
  2147. You can make some adjustments by setting
  2148. <ulink url='&YOCTO_DOCS_REF_URL;#var-EXTRA_OECMAKE'><filename>EXTRA_OECMAKE</filename></ulink>
  2149. to pass any needed configure options that are specific
  2150. to the recipe.</para></listitem>
  2151. <listitem><para><emphasis>Other:</emphasis>
  2152. If your source files do not have a
  2153. <filename>configure.ac</filename> or
  2154. <filename>CMakeLists.txt</filename> file, then your
  2155. software is built using some method other than Autotools
  2156. or CMake.
  2157. If this is the case, you normally need to provide a
  2158. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-configure'><filename>do_configure</filename></ulink>
  2159. task in your recipe
  2160. unless, of course, there is nothing to configure.
  2161. </para>
  2162. <para>Even if your software is not being built by
  2163. Autotools or CMake, you still might not need to deal
  2164. with any configuration issues.
  2165. You need to determine if configuration is even a required step.
  2166. You might need to modify a Makefile or some configuration file
  2167. used for the build to specify necessary build options.
  2168. Or, perhaps you might need to run a provided, custom
  2169. configure script with the appropriate options.</para>
  2170. <para>For the case involving a custom configure
  2171. script, you would run
  2172. <filename>./configure --help</filename> and look for
  2173. the options you need to set.</para></listitem>
  2174. </itemizedlist>
  2175. </para>
  2176. <para>
  2177. Once configuration succeeds, it is always good practice to
  2178. look at the <filename>log.do_configure</filename> file to
  2179. ensure that the appropriate options have been enabled and no
  2180. additional build-time dependencies need to be added to
  2181. <filename>DEPENDS</filename>.
  2182. For example, if the configure script reports that it found
  2183. something not mentioned in <filename>DEPENDS</filename>, or
  2184. that it did not find something that it needed for some
  2185. desired optional functionality, then you would need to add
  2186. those to <filename>DEPENDS</filename>.
  2187. Looking at the log might also reveal items being checked for,
  2188. enabled, or both that you do not want, or items not being found
  2189. that are in <filename>DEPENDS</filename>, in which case
  2190. you would need to look at passing extra options to the
  2191. configure script as needed.
  2192. For reference information on configure options specific to the
  2193. software you are building, you can consult the output of the
  2194. <filename>./configure --help</filename> command within
  2195. <filename>${S}</filename> or consult the software's upstream
  2196. documentation.
  2197. </para>
  2198. </section>
  2199. <section id='new-recipe-compilation'>
  2200. <title>Compilation</title>
  2201. <para>
  2202. During a build, the <filename>do_compile</filename> task
  2203. happens after source is fetched, unpacked, and configured.
  2204. If the recipe passes through <filename>do_compile</filename>
  2205. successfully, nothing needs to be done.
  2206. </para>
  2207. <para>
  2208. However, if the compile step fails, you need to diagnose the
  2209. failure.
  2210. Here are some common issues that cause failures.
  2211. <note>
  2212. For cases where improper paths are detected for
  2213. configuration files or for when libraries/headers cannot
  2214. be found, be sure you are using the more robust
  2215. <filename>pkg-config</filename>.
  2216. See the note in section
  2217. "<link linkend='new-recipe-configuring-the-recipe'>Configuring the Recipe</link>"
  2218. for additional information.
  2219. </note>
  2220. <itemizedlist>
  2221. <listitem><para><emphasis>Parallel build failures:</emphasis>
  2222. These failures manifest themselves as intermittent
  2223. errors, or errors reporting that a file or directory
  2224. that should be created by some other part of the build
  2225. process could not be found.
  2226. This type of failure can occur even if, upon inspection,
  2227. the file or directory does exist after the build has
  2228. failed, because that part of the build process happened
  2229. in the wrong order.</para>
  2230. <para>To fix the problem, you need to either satisfy
  2231. the missing dependency in the Makefile or whatever
  2232. script produced the Makefile, or (as a workaround)
  2233. set
  2234. <ulink url='&YOCTO_DOCS_REF_URL;#var-PARALLEL_MAKE'><filename>PARALLEL_MAKE</filename></ulink>
  2235. to an empty string:
  2236. <literallayout class='monospaced'>
  2237. PARALLEL_MAKE = ""
  2238. </literallayout></para>
  2239. <para>
  2240. For information on parallel Makefile issues, see the
  2241. "<link linkend='debugging-parallel-make-races'>Debugging Parallel Make Races</link>"
  2242. section.
  2243. </para></listitem>
  2244. <listitem><para><emphasis>Improper host path usage:</emphasis>
  2245. This failure applies to recipes building for the target
  2246. or <filename>nativesdk</filename> only.
  2247. The failure occurs when the compilation process uses
  2248. improper headers, libraries, or other files from the
  2249. host system when cross-compiling for the target.
  2250. </para>
  2251. <para>To fix the problem, examine the
  2252. <filename>log.do_compile</filename> file to identify
  2253. the host paths being used (e.g.
  2254. <filename>/usr/include</filename>,
  2255. <filename>/usr/lib</filename>, and so forth) and then
  2256. either add configure options, apply a patch, or do both.
  2257. </para></listitem>
  2258. <listitem><para><emphasis>Failure to find required
  2259. libraries/headers:</emphasis>
  2260. If a build-time dependency is missing because it has
  2261. not been declared in
  2262. <ulink url='&YOCTO_DOCS_REF_URL;#var-DEPENDS'><filename>DEPENDS</filename></ulink>,
  2263. or because the dependency exists but the path used by
  2264. the build process to find the file is incorrect and the
  2265. configure step did not detect it, the compilation
  2266. process could fail.
  2267. For either of these failures, the compilation process
  2268. notes that files could not be found.
  2269. In these cases, you need to go back and add additional
  2270. options to the configure script as well as possibly
  2271. add additional build-time dependencies to
  2272. <filename>DEPENDS</filename>.</para>
  2273. <para>Occasionally, it is necessary to apply a patch
  2274. to the source to ensure the correct paths are used.
  2275. If you need to specify paths to find files staged
  2276. into the sysroot from other recipes, use the variables
  2277. that the OpenEmbedded build system provides
  2278. (e.g.
  2279. <filename>STAGING_BINDIR</filename>,
  2280. <filename>STAGING_INCDIR</filename>,
  2281. <filename>STAGING_DATADIR</filename>, and so forth).
  2282. <!--
  2283. (e.g.
  2284. <ulink url='&YOCTO_DOCS_REF_URL;#var-STAGING_BINDIR'><filename>STAGING_BINDIR</filename></ulink>,
  2285. <ulink url='&YOCTO_DOCS_REF_URL;#var-STAGING_INCDIR'><filename>STAGING_INCDIR</filename></ulink>,
  2286. <ulink url='&YOCTO_DOCS_REF_URL;#var-STAGING_DATADIR'><filename>STAGING_DATADIR</filename></ulink>,
  2287. and so forth).
  2288. -->
  2289. </para></listitem>
  2290. </itemizedlist>
  2291. </para>
  2292. </section>
  2293. <section id='new-recipe-installing'>
  2294. <title>Installing</title>
  2295. <para>
  2296. During <filename>do_install</filename>, the task copies the
  2297. built files along with their hierarchy to locations that
  2298. would mirror their locations on the target device.
  2299. The installation process copies files from the
  2300. <filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-S'><filename>S</filename></ulink><filename>}</filename>,
  2301. <filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-B'><filename>B</filename></ulink><filename>}</filename>,
  2302. and
  2303. <filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-WORKDIR'><filename>WORKDIR</filename></ulink><filename>}</filename>
  2304. directories to the
  2305. <filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-D'><filename>D</filename></ulink><filename>}</filename>
  2306. directory to create the structure as it should appear on the
  2307. target system.
  2308. </para>
  2309. <para>
  2310. How your software is built affects what you must do to be
  2311. sure your software is installed correctly.
  2312. The following list describes what you must do for installation
  2313. depending on the type of build system used by the software
  2314. being built:
  2315. <itemizedlist>
  2316. <listitem><para><emphasis>Autotools and CMake:</emphasis>
  2317. If the software your recipe is building uses Autotools
  2318. or CMake, the OpenEmbedded build
  2319. system understands how to install the software.
  2320. Consequently, you do not have to have a
  2321. <filename>do_install</filename> task as part of your
  2322. recipe.
  2323. You just need to make sure the install portion of the
  2324. build completes with no issues.
  2325. However, if you wish to install additional files not
  2326. already being installed by
  2327. <filename>make install</filename>, you should do this
  2328. using a <filename>do_install_append</filename> function
  2329. using the install command as described in
  2330. the "Manual" bulleted item later in this list.
  2331. </para></listitem>
  2332. <listitem><para><emphasis>Other (using
  2333. <filename>make install</filename>):</emphasis>
  2334. You need to define a
  2335. <filename>do_install</filename> function in your
  2336. recipe.
  2337. The function should call
  2338. <filename>oe_runmake install</filename> and will likely
  2339. need to pass in the destination directory as well.
  2340. How you pass that path is dependent on how the
  2341. <filename>Makefile</filename> being run is written
  2342. (e.g. <filename>DESTDIR=${D}</filename>,
  2343. <filename>PREFIX=${D}</filename>,
  2344. <filename>INSTALLROOT=${D}</filename>, and so forth).
  2345. </para>
  2346. <para>For an example recipe using
  2347. <filename>make install</filename>, see the
  2348. "<link linkend='new-recipe-makefile-based-package'>Makefile-Based Package</link>"
  2349. section.</para></listitem>
  2350. <listitem><para><emphasis>Manual:</emphasis>
  2351. You need to define a
  2352. <filename>do_install</filename> function in your
  2353. recipe.
  2354. The function must first use
  2355. <filename>install -d</filename> to create the
  2356. directories under
  2357. <filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-D'><filename>D</filename></ulink><filename>}</filename>.
  2358. Once the directories exist, your function can use
  2359. <filename>install</filename> to manually install the
  2360. built software into the directories.</para>
  2361. <para>You can find more information on
  2362. <filename>install</filename> at
  2363. <ulink url='http://www.gnu.org/software/coreutils/manual/html_node/install-invocation.html'></ulink>.
  2364. </para></listitem>
  2365. </itemizedlist>
  2366. </para>
  2367. <para>
  2368. For the scenarios that do not use Autotools or
  2369. CMake, you need to track the installation
  2370. and diagnose and fix any issues until everything installs
  2371. correctly.
  2372. You need to look in the default location of
  2373. <filename>${D}</filename>, which is
  2374. <filename>${WORKDIR}/image</filename>, to be sure your
  2375. files have been installed correctly.
  2376. </para>
  2377. <note><title>Notes</title>
  2378. <itemizedlist>
  2379. <listitem><para>
  2380. During the installation process, you might need to
  2381. modify some of the installed files to suit the target
  2382. layout.
  2383. For example, you might need to replace hard-coded paths
  2384. in an initscript with values of variables provided by
  2385. the build system, such as replacing
  2386. <filename>/usr/bin/</filename> with
  2387. <filename>${bindir}</filename>.
  2388. If you do perform such modifications during
  2389. <filename>do_install</filename>, be sure to modify the
  2390. destination file after copying rather than before
  2391. copying.
  2392. Modifying after copying ensures that the build system
  2393. can re-execute <filename>do_install</filename> if
  2394. needed.
  2395. </para></listitem>
  2396. <listitem><para>
  2397. <filename>oe_runmake install</filename>, which can be
  2398. run directly or can be run indirectly by the
  2399. <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-autotools'><filename>autotools</filename></ulink>
  2400. and
  2401. <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-cmake'><filename>cmake</filename></ulink>
  2402. classes, runs <filename>make install</filename> in
  2403. parallel.
  2404. Sometimes, a Makefile can have missing dependencies
  2405. between targets that can result in race conditions.
  2406. If you experience intermittent failures during
  2407. <filename>do_install</filename>, you might be able to
  2408. work around them by disabling parallel Makefile
  2409. installs by adding the following to the recipe:
  2410. <literallayout class='monospaced'>
  2411. PARALLEL_MAKEINST = ""
  2412. </literallayout>
  2413. See
  2414. <ulink url='&YOCTO_DOCS_REF_URL;#var-PARALLEL_MAKEINST'><filename>PARALLEL_MAKEINST</filename></ulink>
  2415. for additional information.
  2416. </para></listitem>
  2417. </itemizedlist>
  2418. </note>
  2419. </section>
  2420. <section id='new-recipe-enabling-system-services'>
  2421. <title>Enabling System Services</title>
  2422. <para>
  2423. If you want to install a service, which is a process that
  2424. usually starts on boot and runs in the background, then
  2425. you must include some additional definitions in your recipe.
  2426. </para>
  2427. <para>
  2428. If you are adding services and the service initialization
  2429. script or the service file itself is not installed, you must
  2430. provide for that installation in your recipe using a
  2431. <filename>do_install_append</filename> function.
  2432. If your recipe already has a <filename>do_install</filename>
  2433. function, update the function near its end rather than
  2434. adding an additional <filename>do_install_append</filename>
  2435. function.
  2436. </para>
  2437. <para>
  2438. When you create the installation for your services, you need
  2439. to accomplish what is normally done by
  2440. <filename>make install</filename>.
  2441. In other words, make sure your installation arranges the output
  2442. similar to how it is arranged on the target system.
  2443. </para>
  2444. <para>
  2445. The OpenEmbedded build system provides support for starting
  2446. services two different ways:
  2447. <itemizedlist>
  2448. <listitem><para><emphasis>SysVinit:</emphasis>
  2449. SysVinit is a system and service manager that
  2450. manages the init system used to control the very basic
  2451. functions of your system.
  2452. The init program is the first program
  2453. started by the Linux kernel when the system boots.
  2454. Init then controls the startup, running and shutdown
  2455. of all other programs.</para>
  2456. <para>To enable a service using SysVinit, your recipe
  2457. needs to inherit the
  2458. <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-update-rc.d'><filename>update-rc.d</filename></ulink>
  2459. class.
  2460. The class helps facilitate safely installing the
  2461. package on the target.</para>
  2462. <para>You will need to set the
  2463. <ulink url='&YOCTO_DOCS_REF_URL;#var-INITSCRIPT_PACKAGES'><filename>INITSCRIPT_PACKAGES</filename></ulink>,
  2464. <ulink url='&YOCTO_DOCS_REF_URL;#var-INITSCRIPT_NAME'><filename>INITSCRIPT_NAME</filename></ulink>,
  2465. and
  2466. <ulink url='&YOCTO_DOCS_REF_URL;#var-INITSCRIPT_PARAMS'><filename>INITSCRIPT_PARAMS</filename></ulink>
  2467. variables within your recipe.</para></listitem>
  2468. <listitem><para><emphasis>systemd:</emphasis>
  2469. System Management Daemon (systemd) was designed to
  2470. replace SysVinit and to provide
  2471. enhanced management of services.
  2472. For more information on systemd, see the systemd
  2473. homepage at
  2474. <ulink url='http://freedesktop.org/wiki/Software/systemd/'></ulink>.
  2475. </para>
  2476. <para>To enable a service using systemd, your recipe
  2477. needs to inherit the
  2478. <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-systemd'><filename>systemd</filename></ulink>
  2479. class.
  2480. See the <filename>systemd.bbclass</filename> file
  2481. located in your
  2482. <link linkend='source-directory'>Source Directory</link>.
  2483. section for more information.
  2484. </para></listitem>
  2485. </itemizedlist>
  2486. </para>
  2487. </section>
  2488. <section id='new-recipe-packaging'>
  2489. <title>Packaging</title>
  2490. <para>
  2491. Successful packaging is a combination of automated processes
  2492. performed by the OpenEmbedded build system and some
  2493. specific steps you need to take.
  2494. The following list describes the process:
  2495. <itemizedlist>
  2496. <listitem><para><emphasis>Splitting Files</emphasis>:
  2497. The <filename>do_package</filename> task splits the
  2498. files produced by the recipe into logical components.
  2499. Even software that produces a single binary might
  2500. still have debug symbols, documentation, and other
  2501. logical components that should be split out.
  2502. The <filename>do_package</filename> task ensures
  2503. that files are split up and packaged correctly.
  2504. </para></listitem>
  2505. <listitem><para><emphasis>Running QA Checks</emphasis>:
  2506. The
  2507. <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-insane'><filename>insane</filename></ulink>
  2508. class adds a step to
  2509. the package generation process so that output quality
  2510. assurance checks are generated by the OpenEmbedded
  2511. build system.
  2512. This step performs a range of checks to be sure the
  2513. build's output is free of common problems that show
  2514. up during runtime.
  2515. For information on these checks, see the
  2516. <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-insane'><filename>insane</filename></ulink>
  2517. class and the
  2518. "<ulink url='&YOCTO_DOCS_REF_URL;#ref-qa-checks'>QA Error and Warning Messages</ulink>"
  2519. chapter in the Yocto Project Reference Manual.
  2520. </para></listitem>
  2521. <listitem><para><emphasis>Hand-Checking Your Packages</emphasis>:
  2522. After you build your software, you need to be sure
  2523. your packages are correct.
  2524. Examine the
  2525. <filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-WORKDIR'><filename>WORKDIR</filename></ulink><filename>}/packages-split</filename>
  2526. directory and make sure files are where you expect
  2527. them to be.
  2528. If you discover problems, you can set
  2529. <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGES'><filename>PACKAGES</filename></ulink>,
  2530. <ulink url='&YOCTO_DOCS_REF_URL;#var-FILES'><filename>FILES</filename></ulink>,
  2531. <filename>do_install(_append)</filename>, and so forth as
  2532. needed.
  2533. </para></listitem>
  2534. <listitem><para><emphasis>Splitting an Application into Multiple Packages</emphasis>:
  2535. If you need to split an application into several
  2536. packages, see the
  2537. "<link linkend='splitting-an-application-into-multiple-packages'>Splitting an Application into Multiple Packages</link>"
  2538. section for an example.
  2539. </para></listitem>
  2540. <listitem><para><emphasis>Installing a Post-Installation Script</emphasis>:
  2541. For an example showing how to install a
  2542. post-installation script, see the
  2543. "<link linkend='new-recipe-post-installation-scripts'>Post-Installation Scripts</link>"
  2544. section.
  2545. </para></listitem>
  2546. <listitem><para><emphasis>Marking Package Architecture</emphasis>:
  2547. Depending on what your recipe is building and how it
  2548. is configured, it might be important to mark the
  2549. packages produced as being specific to a particular
  2550. machine, or to mark them as not being specific to
  2551. a particular machine or architecture at all.</para>
  2552. <para>By default, packages apply to any machine with the
  2553. same architecture as the target machine.
  2554. When a recipe produces packages that are
  2555. machine-specific (e.g. the
  2556. <ulink url='&YOCTO_DOCS_REF_URL;#var-MACHINE'><filename>MACHINE</filename></ulink>
  2557. value is passed into the configure script or a patch
  2558. is applied only for a particular machine), you should
  2559. mark them as such by adding the following to the
  2560. recipe:
  2561. <literallayout class='monospaced'>
  2562. PACKAGE_ARCH = "${MACHINE_ARCH}"
  2563. </literallayout></para>
  2564. <para>On the other hand, if the recipe produces packages
  2565. that do not contain anything specific to the target
  2566. machine or architecture at all (e.g. recipes
  2567. that simply package script files or configuration
  2568. files), you should use the
  2569. <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-allarch'><filename>allarch</filename></ulink>
  2570. class to do this for you by adding this to your
  2571. recipe:
  2572. <literallayout class='monospaced'>
  2573. inherit allarch
  2574. </literallayout>
  2575. Ensuring that the package architecture is correct is
  2576. not critical while you are doing the first few builds
  2577. of your recipe.
  2578. However, it is important in order
  2579. to ensure that your recipe rebuilds (or does not
  2580. rebuild) appropriately in response to changes in
  2581. configuration, and to ensure that you get the
  2582. appropriate packages installed on the target machine,
  2583. particularly if you run separate builds for more
  2584. than one target machine.
  2585. </para></listitem>
  2586. </itemizedlist>
  2587. </para>
  2588. </section>
  2589. <section id='properly-versioning-pre-release-recipes'>
  2590. <title>Properly Versioning Pre-Release Recipes</title>
  2591. <para>
  2592. Sometimes the name of a recipe can lead to versioning
  2593. problems when the recipe is upgraded to a final release.
  2594. For example, consider the
  2595. <filename>irssi_0.8.16-rc1.bb</filename> recipe file in
  2596. the list of example recipes in the
  2597. "<link linkend='new-recipe-storing-and-naming-the-recipe'>Storing and Naming the Recipe</link>"
  2598. section.
  2599. This recipe is at a release candidate stage (i.e.
  2600. "rc1").
  2601. When the recipe is released, the recipe filename becomes
  2602. <filename>irssi_0.8.16.bb</filename>.
  2603. The version change from <filename>0.8.16-rc1</filename>
  2604. to <filename>0.8.16</filename> is seen as a decrease by the
  2605. build system and package managers, so the resulting packages
  2606. will not correctly trigger an upgrade.
  2607. </para>
  2608. <para>
  2609. In order to ensure the versions compare properly, the
  2610. recommended convention is to set
  2611. <ulink url='&YOCTO_DOCS_REF_URL;#var-PV'><filename>PV</filename></ulink>
  2612. within the recipe to
  2613. "<replaceable>previous_version</replaceable>+<replaceable>current_version</replaceable>".
  2614. You can use an additional variable so that you can use the
  2615. current version elsewhere.
  2616. Here is an example:
  2617. <literallayout class='monospaced'>
  2618. REALPV = "0.8.16-rc1"
  2619. PV = "0.8.15+${REALPV}"
  2620. </literallayout>
  2621. </para>
  2622. </section>
  2623. <section id='new-recipe-post-installation-scripts'>
  2624. <title>Post-Installation Scripts</title>
  2625. <para>
  2626. Post-installation scripts run immediately after installing
  2627. a package on the target or during image creation when a
  2628. package is included in an image.
  2629. To add a post-installation script to a package, add a
  2630. <filename>pkg_postinst_PACKAGENAME()</filename> function to
  2631. the recipe file (<filename>.bb</filename>) and replace
  2632. <filename>PACKAGENAME</filename> with the name of the package
  2633. you want to attach to the <filename>postinst</filename>
  2634. script.
  2635. To apply the post-installation script to the main package
  2636. for the recipe, which is usually what is required, specify
  2637. <filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-PN'><filename>PN</filename></ulink><filename>}</filename>
  2638. in place of <filename>PACKAGENAME</filename>.
  2639. </para>
  2640. <para>
  2641. A post-installation function has the following structure:
  2642. <literallayout class='monospaced'>
  2643. pkg_postinst_PACKAGENAME() {
  2644. # Commands to carry out
  2645. }
  2646. </literallayout>
  2647. </para>
  2648. <para>
  2649. The script defined in the post-installation function is
  2650. called when the root filesystem is created.
  2651. If the script succeeds, the package is marked as installed.
  2652. If the script fails, the package is marked as unpacked and
  2653. the script is executed when the image boots again.
  2654. </para>
  2655. <para>
  2656. Sometimes it is necessary for the execution of a
  2657. post-installation script to be delayed until the first boot.
  2658. For example, the script might need to be executed on the
  2659. device itself.
  2660. To delay script execution until boot time, use the following
  2661. structure in the post-installation script:
  2662. <literallayout class='monospaced'>
  2663. pkg_postinst_PACKAGENAME() {
  2664. if [ x"$D" = "x" ]; then
  2665. # Actions to carry out on the device go here
  2666. else
  2667. exit 1
  2668. fi
  2669. }
  2670. </literallayout>
  2671. </para>
  2672. <para>
  2673. The previous example delays execution until the image boots
  2674. again because the environment variable <filename>D</filename>
  2675. points to the directory containing the image when
  2676. the root filesystem is created at build time but is unset
  2677. when executed on the first boot.
  2678. </para>
  2679. <note>
  2680. Equivalent support for pre-install, pre-uninstall, and
  2681. post-uninstall scripts exist by way of
  2682. <filename>pkg_preinst</filename>,
  2683. <filename>pkg_prerm</filename>, and
  2684. <filename>pkg_postrm</filename>, respectively.
  2685. These scrips work in exactly the same way as does
  2686. <filename>pkg_postinst</filename> with the exception that they
  2687. run at different times.
  2688. Also, because of when they run, they are not applicable to
  2689. being run at image creation time like
  2690. <filename>pkg_postinst</filename>.
  2691. </note>
  2692. </section>
  2693. <section id='new-recipe-testing'>
  2694. <title>Testing</title>
  2695. <para>
  2696. The final step for completing your recipe is to be sure that
  2697. the software you built runs correctly.
  2698. To accomplish runtime testing, add the build's output
  2699. packages to your image and test them on the target.
  2700. </para>
  2701. <para>
  2702. For information on how to customize your image by adding
  2703. specific packages, see the
  2704. "<link linkend='usingpoky-extend-customimage'>Customizing Images</link>"
  2705. section.
  2706. </para>
  2707. </section>
  2708. <section id='new-recipe-testing-examples'>
  2709. <title>Examples</title>
  2710. <para>
  2711. To help summarize how to write a recipe, this section provides
  2712. some examples given various scenarios:
  2713. <itemizedlist>
  2714. <listitem><para>Recipes that use local files</para></listitem>
  2715. <listitem><para>Using an Autotooled package</para></listitem>
  2716. <listitem><para>Using a Makefile-based package</para></listitem>
  2717. <listitem><para>Splitting an application into multiple packages</para></listitem>
  2718. <listitem><para>Adding binaries to an image</para></listitem>
  2719. </itemizedlist>
  2720. </para>
  2721. <section id='new-recipe-single-c-file-package-hello-world'>
  2722. <title>Single .c File Package (Hello World!)</title>
  2723. <para>
  2724. Building an application from a single file that is stored
  2725. locally (e.g. under <filename>files</filename>) requires
  2726. a recipe that has the file listed in the
  2727. <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'>SRC_URI</ulink></filename>
  2728. variable.
  2729. Additionally, you need to manually write the
  2730. <filename>do_compile</filename> and
  2731. <filename>do_install</filename> tasks.
  2732. The <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-S'>S</ulink></filename>
  2733. variable defines the directory containing the source code,
  2734. which is set to
  2735. <ulink url='&YOCTO_DOCS_REF_URL;#var-WORKDIR'><filename>WORKDIR</filename></ulink>
  2736. in this case - the directory BitBake uses for the build.
  2737. <literallayout class='monospaced'>
  2738. SUMMARY = "Simple helloworld application"
  2739. SECTION = "examples"
  2740. LICENSE = "MIT"
  2741. LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"
  2742. SRC_URI = "file://helloworld.c"
  2743. S = "${WORKDIR}"
  2744. do_compile() {
  2745. ${CC} helloworld.c -o helloworld
  2746. }
  2747. do_install() {
  2748. install -d ${D}${bindir}
  2749. install -m 0755 helloworld ${D}${bindir}
  2750. }
  2751. </literallayout>
  2752. </para>
  2753. <para>
  2754. By default, the <filename>helloworld</filename>,
  2755. <filename>helloworld-dbg</filename>, and
  2756. <filename>helloworld-dev</filename> packages are built.
  2757. For information on how to customize the packaging process,
  2758. see the
  2759. "<link linkend='splitting-an-application-into-multiple-packages'>Splitting an Application into Multiple Packages</link>"
  2760. section.
  2761. </para>
  2762. </section>
  2763. <section id='new-recipe-autotooled-package'>
  2764. <title>Autotooled Package</title>
  2765. <para>
  2766. Applications that use Autotools such as <filename>autoconf</filename> and
  2767. <filename>automake</filename> require a recipe that has a source archive listed in
  2768. <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'>SRC_URI</ulink></filename> and
  2769. also inherit the
  2770. <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-autotools'><filename>autotools</filename></ulink>
  2771. class, which contains the definitions of all the steps
  2772. needed to build an Autotool-based application.
  2773. The result of the build is automatically packaged.
  2774. And, if the application uses NLS for localization, packages with local information are
  2775. generated (one package per language).
  2776. Following is one example: (<filename>hello_2.3.bb</filename>)
  2777. <literallayout class='monospaced'>
  2778. SUMMARY = "GNU Helloworld application"
  2779. SECTION = "examples"
  2780. LICENSE = "GPLv2+"
  2781. LIC_FILES_CHKSUM = "file://COPYING;md5=751419260aa954499f7abaabaa882bbe"
  2782. SRC_URI = "${GNU_MIRROR}/hello/hello-${PV}.tar.gz"
  2783. inherit autotools gettext
  2784. </literallayout>
  2785. </para>
  2786. <para>
  2787. The variable
  2788. <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-LIC_FILES_CHKSUM'>LIC_FILES_CHKSUM</ulink></filename>
  2789. is used to track source license changes as described in the
  2790. "<ulink url='&YOCTO_DOCS_REF_URL;#usingpoky-configuring-LIC_FILES_CHKSUM'>Tracking License Changes</ulink>" section.
  2791. You can quickly create Autotool-based recipes in a manner similar to the previous example.
  2792. </para>
  2793. </section>
  2794. <section id='new-recipe-makefile-based-package'>
  2795. <title>Makefile-Based Package</title>
  2796. <para>
  2797. Applications that use GNU <filename>make</filename> also require a recipe that has
  2798. the source archive listed in
  2799. <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'>SRC_URI</ulink></filename>.
  2800. You do not need to add a <filename>do_compile</filename> step since by default BitBake
  2801. starts the <filename>make</filename> command to compile the application.
  2802. If you need additional <filename>make</filename> options, you should store them in the
  2803. <ulink url='&YOCTO_DOCS_REF_URL;#var-EXTRA_OEMAKE'><filename>EXTRA_OEMAKE</filename></ulink>
  2804. or
  2805. <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGECONFIG_CONFARGS'><filename>PACKAGECONFIG_CONFARGS</filename></ulink>
  2806. variables.
  2807. BitBake passes these options into the GNU <filename>make</filename> invocation.
  2808. Note that a <filename>do_install</filename> task is still required.
  2809. Otherwise, BitBake runs an empty <filename>do_install</filename> task by default.
  2810. </para>
  2811. <para>
  2812. Some applications might require extra parameters to be passed to the compiler.
  2813. For example, the application might need an additional header path.
  2814. You can accomplish this by adding to the
  2815. <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-CFLAGS'>CFLAGS</ulink></filename> variable.
  2816. The following example shows this:
  2817. <literallayout class='monospaced'>
  2818. CFLAGS_prepend = "-I ${S}/include "
  2819. </literallayout>
  2820. </para>
  2821. <para>
  2822. In the following example, <filename>mtd-utils</filename> is a makefile-based package:
  2823. <literallayout class='monospaced'>
  2824. SUMMARY = "Tools for managing memory technology devices"
  2825. SECTION = "base"
  2826. DEPENDS = "zlib lzo e2fsprogs util-linux"
  2827. HOMEPAGE = "http://www.linux-mtd.infradead.org/"
  2828. LICENSE = "GPLv2+"
  2829. LIC_FILES_CHKSUM = "file://COPYING;md5=0636e73ff0215e8d672dc4c32c317bb3 \
  2830. file://include/common.h;beginline=1;endline=17;md5=ba05b07912a44ea2bf81ce409380049c"
  2831. # Use the latest version at 26 Oct, 2013
  2832. SRCREV = "9f107132a6a073cce37434ca9cda6917dd8d866b"
  2833. SRC_URI = "git://git.infradead.org/mtd-utils.git \
  2834. file://add-exclusion-to-mkfs-jffs2-git-2.patch \
  2835. "
  2836. PV = "1.5.1+git${SRCPV}"
  2837. S = "${WORKDIR}/git"
  2838. EXTRA_OEMAKE = "'CC=${CC}' 'RANLIB=${RANLIB}' 'AR=${AR}' 'CFLAGS=${CFLAGS} -I${S}/include -DWITHOUT_XATTR' 'BUILDDIR=${S}'"
  2839. do_install () {
  2840. oe_runmake install DESTDIR=${D} SBINDIR=${sbindir} MANDIR=${mandir} INCLUDEDIR=${includedir}
  2841. }
  2842. PACKAGES =+ "mtd-utils-jffs2 mtd-utils-ubifs mtd-utils-misc"
  2843. FILES_mtd-utils-jffs2 = "${sbindir}/mkfs.jffs2 ${sbindir}/jffs2dump ${sbindir}/jffs2reader ${sbindir}/sumtool"
  2844. FILES_mtd-utils-ubifs = "${sbindir}/mkfs.ubifs ${sbindir}/ubi*"
  2845. FILES_mtd-utils-misc = "${sbindir}/nftl* ${sbindir}/ftl* ${sbindir}/rfd* ${sbindir}/doc* ${sbindir}/serve_image ${sbindir}/recv_image"
  2846. PARALLEL_MAKE = ""
  2847. BBCLASSEXTEND = "native"
  2848. </literallayout>
  2849. </para>
  2850. </section>
  2851. <section id='splitting-an-application-into-multiple-packages'>
  2852. <title>Splitting an Application into Multiple Packages</title>
  2853. <para>
  2854. You can use the variables
  2855. <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGES'>PACKAGES</ulink></filename> and
  2856. <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-FILES'>FILES</ulink></filename>
  2857. to split an application into multiple packages.
  2858. </para>
  2859. <para>
  2860. Following is an example that uses the <filename>libxpm</filename> recipe.
  2861. By default, this recipe generates a single package that contains the library along
  2862. with a few binaries.
  2863. You can modify the recipe to split the binaries into separate packages:
  2864. <literallayout class='monospaced'>
  2865. require xorg-lib-common.inc
  2866. SUMMARY = "Xpm: X Pixmap extension library"
  2867. LICENSE = "BSD"
  2868. LIC_FILES_CHKSUM = "file://COPYING;md5=51f4270b012ecd4ab1a164f5f4ed6cf7"
  2869. DEPENDS += "libxext libsm libxt"
  2870. PE = "1"
  2871. XORG_PN = "libXpm"
  2872. PACKAGES =+ "sxpm cxpm"
  2873. FILES_cxpm = "${bindir}/cxpm"
  2874. FILES_sxpm = "${bindir}/sxpm"
  2875. </literallayout>
  2876. </para>
  2877. <para>
  2878. In the previous example, we want to ship the <filename>sxpm</filename>
  2879. and <filename>cxpm</filename> binaries in separate packages.
  2880. Since <filename>bindir</filename> would be packaged into the main
  2881. <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-PN'>PN</ulink></filename>
  2882. package by default, we prepend the <filename>PACKAGES</filename>
  2883. variable so additional package names are added to the start of list.
  2884. This results in the extra <filename>FILES_*</filename>
  2885. variables then containing information that define which files and
  2886. directories go into which packages.
  2887. Files included by earlier packages are skipped by latter packages.
  2888. Thus, the main <filename>PN</filename> package
  2889. does not include the above listed files.
  2890. </para>
  2891. </section>
  2892. <section id='packaging-externally-produced-binaries'>
  2893. <title>Packaging Externally Produced Binaries</title>
  2894. <para>
  2895. Sometimes, you need to add pre-compiled binaries to an
  2896. image.
  2897. For example, suppose that binaries for proprietary code
  2898. exist, which are created by a particular division of a
  2899. company.
  2900. Your part of the company needs to use those binaries as
  2901. part of an image that you are building using the
  2902. OpenEmbedded build system.
  2903. Since you only have the binaries and not the source code,
  2904. you cannot use a typical recipe that expects to fetch the
  2905. source specified in
  2906. <ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'><filename>SRC_URI</filename></ulink>
  2907. and then compile it.
  2908. </para>
  2909. <para>
  2910. One method is to package the binaries and then install them
  2911. as part of the image.
  2912. Generally, it is not a good idea to package binaries
  2913. since, among other things, it can hinder the ability to
  2914. reproduce builds and could lead to compatibility problems
  2915. with ABI in the future.
  2916. However, sometimes you have no choice.
  2917. </para>
  2918. <para>
  2919. The easiest solution is to create a recipe that uses
  2920. the
  2921. <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-bin-package'><filename>bin_package</filename></ulink>
  2922. class and to be sure that you are using default locations
  2923. for build artifacts.
  2924. In most cases, the <filename>bin_package</filename> class
  2925. handles "skipping" the configure and compile steps as well
  2926. as sets things up to grab packages from the appropriate
  2927. area.
  2928. In particular, this class sets <filename>noexec</filename>
  2929. on both the
  2930. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-configure'><filename>do_configure</filename></ulink>
  2931. and
  2932. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-compile'><filename>do_compile</filename></ulink>
  2933. tasks, sets
  2934. <filename>FILES_${PN}</filename> to "/" so that it picks
  2935. up all files, and sets up a
  2936. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-install'><filename>do_install</filename></ulink>
  2937. task, which effectively copies all files from
  2938. <filename>${S}</filename> to <filename>${D}</filename>.
  2939. The <filename>bin_package</filename> class works well when
  2940. the files extracted into <filename>${S}</filename> are
  2941. already laid out in the way they should be laid out
  2942. on the target.
  2943. For more information on these variables, see the
  2944. <ulink url='&YOCTO_DOCS_REF_URL;#var-FILES'><filename>FILES</filename></ulink>,
  2945. <ulink url='&YOCTO_DOCS_REF_URL;#var-PN'><filename>PN</filename></ulink>,
  2946. <ulink url='&YOCTO_DOCS_REF_URL;#var-S'><filename>S</filename></ulink>,
  2947. and
  2948. <ulink url='&YOCTO_DOCS_REF_URL;#var-D'><filename>D</filename></ulink>
  2949. variables in the Yocto Project Reference Manual's variable
  2950. glossary.
  2951. </para>
  2952. <para>
  2953. If you can't use the <filename>bin_package</filename>
  2954. class, you need to be sure you are doing the following:
  2955. <itemizedlist>
  2956. <listitem><para>Create a recipe where the
  2957. <filename>do_configure</filename> and
  2958. <filename>do_compile</filename> tasks do nothing:
  2959. <literallayout class='monospaced'>
  2960. do_configure[noexec] = "1"
  2961. do_compile[noexec] = "1"
  2962. </literallayout>
  2963. Alternatively, you can make these tasks an empty
  2964. function.
  2965. </para></listitem>
  2966. <listitem><para>Make sure your
  2967. <filename>do_install</filename> task installs the
  2968. binaries appropriately.
  2969. </para></listitem>
  2970. <listitem><para>Ensure that you set up
  2971. <filename>FILES</filename> (usually
  2972. <filename>FILES_${PN}</filename>) to point to the
  2973. files you have installed, which of course depends
  2974. on where you have installed them and whether
  2975. those files are in different locations than the
  2976. defaults.
  2977. </para></listitem>
  2978. </itemizedlist>
  2979. </para>
  2980. </section>
  2981. </section>
  2982. </section>
  2983. <section id="platdev-newmachine">
  2984. <title>Adding a New Machine</title>
  2985. <para>
  2986. Adding a new machine to the Yocto Project is a straightforward
  2987. process.
  2988. This section describes how to add machines that are similar
  2989. to those that the Yocto Project already supports.
  2990. <note>
  2991. Although well within the capabilities of the Yocto Project,
  2992. adding a totally new architecture might require
  2993. changes to <filename>gcc/glibc</filename> and to the site
  2994. information, which is beyond the scope of this manual.
  2995. </note>
  2996. </para>
  2997. <para>
  2998. For a complete example that shows how to add a new machine,
  2999. see the
  3000. "<ulink url='&YOCTO_DOCS_BSP_URL;#creating-a-new-bsp-layer-using-the-yocto-bsp-script'>Creating a New BSP Layer Using the yocto-bsp Script</ulink>"
  3001. section in the Yocto Project Board Support Package (BSP) Developer's Guide.
  3002. </para>
  3003. <section id="platdev-newmachine-conffile">
  3004. <title>Adding the Machine Configuration File</title>
  3005. <para>
  3006. To add a new machine, you need to add a new machine
  3007. configuration file to the layer's
  3008. <filename>conf/machine</filename> directory.
  3009. This configuration file provides details about the device
  3010. you are adding.
  3011. </para>
  3012. <para>
  3013. The OpenEmbedded build system uses the root name of the
  3014. machine configuration file to reference the new machine.
  3015. For example, given a machine configuration file named
  3016. <filename>crownbay.conf</filename>, the build system
  3017. recognizes the machine as "crownbay".
  3018. </para>
  3019. <para>
  3020. The most important variables you must set in your machine
  3021. configuration file or include from a lower-level configuration
  3022. file are as follows:
  3023. <itemizedlist>
  3024. <listitem><para><filename><ulink url='&YOCTO_DOCS_REF_URL;#var-TARGET_ARCH'>TARGET_ARCH</ulink></filename>
  3025. (e.g. "arm")</para></listitem>
  3026. <listitem><para><filename><ulink url='&YOCTO_DOCS_REF_URL;#var-PREFERRED_PROVIDER'>PREFERRED_PROVIDER</ulink>_virtual/kernel</filename>
  3027. </para></listitem>
  3028. <listitem><para><filename><ulink url='&YOCTO_DOCS_REF_URL;#var-MACHINE_FEATURES'>MACHINE_FEATURES</ulink></filename>
  3029. (e.g. "apm screen wifi")</para></listitem>
  3030. </itemizedlist>
  3031. </para>
  3032. <para>
  3033. You might also need these variables:
  3034. <itemizedlist>
  3035. <listitem><para><filename><ulink url='&YOCTO_DOCS_REF_URL;#var-SERIAL_CONSOLES'>SERIAL_CONSOLES</ulink></filename>
  3036. (e.g. "115200;ttyS0 115200;ttyS1")</para></listitem>
  3037. <listitem><para><filename><ulink url='&YOCTO_DOCS_REF_URL;#var-KERNEL_IMAGETYPE'>KERNEL_IMAGETYPE</ulink></filename>
  3038. (e.g. "zImage")</para></listitem>
  3039. <listitem><para><filename><ulink url='&YOCTO_DOCS_REF_URL;#var-IMAGE_FSTYPES'>IMAGE_FSTYPES</ulink></filename>
  3040. (e.g. "tar.gz jffs2")</para></listitem>
  3041. </itemizedlist>
  3042. </para>
  3043. <para>
  3044. You can find full details on these variables in the reference
  3045. section.
  3046. You can leverage existing machine <filename>.conf</filename>
  3047. files from <filename>meta-yocto-bsp/conf/machine/</filename>.
  3048. </para>
  3049. </section>
  3050. <section id="platdev-newmachine-kernel">
  3051. <title>Adding a Kernel for the Machine</title>
  3052. <para>
  3053. The OpenEmbedded build system needs to be able to build a kernel
  3054. for the machine.
  3055. You need to either create a new kernel recipe for this machine,
  3056. or extend an existing kernel recipe.
  3057. You can find several kernel recipe examples in the
  3058. Source Directory at
  3059. <filename>meta/recipes-kernel/linux</filename>
  3060. that you can use as references.
  3061. </para>
  3062. <para>
  3063. If you are creating a new kernel recipe, normal recipe-writing
  3064. rules apply for setting up a
  3065. <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'>SRC_URI</ulink></filename>.
  3066. Thus, you need to specify any necessary patches and set
  3067. <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-S'>S</ulink></filename>
  3068. to point at the source code.
  3069. You need to create a <filename>do_configure</filename> task that
  3070. configures the unpacked kernel with a
  3071. <filename>defconfig</filename> file.
  3072. You can do this by using a <filename>make defconfig</filename>
  3073. command or, more commonly, by copying in a suitable
  3074. <filename>defconfig</filename> file and then running
  3075. <filename>make oldconfig</filename>.
  3076. By making use of <filename>inherit kernel</filename> and
  3077. potentially some of the <filename>linux-*.inc</filename> files,
  3078. most other functionality is centralized and the defaults of the
  3079. class normally work well.
  3080. </para>
  3081. <para>
  3082. If you are extending an existing kernel recipe, it is usually
  3083. a matter of adding a suitable <filename>defconfig</filename>
  3084. file.
  3085. The file needs to be added into a location similar to
  3086. <filename>defconfig</filename> files used for other machines
  3087. in a given kernel recipe.
  3088. A possible way to do this is by listing the file in the
  3089. <filename>SRC_URI</filename> and adding the machine to the
  3090. expression in
  3091. <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-COMPATIBLE_MACHINE'>COMPATIBLE_MACHINE</ulink></filename>:
  3092. <literallayout class='monospaced'>
  3093. COMPATIBLE_MACHINE = '(qemux86|qemumips)'
  3094. </literallayout>
  3095. For more information on <filename>defconfig</filename> files,
  3096. see the
  3097. "<ulink url='&YOCTO_DOCS_KERNEL_DEV_URL;#changing-the-configuration'>Changing the Configuration</ulink>"
  3098. section in the Yocto Project Linux Kernel Development Manual.
  3099. </para>
  3100. </section>
  3101. <section id="platdev-newmachine-formfactor">
  3102. <title>Adding a Formfactor Configuration File</title>
  3103. <para>
  3104. A formfactor configuration file provides information about the
  3105. target hardware for which the image is being built and information that
  3106. the build system cannot obtain from other sources such as the kernel.
  3107. Some examples of information contained in a formfactor configuration file include
  3108. framebuffer orientation, whether or not the system has a keyboard,
  3109. the positioning of the keyboard in relation to the screen, and
  3110. the screen resolution.
  3111. </para>
  3112. <para>
  3113. The build system uses reasonable defaults in most cases.
  3114. However, if customization is
  3115. necessary, you need to create a <filename>machconfig</filename> file
  3116. in the <filename>meta/recipes-bsp/formfactor/files</filename>
  3117. directory.
  3118. This directory contains directories for specific machines such as
  3119. <filename>qemuarm</filename> and <filename>qemux86</filename>.
  3120. For information about the settings available and the defaults, see the
  3121. <filename>meta/recipes-bsp/formfactor/files/config</filename> file found in the
  3122. same area.
  3123. </para>
  3124. <para>
  3125. Following is an example for "qemuarm" machine:
  3126. <literallayout class='monospaced'>
  3127. HAVE_TOUCHSCREEN=1
  3128. HAVE_KEYBOARD=1
  3129. DISPLAY_CAN_ROTATE=0
  3130. DISPLAY_ORIENTATION=0
  3131. #DISPLAY_WIDTH_PIXELS=640
  3132. #DISPLAY_HEIGHT_PIXELS=480
  3133. #DISPLAY_BPP=16
  3134. DISPLAY_DPI=150
  3135. DISPLAY_SUBPIXEL_ORDER=vrgb
  3136. </literallayout>
  3137. </para>
  3138. </section>
  3139. </section>
  3140. <section id="platdev-working-with-libraries">
  3141. <title>Working With Libraries</title>
  3142. <para>
  3143. Libraries are an integral part of your system.
  3144. This section describes some common practices you might find
  3145. helpful when working with libraries to build your system:
  3146. <itemizedlist>
  3147. <listitem><para><link linkend='including-static-library-files'>How to include static library files</link>
  3148. </para></listitem>
  3149. <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>
  3150. </para></listitem>
  3151. <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>
  3152. </para></listitem>
  3153. </itemizedlist>
  3154. </para>
  3155. <section id='including-static-library-files'>
  3156. <title>Including Static Library Files</title>
  3157. <para>
  3158. If you are building a library and the library offers static linking, you can control
  3159. which static library files (<filename>*.a</filename> files) get included in the
  3160. built library.
  3161. </para>
  3162. <para>
  3163. The <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGES'><filename>PACKAGES</filename></ulink>
  3164. and <ulink url='&YOCTO_DOCS_REF_URL;#var-FILES'><filename>FILES_*</filename></ulink>
  3165. variables in the
  3166. <filename>meta/conf/bitbake.conf</filename> configuration file define how files installed
  3167. by the <filename>do_install</filename> task are packaged.
  3168. By default, the <filename>PACKAGES</filename> variable includes
  3169. <filename>${PN}-staticdev</filename>, which represents all static library files.
  3170. <note>
  3171. Some previously released versions of the Yocto Project
  3172. defined the static library files through
  3173. <filename>${PN}-dev</filename>.
  3174. </note>
  3175. Following is part of the BitBake configuration file, where
  3176. you can see how the static library files are defined:
  3177. <literallayout class='monospaced'>
  3178. PACKAGE_BEFORE_PN ?= ""
  3179. PACKAGES = "${PN}-dbg ${PN}-staticdev ${PN}-dev ${PN}-doc ${PN}-locale ${PACKAGE_BEFORE_PN} ${PN}"
  3180. PACKAGES_DYNAMIC = "^${PN}-locale-.*"
  3181. FILES = ""
  3182. FILES_${PN} = "${bindir}/* ${sbindir}/* ${libexecdir}/* ${libdir}/lib*${SOLIBS} \
  3183. ${sysconfdir} ${sharedstatedir} ${localstatedir} \
  3184. ${base_bindir}/* ${base_sbindir}/* \
  3185. ${base_libdir}/*${SOLIBS} \
  3186. ${base_prefix}/lib/udev/rules.d ${prefix}/lib/udev/rules.d \
  3187. ${datadir}/${BPN} ${libdir}/${BPN}/* \
  3188. ${datadir}/pixmaps ${datadir}/applications \
  3189. ${datadir}/idl ${datadir}/omf ${datadir}/sounds \
  3190. ${libdir}/bonobo/servers"
  3191. FILES_${PN}-bin = "${bindir}/* ${sbindir}/*"
  3192. FILES_${PN}-doc = "${docdir} ${mandir} ${infodir} ${datadir}/gtk-doc \
  3193. ${datadir}/gnome/help"
  3194. SECTION_${PN}-doc = "doc"
  3195. FILES_SOLIBSDEV ?= "${base_libdir}/lib*${SOLIBSDEV} ${libdir}/lib*${SOLIBSDEV}"
  3196. FILES_${PN}-dev = "${includedir} ${FILES_SOLIBSDEV} ${libdir}/*.la \
  3197. ${libdir}/*.o ${libdir}/pkgconfig ${datadir}/pkgconfig \
  3198. ${datadir}/aclocal ${base_libdir}/*.o \
  3199. ${libdir}/${BPN}/*.la ${base_libdir}/*.la"
  3200. SECTION_${PN}-dev = "devel"
  3201. ALLOW_EMPTY_${PN}-dev = "1"
  3202. RDEPENDS_${PN}-dev = "${PN} (= ${EXTENDPKGV})"
  3203. FILES_${PN}-staticdev = "${libdir}/*.a ${base_libdir}/*.a ${libdir}/${BPN}/*.a"
  3204. SECTION_${PN}-staticdev = "devel"
  3205. RDEPENDS_${PN}-staticdev = "${PN}-dev (= ${EXTENDPKGV})"
  3206. </literallayout>
  3207. </para>
  3208. </section>
  3209. <section id="combining-multiple-versions-library-files-into-one-image">
  3210. <title>Combining Multiple Versions of Library Files into One Image</title>
  3211. <para>
  3212. The build system offers the ability to build libraries with different
  3213. target optimizations or architecture formats and combine these together
  3214. into one system image.
  3215. You can link different binaries in the image
  3216. against the different libraries as needed for specific use cases.
  3217. This feature is called "Multilib."
  3218. </para>
  3219. <para>
  3220. An example would be where you have most of a system compiled in 32-bit
  3221. mode using 32-bit libraries, but you have something large, like a database
  3222. engine, that needs to be a 64-bit application and uses 64-bit libraries.
  3223. Multilib allows you to get the best of both 32-bit and 64-bit libraries.
  3224. </para>
  3225. <para>
  3226. While the Multilib feature is most commonly used for 32 and 64-bit differences,
  3227. the approach the build system uses facilitates different target optimizations.
  3228. You could compile some binaries to use one set of libraries and other binaries
  3229. to use a different set of libraries.
  3230. The libraries could differ in architecture, compiler options, or other
  3231. optimizations.
  3232. </para>
  3233. <para>
  3234. Several examples exist in the
  3235. <filename>meta-skeleton</filename> layer found in the
  3236. <link linkend='source-directory'>Source Directory</link>:
  3237. <itemizedlist>
  3238. <listitem><para><filename>conf/multilib-example.conf</filename>
  3239. configuration file</para></listitem>
  3240. <listitem><para><filename>conf/multilib-example2.conf</filename>
  3241. configuration file</para></listitem>
  3242. <listitem><para><filename>recipes-multilib/images/core-image-multilib-example.bb</filename>
  3243. recipe</para></listitem>
  3244. </itemizedlist>
  3245. </para>
  3246. <section id='preparing-to-use-multilib'>
  3247. <title>Preparing to Use Multilib</title>
  3248. <para>
  3249. User-specific requirements drive the Multilib feature.
  3250. Consequently, there is no one "out-of-the-box" configuration that likely
  3251. exists to meet your needs.
  3252. </para>
  3253. <para>
  3254. In order to enable Multilib, you first need to ensure your recipe is
  3255. extended to support multiple libraries.
  3256. Many standard recipes are already extended and support multiple libraries.
  3257. You can check in the <filename>meta/conf/multilib.conf</filename>
  3258. configuration file in the
  3259. <link linkend='source-directory'>Source Directory</link> to see how this is
  3260. done using the
  3261. <ulink url='&YOCTO_DOCS_REF_URL;#var-BBCLASSEXTEND'><filename>BBCLASSEXTEND</filename></ulink>
  3262. variable.
  3263. Eventually, all recipes will be covered and this list will
  3264. not be needed.
  3265. </para>
  3266. <para>
  3267. For the most part, the Multilib class extension works automatically to
  3268. extend the package name from <filename>${PN}</filename> to
  3269. <filename>${MLPREFIX}${PN}</filename>, where <filename>MLPREFIX</filename>
  3270. is the particular multilib (e.g. "lib32-" or "lib64-").
  3271. Standard variables such as
  3272. <ulink url='&YOCTO_DOCS_REF_URL;#var-DEPENDS'><filename>DEPENDS</filename></ulink>,
  3273. <ulink url='&YOCTO_DOCS_REF_URL;#var-RDEPENDS'><filename>RDEPENDS</filename></ulink>,
  3274. <ulink url='&YOCTO_DOCS_REF_URL;#var-RPROVIDES'><filename>RPROVIDES</filename></ulink>,
  3275. <ulink url='&YOCTO_DOCS_REF_URL;#var-RRECOMMENDS'><filename>RRECOMMENDS</filename></ulink>,
  3276. <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGES'><filename>PACKAGES</filename></ulink>, and
  3277. <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGES_DYNAMIC'><filename>PACKAGES_DYNAMIC</filename></ulink>
  3278. are automatically extended by the system.
  3279. If you are extending any manual code in the recipe, you can use the
  3280. <filename>${MLPREFIX}</filename> variable to ensure those names are extended
  3281. correctly.
  3282. This automatic extension code resides in <filename>multilib.bbclass</filename>.
  3283. </para>
  3284. </section>
  3285. <section id='using-multilib'>
  3286. <title>Using Multilib</title>
  3287. <para>
  3288. After you have set up the recipes, you need to define the actual
  3289. combination of multiple libraries you want to build.
  3290. You accomplish this through your <filename>local.conf</filename>
  3291. configuration file in the
  3292. <link linkend='build-directory'>Build Directory</link>.
  3293. An example configuration would be as follows:
  3294. <literallayout class='monospaced'>
  3295. MACHINE = "qemux86-64"
  3296. require conf/multilib.conf
  3297. MULTILIBS = "multilib:lib32"
  3298. DEFAULTTUNE_virtclass-multilib-lib32 = "x86"
  3299. IMAGE_INSTALL_append = " lib32-glib-2.0"
  3300. </literallayout>
  3301. This example enables an
  3302. additional library named <filename>lib32</filename> alongside the
  3303. normal target packages.
  3304. When combining these "lib32" alternatives, the example uses "x86" for tuning.
  3305. For information on this particular tuning, see
  3306. <filename>meta/conf/machine/include/ia32/arch-ia32.inc</filename>.
  3307. </para>
  3308. <para>
  3309. The example then includes <filename>lib32-glib-2.0</filename>
  3310. in all the images, which illustrates one method of including a
  3311. multiple library dependency.
  3312. You can use a normal image build to include this dependency,
  3313. for example:
  3314. <literallayout class='monospaced'>
  3315. $ bitbake core-image-sato
  3316. </literallayout>
  3317. You can also build Multilib packages specifically with a command like this:
  3318. <literallayout class='monospaced'>
  3319. $ bitbake lib32-glib-2.0
  3320. </literallayout>
  3321. </para>
  3322. </section>
  3323. <section id='additional-implementation-details'>
  3324. <title>Additional Implementation Details</title>
  3325. <para>
  3326. Generic implementation details as well as details that are
  3327. specific to package management systems exist.
  3328. Following are implementation details that exist regardless
  3329. of the package management system:
  3330. <itemizedlist>
  3331. <listitem><para>The typical convention used for the
  3332. class extension code as used by
  3333. Multilib assumes that all package names specified
  3334. in
  3335. <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGES'><filename>PACKAGES</filename></ulink>
  3336. that contain <filename>${PN}</filename> have
  3337. <filename>${PN}</filename> at the start of the name.
  3338. When that convention is not followed and
  3339. <filename>${PN}</filename> appears at
  3340. the middle or the end of a name, problems occur.
  3341. </para></listitem>
  3342. <listitem><para>The
  3343. <ulink url='&YOCTO_DOCS_REF_URL;#var-TARGET_VENDOR'><filename>TARGET_VENDOR</filename></ulink>
  3344. value under Multilib will be extended to
  3345. "-<replaceable>vendor</replaceable>ml<replaceable>multilib</replaceable>"
  3346. (e.g. "-pokymllib32" for a "lib32" Multilib with
  3347. Poky).
  3348. The reason for this slightly unwieldy contraction
  3349. is that any "-" characters in the vendor
  3350. string presently break Autoconf's
  3351. <filename>config.sub</filename>, and
  3352. other separators are problematic for different
  3353. reasons.
  3354. </para></listitem>
  3355. </itemizedlist>
  3356. </para>
  3357. '
  3358. <para>
  3359. For the RPM Package Management System, the following implementation details
  3360. exist:
  3361. <itemizedlist>
  3362. <listitem><para>A unique architecture is defined for the Multilib packages,
  3363. along with creating a unique deploy folder under
  3364. <filename>tmp/deploy/rpm</filename> in the
  3365. <link linkend='build-directory'>Build Directory</link>.
  3366. For example, consider <filename>lib32</filename> in a
  3367. <filename>qemux86-64</filename> image.
  3368. The possible architectures in the system are "all", "qemux86_64",
  3369. "lib32_qemux86_64", and "lib32_x86".</para></listitem>
  3370. <listitem><para>The <filename>${MLPREFIX}</filename> variable is stripped from
  3371. <filename>${PN}</filename> during RPM packaging.
  3372. The naming for a normal RPM package and a Multilib RPM package in a
  3373. <filename>qemux86-64</filename> system resolves to something similar to
  3374. <filename>bash-4.1-r2.x86_64.rpm</filename> and
  3375. <filename>bash-4.1.r2.lib32_x86.rpm</filename>, respectively.
  3376. </para></listitem>
  3377. <listitem><para>When installing a Multilib image, the RPM backend first
  3378. installs the base image and then installs the Multilib libraries.
  3379. </para></listitem>
  3380. <listitem><para>The build system relies on RPM to resolve the identical files in the
  3381. two (or more) Multilib packages.</para></listitem>
  3382. </itemizedlist>
  3383. </para>
  3384. <para>
  3385. For the IPK Package Management System, the following implementation details exist:
  3386. <itemizedlist>
  3387. <listitem><para>The <filename>${MLPREFIX}</filename> is not stripped from
  3388. <filename>${PN}</filename> during IPK packaging.
  3389. The naming for a normal RPM package and a Multilib IPK package in a
  3390. <filename>qemux86-64</filename> system resolves to something like
  3391. <filename>bash_4.1-r2.x86_64.ipk</filename> and
  3392. <filename>lib32-bash_4.1-rw_x86.ipk</filename>, respectively.
  3393. </para></listitem>
  3394. <listitem><para>The IPK deploy folder is not modified with
  3395. <filename>${MLPREFIX}</filename> because packages with and without
  3396. the Multilib feature can exist in the same folder due to the
  3397. <filename>${PN}</filename> differences.</para></listitem>
  3398. <listitem><para>IPK defines a sanity check for Multilib installation
  3399. using certain rules for file comparison, overridden, etc.
  3400. </para></listitem>
  3401. </itemizedlist>
  3402. </para>
  3403. </section>
  3404. </section>
  3405. <section id='installing-multiple-versions-of-the-same-library'>
  3406. <title>Installing Multiple Versions of the Same Library</title>
  3407. <para>
  3408. Situations can exist where you need to install and use
  3409. multiple versions of the same library on the same system
  3410. at the same time.
  3411. These situations almost always exist when a library API
  3412. changes and you have multiple pieces of software that
  3413. depend on the separate versions of the library.
  3414. To accommodate these situations, you can install multiple
  3415. versions of the same library in parallel on the same system.
  3416. </para>
  3417. <para>
  3418. The process is straightforward as long as the libraries use
  3419. proper versioning.
  3420. With properly versioned libraries, all you need to do to
  3421. individually specify the libraries is create separate,
  3422. appropriately named recipes where the
  3423. <ulink url='&YOCTO_DOCS_REF_URL;#var-PN'><filename>PN</filename></ulink> part of the
  3424. name includes a portion that differentiates each library version
  3425. (e.g.the major part of the version number).
  3426. Thus, instead of having a single recipe that loads one version
  3427. of a library (e.g. <filename>clutter</filename>), you provide
  3428. multiple recipes that result in different versions
  3429. of the libraries you want.
  3430. As an example, the following two recipes would allow the
  3431. two separate versions of the <filename>clutter</filename>
  3432. library to co-exist on the same system:
  3433. <literallayout class='monospaced'>
  3434. clutter-1.6_1.6.20.bb
  3435. clutter-1.8_1.8.4.bb
  3436. </literallayout>
  3437. Additionally, if you have other recipes that depend on a given
  3438. library, you need to use the
  3439. <ulink url='&YOCTO_DOCS_REF_URL;#var-DEPENDS'><filename>DEPENDS</filename></ulink>
  3440. variable to create the dependency.
  3441. Continuing with the same example, if you want to have a recipe
  3442. depend on the 1.8 version of the <filename>clutter</filename>
  3443. library, use the following in your recipe:
  3444. <literallayout class='monospaced'>
  3445. DEPENDS = "clutter-1.8"
  3446. </literallayout>
  3447. </para>
  3448. </section>
  3449. </section>
  3450. <section id='enabling-gobject-introspection-support'>
  3451. <title>Enabling GObject Introspection Support</title>
  3452. <para>
  3453. <ulink url='https://wiki.gnome.org/Projects/GObjectIntrospection'>GObject introspection</ulink>
  3454. is the standard mechanism for accessing GObject-based software
  3455. from runtime environments.
  3456. GObject is a feature of the GLib library that provides an object
  3457. framework for the GNOME desktop and related software.
  3458. GObject Introspection adds information to GObject that allows
  3459. objects created within it to be represented across different
  3460. programming languages.
  3461. If you want to construct GStreamer pipelines using Python, or
  3462. control UPnP infrastructure using Javascript and GUPnP,
  3463. GObject introspection is the only way to do it.
  3464. </para>
  3465. <para>
  3466. This section describes the Yocto Project support for generating
  3467. and packaging GObject introspection data.
  3468. GObject introspection data is a description of the
  3469. API provided by libraries built on top of GLib framework,
  3470. and, in particular, that framework's GObject mechanism.
  3471. GObject Introspection Repository (GIR) files go to
  3472. <filename>-dev</filename> packages,
  3473. <filename>typelib</filename> files go to main packages as they
  3474. are packaged together with libraries that are introspected.
  3475. </para>
  3476. <para>
  3477. The data is generated when building such a library, by linking
  3478. the library with a small executable binary that asks the library
  3479. to describe itself, and then executing the binary and
  3480. processing its output.
  3481. </para>
  3482. <para>
  3483. Generating this data in a cross-compilation environment
  3484. is difficult because the library is produced for the target
  3485. architecture, but its code needs to be executed on the build host.
  3486. This problem is solved with the OpenEmbedded build system by
  3487. running the code through QEMU, which allows precisely that.
  3488. Unfortunately, QEMU does not always work perfectly as mentioned
  3489. in the xxx section.
  3490. </para>
  3491. <section id='enabling-the-generation-of-introspection-data'>
  3492. <title>Enabling the Generation of Introspection Data</title>
  3493. <para>
  3494. Enabling the generation of introspection data (GIR files)
  3495. in your library package involves the following:
  3496. <orderedlist>
  3497. <listitem><para>
  3498. Inherit the
  3499. <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-gobject-introspection'><filename>gobject-introspection</filename></ulink>
  3500. class.
  3501. </para></listitem>
  3502. <listitem><para>
  3503. Make sure introspection is not disabled anywhere in
  3504. the recipe or from anything the recipe includes.
  3505. Also, make sure that "gobject-introspection-data" is
  3506. not in
  3507. <ulink url='&YOCTO_DOCS_REF_URL;#var-DISTRO_FEATURES_BACKFILL_CONSIDERED'><filename>DISTRO_FEATURES_BACKFILL_CONSIDERED</filename></ulink>
  3508. and that "qemu-usermode" is not in
  3509. <ulink url='&YOCTO_DOCS_REF_URL;#var-MACHINE_FEATURES_BACKFILL_CONSIDERED'><filename>MACHINE_FEATURES_BACKFILL_CONSIDERED</filename></ulink>.
  3510. If either of these conditions exist, nothing will
  3511. happen.
  3512. </para></listitem>
  3513. <listitem><para>
  3514. Try to build the recipe.
  3515. If you encounter build errors that look like
  3516. something is unable to find
  3517. <filename>.so</filename> libraries, check where these
  3518. libraries are located in the source tree and add
  3519. the following to the recipe:
  3520. <literallayout class='monospaced'>
  3521. GIR_EXTRA_LIBS_PATH = "${B}/<replaceable>something</replaceable>/.libs"
  3522. </literallayout>
  3523. <note>
  3524. See recipes in the <filename>oe-core</filename>
  3525. repository that use that
  3526. <filename>GIR_EXTRA_LIBS_PATH</filename> variable
  3527. as an example.
  3528. </note>
  3529. </para></listitem>
  3530. <listitem><para>
  3531. Look for any other errors, which probably mean that
  3532. introspection support in a package is not entirely
  3533. standard, and thus breaks down in a cross-compilation
  3534. environment.
  3535. For such cases, custom-made fixes are needed.
  3536. A good place to ask and receive help in these cases
  3537. is the
  3538. <ulink url='&YOCTO_DOCS_REF_URL;#resources-mailinglist'>Yocto Project mailing lists</ulink>.
  3539. </para></listitem>
  3540. </orderedlist>
  3541. <note>
  3542. Using a library that no longer builds against the latest
  3543. Yocto Project release and prints introspection related
  3544. errors is a good candidate for the previous procedure.
  3545. </note>
  3546. </para>
  3547. </section>
  3548. <section id='disabling-the-generation-of-introspection-data'>
  3549. <title>Disabling the Generation of Introspection Data</title>
  3550. <para>
  3551. You might find that you do not want to generate
  3552. introspection data.
  3553. Or, perhaps QEMU does not work on your build host and
  3554. target architecture combination.
  3555. If so, you can use either of the following methods to
  3556. disable GIR file generations:
  3557. <itemizedlist>
  3558. <listitem><para>
  3559. Add the following to your distro configuration:
  3560. <literallayout class='monospaced'>
  3561. DISTRO_FEATURES_BACKFILL_CONSIDERED = "gobject-introspection-data"
  3562. </literallayout>
  3563. Adding this statement disables generating
  3564. introspection data using QEMU but will still enable
  3565. building introspection tools and libraries
  3566. (i.e. building them does not require the use of QEMU).
  3567. </para></listitem>
  3568. <listitem><para>
  3569. Add the following to your machine configuration:
  3570. <literallayout class='monospaced'>
  3571. MACHINE_FEATURES_BACKFILL_CONSIDERED = "qemu-usermode"
  3572. </literallayout>
  3573. Adding this statement disables the use of QEMU
  3574. when building packages for your machine.
  3575. Currently, this feature is used only by introspection
  3576. recipes and has the same effect as the previously
  3577. described option.
  3578. <note>
  3579. Future releases of the Yocto Project might have
  3580. other features affected by this option.
  3581. </note>
  3582. </para></listitem>
  3583. </itemizedlist>
  3584. If you disable introspection data, you can still
  3585. obtain it through other means such as copying the data
  3586. from a suitable sysroot, or by generating it on the
  3587. target hardware.
  3588. The OpenEmbedded build system does not currently
  3589. provide specific support for these techniques.
  3590. </para>
  3591. </section>
  3592. <section id='testing-that-introspection-works-in-an-image'>
  3593. <title>Testing that Introspection Works in an Image</title>
  3594. <para>
  3595. Use the following procedure to test if generating
  3596. introspection data is working in an image:
  3597. <orderedlist>
  3598. <listitem><para>
  3599. Make sure that "gobject-introspection-data" is not in
  3600. <ulink url='&YOCTO_DOCS_REF_URL;#var-DISTRO_FEATURES_BACKFILL_CONSIDERED'><filename>DISTRO_FEATURES_BACKFILL_CONSIDERED</filename></ulink>
  3601. and that "qemu-usermode" is not in
  3602. <ulink url='&YOCTO_DOCS_REF_URL;#var-MACHINE_FEATURES_BACKFILL_CONSIDERED'><filename>MACHINE_FEATURES_BACKFILL_CONSIDERED</filename></ulink>.
  3603. </para></listitem>
  3604. <listitem><para>
  3605. Build <filename>core-image-sato</filename>.
  3606. </para></listitem>
  3607. <listitem><para>
  3608. Launch a Terminal and then start Python in the
  3609. terminal.
  3610. </para></listitem>
  3611. <listitem><para>
  3612. Enter the following in the terminal:
  3613. <literallayout class='monospaced'>
  3614. >>> from gi.repository import GLib
  3615. >>> GLib.get_host_name()
  3616. </literallayout>
  3617. </para></listitem>
  3618. <listitem><para>
  3619. For something a little more advanced, enter the
  3620. following:
  3621. <literallayout class='monospaced'>
  3622. http://python-gtk-3-tutorial.readthedocs.org/en/latest/introduction.html
  3623. </literallayout>
  3624. </para></listitem>
  3625. </orderedlist>
  3626. </para>
  3627. </section>
  3628. <section id='known-issues'>
  3629. <title>Known Issues</title>
  3630. <para>
  3631. The following know issues exist for
  3632. GObject Introspection Support:
  3633. <itemizedlist>
  3634. <listitem><para>
  3635. <filename>qemu-ppc64</filename> immediately crashes.
  3636. Consequently, you cannot build introspection data on
  3637. that architecture.
  3638. </para></listitem>
  3639. <listitem><para>
  3640. x32 is not supported by QEMU.
  3641. Consequently, introspection data is disabled.
  3642. </para></listitem>
  3643. <listitem><para>
  3644. musl causes transient GLib binaries to crash on
  3645. assertion failures.
  3646. Consequently, generating introspection data is
  3647. disabled.
  3648. </para></listitem>
  3649. <listitem><para>
  3650. Because QEMU is not able to run the binaries correctly,
  3651. introspection is disabled for some specific packages
  3652. under specific architectures (e.g.
  3653. <filename>gcr</filename>,
  3654. <filename>libsecret</filename>, and
  3655. <filename>webkit</filename>).
  3656. </para></listitem>
  3657. <listitem><para>
  3658. QEMU might not work properly when using QEMU in
  3659. usermode and running 64-bit binaries under 32-bit
  3660. host machines.
  3661. In particular, "qemumips64" is known to not work under
  3662. i686.
  3663. </para></listitem>
  3664. </itemizedlist>
  3665. </para>
  3666. </section>
  3667. </section>
  3668. <section id='dev-optionally-using-an-external-toolchain'>
  3669. <title>Optionally Using an External Toolchain</title>
  3670. <para>
  3671. You might want to use an external toolchain as part of your
  3672. development.
  3673. If this is the case, the fundamental steps you need to accomplish
  3674. are as follows:
  3675. <itemizedlist>
  3676. <listitem><para>
  3677. Understand where the installed toolchain resides.
  3678. For cases where you need to build the external toolchain,
  3679. you would need to take separate steps to build and install
  3680. the toolchain.
  3681. </para></listitem>
  3682. <listitem><para>
  3683. Make sure you add the layer that contains the toolchain to
  3684. your <filename>bblayers.conf</filename> file through the
  3685. <ulink url='&YOCTO_DOCS_REF_URL;#var-BBLAYERS'><filename>BBLAYERS</filename></ulink>
  3686. variable.
  3687. </para></listitem>
  3688. <listitem><para>
  3689. Set the
  3690. <ulink url='&YOCTO_DOCS_REF_URL;#var-EXTERNAL_TOOLCHAIN'><filename>EXTERNAL_TOOLCHAIN</filename></ulink>
  3691. variable in your <filename>local.conf</filename> file
  3692. to the location in which you installed the toolchain.
  3693. </para></listitem>
  3694. </itemizedlist>
  3695. A good example of an external toolchain used with the Yocto Project
  3696. is <trademark class='registered'>Mentor Graphics</trademark>
  3697. Sourcery G++ Toolchain.
  3698. You can see information on how to use that particular layer in the
  3699. <filename>README</filename> file at
  3700. <ulink url='http://github.com/MentorEmbedded/meta-sourcery/'></ulink>.
  3701. You can find further information by reading about the
  3702. <ulink url='&YOCTO_DOCS_REF_URL;#var-TCMODE'><filename>TCMODE</filename></ulink>
  3703. variable in the Yocto Project Reference Manual's variable glossary.
  3704. </para>
  3705. </section>
  3706. <section id='creating-partitioned-images'>
  3707. <title>Creating Partitioned Images</title>
  3708. <para>
  3709. Creating an image for a particular hardware target using the
  3710. OpenEmbedded build system does not necessarily mean you can boot
  3711. that image as is on your device.
  3712. Physical devices accept and boot images in various ways depending
  3713. on the specifics of the device.
  3714. Usually, information about the hardware can tell you what image
  3715. format the device requires.
  3716. Should your device require multiple partitions on an SD card, flash,
  3717. or an HDD, you can use the OpenEmbedded Image Creator,
  3718. <filename>wic</filename>, to create the properly partitioned image.
  3719. </para>
  3720. <para>
  3721. The <filename>wic</filename> command generates partitioned images
  3722. from existing OpenEmbedded build artifacts.
  3723. Image generation is driven by partitioning commands contained
  3724. in an Openembedded kickstart file (<filename>.wks</filename>)
  3725. specified either directly on the command line or as one of a
  3726. selection of canned <filename>.wks</filename> files as shown
  3727. with the <filename>wic list images</filename> command in the
  3728. "<link linkend='using-a-provided-kickstart_file'>Using an Existing Kickstart File</link>"
  3729. section.
  3730. When applied to a given set of build artifacts, the result is an
  3731. image or set of images that can be directly written onto media and
  3732. used on a particular system.
  3733. </para>
  3734. <para>
  3735. The <filename>wic</filename> command and the infrastructure
  3736. it is based on is by definition incomplete.
  3737. Its purpose is to allow the generation of customized images,
  3738. and as such was designed to be completely extensible through a
  3739. plug-in interface.
  3740. See the
  3741. "<link linkend='openembedded-kickstart-plugins'>Plug-ins</link>"
  3742. section for information on these plug-ins.
  3743. </para>
  3744. <para>
  3745. This section provides some background information on
  3746. <filename>wic</filename>, describes what you need to have in
  3747. place to run the tool, provides instruction on how to use
  3748. <filename>wic</filename>, and provides several examples.
  3749. </para>
  3750. <section id='wic-background'>
  3751. <title>Background</title>
  3752. <para>
  3753. This section provides some background on the
  3754. <filename>wic</filename> utility.
  3755. While none of this information is required to use
  3756. <filename>wic</filename>, you might find it interesting.
  3757. <itemizedlist>
  3758. <listitem><para>
  3759. The name "wic" is derived from OpenEmbedded
  3760. Image Creator (oeic).
  3761. The "oe" diphthong in "oeic" was promoted to the
  3762. letter "w", because "oeic" is both difficult to remember and
  3763. pronounce.</para></listitem>
  3764. <listitem><para>
  3765. <filename>wic</filename> is loosely based on the
  3766. Meego Image Creator (<filename>mic</filename>)
  3767. framework.
  3768. The <filename>wic</filename> implementation has been
  3769. heavily modified to make direct use of OpenEmbedded
  3770. build artifacts instead of package installation and
  3771. configuration, which are already incorporated within
  3772. the OpenEmbedded artifacts.</para></listitem>
  3773. <listitem><para>
  3774. <filename>wic</filename> is a completely independent
  3775. standalone utility that initially provides
  3776. easier-to-use and more flexible replacements for a
  3777. couple bits of existing functionality in OE Core's
  3778. <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-image-live'><filename>image-live</filename></ulink>
  3779. class and <filename>mkefidisk.sh</filename> script.
  3780. The difference between
  3781. <filename>wic</filename> and those examples is
  3782. that with <filename>wic</filename> the
  3783. functionality of those scripts is implemented
  3784. by a general-purpose partitioning language, which is
  3785. based on Redhat kickstart syntax.</para></listitem>
  3786. </itemizedlist>
  3787. </para>
  3788. </section>
  3789. <section id='wic-requirements'>
  3790. <title>Requirements</title>
  3791. <para>
  3792. In order to use the <filename>wic</filename> utility
  3793. with the OpenEmbedded Build system, your system needs
  3794. to meet the following requirements:
  3795. <itemizedlist>
  3796. <listitem><para>The Linux distribution on your
  3797. development host must support the Yocto Project.
  3798. See the
  3799. "<ulink url='&YOCTO_DOCS_REF_URL;#detailed-supported-distros'>Supported Linux Distributions</ulink>"
  3800. section in the Yocto Project Reference Manual for this
  3801. list of distributions.</para></listitem>
  3802. <listitem><para>
  3803. The standard system utilities, such as
  3804. <filename>cp</filename>, must be installed on your
  3805. development host system.
  3806. </para></listitem>
  3807. <listitem><para>
  3808. You need to have the build artifacts already
  3809. available, which typically means that you must
  3810. have already created an image using the
  3811. Openembedded build system (e.g.
  3812. <filename>core-image-minimal</filename>).
  3813. While it might seem redundant to generate an image in
  3814. order to create an image using
  3815. <filename>wic</filename>, the current version of
  3816. <filename>wic</filename> requires the artifacts
  3817. in the form generated by the build system.
  3818. </para></listitem>
  3819. <listitem><para>
  3820. You must build several native tools, which are tools
  3821. built to run on the build system:
  3822. <literallayout class='monospaced'>
  3823. $ bitbake parted-native dosfstools-native mtools-native
  3824. </literallayout>
  3825. </para></listitem>
  3826. <listitem><para>
  3827. You must have sourced one of the build environment
  3828. setup scripts (i.e.
  3829. <ulink url='&YOCTO_DOCS_REF_URL;#structure-core-script'><filename>&OE_INIT_FILE;</filename></ulink>
  3830. or
  3831. <ulink url='&YOCTO_DOCS_REF_URL;#structure-memres-core-script'><filename>oe-init-build-env-memres</filename></ulink>)
  3832. found in the
  3833. <link linkend='build-directory'>Build Directory</link>.
  3834. </para></listitem>
  3835. </itemizedlist>
  3836. </para>
  3837. </section>
  3838. <section id='wic-getting-help'>
  3839. <title>Getting Help</title>
  3840. <para>
  3841. You can get general help for the <filename>wic</filename>
  3842. by entering the <filename>wic</filename> command by itself
  3843. or by entering the command with a help argument as follows:
  3844. <literallayout class='monospaced'>
  3845. $ wic -h
  3846. $ wic --help
  3847. </literallayout>
  3848. </para>
  3849. <para>
  3850. Currently, <filename>wic</filename> supports two commands:
  3851. <filename>create</filename> and <filename>list</filename>.
  3852. You can get help for these commands as follows:
  3853. <literallayout class='monospaced'>
  3854. $ wic help <replaceable>command</replaceable>
  3855. </literallayout>
  3856. </para>
  3857. <para>
  3858. You can also get detailed help on a number of topics
  3859. from the help system.
  3860. The output of <filename>wic --help</filename>
  3861. displays a list of available help
  3862. topics under a "Help topics" heading.
  3863. You can have the help system display the help text for
  3864. a given topic by prefacing the topic with
  3865. <filename>wic help</filename>:
  3866. <literallayout class='monospaced'>
  3867. $ wic help <replaceable>help_topic</replaceable>
  3868. </literallayout>
  3869. </para>
  3870. <para>
  3871. You can find out more about the images
  3872. <filename>wic</filename> creates using the existing
  3873. kickstart files with the following form of the command:
  3874. <literallayout class='monospaced'>
  3875. $ wic list <replaceable>image</replaceable> help
  3876. </literallayout>
  3877. where <filename><replaceable>image</replaceable></filename> is either
  3878. <filename>directdisk</filename> or
  3879. <filename>mkefidisk</filename>.
  3880. </para>
  3881. </section>
  3882. <section id='operational-modes'>
  3883. <title>Operational Modes</title>
  3884. <para>
  3885. You can use <filename>wic</filename> in two different
  3886. modes, depending on how much control you need for
  3887. specifying the Openembedded build artifacts that are
  3888. used for creating the image: Raw and Cooked:
  3889. <itemizedlist>
  3890. <listitem><para><emphasis>Raw Mode:</emphasis>
  3891. You explicitly specify build artifacts through
  3892. command-line arguments.</para></listitem>
  3893. <listitem><para><emphasis>Cooked Mode:</emphasis>
  3894. The current
  3895. <ulink url='&YOCTO_DOCS_REF_URL;#var-MACHINE'><filename>MACHINE</filename></ulink>
  3896. setting and image name are used to automatically locate
  3897. and provide the build artifacts.</para></listitem>
  3898. </itemizedlist>
  3899. </para>
  3900. <para>
  3901. Regardless of the mode you use, you need to have the build
  3902. artifacts ready and available.
  3903. Additionally, the environment must be set up using the
  3904. <ulink url='&YOCTO_DOCS_REF_URL;#structure-core-script'><filename>&OE_INIT_FILE;</filename></ulink>
  3905. or
  3906. <ulink url='&YOCTO_DOCS_REF_URL;#structure-memres-core-script'><filename>oe-init-build-env-memres</filename></ulink>
  3907. script found in the
  3908. <link linkend='build-directory'>Build Directory</link>.
  3909. </para>
  3910. <section id='raw-mode'>
  3911. <title>Raw Mode</title>
  3912. <para>
  3913. The general form of the 'wic' command in raw mode is:
  3914. <literallayout class='monospaced'>
  3915. $ wic create <replaceable>image_name</replaceable>.wks [<replaceable>options</replaceable>] [...]
  3916. Where:
  3917. <replaceable>image_name</replaceable>.wks
  3918. An OpenEmbedded kickstart file. You can provide
  3919. your own custom file or use a file from a set of
  3920. existing files as described by further options.
  3921. -o <replaceable>OUTDIR</replaceable>, --outdir=<replaceable>OUTDIR</replaceable>
  3922. The name of a directory in which to create image.
  3923. -i <replaceable>PROPERTIES_FILE</replaceable>, --infile=<replaceable>PROPERTIES_FILE</replaceable>
  3924. The name of a file containing the values for image
  3925. properties as a JSON file.
  3926. -e <replaceable>IMAGE_NAME</replaceable>, --image-name=<replaceable>IMAGE_NAME</replaceable>
  3927. The name of the image from which to use the artifacts
  3928. (e.g. <filename>core-image-sato</filename>).
  3929. -r <replaceable>ROOTFS_DIR</replaceable>, --rootfs-dir=<replaceable>ROOTFS_DIR</replaceable>
  3930. The path to the <filename>/rootfs</filename> directory to use as the
  3931. <filename>.wks</filename> rootfs source.
  3932. -b <replaceable>BOOTIMG_DIR</replaceable>, --bootimg-dir=<replaceable>BOOTIMG_DIR</replaceable>
  3933. The path to the directory containing the boot artifacts
  3934. (e.g. <filename>/EFI</filename> or <filename>/syslinux</filename>) to use as the <filename>.wks</filename> bootimg
  3935. source.
  3936. -k <replaceable>KERNEL_DIR</replaceable>, --kernel-dir=<replaceable>KERNEL_DIR</replaceable>
  3937. The path to the directory containing the kernel to use
  3938. in the <filename>.wks</filename> boot image.
  3939. -n <replaceable>NATIVE_SYSROOT</replaceable>, --native-sysroot=<replaceable>NATIVE_SYSROOT</replaceable>
  3940. The path to the native sysroot containing the tools to use
  3941. to build the image.
  3942. -s, --skip-build-check
  3943. Skips the build check.
  3944. -D, --debug
  3945. Output debug information.
  3946. </literallayout>
  3947. <note>
  3948. You do not need root privileges to run
  3949. <filename>wic</filename>.
  3950. In fact, you should not run as root when using the
  3951. utility.
  3952. </note>
  3953. </para>
  3954. </section>
  3955. <section id='cooked-mode'>
  3956. <title>Cooked Mode</title>
  3957. <para>
  3958. The general form of the <filename>wic</filename> command
  3959. using Cooked Mode is:
  3960. <literallayout class='monospaced'>
  3961. $ wic create <replaceable>kickstart_file</replaceable> -e <replaceable>image_name</replaceable>
  3962. Where:
  3963. <replaceable>kickstart_file</replaceable>
  3964. An OpenEmbedded kickstart file. You can provide your own
  3965. custom file or supplied file.
  3966. <replaceable>image_name</replaceable>
  3967. Specifies the image built using the OpenEmbedded build
  3968. system.
  3969. </literallayout>
  3970. This form is the simplest and most user-friendly, as it
  3971. does not require specifying all individual parameters.
  3972. All you need to provide is your own
  3973. <filename>.wks</filename> file or one provided with the
  3974. release.
  3975. </para>
  3976. </section>
  3977. </section>
  3978. <section id='using-a-provided-kickstart_file'>
  3979. <title>Using an Existing Kickstart File</title>
  3980. <para>
  3981. If you do not want to create your own
  3982. <filename>.wks</filename> file, you can use an existing
  3983. file provided by the <filename>wic</filename> installation.
  3984. Use the following command to list the available files:
  3985. <literallayout class='monospaced'>
  3986. $ wic list images
  3987. directdisk Create a 'pcbios' direct disk image
  3988. mkefidisk Create an EFI disk image
  3989. </literallayout>
  3990. When you use an existing file, you do not have to use the
  3991. <filename>.wks</filename> extension.
  3992. Here is an example in Raw Mode that uses the
  3993. <filename>directdisk</filename> file:
  3994. <literallayout class='monospaced'>
  3995. $ wic create directdisk -r <replaceable>rootfs_dir</replaceable> -b <replaceable>bootimg_dir</replaceable> \
  3996. -k <replaceable>kernel_dir</replaceable> -n <replaceable>native_sysroot</replaceable>
  3997. </literallayout>
  3998. </para>
  3999. <para>
  4000. Here are the actual partition language commands
  4001. used in the <filename>mkefidisk.wks</filename> file to generate
  4002. an image:
  4003. <literallayout class='monospaced'>
  4004. # short-description: Create an EFI disk image
  4005. # long-description: Creates a partitioned EFI disk image that the user
  4006. # can directly dd to boot media.
  4007. part /boot --source bootimg-efi --ondisk sda --label msdos --active --align 1024
  4008. part / --source rootfs --ondisk sda --fstype=ext3 --label platform --align 1024
  4009. part swap --ondisk sda --size 44 --label swap1 --fstype=swap
  4010. bootloader --timeout=10 --append="rootwait rootfstype=ext3 console=ttyPCH0,115200 console=tty0 vmalloc=256MB snd-hda-intel.enable_msi=0"
  4011. </literallayout>
  4012. </para>
  4013. </section>
  4014. <section id='wic-usage-examples'>
  4015. <title>Examples</title>
  4016. <para>
  4017. This section provides several examples that show how to use
  4018. the <filename>wic</filename> utility.
  4019. All the examples assume the list of requirements in the
  4020. "<link linkend='wic-requirements'>Requirements</link>" section
  4021. have been met.
  4022. The examples assume the previously generated image is
  4023. <filename>core-image-minimal</filename>.
  4024. </para>
  4025. <section id='generate-an-image-using-a-provided-kickstart-file'>
  4026. <title>Generate an Image using an Existing Kickstart File</title>
  4027. <para>
  4028. This example runs in Cooked Mode and uses the
  4029. <filename>mkefidisk</filename> kickstart file:
  4030. <literallayout class='monospaced'>
  4031. $ wic create mkefidisk -e core-image-minimal
  4032. Checking basic build environment...
  4033. Done.
  4034. Creating image(s)...
  4035. Info: The new image(s) can be found here:
  4036. /var/tmp/wic/build/mkefidisk-201310230946-sda.direct
  4037. The following build artifacts were used to create the image(s):
  4038. ROOTFS_DIR: /home/trz/yocto/yocto-image/build/tmp/work/minnow-poky-linux/core-image-minimal/1.0-r0/rootfs
  4039. BOOTIMG_DIR: /home/trz/yocto/yocto-image/build/tmp/work/minnow-poky-linux/core-image-minimal/1.0-r0/core-image-minimal-1.0/hddimg
  4040. KERNEL_DIR: /home/trz/yocto/yocto-image/build/tmp/sysroots/minnow/usr/src/kernel
  4041. NATIVE_SYSROOT: /home/trz/yocto/yocto-image/build/tmp/sysroots/x86_64-linux
  4042. The image(s) were created using OE kickstart file:
  4043. /home/trz/yocto/yocto-image/scripts/lib/image/canned-wks/mkefidisk.wks
  4044. </literallayout>
  4045. This example shows the easiest way to create an image
  4046. by running in Cooked Mode and using the
  4047. <filename>-e</filename> option with an existing kickstart
  4048. file.
  4049. All that is necessary is to specify the image used to
  4050. generate the artifacts.
  4051. Your <filename>local.conf</filename> needs to have the
  4052. <ulink url='&YOCTO_DOCS_REF_URL;#var-MACHINE'><filename>MACHINE</filename></ulink>
  4053. variable set to the machine you are using, which is
  4054. "minnow" in this example.
  4055. </para>
  4056. <para>
  4057. The output specifies the exact image created as well as
  4058. where it was created.
  4059. The output also names the artifacts used and the exact
  4060. <filename>.wks</filename> script that was used to generate
  4061. the image.
  4062. <note>
  4063. You should always verify the details provided in the
  4064. output to make sure that the image was indeed created
  4065. exactly as expected.
  4066. </note>
  4067. </para>
  4068. <para>
  4069. Continuing with the example, you can now directly
  4070. <filename>dd</filename> the image to a USB stick, or
  4071. whatever media for which you built your image,
  4072. and boot the resulting media:
  4073. <literallayout class='monospaced'>
  4074. $ sudo dd if=/var/tmp/wic/build/mkefidisk-201310230946-sda.direct of=/dev/sdb
  4075. [sudo] password for trz:
  4076. 182274+0 records in
  4077. 182274+0 records out
  4078. 93324288 bytes (93 MB) copied, 14.4777 s, 6.4 MB/s
  4079. [trz@empanada ~]$ sudo eject /dev/sdb
  4080. </literallayout>
  4081. </para>
  4082. </section>
  4083. <section id='using-a-modified-kickstart-file'>
  4084. <title>Using a Modified Kickstart File</title>
  4085. <para>
  4086. Because <filename>wic</filename> image creation is driven
  4087. by the kickstart file, it is easy to affect image creation
  4088. by changing the parameters in the file.
  4089. This next example demonstrates that through modification
  4090. of the <filename>directdisk</filename> kickstart file.
  4091. </para>
  4092. <para>
  4093. As mentioned earlier, you can use the command
  4094. <filename>wic list images</filename> to show the list
  4095. of existing kickstart files.
  4096. The directory in which these files reside is
  4097. <filename>scripts/lib/image/canned-wks/</filename>
  4098. located in the
  4099. <link linkend='source-directory'>Source Directory</link>.
  4100. Because the available files reside in this directory, you
  4101. can create and add your own custom files to the directory.
  4102. Subsequent use of the <filename>wic list images</filename>
  4103. command would then include your kickstart files.
  4104. </para>
  4105. <para>
  4106. In this example, the existing
  4107. <filename>directdisk</filename> file already does most
  4108. of what is needed.
  4109. However, for the hardware in this example, the image will
  4110. need to boot from <filename>sdb</filename> instead of
  4111. <filename>sda</filename>, which is what the
  4112. <filename>directdisk</filename> kickstart file uses.
  4113. </para>
  4114. <para>
  4115. The example begins by making a copy of the
  4116. <filename>directdisk.wks</filename> file in the
  4117. <filename>scripts/lib/image/canned-wks</filename>
  4118. directory and then changing the lines that specify the
  4119. target disk from which to boot.
  4120. <literallayout class='monospaced'>
  4121. $ cp /home/trz/yocto/yocto-image/scripts/lib/image/canned-wks/directdisk.wks \
  4122. /home/trz/yocto/yocto-image/scripts/lib/image/canned-wks/directdisksdb.wks
  4123. </literallayout>
  4124. Next, the example modifies the
  4125. <filename>directdisksdb.wks</filename> file and changes all
  4126. instances of "<filename>--ondisk sda</filename>"
  4127. to "<filename>--ondisk sdb</filename>".
  4128. The example changes the following two lines and leaves the
  4129. remaining lines untouched:
  4130. <literallayout class='monospaced'>
  4131. part /boot --source bootimg-pcbios --ondisk sdb --label boot --active --align 1024
  4132. part / --source rootfs --ondisk sdb --fstype=ext3 --label platform --align 1024
  4133. </literallayout>
  4134. Once the lines are changed, the example generates the
  4135. <filename>directdisksdb</filename> image.
  4136. The command points the process at the
  4137. <filename>core-image-minimal</filename> artifacts for the
  4138. Next Unit of Computing (nuc)
  4139. <ulink url='&YOCTO_DOCS_REF_URL;#var-MACHINE'><filename>MACHINE</filename></ulink>
  4140. the <filename>local.conf</filename>.
  4141. <literallayout class='monospaced'>
  4142. $ wic create directdisksdb -e core-image-minimal
  4143. Checking basic build environment...
  4144. Done.
  4145. Creating image(s)...
  4146. Info: The new image(s) can be found here:
  4147. /var/tmp/wic/build/directdisksdb-201310231131-sdb.direct
  4148. The following build artifacts were used to create the image(s):
  4149. ROOTFS_DIR: /home/trz/yocto/yocto-image/build/tmp/work/nuc-poky-linux/core-image-minimal/1.0-r0/rootfs
  4150. BOOTIMG_DIR: /home/trz/yocto/yocto-image/build/tmp/sysroots/nuc/usr/share
  4151. KERNEL_DIR: /home/trz/yocto/yocto-image/build/tmp/sysroots/nuc/usr/src/kernel
  4152. NATIVE_SYSROOT: /home/trz/yocto/yocto-image/build/tmp/sysroots/x86_64-linux
  4153. The image(s) were created using OE kickstart file:
  4154. /home/trz/yocto/yocto-image/scripts/lib/image/canned-wks/directdisksdb.wks
  4155. </literallayout>
  4156. Continuing with the example, you can now directly
  4157. <filename>dd</filename> the image to a USB stick, or
  4158. whatever media for which you built your image,
  4159. and boot the resulting media:
  4160. <literallayout class='monospaced'>
  4161. $ sudo dd if=/var/tmp/wic/build/directdisksdb-201310231131-sdb.direct of=/dev/sdb
  4162. 86018+0 records in
  4163. 86018+0 records out
  4164. 44041216 bytes (44 MB) copied, 13.0734 s, 3.4 MB/s
  4165. [trz@empanada tmp]$ sudo eject /dev/sdb
  4166. </literallayout>
  4167. </para>
  4168. </section>
  4169. <section id='creating-an-image-based-on-core-image-minimal-and-crownbay-noemgd'>
  4170. <title>Creating an Image Based on <filename>core-image-minimal</filename> and <filename>crownbay-noemgd</filename></title>
  4171. <para>
  4172. This example creates an image based on
  4173. <filename>core-image-minimal</filename> and a
  4174. <filename>crownbay-noemgd</filename>
  4175. <ulink url='&YOCTO_DOCS_REF_URL;#var-MACHINE'><filename>MACHINE</filename></ulink>
  4176. that works right out of the box.
  4177. <literallayout class='monospaced'>
  4178. $ wic create directdisk -e core-image-minimal
  4179. Checking basic build environment...
  4180. Done.
  4181. Creating image(s)...
  4182. Info: The new image(s) can be found here:
  4183. /var/tmp/wic/build/directdisk-201309252350-sda.direct
  4184. The following build artifacts were used to create the image(s):
  4185. ROOTFS_DIR: /home/trz/yocto/yocto-image/build/tmp/work/crownbay_noemgd-poky-linux/core-image-minimal/1.0-r0/rootfs
  4186. BOOTIMG_DIR: /home/trz/yocto/yocto-image/build/tmp/sysroots/crownbay-noemgd/usr/share
  4187. KERNEL_DIR: /home/trz/yocto/yocto-image/build/tmp/sysroots/crownbay-noemgd/usr/src/kernel
  4188. NATIVE_SYSROOT: /home/trz/yocto/yocto-image/build/tmp/sysroots/crownbay-noemgd/usr/src/kernel
  4189. The image(s) were created using OE kickstart file:
  4190. /home/trz/yocto/yocto-image/scripts/lib/image/canned-wks/directdisk.wks
  4191. </literallayout>
  4192. </para>
  4193. </section>
  4194. <section id='using-a-modified-kickstart-file-and-running-in-raw-mode'>
  4195. <title>Using a Modified Kickstart File and Running in Raw Mode</title>
  4196. <para>
  4197. This next example manually specifies each build artifact
  4198. (runs in Raw Mode) and uses a modified kickstart file.
  4199. The example also uses the <filename>-o</filename> option
  4200. to cause <filename>wic</filename> to create the output
  4201. somewhere other than the default
  4202. <filename>/var/tmp/wic</filename> directory:
  4203. <literallayout class='monospaced'>
  4204. $ wic create ~/test.wks -o /home/trz/testwic --rootfs-dir \
  4205. /home/trz/yocto/yocto-image/build/tmp/work/crownbay_noemgd-poky-linux/core-image-minimal/1.0-r0/rootfs \
  4206. --bootimg-dir /home/trz/yocto/yocto-image/build/tmp/sysroots/crownbay-noemgd/usr/share \
  4207. --kernel-dir /home/trz/yocto/yocto-image/build/tmp/sysroots/crownbay-noemgd/usr/src/kernel \
  4208. --native-sysroot /home/trz/yocto/yocto-image/build/tmp/sysroots/x86_64-linux
  4209. Creating image(s)...
  4210. Info: The new image(s) can be found here:
  4211. /home/trz/testwic/build/test-201309260032-sda.direct
  4212. The following build artifacts were used to create the image(s):
  4213. ROOTFS_DIR: /home/trz/yocto/yocto-image/build/tmp/work/crownbay_noemgd-poky-linux/core-image-minimal/1.0-r0/rootfs
  4214. BOOTIMG_DIR: /home/trz/yocto/yocto-image/build/tmp/sysroots/crownbay-noemgd/usr/share
  4215. KERNEL_DIR: /home/trz/yocto/yocto-image/build/tmp/sysroots/crownbay-noemgd/usr/src/kernel
  4216. NATIVE_SYSROOT: /home/trz/yocto/yocto-image/build/tmp/sysroots/crownbay-noemgd/usr/src/kernel
  4217. The image(s) were created using OE kickstart file:
  4218. /home/trz/test.wks
  4219. </literallayout>
  4220. For this example,
  4221. <ulink url='&YOCTO_DOCS_REF_URL;#var-MACHINE'><filename>MACHINE</filename></ulink>
  4222. did not have to be specified in the
  4223. <filename>local.conf</filename> file since the artifact is
  4224. manually specified.
  4225. </para>
  4226. </section>
  4227. </section>
  4228. <section id='openembedded-kickstart-plugins'>
  4229. <title>Plug-ins</title>
  4230. <para>
  4231. Plug-ins allow <filename>wic</filename> functionality to
  4232. be extended and specialized by users.
  4233. This section documents the plugin interface, which is
  4234. currently restricted to source plug ins.
  4235. </para>
  4236. <para>
  4237. Source plug ins provide a mechanism to customize
  4238. various aspects of the image generation process in
  4239. <filename>wic</filename>, mainly the contents of
  4240. partitions.
  4241. The plug ins provide a mechanism for mapping values
  4242. specified in <filename>.wks</filename> files using the
  4243. <filename>--source</filename> keyword to a
  4244. particular plugin implementation that populates a
  4245. corresponding partition.
  4246. </para>
  4247. <para>
  4248. A source plugin is created as a subclass of
  4249. <filename>SourcePlugin</filename>.
  4250. The plugin file containing it is added to
  4251. <filename>scripts/lib/wic/plugins/source/</filename> to
  4252. make the plugin implementation available to the
  4253. <filename>wic</filename> implementation.
  4254. For more information, see
  4255. <filename>scripts/lib/wic/pluginbase.py</filename>.
  4256. </para>
  4257. <para>
  4258. Source plugins can also be implemented and added by
  4259. external layers.
  4260. As such, any plugins found in a
  4261. <filename>scripts/lib/wic/plugins/source/</filename>
  4262. directory in an external layer are also made
  4263. available.
  4264. </para>
  4265. <para>
  4266. When the <filename>wic</filename> implementation needs
  4267. to invoke a partition-specific implementation, it looks
  4268. for the plugin that has the same name as the
  4269. <filename>--source</filename> parameter given to
  4270. that partition.
  4271. For example, if the partition is set up as follows:
  4272. <literallayout class='monospaced'>
  4273. part /boot --source bootimg-pcbios ...
  4274. </literallayout>
  4275. The methods defined as class members of the plugin
  4276. having the matching <filename>bootimg-pcbios.name</filename>
  4277. class member are used.
  4278. </para>
  4279. <para>
  4280. To be more concrete, here is the plugin definition that
  4281. matches a
  4282. <filename>--source bootimg-pcbios</filename> usage,
  4283. along with an example
  4284. method called by the <filename>wic</filename> implementation
  4285. when it needs to invoke an implementation-specific
  4286. partition-preparation function:
  4287. <literallayout class='monospaced'>
  4288. class BootimgPcbiosPlugin(SourcePlugin):
  4289. name = 'bootimg-pcbios'
  4290. @classmethod
  4291. def do_prepare_partition(self, part, ...)
  4292. </literallayout>
  4293. If the subclass itself does not implement a function, a
  4294. default version in a superclass is located and
  4295. used, which is why all plugins must be derived from
  4296. <filename>SourcePlugin</filename>.
  4297. </para>
  4298. <para>
  4299. The <filename>SourcePlugin</filename> class defines the
  4300. following methods, which is the current set of methods
  4301. that can be implemented or overridden by
  4302. <filename>--source</filename> plugins.
  4303. Any methods not implemented by a
  4304. <filename>SourcePlugin</filename> subclass inherit the
  4305. implementations present in the
  4306. <filename>SourcePlugin</filename> class.
  4307. For more information, see the
  4308. <filename>SourcePlugin</filename> source for details:
  4309. </para>
  4310. <para>
  4311. <itemizedlist>
  4312. <listitem><para><emphasis><filename>do_prepare_partition()</filename>:</emphasis>
  4313. Called to do the actual content population for a
  4314. partition.
  4315. In other words, the method prepares the final
  4316. partition image that is incorporated into the
  4317. disk image.
  4318. </para></listitem>
  4319. <listitem><para><emphasis><filename>do_configure_partition()</filename>:</emphasis>
  4320. Called before
  4321. <filename>do_prepare_partition()</filename>.
  4322. This method is typically used to create custom
  4323. configuration files for a partition (e.g. syslinux or
  4324. grub configuration files).
  4325. </para></listitem>
  4326. <listitem><para><emphasis><filename>do_install_disk()</filename>:</emphasis>
  4327. Called after all partitions have been prepared and
  4328. assembled into a disk image.
  4329. This method provides a hook to allow finalization of a
  4330. disk image, (e.g. writing an MBR).
  4331. </para></listitem>
  4332. <listitem><para><emphasis><filename>do_stage_partition()</filename>:</emphasis>
  4333. Special content-staging hook called before
  4334. <filename>do_prepare_partition()</filename>.
  4335. This method is normally empty.</para>
  4336. <para>Typically, a partition just uses the passed-in
  4337. parameters (e.g. the unmodified value of
  4338. <filename>bootimg_dir</filename>).
  4339. However, in some cases things might need to be
  4340. more tailored.
  4341. As an example, certain files might additionally
  4342. need to be taken from
  4343. <filename>bootimg_dir + /boot</filename>.
  4344. This hook allows those files to be staged in a
  4345. customized fashion.
  4346. <note>
  4347. <filename>get_bitbake_var()</filename>
  4348. allows you to access non-standard variables
  4349. that you might want to use for this.
  4350. </note>
  4351. </para></listitem>
  4352. </itemizedlist>
  4353. </para>
  4354. <para>
  4355. This scheme is extensible.
  4356. Adding more hooks is a simple matter of adding more
  4357. plugin methods to <filename>SourcePlugin</filename> and
  4358. derived classes.
  4359. The code that then needs to call the plugin methods uses
  4360. <filename>plugin.get_source_plugin_methods()</filename>
  4361. to find the method or methods needed by the call.
  4362. Retrieval of those methods is accomplished
  4363. by filling up a dict with keys
  4364. containing the method names of interest.
  4365. On success, these will be filled in with the actual
  4366. methods.
  4367. Please see the <filename>wic</filename>
  4368. implementation for examples and details.
  4369. </para>
  4370. </section>
  4371. <section id='openembedded-kickstart-wks-reference'>
  4372. <title>OpenEmbedded Kickstart (.wks) Reference</title>
  4373. <para>
  4374. The current <filename>wic</filename> implementation supports
  4375. only the basic kickstart partitioning commands:
  4376. <filename>partition</filename> (or <filename>part</filename>
  4377. for short) and <filename>bootloader</filename>.
  4378. <note>
  4379. Future updates will implement more commands and options.
  4380. If you use anything that is not specifically
  4381. supported, results can be unpredictable.
  4382. </note>
  4383. </para>
  4384. <para>
  4385. The following is a list of the commands, their syntax,
  4386. and meanings.
  4387. The commands are based on the Fedora
  4388. kickstart versions but with modifications to
  4389. reflect <filename>wic</filename> capabilities.
  4390. You can see the original documentation for those commands
  4391. at the following links:
  4392. <itemizedlist>
  4393. <listitem><para>
  4394. <ulink url='http://fedoraproject.org/wiki/Anaconda/Kickstart#part_or_partition'>http://fedoraproject.org/wiki/Anaconda/Kickstart#part_or_partition</ulink>
  4395. </para></listitem>
  4396. <listitem><para>
  4397. <ulink url='http://fedoraproject.org/wiki/Anaconda/Kickstart#bootloader'>http://fedoraproject.org/wiki/Anaconda/Kickstart#bootloader</ulink>
  4398. </para></listitem>
  4399. </itemizedlist>
  4400. </para>
  4401. <section id='command-part-or-partition'>
  4402. <title>Command: part or partition</title>
  4403. <para>
  4404. Either of these commands create a partition on the system
  4405. and uses the following syntax:
  4406. <literallayout class='monospaced'>
  4407. part [<replaceable>mntpoint</replaceable>]
  4408. partition [<replaceable>mntpoint</replaceable>]
  4409. </literallayout>
  4410. If you do not provide
  4411. <replaceable>mntpoint</replaceable>, wic creates a partition
  4412. but does not mount it.
  4413. </para>
  4414. <para>
  4415. The <filename><replaceable>mntpoint</replaceable></filename>
  4416. is where the
  4417. partition will be mounted and must be of one of the
  4418. following forms:
  4419. <itemizedlist>
  4420. <listitem><para><filename>/<replaceable>path</replaceable></filename>:
  4421. For example, <filename>/</filename>,
  4422. <filename>/usr</filename>, or
  4423. <filename>/home</filename></para></listitem>
  4424. <listitem><para><filename>swap</filename>:
  4425. The created partition is used as swap space.
  4426. </para></listitem>
  4427. </itemizedlist>
  4428. </para>
  4429. <para>
  4430. Specifying a <replaceable>mntpoint</replaceable> causes
  4431. the partition to automatically be mounted.
  4432. Wic achieves this by adding entries to the filesystem
  4433. table (fstab) during image generation.
  4434. In order for wic to generate a valid fstab, you must
  4435. also provide one of the <filename>--ondrive</filename>,
  4436. <filename>--ondisk</filename>, or
  4437. <filename>--use-uuid</filename> partition options as part
  4438. of the command.
  4439. Here is an example using "/" as the mountpoint.
  4440. The command uses "--ondisk" to force the partition onto
  4441. the <filename>sdb</filename> disk:
  4442. <literallayout class='monospaced'>
  4443. part / --source rootfs --ondisk sdb --fstype=ext3 --label platform --align 1024
  4444. </literallayout>
  4445. </para>
  4446. <para>
  4447. Here is a list that describes other supported options you
  4448. can use with the <filename>part</filename> and
  4449. <filename>partition</filename> commands:
  4450. <itemizedlist>
  4451. <listitem><para><emphasis><filename>--size</filename>:</emphasis>
  4452. The minimum partition size in MBytes.
  4453. Specify an integer value such as 500.
  4454. Do not append the number with "MB".
  4455. You do not need this option if you use
  4456. <filename>--source</filename>.</para></listitem>
  4457. <listitem><para><emphasis><filename>--source</filename>:</emphasis>
  4458. This option is a
  4459. <filename>wic</filename>-specific option that
  4460. names the source of the data that populates
  4461. the partition.
  4462. The most common value for this option is
  4463. "rootfs", but you can use any value that maps to
  4464. a valid source plugin.
  4465. For information on the source plugins, see the
  4466. "<link linkend='openembedded-kickstart-plugins'>Plugins</link>"
  4467. section.</para>
  4468. <para>If you use
  4469. <filename>--source rootfs</filename>,
  4470. <filename>wic</filename> creates a partition as
  4471. large as needed and to fill it with the contents of
  4472. the root filesystem pointed to by the
  4473. <filename>-r</filename> command-line option
  4474. or the equivalent rootfs derived from the
  4475. <filename>-e</filename> command-line
  4476. option.
  4477. The filesystem type used to create the
  4478. partition is driven by the value of the
  4479. <filename>--fstype</filename> option
  4480. specified for the partition.
  4481. See the entry on
  4482. <filename>--fstype</filename> that
  4483. follows for more information.
  4484. </para>
  4485. <para>If you use
  4486. <filename>--source <replaceable>plugin-name</replaceable></filename>,
  4487. <filename>wic</filename> creates a partition as
  4488. large as needed and fills it with the contents of
  4489. the partition that is generated by the
  4490. specified plugin name using the data pointed
  4491. to by the <filename>-r</filename> command-line
  4492. option or the equivalent rootfs derived from the
  4493. <filename>-e</filename> command-line
  4494. option.
  4495. Exactly what those contents and filesystem type end
  4496. up being are dependent on the given plugin
  4497. implementation.
  4498. </para>
  4499. <para>If you do not use the
  4500. <filename>--source</filename> option, the
  4501. <filename>wic</filename> command creates an empty
  4502. partition.
  4503. Consequently, you must use the
  4504. <filename>--size</filename> option to specify the
  4505. size of the empty partition.
  4506. </para></listitem>
  4507. <listitem><para><emphasis><filename>--ondisk</filename> or <filename>--ondrive</filename>:</emphasis>
  4508. Forces the partition to be created on a particular
  4509. disk.</para></listitem>
  4510. <listitem><para><emphasis><filename>--fstype</filename>:</emphasis>
  4511. Sets the file system type for the partition.
  4512. Valid values are:
  4513. <itemizedlist>
  4514. <listitem><para><filename>ext4</filename>
  4515. </para></listitem>
  4516. <listitem><para><filename>ext3</filename>
  4517. </para></listitem>
  4518. <listitem><para><filename>ext2</filename>
  4519. </para></listitem>
  4520. <listitem><para><filename>btrfs</filename>
  4521. </para></listitem>
  4522. <listitem><para><filename>squashfs</filename>
  4523. </para></listitem>
  4524. <listitem><para><filename>swap</filename>
  4525. </para></listitem>
  4526. </itemizedlist></para></listitem>
  4527. <listitem><para><emphasis><filename>--fsoptions</filename>:</emphasis>
  4528. Specifies a free-form string of options to be
  4529. used when mounting the filesystem.
  4530. This string will be copied into the
  4531. <filename>/etc/fstab</filename> file of the
  4532. installed system and should be enclosed in
  4533. quotes.
  4534. If not specified, the default string
  4535. is "defaults".
  4536. </para></listitem>
  4537. <listitem><para><emphasis><filename>--label label</filename>:</emphasis>
  4538. Specifies the label to give to the filesystem to
  4539. be made on the partition.
  4540. If the given label is already in use by another
  4541. filesystem, a new label is created for the
  4542. partition.</para></listitem>
  4543. <listitem><para><emphasis><filename>--active</filename>:</emphasis>
  4544. Marks the partition as active.</para></listitem>
  4545. <listitem><para><emphasis><filename>--align (in KBytes)</filename>:</emphasis>
  4546. This option is a <filename>wic</filename>-specific
  4547. option that says to start a partition on an
  4548. x KBytes boundary.</para></listitem>
  4549. <listitem><para><emphasis><filename>--no-table</filename>:</emphasis>
  4550. This option is a <filename>wic</filename>-specific
  4551. option.
  4552. Using the option reserves space for the partition
  4553. and causes it to become populated.
  4554. However, the partition is not added to the
  4555. partition table.
  4556. </para></listitem>
  4557. <listitem><para><emphasis><filename>--extra-space</filename>:</emphasis>
  4558. This option is a <filename>wic</filename>-specific
  4559. option that adds extra space after the space
  4560. filled by the content of the partition.
  4561. The final size can go beyond the size specified
  4562. by the <filename>--size</filename> option.
  4563. The default value is 10 Mbytes.
  4564. </para></listitem>
  4565. <listitem><para><emphasis><filename>--overhead-factor</filename>:</emphasis>
  4566. This option is a <filename>wic</filename>-specific
  4567. option that multiplies the size of the partition by
  4568. the option's value.
  4569. You must supply a value greater than or equal to
  4570. "1".
  4571. The default value is "1.3".
  4572. </para></listitem>
  4573. <listitem><para><emphasis><filename>--part-type</filename>:</emphasis>
  4574. This option is a <filename>wic</filename>-specific
  4575. option that specifies the partition type globally
  4576. unique identifier (GUID) for GPT partitions.
  4577. You can find the list of partition type GUIDs
  4578. at
  4579. <ulink url='http://en.wikipedia.org/wiki/GUID_Partition_Table#Partition_type_GUIDs'></ulink>.
  4580. </para></listitem>
  4581. <listitem><para><emphasis><filename>--use-uuid</filename>:</emphasis>
  4582. This option is a <filename>wic</filename>-specific
  4583. option that causes <filename>wic</filename> to
  4584. generate a random GUID for the partition.
  4585. The generated identifier is used in the bootloader
  4586. configuration to specify the root partition.
  4587. </para></listitem>
  4588. <listitem><para><emphasis><filename>--uuid</filename>:</emphasis>
  4589. This option is a <filename>wic</filename>-specific
  4590. option that specifies the partition UUID.
  4591. </para></listitem>
  4592. </itemizedlist>
  4593. </para>
  4594. </section>
  4595. <section id='command-bootloader'>
  4596. <title>Command: bootloader</title>
  4597. <para>
  4598. This command specifies how the boot loader should be
  4599. configured and supports the following options:
  4600. <note>
  4601. Bootloader functionality and boot partitions are
  4602. implemented by the various
  4603. <filename>--source</filename>
  4604. plugins that implement bootloader functionality.
  4605. The bootloader command essentially provides a means of
  4606. modifying bootloader configuration.
  4607. </note>
  4608. <itemizedlist>
  4609. <listitem><para><emphasis><filename>--timeout</filename>:</emphasis>
  4610. Specifies the number of seconds before the
  4611. bootloader times out and boots the default option.
  4612. </para></listitem>
  4613. <listitem><para><emphasis><filename>--append</filename>:</emphasis>
  4614. Specifies kernel parameters.
  4615. These parameters will be added to the syslinux
  4616. <filename>APPEND</filename> or
  4617. <filename>grub</filename> kernel command line.
  4618. </para></listitem>
  4619. <listitem><para><emphasis><filename>--configfile</filename>:</emphasis>
  4620. Specifies a user-defined configuration file for
  4621. the bootloader.
  4622. You can provide a full pathname for the file or
  4623. a file that exists in the
  4624. <filename>canned-wks</filename> folder.
  4625. This option overrides all other bootloader options.
  4626. </para></listitem>
  4627. </itemizedlist>
  4628. </para>
  4629. </section>
  4630. </section>
  4631. </section>
  4632. <section id='configuring-the-kernel'>
  4633. <title>Configuring the Kernel</title>
  4634. <para>
  4635. Configuring the Yocto Project kernel consists of making sure the
  4636. <filename>.config</filename> file has all the right information
  4637. in it for the image you are building.
  4638. You can use the <filename>menuconfig</filename> tool and
  4639. configuration fragments to make sure your
  4640. <filename>.config</filename> file is just how you need it.
  4641. You can also save known configurations in a
  4642. <filename>defconfig</filename> file that the build system can use
  4643. for kernel configuration.
  4644. </para>
  4645. <para>
  4646. This section describes how to use <filename>menuconfig</filename>,
  4647. create and use configuration fragments, and how to interactively
  4648. modify your <filename>.config</filename> file to create the
  4649. leanest kernel configuration file possible.
  4650. </para>
  4651. <para>
  4652. For more information on kernel configuration, see the
  4653. "<ulink url='&YOCTO_DOCS_KERNEL_DEV_URL;#changing-the-configuration'>Changing the Configuration</ulink>"
  4654. section in the Yocto Project Linux Kernel Development Manual.
  4655. </para>
  4656. <section id='using-menuconfig'>
  4657. <title>Using&nbsp;&nbsp;<filename>menuconfig</filename></title>
  4658. <para>
  4659. The easiest way to define kernel configurations is to set them through the
  4660. <filename>menuconfig</filename> tool.
  4661. This tool provides an interactive method with which
  4662. to set kernel configurations.
  4663. For general information on <filename>menuconfig</filename>, see
  4664. <ulink url='http://en.wikipedia.org/wiki/Menuconfig'></ulink>.
  4665. </para>
  4666. <para>
  4667. To use the <filename>menuconfig</filename> tool in the Yocto Project development
  4668. environment, you must launch it using BitBake.
  4669. Thus, the environment must be set up using the
  4670. <ulink url='&YOCTO_DOCS_REF_URL;#structure-core-script'><filename>&OE_INIT_FILE;</filename></ulink>
  4671. or
  4672. <ulink url='&YOCTO_DOCS_REF_URL;#structure-memres-core-script'><filename>oe-init-build-env-memres</filename></ulink>
  4673. script found in the
  4674. <link linkend='build-directory'>Build Directory</link>.
  4675. You must also be sure of the state of your build in the
  4676. <link linkend='source-directory'>Source Directory</link>.
  4677. The following commands run <filename>menuconfig</filename>
  4678. assuming the Source Directory's top-level folder is
  4679. <filename>~/poky</filename>:
  4680. <literallayout class='monospaced'>
  4681. $ cd poky
  4682. $ source oe-init-build-env
  4683. $ bitbake linux-yocto -c kernel_configme -f
  4684. $ bitbake linux-yocto -c menuconfig
  4685. </literallayout>
  4686. Once <filename>menuconfig</filename> comes up, its standard
  4687. interface allows you to interactively examine and configure
  4688. all the kernel configuration parameters.
  4689. After making your changes, simply exit the tool and save your
  4690. changes to create an updated version of the
  4691. <filename>.config</filename> configuration file.
  4692. </para>
  4693. <para>
  4694. Consider an example that configures the <filename>linux-yocto-3.14</filename>
  4695. kernel.
  4696. The OpenEmbedded build system recognizes this kernel as
  4697. <filename>linux-yocto</filename>.
  4698. Thus, the following commands from the shell in which you previously sourced the
  4699. environment initialization script cleans the shared state cache and the
  4700. <ulink url='&YOCTO_DOCS_REF_URL;#var-WORKDIR'><filename>WORKDIR</filename></ulink>
  4701. directory and then runs <filename>menuconfig</filename>:
  4702. <literallayout class='monospaced'>
  4703. $ bitbake linux-yocto -c menuconfig
  4704. </literallayout>
  4705. </para>
  4706. <para>
  4707. Once <filename>menuconfig</filename> launches, use the interface
  4708. to navigate through the selections to find the configuration settings in
  4709. which you are interested.
  4710. For example, consider the <filename>CONFIG_SMP</filename> configuration setting.
  4711. You can find it at <filename>Processor Type and Features</filename> under
  4712. the configuration selection <filename>Symmetric Multi-processing Support</filename>.
  4713. After highlighting the selection, use the arrow keys to select or deselect
  4714. the setting.
  4715. When you are finished with all your selections, exit out and save them.
  4716. </para>
  4717. <para>
  4718. Saving the selections updates the <filename>.config</filename> configuration file.
  4719. This is the file that the OpenEmbedded build system uses to configure the
  4720. kernel during the build.
  4721. You can find and examine this file in the Build Directory in
  4722. <filename>tmp/work/</filename>.
  4723. The actual <filename>.config</filename> is located in the area where the
  4724. specific kernel is built.
  4725. For example, if you were building a Linux Yocto kernel based on the
  4726. Linux 3.14 kernel and you were building a QEMU image targeted for
  4727. <filename>x86</filename> architecture, the
  4728. <filename>.config</filename> file would be located here:
  4729. <literallayout class='monospaced'>
  4730. poky/build/tmp/work/qemux86-poky-linux/linux-yocto-3.14.11+git1+84f...
  4731. ...656ed30-r1/linux-qemux86-standard-build
  4732. </literallayout>
  4733. <note>
  4734. The previous example directory is artificially split and many of the characters
  4735. in the actual filename are omitted in order to make it more readable.
  4736. Also, depending on the kernel you are using, the exact pathname
  4737. for <filename>linux-yocto-3.14...</filename> might differ.
  4738. </note>
  4739. </para>
  4740. <para>
  4741. Within the <filename>.config</filename> file, you can see the kernel settings.
  4742. For example, the following entry shows that symmetric multi-processor support
  4743. is not set:
  4744. <literallayout class='monospaced'>
  4745. # CONFIG_SMP is not set
  4746. </literallayout>
  4747. </para>
  4748. <para>
  4749. A good method to isolate changed configurations is to use a combination of the
  4750. <filename>menuconfig</filename> tool and simple shell commands.
  4751. Before changing configurations with <filename>menuconfig</filename>, copy the
  4752. existing <filename>.config</filename> and rename it to something else,
  4753. use <filename>menuconfig</filename> to make
  4754. as many changes as you want and save them, then compare the renamed configuration
  4755. file against the newly created file.
  4756. You can use the resulting differences as your base to create configuration fragments
  4757. to permanently save in your kernel layer.
  4758. <note>
  4759. Be sure to make a copy of the <filename>.config</filename> and don't just
  4760. rename it.
  4761. The build system needs an existing <filename>.config</filename>
  4762. from which to work.
  4763. </note>
  4764. </para>
  4765. </section>
  4766. <section id='creating-a-defconfig-file'>
  4767. <title>Creating a&nbsp;&nbsp;<filename>defconfig</filename> File</title>
  4768. <para>
  4769. A <filename>defconfig</filename> file is simply a
  4770. <filename>.config</filename> renamed to "defconfig".
  4771. You can use a <filename>defconfig</filename> file
  4772. to retain a known set of kernel configurations from which the
  4773. OpenEmbedded build system can draw to create the final
  4774. <filename>.config</filename> file.
  4775. <note>
  4776. Out-of-the-box, the Yocto Project never ships a
  4777. <filename>defconfig</filename> or
  4778. <filename>.config</filename> file.
  4779. The OpenEmbedded build system creates the final
  4780. <filename>.config</filename> file used to configure the
  4781. kernel.
  4782. </note>
  4783. </para>
  4784. <para>
  4785. To create a <filename>defconfig</filename>, start with a
  4786. complete, working Linux kernel <filename>.config</filename>
  4787. file.
  4788. Copy that file to the appropriate
  4789. <filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-PN'><filename>PN</filename></ulink><filename>}</filename>
  4790. directory in your layer's
  4791. <filename>recipes-kernel/linux</filename> directory, and rename
  4792. the copied file to "defconfig".
  4793. Then, add the following lines to the linux-yocto
  4794. <filename>.bbappend</filename> file in your layer:
  4795. <literallayout class='monospaced'>
  4796. FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:"
  4797. SRC_URI += "file://defconfig"
  4798. </literallayout>
  4799. The
  4800. <ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'><filename>SRC_URI</filename></ulink>
  4801. tells the build system how to search for the file, while the
  4802. <ulink url='&YOCTO_DOCS_REF_URL;#var-FILESEXTRAPATHS'><filename>FILESEXTRAPATHS</filename></ulink>
  4803. extends the
  4804. <ulink url='&YOCTO_DOCS_REF_URL;#var-FILESPATH'><filename>FILESPATH</filename></ulink>
  4805. variable (search directories) to include the
  4806. <filename>${PN}</filename> directory you created to hold the
  4807. configuration changes.
  4808. <note>
  4809. The build system applies the configurations from the
  4810. <filename>defconfig</filename> file before applying any
  4811. subsequent configuration fragments.
  4812. The final kernel configuration is a combination of the
  4813. configurations in the <filename>defconfig</filename>
  4814. file and any configuration fragments you provide.
  4815. You need to realize that if you have any configuration
  4816. fragments, the build system applies these on top of and
  4817. after applying the existing defconfig file configurations.
  4818. </note>
  4819. For more information on configuring the kernel, see the
  4820. "<ulink url='&YOCTO_DOCS_KERNEL_DEV_URL;#changing-the-configuration'>Changing the Configuration</ulink>"
  4821. and
  4822. "<ulink url='&YOCTO_DOCS_KERNEL_DEV_URL;#generating-configuration-files'>Generating Configuration Files</ulink>"
  4823. sections, both in the Yocto Project Linux Kernel Development
  4824. Manual.
  4825. </para>
  4826. </section>
  4827. <section id='creating-config-fragments'>
  4828. <title>Creating Configuration Fragments</title>
  4829. <para>
  4830. Configuration fragments are simply kernel options that appear in a file
  4831. placed where the OpenEmbedded build system can find and apply them.
  4832. Syntactically, the configuration statement is identical to what would appear
  4833. in the <filename>.config</filename> file, which is in the
  4834. <link linkend='build-directory'>Build Directory</link>:
  4835. <literallayout class='monospaced'>
  4836. tmp/work/<replaceable>arch</replaceable>-poky-linux/linux-yocto-<replaceable>release_specific_string</replaceable>/linux-<replaceable>arch</replaceable>-<replaceable>build_type</replaceable>
  4837. </literallayout>
  4838. </para>
  4839. <para>
  4840. It is simple to create a configuration fragment.
  4841. For example, issuing the following from the shell creates a configuration fragment
  4842. file named <filename>my_smp.cfg</filename> that enables multi-processor support
  4843. within the kernel:
  4844. <literallayout class='monospaced'>
  4845. $ echo "CONFIG_SMP=y" >> my_smp.cfg
  4846. </literallayout>
  4847. <note>
  4848. All configuration fragment files must use the
  4849. <filename>.cfg</filename> extension in order for the
  4850. OpenEmbedded build system to recognize them as a
  4851. configuration fragment.
  4852. </note>
  4853. </para>
  4854. <para>
  4855. Where do you put your configuration fragment files?
  4856. You can place these files in the same area pointed to by
  4857. <ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'><filename>SRC_URI</filename></ulink>.
  4858. The OpenEmbedded build system picks up the configuration and
  4859. adds it to the kernel's configuration.
  4860. For example, suppose you had a set of configuration options
  4861. in a file called <filename>myconfig.cfg</filename>.
  4862. If you put that file inside a directory named
  4863. <filename>linux-yocto</filename> that resides in the same
  4864. directory as the kernel's append file and then add a
  4865. <filename>SRC_URI</filename> statement such as the following
  4866. to the kernel's append file, those configuration options
  4867. will be picked up and applied when the kernel is built.
  4868. <literallayout class='monospaced'>
  4869. SRC_URI += "file://myconfig.cfg"
  4870. </literallayout>
  4871. </para>
  4872. <para>
  4873. As mentioned earlier, you can group related configurations into multiple files and
  4874. name them all in the <filename>SRC_URI</filename> statement as well.
  4875. For example, you could group separate configurations specifically for Ethernet and graphics
  4876. into their own files and add those by using a <filename>SRC_URI</filename> statement like the
  4877. following in your append file:
  4878. <literallayout class='monospaced'>
  4879. SRC_URI += "file://myconfig.cfg \
  4880. file://eth.cfg \
  4881. file://gfx.cfg"
  4882. </literallayout>
  4883. </para>
  4884. </section>
  4885. <section id='fine-tuning-the-kernel-configuration-file'>
  4886. <title>Fine-Tuning the Kernel Configuration File</title>
  4887. <para>
  4888. You can make sure the <filename>.config</filename> file is as lean or efficient as
  4889. possible by reading the output of the kernel configuration fragment audit,
  4890. noting any issues, making changes to correct the issues, and then repeating.
  4891. </para>
  4892. <para>
  4893. As part of the kernel build process, the
  4894. <filename>do_kernel_configcheck</filename> task runs.
  4895. This task validates the kernel configuration by checking the final
  4896. <filename>.config</filename> file against the input files.
  4897. During the check, the task produces warning messages for the following
  4898. issues:
  4899. <itemizedlist>
  4900. <listitem><para>Requested options that did not make the final
  4901. <filename>.config</filename> file.</para></listitem>
  4902. <listitem><para>Configuration items that appear twice in the same
  4903. configuration fragment.</para></listitem>
  4904. <listitem><para>Configuration items tagged as "required" that were overridden.
  4905. </para></listitem>
  4906. <listitem><para>A board overrides a non-board specific option.</para></listitem>
  4907. <listitem><para>Listed options not valid for the kernel being processed.
  4908. In other words, the option does not appear anywhere.</para></listitem>
  4909. </itemizedlist>
  4910. <note>
  4911. The <filename>do_kernel_configcheck</filename> task can
  4912. also optionally report if an option is overridden during
  4913. processing.
  4914. </note>
  4915. </para>
  4916. <para>
  4917. For each output warning, a message points to the file
  4918. that contains a list of the options and a pointer to the
  4919. configuration fragment that defines them.
  4920. Collectively, the files are the key to streamlining the
  4921. configuration.
  4922. </para>
  4923. <para>
  4924. To streamline the configuration, do the following:
  4925. <orderedlist>
  4926. <listitem><para>Start with a full configuration that you
  4927. know works - it builds and boots successfully.
  4928. This configuration file will be your baseline.
  4929. </para></listitem>
  4930. <listitem><para>Separately run the
  4931. <filename>do_kernel_configme</filename> and
  4932. <filename>do_kernel_configcheck</filename> tasks.
  4933. </para></listitem>
  4934. <listitem><para>Take the resulting list of files from the
  4935. <filename>do_kernel_configcheck</filename> task
  4936. warnings and do the following:
  4937. <itemizedlist>
  4938. <listitem><para>
  4939. Drop values that are redefined in the fragment
  4940. but do not change the final
  4941. <filename>.config</filename> file.
  4942. </para></listitem>
  4943. <listitem><para>
  4944. Analyze and potentially drop values from the
  4945. <filename>.config</filename> file that override
  4946. required configurations.
  4947. </para></listitem>
  4948. <listitem><para>
  4949. Analyze and potentially remove non-board
  4950. specific options.
  4951. </para></listitem>
  4952. <listitem><para>
  4953. Remove repeated and invalid options.
  4954. </para></listitem>
  4955. </itemizedlist></para></listitem>
  4956. <listitem><para>
  4957. After you have worked through the output of the kernel
  4958. configuration audit, you can re-run the
  4959. <filename>do_kernel_configme</filename> and
  4960. <filename>do_kernel_configcheck</filename> tasks to
  4961. see the results of your changes.
  4962. If you have more issues, you can deal with them as
  4963. described in the previous step.
  4964. </para></listitem>
  4965. </orderedlist>
  4966. </para>
  4967. <para>
  4968. Iteratively working through steps two through four eventually yields
  4969. a minimal, streamlined configuration file.
  4970. Once you have the best <filename>.config</filename>, you can build the Linux
  4971. Yocto kernel.
  4972. </para>
  4973. </section>
  4974. <section id='determining-hardware-and-non-hardware-features-for-the-kernel-configuration-audit-phase'>
  4975. <title>Determining Hardware and Non-Hardware Features for the Kernel Configuration Audit Phase</title>
  4976. <para>
  4977. This section describes part of the kernel configuration audit
  4978. phase that most developers can ignore.
  4979. During this part of the audit phase, the contents of the final
  4980. <filename>.config</filename> file are compared against the
  4981. fragments specified by the system.
  4982. These fragments can be system fragments, distro fragments,
  4983. or user specified configuration elements.
  4984. Regardless of their origin, the OpenEmbedded build system
  4985. warns the user if a specific option is not included in the
  4986. final kernel configuration.
  4987. </para>
  4988. <para>
  4989. In order to not overwhelm the user with configuration warnings,
  4990. by default the system only reports on missing "hardware"
  4991. options because a missing hardware option could mean a boot
  4992. failure or that important hardware is not available.
  4993. </para>
  4994. <para>
  4995. To determine whether or not a given option is "hardware" or
  4996. "non-hardware", the kernel Metadata contains files that
  4997. classify individual or groups of options as either hardware
  4998. or non-hardware.
  4999. To better show this, consider a situation where the
  5000. Yocto Project kernel cache contains the following files:
  5001. <literallayout class='monospaced'>
  5002. kernel-cache/features/drm-psb/hardware.cfg
  5003. kernel-cache/features/kgdb/hardware.cfg
  5004. kernel-cache/ktypes/base/hardware.cfg
  5005. kernel-cache/bsp/mti-malta32/hardware.cfg
  5006. kernel-cache/bsp/fsl-mpc8315e-rdb/hardware.cfg
  5007. kernel-cache/bsp/qemu-ppc32/hardware.cfg
  5008. kernel-cache/bsp/qemuarma9/hardware.cfg
  5009. kernel-cache/bsp/mti-malta64/hardware.cfg
  5010. kernel-cache/bsp/arm-versatile-926ejs/hardware.cfg
  5011. kernel-cache/bsp/common-pc/hardware.cfg
  5012. kernel-cache/bsp/common-pc-64/hardware.cfg
  5013. kernel-cache/features/rfkill/non-hardware.cfg
  5014. kernel-cache/ktypes/base/non-hardware.cfg
  5015. kernel-cache/features/aufs/non-hardware.kcf
  5016. kernel-cache/features/ocf/non-hardware.kcf
  5017. kernel-cache/ktypes/base/non-hardware.kcf
  5018. kernel-cache/ktypes/base/hardware.kcf
  5019. kernel-cache/bsp/qemu-ppc32/hardware.kcf
  5020. </literallayout>
  5021. The following list provides explanations for the various
  5022. files:
  5023. <itemizedlist>
  5024. <listitem><para><filename>hardware.kcf</filename>:
  5025. Specifies a list of kernel Kconfig files that contain
  5026. hardware options only.
  5027. </para></listitem>
  5028. <listitem><para><filename>non-hardware.kcf</filename>:
  5029. Specifies a list of kernel Kconfig files that contain
  5030. non-hardware options only.
  5031. </para></listitem>
  5032. <listitem><para><filename>hardware.cfg</filename>:
  5033. Specifies a list of kernel
  5034. <filename>CONFIG_</filename> options that are hardware,
  5035. regardless of whether or not they are within a Kconfig
  5036. file specified by a hardware or non-hardware
  5037. Kconfig file (i.e. <filename>hardware.kcf</filename> or
  5038. <filename>non-hardware.kcf</filename>).
  5039. </para></listitem>
  5040. <listitem><para><filename>non-hardware.cfg</filename>:
  5041. Specifies a list of kernel
  5042. <filename>CONFIG_</filename> options that are
  5043. not hardware, regardless of whether or not they are
  5044. within a Kconfig file specified by a hardware or
  5045. non-hardware Kconfig file (i.e.
  5046. <filename>hardware.kcf</filename> or
  5047. <filename>non-hardware.kcf</filename>).
  5048. </para></listitem>
  5049. </itemizedlist>
  5050. Here is a specific example using the
  5051. <filename>kernel-cache/bsp/mti-malta32/hardware.cfg</filename>:
  5052. <literallayout class='monospaced'>
  5053. CONFIG_SERIAL_8250
  5054. CONFIG_SERIAL_8250_CONSOLE
  5055. CONFIG_SERIAL_8250_NR_UARTS
  5056. CONFIG_SERIAL_8250_PCI
  5057. CONFIG_SERIAL_CORE
  5058. CONFIG_SERIAL_CORE_CONSOLE
  5059. CONFIG_VGA_ARB
  5060. </literallayout>
  5061. The kernel configuration audit automatically detects these
  5062. files (hence the names must be exactly the ones discussed here),
  5063. and uses them as inputs when generating warnings about the
  5064. final <filename>.config</filename> file.
  5065. </para>
  5066. <para>
  5067. A user-specified kernel Metadata repository, or recipe space
  5068. feature, can use these same files to classify options that are
  5069. found within its <filename>.cfg</filename> files as hardware
  5070. or non-hardware, to prevent the OpenEmbedded build system from
  5071. producing an error or warning when an option is not in the
  5072. final <filename>.config</filename> file.
  5073. </para>
  5074. </section>
  5075. </section>
  5076. <section id="patching-the-kernel">
  5077. <title>Patching the Kernel</title>
  5078. <para>
  5079. Patching the kernel involves changing or adding configurations to an existing kernel,
  5080. changing or adding recipes to the kernel that are needed to support specific hardware features,
  5081. or even altering the source code itself.
  5082. <note>
  5083. You can use the <filename>yocto-kernel</filename> script
  5084. found in the <link linkend='source-directory'>Source Directory</link>
  5085. under <filename>scripts</filename> to manage kernel patches and configuration.
  5086. See the "<ulink url='&YOCTO_DOCS_BSP_URL;#managing-kernel-patches-and-config-items-with-yocto-kernel'>Managing kernel Patches and Config Items with yocto-kernel</ulink>"
  5087. section in the Yocto Project Board Support Packages (BSP) Developer's Guide for
  5088. more information.</note>
  5089. </para>
  5090. <para>
  5091. This example creates a simple patch by adding some QEMU emulator console
  5092. output at boot time through <filename>printk</filename> statements in the kernel's
  5093. <filename>calibrate.c</filename> source code file.
  5094. Applying the patch and booting the modified image causes the added
  5095. messages to appear on the emulator's console.
  5096. </para>
  5097. <para>
  5098. The example assumes a clean build exists for the <filename>qemux86</filename>
  5099. machine in a
  5100. <link linkend='source-directory'>Source Directory</link>
  5101. named <filename>poky</filename>.
  5102. Furthermore, the <link linkend='build-directory'>Build Directory</link> is
  5103. <filename>build</filename> and is located in <filename>poky</filename> and
  5104. the kernel is based on the Linux 3.4 kernel.
  5105. </para>
  5106. <para>
  5107. Also, for more information on patching the kernel, see the
  5108. "<ulink url='&YOCTO_DOCS_KERNEL_DEV_URL;#applying-patches'>Applying Patches</ulink>"
  5109. section in the Yocto Project Linux Kernel Development Manual.
  5110. </para>
  5111. <section id='create-a-layer-for-your-changes'>
  5112. <title>Create a Layer for your Changes</title>
  5113. <para>
  5114. The first step is to create a layer so you can isolate your
  5115. changes.
  5116. Rather than use the <filename>yocto-layer</filename> script
  5117. to create the layer, this example steps through the process
  5118. by hand.
  5119. If you want information on the script that creates a general
  5120. layer, see the
  5121. "<link linkend='creating-a-general-layer-using-the-yocto-layer-script'>Creating a General Layer Using the yocto-layer Script</link>"
  5122. section.
  5123. </para>
  5124. <para>
  5125. These two commands create a directory you can use for your
  5126. layer:
  5127. <literallayout class='monospaced'>
  5128. $ cd ~/poky
  5129. $ mkdir meta-mylayer
  5130. </literallayout>
  5131. Creating a directory that follows the Yocto Project layer naming
  5132. conventions sets up the layer for your changes.
  5133. The layer is where you place your configuration files, append
  5134. files, and patch files.
  5135. To learn more about creating a layer and filling it with the
  5136. files you need, see the "<link linkend='understanding-and-creating-layers'>Understanding
  5137. and Creating Layers</link>" section.
  5138. </para>
  5139. </section>
  5140. <section id='finding-the-kernel-source-code'>
  5141. <title>Finding the Kernel Source Code</title>
  5142. <para>
  5143. Each time you build a kernel image, the kernel source code is fetched
  5144. and unpacked into the following directory:
  5145. <literallayout class='monospaced'>
  5146. ${S}/linux
  5147. </literallayout>
  5148. See the "<link linkend='finding-the-temporary-source-code'>Finding Temporary Source Code</link>"
  5149. section and the
  5150. <ulink url='&YOCTO_DOCS_REF_URL;#var-S'><filename>S</filename></ulink> variable
  5151. for more information about where source is kept during a build.
  5152. </para>
  5153. <para>
  5154. For this example, we are going to patch the
  5155. <filename>init/calibrate.c</filename> file
  5156. by adding some simple console <filename>printk</filename> statements that we can
  5157. see when we boot the image using QEMU.
  5158. </para>
  5159. </section>
  5160. <section id='creating-the-patch'>
  5161. <title>Creating the Patch</title>
  5162. <para>
  5163. Two methods exist by which you can create the patch:
  5164. <link linkend='using-devtool-in-your-workflow'><filename>devtool</filename></link> and
  5165. <link linkend='using-a-quilt-workflow'>Quilt</link>.
  5166. For kernel patches, the Git workflow is more appropriate.
  5167. This section assumes the Git workflow and shows the steps specific to
  5168. this example.
  5169. <orderedlist>
  5170. <listitem><para><emphasis>Change the working directory</emphasis>:
  5171. Change to where the kernel source code is before making
  5172. your edits to the <filename>calibrate.c</filename> file:
  5173. <literallayout class='monospaced'>
  5174. $ cd ~/poky/build/tmp/work/qemux86-poky-linux/linux-yocto-${PV}-${PR}/linux
  5175. </literallayout>
  5176. Because you are working in an established Git repository,
  5177. you must be in this directory in order to commit your changes
  5178. and create the patch file.
  5179. <note>The <ulink url='&YOCTO_DOCS_REF_URL;#var-PV'><filename>PV</filename></ulink> and
  5180. <ulink url='&YOCTO_DOCS_REF_URL;#var-PR'><filename>PR</filename></ulink> variables
  5181. represent the version and revision for the
  5182. <filename>linux-yocto</filename> recipe.
  5183. The <filename>PV</filename> variable includes the Git meta and machine
  5184. hashes, which make the directory name longer than you might
  5185. expect.
  5186. </note></para></listitem>
  5187. <listitem><para><emphasis>Edit the source file</emphasis>:
  5188. Edit the <filename>init/calibrate.c</filename> file to have the
  5189. following changes:
  5190. <literallayout class='monospaced'>
  5191. void calibrate_delay(void)
  5192. {
  5193. unsigned long lpj;
  5194. static bool printed;
  5195. int this_cpu = smp_processor_id();
  5196. printk("*************************************\n");
  5197. printk("* *\n");
  5198. printk("* HELLO YOCTO KERNEL *\n");
  5199. printk("* *\n");
  5200. printk("*************************************\n");
  5201. if (per_cpu(cpu_loops_per_jiffy, this_cpu)) {
  5202. .
  5203. .
  5204. .
  5205. </literallayout></para></listitem>
  5206. <listitem><para><emphasis>Stage and commit your changes</emphasis>:
  5207. These Git commands display the modified file, stage it, and then
  5208. commit the file:
  5209. <literallayout class='monospaced'>
  5210. $ git status
  5211. $ git add init/calibrate.c
  5212. $ git commit -m "calibrate: Add printk example"
  5213. </literallayout></para></listitem>
  5214. <listitem><para><emphasis>Generate the patch file</emphasis>:
  5215. This Git command creates the a patch file named
  5216. <filename>0001-calibrate-Add-printk-example.patch</filename>
  5217. in the current directory.
  5218. <literallayout class='monospaced'>
  5219. $ git format-patch -1
  5220. </literallayout>
  5221. </para></listitem>
  5222. </orderedlist>
  5223. </para>
  5224. </section>
  5225. <section id='set-up-your-layer-for-the-build'>
  5226. <title>Set Up Your Layer for the Build</title>
  5227. <para>These steps get your layer set up for the build:
  5228. <orderedlist>
  5229. <listitem><para><emphasis>Create additional structure</emphasis>:
  5230. Create the additional layer structure:
  5231. <literallayout class='monospaced'>
  5232. $ cd ~/poky/meta-mylayer
  5233. $ mkdir conf
  5234. $ mkdir recipes-kernel
  5235. $ mkdir recipes-kernel/linux
  5236. $ mkdir recipes-kernel/linux/linux-yocto
  5237. </literallayout>
  5238. The <filename>conf</filename> directory holds your configuration files, while the
  5239. <filename>recipes-kernel</filename> directory holds your append file and
  5240. your patch file.</para></listitem>
  5241. <listitem><para><emphasis>Create the layer configuration file</emphasis>:
  5242. Move to the <filename>meta-mylayer/conf</filename> directory and create
  5243. the <filename>layer.conf</filename> file as follows:
  5244. <literallayout class='monospaced'>
  5245. # We have a conf and classes directory, add to BBPATH
  5246. BBPATH .= ":${LAYERDIR}"
  5247. # We have recipes-* directories, add to BBFILES
  5248. BBFILES += "${LAYERDIR}/recipes-*/*/*.bb \
  5249. ${LAYERDIR}/recipes-*/*/*.bbappend"
  5250. BBFILE_COLLECTIONS += "mylayer"
  5251. BBFILE_PATTERN_mylayer = "^${LAYERDIR}/"
  5252. BBFILE_PRIORITY_mylayer = "5"
  5253. </literallayout>
  5254. Notice <filename>mylayer</filename> as part of the last three
  5255. statements.</para></listitem>
  5256. <listitem><para><emphasis>Create the kernel recipe append file</emphasis>:
  5257. Move to the <filename>meta-mylayer/recipes-kernel/linux</filename> directory and create
  5258. the <filename>linux-yocto_3.4.bbappend</filename> file as follows:
  5259. <literallayout class='monospaced'>
  5260. FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:"
  5261. SRC_URI += "file://0001-calibrate-Add-printk-example.patch"
  5262. </literallayout>
  5263. The <ulink url='&YOCTO_DOCS_REF_URL;#var-FILESEXTRAPATHS'><filename>FILESEXTRAPATHS</filename></ulink>
  5264. and <ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'><filename>SRC_URI</filename></ulink>
  5265. statements enable the OpenEmbedded build system to find the patch file.
  5266. For more information on using append files, see the
  5267. "<link linkend='using-bbappend-files'>Using .bbappend Files</link>"
  5268. section.
  5269. </para></listitem>
  5270. <listitem><para><emphasis>Put the patch file in your layer</emphasis>:
  5271. Move the <filename>0001-calibrate-Add-printk-example.patch</filename> file to
  5272. the <filename>meta-mylayer/recipes-kernel/linux/linux-yocto</filename>
  5273. directory.</para></listitem>
  5274. </orderedlist>
  5275. </para>
  5276. </section>
  5277. <section id='set-up-for-the-build'>
  5278. <title>Set Up for the Build</title>
  5279. <para>
  5280. Do the following to make sure the build parameters are set up for the example.
  5281. Once you set up these build parameters, they do not have to change unless you
  5282. change the target architecture of the machine you are building:
  5283. <itemizedlist>
  5284. <listitem><para><emphasis>Build for the correct target architecture:</emphasis> Your
  5285. selected <ulink url='&YOCTO_DOCS_REF_URL;#var-MACHINE'><filename>MACHINE</filename></ulink>
  5286. definition within the <filename>local.conf</filename> file in the
  5287. <link linkend='build-directory'>Build Directory</link>
  5288. specifies the target architecture used when building the Linux kernel.
  5289. By default, <filename>MACHINE</filename> is set to
  5290. <filename>qemux86</filename>, which specifies a 32-bit
  5291. <trademark class='registered'>Intel</trademark> Architecture
  5292. target machine suitable for the QEMU emulator.</para></listitem>
  5293. <listitem><para><emphasis>Identify your <filename>meta-mylayer</filename>
  5294. layer:</emphasis> The
  5295. <ulink url='&YOCTO_DOCS_REF_URL;#var-BBLAYERS'><filename>BBLAYERS</filename></ulink>
  5296. variable in the
  5297. <filename>bblayers.conf</filename> file found in the
  5298. <filename>poky/build/conf</filename> directory needs to have the path to your local
  5299. <filename>meta-mylayer</filename> layer.
  5300. By default, the <filename>BBLAYERS</filename> variable contains paths to
  5301. <filename>meta</filename>, <filename>meta-poky</filename>, and
  5302. <filename>meta-yocto-bsp</filename> in the
  5303. <filename>poky</filename> Git repository.
  5304. Add the path to your <filename>meta-mylayer</filename> location:
  5305. <literallayout class='monospaced'>
  5306. BBLAYERS ?= " \
  5307. $HOME/poky/meta \
  5308. $HOME/poky/meta-poky \
  5309. $HOME/poky/meta-yocto-bsp \
  5310. $HOME/poky/meta-mylayer \
  5311. "
  5312. </literallayout></para></listitem>
  5313. </itemizedlist>
  5314. </para>
  5315. </section>
  5316. <section id='build-the-modified-qemu-kernel-image'>
  5317. <title>Build the Modified QEMU Kernel Image</title>
  5318. <para>
  5319. The following steps build your modified kernel image:
  5320. <orderedlist>
  5321. <listitem><para><emphasis>Be sure your build environment is initialized</emphasis>:
  5322. Your environment should be set up since you previously sourced
  5323. the
  5324. <ulink url='&YOCTO_DOCS_REF_URL;#structure-core-script'><filename>&OE_INIT_FILE;</filename></ulink>
  5325. script.
  5326. If it is not, source the script again from <filename>poky</filename>.
  5327. <literallayout class='monospaced'>
  5328. $ cd ~/poky
  5329. $ source &OE_INIT_FILE;
  5330. </literallayout>
  5331. </para></listitem>
  5332. <listitem><para><emphasis>Clean up</emphasis>:
  5333. Be sure to clean the shared state out by using BitBake
  5334. to run from within the Build Directory the
  5335. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-cleansstate'><filename>do_cleansstate</filename></ulink>
  5336. task as follows:
  5337. <literallayout class='monospaced'>
  5338. $ bitbake -c cleansstate linux-yocto
  5339. </literallayout></para>
  5340. <para>
  5341. <note>
  5342. Never remove any files by hand from the
  5343. <filename>tmp/deploy</filename>
  5344. directory inside the
  5345. <link linkend='build-directory'>Build Directory</link>.
  5346. Always use the various BitBake clean tasks to
  5347. clear out previous build artifacts.
  5348. For information on the clean tasks, see the
  5349. "<ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-clean'><filename>do_clean</filename></ulink>",
  5350. "<ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-cleanall'><filename>do_cleanall</filename></ulink>",
  5351. and
  5352. "<ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-cleansstate'><filename>do_cleansstate</filename></ulink>"
  5353. sections all in the Yocto Project Reference
  5354. Manual.
  5355. </note>
  5356. </para></listitem>
  5357. <listitem><para><emphasis>Build the image</emphasis>:
  5358. Next, build the kernel image using this command:
  5359. <literallayout class='monospaced'>
  5360. $ bitbake -k linux-yocto
  5361. </literallayout></para></listitem>
  5362. </orderedlist>
  5363. </para>
  5364. </section>
  5365. <section id='boot-the-image-and-verify-your-changes'>
  5366. <title>Boot the Image and Verify Your Changes</title>
  5367. <para>
  5368. These steps boot the image and allow you to see the changes
  5369. <orderedlist>
  5370. <listitem><para><emphasis>Boot the image</emphasis>:
  5371. Boot the modified image in the QEMU emulator
  5372. using this command:
  5373. <literallayout class='monospaced'>
  5374. $ runqemu qemux86
  5375. </literallayout></para></listitem>
  5376. <listitem><para><emphasis>Verify the changes</emphasis>:
  5377. Log into the machine using <filename>root</filename> with no password and then
  5378. use the following shell command to scroll through the console's boot output.
  5379. <literallayout class='monospaced'>
  5380. # dmesg | less
  5381. </literallayout>
  5382. You should see the results of your <filename>printk</filename> statements
  5383. as part of the output.</para></listitem>
  5384. </orderedlist>
  5385. </para>
  5386. </section>
  5387. </section>
  5388. <section id='making-images-more-secure'>
  5389. <title>Making Images More Secure</title>
  5390. <para>
  5391. Security is of increasing concern for embedded devices.
  5392. Consider the issues and problems discussed in just this
  5393. sampling of work found across the Internet:
  5394. <itemizedlist>
  5395. <listitem><para><emphasis>
  5396. "<ulink url='https://www.schneier.com/blog/archives/2014/01/security_risks_9.html'>Security Risks of Embedded Systems</ulink>"</emphasis>
  5397. by Bruce Schneier
  5398. </para></listitem>
  5399. <listitem><para><emphasis>
  5400. "<ulink url='http://internetcensus2012.bitbucket.org/paper.html'>Internet Census 2012</ulink>"</emphasis>
  5401. by Carna Botnet</para></listitem>
  5402. <listitem><para><emphasis>
  5403. "<ulink url='http://elinux.org/images/6/6f/Security-issues.pdf'>Security Issues for Embedded Devices</ulink>"</emphasis>
  5404. by Jake Edge
  5405. </para></listitem>
  5406. </itemizedlist>
  5407. </para>
  5408. <para>
  5409. When securing your image is of concern, there are steps, tools,
  5410. and variables that you can consider to help you reach the
  5411. security goals you need for your particular device.
  5412. Not all situations are identical when it comes to making an
  5413. image secure.
  5414. Consequently, this section provides some guidance and suggestions
  5415. for consideration when you want to make your image more secure.
  5416. <note>
  5417. Because the security requirements and risks are
  5418. different for every type of device, this section cannot
  5419. provide a complete reference on securing your custom OS.
  5420. It is strongly recommended that you also consult other sources
  5421. of information on embedded Linux system hardening and on
  5422. security.
  5423. </note>
  5424. </para>
  5425. <section id='general-considerations'>
  5426. <title>General Considerations</title>
  5427. <para>
  5428. General considerations exist that help you create more
  5429. secure images.
  5430. You should consider the following suggestions to help
  5431. make your device more secure:
  5432. <itemizedlist>
  5433. <listitem><para>
  5434. Scan additional code you are adding to the system
  5435. (e.g. application code) by using static analysis
  5436. tools.
  5437. Look for buffer overflows and other potential
  5438. security problems.
  5439. </para></listitem>
  5440. <listitem><para>
  5441. Pay particular attention to the security for
  5442. any web-based administration interface.
  5443. </para>
  5444. <para>Web interfaces typically need to perform
  5445. administrative functions and tend to need to run with
  5446. elevated privileges.
  5447. Thus, the consequences resulting from the interface's
  5448. security becoming compromised can be serious.
  5449. Look for common web vulnerabilities such as
  5450. cross-site-scripting (XSS), unvalidated inputs,
  5451. and so forth.</para>
  5452. <para>As with system passwords, the default credentials
  5453. for accessing a web-based interface should not be the
  5454. same across all devices.
  5455. This is particularly true if the interface is enabled
  5456. by default as it can be assumed that many end-users
  5457. will not change the credentials.
  5458. </para></listitem>
  5459. <listitem><para>
  5460. Ensure you can update the software on the device to
  5461. mitigate vulnerabilities discovered in the future.
  5462. This consideration especially applies when your
  5463. device is network-enabled.
  5464. </para></listitem>
  5465. <listitem><para>
  5466. Ensure you remove or disable debugging functionality
  5467. before producing the final image.
  5468. For information on how to do this, see the
  5469. "<link linkend='considerations-specific-to-the-openembedded-build-system'>Considerations Specific to the OpenEmbedded Build System</link>"
  5470. section.
  5471. </para></listitem>
  5472. <listitem><para>
  5473. Ensure you have no network services listening that
  5474. are not needed.
  5475. </para></listitem>
  5476. <listitem><para>
  5477. Remove any software from the image that is not needed.
  5478. </para></listitem>
  5479. <listitem><para>
  5480. Enable hardware support for secure boot functionality
  5481. when your device supports this functionality.
  5482. </para></listitem>
  5483. </itemizedlist>
  5484. </para>
  5485. </section>
  5486. <section id='security-flags'>
  5487. <title>Security Flags</title>
  5488. <para>
  5489. The Yocto Project has security flags that you can enable that
  5490. help make your build output more secure.
  5491. The security flags are in the
  5492. <filename>meta/conf/distro/include/security_flags.inc</filename>
  5493. file in your
  5494. <link linkend='source-directory'>Source Directory</link>
  5495. (e.g. <filename>poky</filename>).
  5496. <note>
  5497. Depending on the recipe, certain security flags are enabled
  5498. and disabled by default.
  5499. </note>
  5500. </para>
  5501. <para>
  5502. <!--
  5503. The GCC/LD flags in <filename>security_flags.inc</filename>
  5504. enable more secure code generation.
  5505. By including the <filename>security_flags.inc</filename>
  5506. file, you enable flags to the compiler and linker that cause
  5507. them to generate more secure code.
  5508. <note>
  5509. The GCC/LD flags are enabled by default in the
  5510. <filename>poky-lsb</filename> distribution.
  5511. </note>
  5512. -->
  5513. Use the following line in your
  5514. <filename>local.conf</filename> file or in your custom
  5515. distribution configuration file to enable the security
  5516. compiler and linker flags for your build:
  5517. <literallayout class='monospaced'>
  5518. require conf/distro/include/security_flags.inc
  5519. </literallayout>
  5520. </para>
  5521. </section>
  5522. <section id='considerations-specific-to-the-openembedded-build-system'>
  5523. <title>Considerations Specific to the OpenEmbedded Build System</title>
  5524. <para>
  5525. You can take some steps that are specific to the
  5526. OpenEmbedded build system to make your images more secure:
  5527. <itemizedlist>
  5528. <listitem><para>
  5529. Ensure "debug-tweaks" is not one of your selected
  5530. <ulink url='&YOCTO_DOCS_REF_URL;#var-IMAGE_FEATURES'><filename>IMAGE_FEATURES</filename></ulink>.
  5531. When creating a new project, the default is to provide you
  5532. with an initial <filename>local.conf</filename> file that
  5533. enables this feature using the
  5534. <ulink url='&YOCTO_DOCS_REF_URL;#var-EXTRA_IMAGE_FEATURES'><filename>EXTRA_IMAGE_FEATURES</filename></ulink> variable with the line:
  5535. <literallayout class='monospaced'>
  5536. EXTRA_IMAGE_FEATURES = "debug-tweaks"
  5537. </literallayout>
  5538. To disable that feature, simply comment out that line in your
  5539. <filename>local.conf</filename> file, or
  5540. make sure <filename>IMAGE_FEATURES</filename> does not contain
  5541. "debug-tweaks" before producing your final image.
  5542. Among other things, leaving this in place sets the
  5543. root password as blank, which makes logging in for
  5544. debugging or inspection easy during
  5545. development but also means anyone can easily log in
  5546. during production.
  5547. </para></listitem>
  5548. <listitem><para>
  5549. It is possible to set a root password for the image
  5550. and also to set passwords for any extra users you might
  5551. add (e.g. administrative or service type users).
  5552. When you set up passwords for multiple images or
  5553. users, you should not duplicate passwords.
  5554. </para>
  5555. <para>
  5556. To set up passwords, use the
  5557. <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-extrausers'><filename>extrausers</filename></ulink>
  5558. class, which is the preferred method.
  5559. For an example on how to set up both root and user
  5560. passwords, see the
  5561. "<ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-extrausers'><filename>extrausers.bbclass</filename></ulink>"
  5562. section.
  5563. <note>
  5564. When adding extra user accounts or setting a
  5565. root password, be cautious about setting the
  5566. same password on every device.
  5567. If you do this, and the password you have set
  5568. is exposed, then every device is now potentially
  5569. compromised.
  5570. If you need this access but want to ensure
  5571. security, consider setting a different,
  5572. random password for each device.
  5573. Typically, you do this as a separate step after
  5574. you deploy the image onto the device.
  5575. </note>
  5576. </para></listitem>
  5577. <listitem><para>
  5578. Consider enabling a Mandatory Access Control (MAC)
  5579. framework such as SMACK or SELinux and tuning it
  5580. appropriately for your device's usage.
  5581. You can find more information in the
  5582. <ulink url='http://git.yoctoproject.org/cgit/cgit.cgi/meta-selinux/'><filename>meta-selinux</filename></ulink>
  5583. layer.
  5584. </para></listitem>
  5585. </itemizedlist>
  5586. </para>
  5587. <para>
  5588. </para>
  5589. </section>
  5590. <section id='tools-for-hardening-your-image'>
  5591. <title>Tools for Hardening Your Image</title>
  5592. <para>
  5593. The Yocto Project provides tools for making your image
  5594. more secure.
  5595. You can find these tools in the
  5596. <filename>meta-security</filename> layer of the
  5597. <ulink url='&YOCTO_GIT_URL;/cgit/cgit.cgi'>Yocto Project Source Repositories</ulink>.
  5598. </para>
  5599. </section>
  5600. </section>
  5601. <section id='creating-your-own-distribution'>
  5602. <title>Creating Your Own Distribution</title>
  5603. <para>
  5604. When you build an image using the Yocto Project and
  5605. do not alter any distribution
  5606. <link linkend='metadata'>Metadata</link>, you are creating a
  5607. Poky distribution.
  5608. If you wish to gain more control over package alternative
  5609. selections, compile-time options, and other low-level
  5610. configurations, you can create your own distribution.
  5611. </para>
  5612. <para>
  5613. To create your own distribution, the basic steps consist of
  5614. creating your own distribution layer, creating your own
  5615. distribution configuration file, and then adding any needed
  5616. code and Metadata to the layer.
  5617. The following steps provide some more detail:
  5618. <itemizedlist>
  5619. <listitem><para><emphasis>Create a layer for your new distro:</emphasis>
  5620. Create your distribution layer so that you can keep your
  5621. Metadata and code for the distribution separate.
  5622. It is strongly recommended that you create and use your own
  5623. layer for configuration and code.
  5624. Using your own layer as compared to just placing
  5625. configurations in a <filename>local.conf</filename>
  5626. configuration file makes it easier to reproduce the same
  5627. build configuration when using multiple build machines.
  5628. See the
  5629. "<link linkend='creating-a-general-layer-using-the-yocto-layer-script'>Creating a General Layer Using the yocto-layer Script</link>"
  5630. section for information on how to quickly set up a layer.
  5631. </para></listitem>
  5632. <listitem><para><emphasis>Create the distribution configuration file:</emphasis>
  5633. The distribution configuration file needs to be created in
  5634. the <filename>conf/distro</filename> directory of your
  5635. layer.
  5636. You need to name it using your distribution name
  5637. (e.g. <filename>mydistro.conf</filename>).
  5638. <note>
  5639. The
  5640. <ulink url='&YOCTO_DOCS_REF_URL;#var-DISTRO'><filename>DISTRO</filename></ulink>
  5641. variable in your
  5642. <filename>local.conf</filename> file determines the
  5643. name of your distribution.
  5644. </note></para>
  5645. <para>You can split out parts of your configuration file
  5646. into include files and then "require" them from within
  5647. your distribution configuration file.
  5648. Be sure to place the include files in the
  5649. <filename>conf/distro/include</filename> directory of
  5650. your layer.
  5651. A common example usage of include files would be to
  5652. separate out the selection of desired version and revisions
  5653. for individual recipes.
  5654. </para>
  5655. <para>Your configuration file needs to set the following
  5656. required variables:
  5657. <literallayout class='monospaced'>
  5658. <ulink url='&YOCTO_DOCS_REF_URL;#var-DISTRO_NAME'><filename>DISTRO_NAME</filename></ulink>
  5659. <ulink url='&YOCTO_DOCS_REF_URL;#var-DISTRO_VERSION'><filename>DISTRO_VERSION</filename></ulink>
  5660. </literallayout>
  5661. These following variables are optional and you typically
  5662. set them from the distribution configuration file:
  5663. <literallayout class='monospaced'>
  5664. <ulink url='&YOCTO_DOCS_REF_URL;#var-DISTRO_FEATURES'><filename>DISTRO_FEATURES</filename></ulink>
  5665. <ulink url='&YOCTO_DOCS_REF_URL;#var-DISTRO_EXTRA_RDEPENDS'><filename>DISTRO_EXTRA_RDEPENDS</filename></ulink>
  5666. <ulink url='&YOCTO_DOCS_REF_URL;#var-DISTRO_EXTRA_RRECOMMENDS'><filename>DISTRO_EXTRA_RRECOMMENDS</filename></ulink>
  5667. <ulink url='&YOCTO_DOCS_REF_URL;#var-TCLIBC'><filename>TCLIBC</filename></ulink>
  5668. </literallayout>
  5669. <tip>
  5670. If you want to base your distribution configuration file
  5671. on the very basic configuration from OE-Core, you
  5672. can use
  5673. <filename>conf/distro/defaultsetup.conf</filename> as
  5674. a reference and just include variables that differ
  5675. as compared to <filename>defaultsetup.conf</filename>.
  5676. Alternatively, you can create a distribution
  5677. configuration file from scratch using the
  5678. <filename>defaultsetup.conf</filename> file
  5679. or configuration files from other distributions
  5680. such as Poky or Angstrom as references.
  5681. </tip></para></listitem>
  5682. <listitem><para><emphasis>Provide miscellaneous variables:</emphasis>
  5683. Be sure to define any other variables for which you want to
  5684. create a default or enforce as part of the distribution
  5685. configuration.
  5686. You can include nearly any variable from the
  5687. <filename>local.conf</filename> file.
  5688. The variables you use are not limited to the list in the
  5689. previous bulleted item.</para></listitem>
  5690. <listitem><para><emphasis>Point to Your distribution configuration file:</emphasis>
  5691. In your <filename>local.conf</filename> file in the
  5692. <link linkend='build-directory'>Build Directory</link>,
  5693. set your
  5694. <ulink url='&YOCTO_DOCS_REF_URL;#var-DISTRO'><filename>DISTRO</filename></ulink>
  5695. variable to point to your distribution's configuration file.
  5696. For example, if your distribution's configuration file is
  5697. named <filename>mydistro.conf</filename>, then you point
  5698. to it as follows:
  5699. <literallayout class='monospaced'>
  5700. DISTRO = "mydistro"
  5701. </literallayout></para></listitem>
  5702. <listitem><para><emphasis>Add more to the layer if necessary:</emphasis>
  5703. Use your layer to hold other information needed for the
  5704. distribution:
  5705. <itemizedlist>
  5706. <listitem><para>Add recipes for installing
  5707. distro-specific configuration files that are not
  5708. already installed by another recipe.
  5709. If you have distro-specific configuration files
  5710. that are included by an existing recipe, you should
  5711. add an append file (<filename>.bbappend</filename>)
  5712. for those.
  5713. For general information and recommendations
  5714. on how to add recipes to your layer, see the
  5715. "<link linkend='creating-your-own-layer'>Creating Your Own Layer</link>"
  5716. and
  5717. "<link linkend='best-practices-to-follow-when-creating-layers'>Best Practices to Follow When Creating Layers</link>"
  5718. sections.</para></listitem>
  5719. <listitem><para>Add any image recipes that are specific
  5720. to your distribution.</para></listitem>
  5721. <listitem><para>Add a <filename>psplash</filename>
  5722. append file for a branded splash screen.
  5723. For information on append files, see the
  5724. "<link linkend='using-bbappend-files'>Using .bbappend Files</link>"
  5725. section.</para></listitem>
  5726. <listitem><para>Add any other append files to make
  5727. custom changes that are specific to individual
  5728. recipes.</para></listitem>
  5729. </itemizedlist></para></listitem>
  5730. </itemizedlist>
  5731. </para>
  5732. </section>
  5733. <section id='creating-a-custom-template-configuration-directory'>
  5734. <title>Creating a Custom Template Configuration Directory</title>
  5735. <para>
  5736. If you are producing your own customized version
  5737. of the build system for use by other users, you might
  5738. want to customize the message shown by the setup script or
  5739. you might want to change the template configuration files (i.e.
  5740. <filename>local.conf</filename> and
  5741. <filename>bblayers.conf</filename>) that are created in
  5742. a new build directory.
  5743. </para>
  5744. <para>
  5745. The OpenEmbedded build system uses the environment variable
  5746. <filename>TEMPLATECONF</filename> to locate the directory
  5747. from which it gathers configuration information that ultimately
  5748. ends up in the
  5749. <link linkend='build-directory'>Build Directory's</link>
  5750. <filename>conf</filename> directory.
  5751. By default, <filename>TEMPLATECONF</filename> is set as
  5752. follows in the <filename>poky</filename> repository:
  5753. <literallayout class='monospaced'>
  5754. TEMPLATECONF=${TEMPLATECONF:-meta-poky/conf}
  5755. </literallayout>
  5756. This is the directory used by the build system to find templates
  5757. from which to build some key configuration files.
  5758. If you look at this directory, you will see the
  5759. <filename>bblayers.conf.sample</filename>,
  5760. <filename>local.conf.sample</filename>, and
  5761. <filename>conf-notes.txt</filename> files.
  5762. The build system uses these files to form the respective
  5763. <filename>bblayers.conf</filename> file,
  5764. <filename>local.conf</filename> file, and display the list of
  5765. BitBake targets when running the setup script.
  5766. </para>
  5767. <para>
  5768. To override these default configuration files with
  5769. configurations you want used within every new
  5770. Build Directory, simply set the
  5771. <filename>TEMPLATECONF</filename> variable to your directory.
  5772. The <filename>TEMPLATECONF</filename> variable is set in the
  5773. <filename>.templateconf</filename> file, which is in the
  5774. top-level
  5775. <link linkend='source-directory'>Source Directory</link>
  5776. folder (e.g. <filename>poky</filename>).
  5777. Edit the <filename>.templateconf</filename> so that it can locate
  5778. your directory.
  5779. </para>
  5780. <para>
  5781. Best practices dictate that you should keep your
  5782. template configuration directory in your custom distribution layer.
  5783. For example, suppose you have a layer named
  5784. <filename>meta-mylayer</filename> located in your home directory
  5785. and you want your template configuration directory named
  5786. <filename>myconf</filename>.
  5787. Changing the <filename>.templateconf</filename> as follows
  5788. causes the OpenEmbedded build system to look in your directory
  5789. and base its configuration files on the
  5790. <filename>*.sample</filename> configuration files it finds.
  5791. The final configuration files (i.e.
  5792. <filename>local.conf</filename> and
  5793. <filename>bblayers.conf</filename> ultimately still end up in
  5794. your Build Directory, but they are based on your
  5795. <filename>*.sample</filename> files.
  5796. <literallayout class='monospaced'>
  5797. TEMPLATECONF=${TEMPLATECONF:-meta-mylayer/myconf}
  5798. </literallayout>
  5799. </para>
  5800. <para>
  5801. Aside from the <filename>*.sample</filename> configuration files,
  5802. the <filename>conf-notes.txt</filename> also resides in the
  5803. default <filename>meta-poky/conf</filename> directory.
  5804. The scripts that set up the build environment
  5805. (i.e.
  5806. <ulink url="&YOCTO_DOCS_REF_URL;#structure-core-script"><filename>&OE_INIT_FILE;</filename></ulink>
  5807. and
  5808. <ulink url="&YOCTO_DOCS_REF_URL;#structure-memres-core-script"><filename>oe-init-build-env-memres</filename></ulink>)
  5809. use this file to display BitBake targets as part of the script
  5810. output.
  5811. Customizing this <filename>conf-notes.txt</filename> file is a
  5812. good way to make sure your list of custom targets appears
  5813. as part of the script's output.
  5814. </para>
  5815. <para>
  5816. Here is the default list of targets displayed as a result of
  5817. running either of the setup scripts:
  5818. <literallayout class='monospaced'>
  5819. You can now run 'bitbake &lt;target&gt;'
  5820. Common targets are:
  5821. core-image-minimal
  5822. core-image-sato
  5823. meta-toolchain
  5824. meta-ide-support
  5825. </literallayout>
  5826. </para>
  5827. <para>
  5828. Changing the listed common targets is as easy as editing your
  5829. version of <filename>conf-notes.txt</filename> in your
  5830. custom template configuration directory and making sure you
  5831. have <filename>TEMPLATECONF</filename> set to your directory.
  5832. </para>
  5833. </section>
  5834. <section id='building-a-tiny-system'>
  5835. <title>Building a Tiny System</title>
  5836. <para>
  5837. Very small distributions have some significant advantages such
  5838. as requiring less on-die or in-package memory (cheaper), better
  5839. performance through efficient cache usage, lower power requirements
  5840. due to less memory, faster boot times, and reduced development
  5841. overhead.
  5842. Some real-world examples where a very small distribution gives
  5843. you distinct advantages are digital cameras, medical devices,
  5844. and small headless systems.
  5845. </para>
  5846. <para>
  5847. This section presents information that shows you how you can
  5848. trim your distribution to even smaller sizes than the
  5849. <filename>poky-tiny</filename> distribution, which is around
  5850. 5 Mbytes, that can be built out-of-the-box using the Yocto Project.
  5851. </para>
  5852. <section id='tiny-system-overview'>
  5853. <title>Overview</title>
  5854. <para>
  5855. The following list presents the overall steps you need to
  5856. consider and perform to create distributions with smaller
  5857. root filesystems, achieve faster boot times, maintain your critical
  5858. functionality, and avoid initial RAM disks:
  5859. <itemizedlist>
  5860. <listitem><para>
  5861. <link linkend='goals-and-guiding-principles'>Determine your goals and guiding principles.</link>
  5862. </para></listitem>
  5863. <listitem><para>
  5864. <link linkend='understand-what-gives-your-image-size'>Understand what contributes to your image size.</link>
  5865. </para></listitem>
  5866. <listitem><para>
  5867. <link linkend='trim-the-root-filesystem'>Reduce the size of the root filesystem.</link>
  5868. </para></listitem>
  5869. <listitem><para>
  5870. <link linkend='trim-the-kernel'>Reduce the size of the kernel.</link>
  5871. </para></listitem>
  5872. <listitem><para>
  5873. <link linkend='remove-package-management-requirements'>Eliminate packaging requirements.</link>
  5874. </para></listitem>
  5875. <listitem><para>
  5876. <link linkend='look-for-other-ways-to-minimize-size'>Look for other ways to minimize size.</link>
  5877. </para></listitem>
  5878. <listitem><para>
  5879. <link linkend='iterate-on-the-process'>Iterate on the process.</link>
  5880. </para></listitem>
  5881. </itemizedlist>
  5882. </para>
  5883. </section>
  5884. <section id='goals-and-guiding-principles'>
  5885. <title>Goals and Guiding Principles</title>
  5886. <para>
  5887. Before you can reach your destination, you need to know
  5888. where you are going.
  5889. Here is an example list that you can use as a guide when
  5890. creating very small distributions:
  5891. <itemizedlist>
  5892. <listitem><para>Determine how much space you need
  5893. (e.g. a kernel that is 1 Mbyte or less and
  5894. a root filesystem that is 3 Mbytes or less).
  5895. </para></listitem>
  5896. <listitem><para>Find the areas that are currently
  5897. taking 90% of the space and concentrate on reducing
  5898. those areas.
  5899. </para></listitem>
  5900. <listitem><para>Do not create any difficult "hacks"
  5901. to achieve your goals.</para></listitem>
  5902. <listitem><para>Leverage the device-specific
  5903. options.</para></listitem>
  5904. <listitem><para>Work in a separate layer so that you
  5905. keep changes isolated.
  5906. For information on how to create layers, see
  5907. the "<link linkend='understanding-and-creating-layers'>Understanding and Creating Layers</link>" section.
  5908. </para></listitem>
  5909. </itemizedlist>
  5910. </para>
  5911. </section>
  5912. <section id='understand-what-gives-your-image-size'>
  5913. <title>Understand What Contributes to Your Image Size</title>
  5914. <para>
  5915. It is easiest to have something to start with when creating
  5916. your own distribution.
  5917. You can use the Yocto Project out-of-the-box to create the
  5918. <filename>poky-tiny</filename> distribution.
  5919. Ultimately, you will want to make changes in your own
  5920. distribution that are likely modeled after
  5921. <filename>poky-tiny</filename>.
  5922. <note>
  5923. To use <filename>poky-tiny</filename> in your build,
  5924. set the
  5925. <ulink url='&YOCTO_DOCS_REF_URL;#var-DISTRO'><filename>DISTRO</filename></ulink>
  5926. variable in your
  5927. <filename>local.conf</filename> file to "poky-tiny"
  5928. as described in the
  5929. "<link linkend='creating-your-own-distribution'>Creating Your Own Distribution</link>"
  5930. section.
  5931. </note>
  5932. </para>
  5933. <para>
  5934. Understanding some memory concepts will help you reduce the
  5935. system size.
  5936. Memory consists of static, dynamic, and temporary memory.
  5937. Static memory is the TEXT (code), DATA (initialized data
  5938. in the code), and BSS (uninitialized data) sections.
  5939. Dynamic memory represents memory that is allocated at runtime:
  5940. stacks, hash tables, and so forth.
  5941. Temporary memory is recovered after the boot process.
  5942. This memory consists of memory used for decompressing
  5943. the kernel and for the <filename>__init__</filename>
  5944. functions.
  5945. </para>
  5946. <para>
  5947. To help you see where you currently are with kernel and root
  5948. filesystem sizes, you can use two tools found in the
  5949. <link linkend='source-directory'>Source Directory</link> in
  5950. the <filename>scripts/tiny/</filename> directory:
  5951. <itemizedlist>
  5952. <listitem><para><filename>ksize.py</filename>: Reports
  5953. component sizes for the kernel build objects.
  5954. </para></listitem>
  5955. <listitem><para><filename>dirsize.py</filename>: Reports
  5956. component sizes for the root filesystem.</para></listitem>
  5957. </itemizedlist>
  5958. This next tool and command help you organize configuration
  5959. fragments and view file dependencies in a human-readable form:
  5960. <itemizedlist>
  5961. <listitem><para><filename>merge_config.sh</filename>:
  5962. Helps you manage configuration files and fragments
  5963. within the kernel.
  5964. With this tool, you can merge individual configuration
  5965. fragments together.
  5966. The tool allows you to make overrides and warns you
  5967. of any missing configuration options.
  5968. The tool is ideal for allowing you to iterate on
  5969. configurations, create minimal configurations, and
  5970. create configuration files for different machines
  5971. without having to duplicate your process.</para>
  5972. <para>The <filename>merge_config.sh</filename> script is
  5973. part of the Linux Yocto kernel Git repositories
  5974. (i.e. <filename>linux-yocto-3.14</filename>,
  5975. <filename>linux-yocto-3.10</filename>,
  5976. <filename>linux-yocto-3.8</filename>, and so forth)
  5977. in the
  5978. <filename>scripts/kconfig</filename> directory.</para>
  5979. <para>For more information on configuration fragments,
  5980. see the
  5981. "<ulink url='&YOCTO_DOCS_KERNEL_DEV_URL;#generating-configuration-files'>Generating Configuration Files</ulink>"
  5982. section of the Yocto Project Linux Kernel Development
  5983. Manual and the "<link linkend='creating-config-fragments'>Creating Configuration Fragments</link>"
  5984. section, which is in this manual.</para></listitem>
  5985. <listitem><para><filename>bitbake -u depexp -g <replaceable>bitbake_target</replaceable></filename>:
  5986. Using the BitBake command with these options brings up
  5987. a Dependency Explorer from which you can view file
  5988. dependencies.
  5989. Understanding these dependencies allows you to make
  5990. informed decisions when cutting out various pieces of the
  5991. kernel and root filesystem.</para></listitem>
  5992. </itemizedlist>
  5993. </para>
  5994. </section>
  5995. <section id='trim-the-root-filesystem'>
  5996. <title>Trim the Root Filesystem</title>
  5997. <para>
  5998. The root filesystem is made up of packages for booting,
  5999. libraries, and applications.
  6000. To change things, you can configure how the packaging happens,
  6001. which changes the way you build them.
  6002. You can also modify the filesystem itself or select a different
  6003. filesystem.
  6004. </para>
  6005. <para>
  6006. First, find out what is hogging your root filesystem by running the
  6007. <filename>dirsize.py</filename> script from your root directory:
  6008. <literallayout class='monospaced'>
  6009. $ cd <replaceable>root-directory-of-image</replaceable>
  6010. $ dirsize.py 100000 > dirsize-100k.log
  6011. $ cat dirsize-100k.log
  6012. </literallayout>
  6013. You can apply a filter to the script to ignore files under
  6014. a certain size.
  6015. The previous example filters out any files below 100 Kbytes.
  6016. The sizes reported by the tool are uncompressed, and thus
  6017. will be smaller by a relatively constant factor in a
  6018. compressed root filesystem.
  6019. When you examine your log file, you can focus on areas of the
  6020. root filesystem that take up large amounts of memory.
  6021. </para>
  6022. <para>
  6023. You need to be sure that what you eliminate does not cripple
  6024. the functionality you need.
  6025. One way to see how packages relate to each other is by using
  6026. the Dependency Explorer UI with the BitBake command:
  6027. <literallayout class='monospaced'>
  6028. $ cd <replaceable>image-directory</replaceable>
  6029. $ bitbake -u depexp -g <replaceable>image</replaceable>
  6030. </literallayout>
  6031. Use the interface to select potential packages you wish to
  6032. eliminate and see their dependency relationships.
  6033. </para>
  6034. <para>
  6035. When deciding how to reduce the size, get rid of packages that
  6036. result in minimal impact on the feature set.
  6037. For example, you might not need a VGA display.
  6038. Or, you might be able to get by with <filename>devtmpfs</filename>
  6039. and <filename>mdev</filename> instead of
  6040. <filename>udev</filename>.
  6041. </para>
  6042. <para>
  6043. Use your <filename>local.conf</filename> file to make changes.
  6044. For example, to eliminate <filename>udev</filename> and
  6045. <filename>glib</filename>, set the following in the
  6046. local configuration file:
  6047. <literallayout class='monospaced'>
  6048. VIRTUAL-RUNTIME_dev_manager = ""
  6049. </literallayout>
  6050. </para>
  6051. <para>
  6052. Finally, you should consider exactly the type of root
  6053. filesystem you need to meet your needs while also reducing
  6054. its size.
  6055. For example, consider <filename>cramfs</filename>,
  6056. <filename>squashfs</filename>, <filename>ubifs</filename>,
  6057. <filename>ext2</filename>, or an <filename>initramfs</filename>
  6058. using <filename>initramfs</filename>.
  6059. Be aware that <filename>ext3</filename> requires a 1 Mbyte
  6060. journal.
  6061. If you are okay with running read-only, you do not need this
  6062. journal.
  6063. </para>
  6064. <note>
  6065. After each round of elimination, you need to rebuild your
  6066. system and then use the tools to see the effects of your
  6067. reductions.
  6068. </note>
  6069. </section>
  6070. <section id='trim-the-kernel'>
  6071. <title>Trim the Kernel</title>
  6072. <para>
  6073. The kernel is built by including policies for hardware-independent
  6074. aspects.
  6075. What subsystems do you enable?
  6076. For what architecture are you building?
  6077. Which drivers do you build by default?
  6078. <note>You can modify the kernel source if you want to help
  6079. with boot time.
  6080. </note>
  6081. </para>
  6082. <para>
  6083. Run the <filename>ksize.py</filename> script from the top-level
  6084. Linux build directory to get an idea of what is making up
  6085. the kernel:
  6086. <literallayout class='monospaced'>
  6087. $ cd <replaceable>top-level-linux-build-directory</replaceable>
  6088. $ ksize.py > ksize.log
  6089. $ cat ksize.log
  6090. </literallayout>
  6091. When you examine the log, you will see how much space is
  6092. taken up with the built-in <filename>.o</filename> files for
  6093. drivers, networking, core kernel files, filesystem, sound,
  6094. and so forth.
  6095. The sizes reported by the tool are uncompressed, and thus
  6096. will be smaller by a relatively constant factor in a compressed
  6097. kernel image.
  6098. Look to reduce the areas that are large and taking up around
  6099. the "90% rule."
  6100. </para>
  6101. <para>
  6102. To examine, or drill down, into any particular area, use the
  6103. <filename>-d</filename> option with the script:
  6104. <literallayout class='monospaced'>
  6105. $ ksize.py -d > ksize.log
  6106. </literallayout>
  6107. Using this option breaks out the individual file information
  6108. for each area of the kernel (e.g. drivers, networking, and
  6109. so forth).
  6110. </para>
  6111. <para>
  6112. Use your log file to see what you can eliminate from the kernel
  6113. based on features you can let go.
  6114. For example, if you are not going to need sound, you do not
  6115. need any drivers that support sound.
  6116. </para>
  6117. <para>
  6118. After figuring out what to eliminate, you need to reconfigure
  6119. the kernel to reflect those changes during the next build.
  6120. You could run <filename>menuconfig</filename> and make all your
  6121. changes at once.
  6122. However, that makes it difficult to see the effects of your
  6123. individual eliminations and also makes it difficult to replicate
  6124. the changes for perhaps another target device.
  6125. A better method is to start with no configurations using
  6126. <filename>allnoconfig</filename>, create configuration
  6127. fragments for individual changes, and then manage the
  6128. fragments into a single configuration file using
  6129. <filename>merge_config.sh</filename>.
  6130. The tool makes it easy for you to iterate using the
  6131. configuration change and build cycle.
  6132. </para>
  6133. <para>
  6134. Each time you make configuration changes, you need to rebuild
  6135. the kernel and check to see what impact your changes had on
  6136. the overall size.
  6137. </para>
  6138. </section>
  6139. <section id='remove-package-management-requirements'>
  6140. <title>Remove Package Management Requirements</title>
  6141. <para>
  6142. Packaging requirements add size to the image.
  6143. One way to reduce the size of the image is to remove all the
  6144. packaging requirements from the image.
  6145. This reduction includes both removing the package manager
  6146. and its unique dependencies as well as removing the package
  6147. management data itself.
  6148. </para>
  6149. <para>
  6150. To eliminate all the packaging requirements for an image,
  6151. be sure that "package-management" is not part of your
  6152. <ulink url='&YOCTO_DOCS_REF_URL;#var-IMAGE_FEATURES'><filename>IMAGE_FEATURES</filename></ulink>
  6153. statement for the image.
  6154. When you remove this feature, you are removing the package
  6155. manager as well as its dependencies from the root filesystem.
  6156. </para>
  6157. </section>
  6158. <section id='look-for-other-ways-to-minimize-size'>
  6159. <title>Look for Other Ways to Minimize Size</title>
  6160. <para>
  6161. Depending on your particular circumstances, other areas that you
  6162. can trim likely exist.
  6163. The key to finding these areas is through tools and methods
  6164. described here combined with experimentation and iteration.
  6165. Here are a couple of areas to experiment with:
  6166. <itemizedlist>
  6167. <listitem><para><filename>glibc</filename>:
  6168. In general, follow this process:
  6169. <orderedlist>
  6170. <listitem><para>Remove <filename>glibc</filename>
  6171. features from
  6172. <ulink url='&YOCTO_DOCS_REF_URL;#var-DISTRO_FEATURES'><filename>DISTRO_FEATURES</filename></ulink>
  6173. that you think you do not need.</para></listitem>
  6174. <listitem><para>Build your distribution.
  6175. </para></listitem>
  6176. <listitem><para>If the build fails due to missing
  6177. symbols in a package, determine if you can
  6178. reconfigure the package to not need those
  6179. features.
  6180. For example, change the configuration to not
  6181. support wide character support as is done for
  6182. <filename>ncurses</filename>.
  6183. Or, if support for those characters is needed,
  6184. determine what <filename>glibc</filename>
  6185. features provide the support and restore the
  6186. configuration.
  6187. </para></listitem>
  6188. <listitem><para>Rebuild and repeat the process.
  6189. </para></listitem>
  6190. </orderedlist></para></listitem>
  6191. <listitem><para><filename>busybox</filename>:
  6192. For BusyBox, use a process similar as described for
  6193. <filename>glibc</filename>.
  6194. A difference is you will need to boot the resulting
  6195. system to see if you are able to do everything you
  6196. expect from the running system.
  6197. You need to be sure to integrate configuration fragments
  6198. into Busybox because BusyBox handles its own core
  6199. features and then allows you to add configuration
  6200. fragments on top.
  6201. </para></listitem>
  6202. </itemizedlist>
  6203. </para>
  6204. </section>
  6205. <section id='iterate-on-the-process'>
  6206. <title>Iterate on the Process</title>
  6207. <para>
  6208. If you have not reached your goals on system size, you need
  6209. to iterate on the process.
  6210. The process is the same.
  6211. Use the tools and see just what is taking up 90% of the root
  6212. filesystem and the kernel.
  6213. Decide what you can eliminate without limiting your device
  6214. beyond what you need.
  6215. </para>
  6216. <para>
  6217. Depending on your system, a good place to look might be
  6218. Busybox, which provides a stripped down
  6219. version of Unix tools in a single, executable file.
  6220. You might be able to drop virtual terminal services or perhaps
  6221. ipv6.
  6222. </para>
  6223. </section>
  6224. </section>
  6225. <section id='building-images-for-more-than-one-machine'>
  6226. <title>Building Images for More than One Machine</title>
  6227. <para>
  6228. A common scenario developers face is creating images for several
  6229. different machines that use the same software environment.
  6230. In this situation, it is tempting to set the
  6231. tunings and optimization flags for each build specifically for
  6232. the targeted hardware (i.e. "maxing out" the tunings).
  6233. Doing so can considerably add to build times and package feed
  6234. maintenance collectively for the machines.
  6235. For example, selecting tunes that are extremely specific to a
  6236. CPU core used in a system might enable some micro optimizations
  6237. in GCC for that particular system but would otherwise not gain
  6238. you much of a performance difference across the other systems
  6239. as compared to using a more general tuning across all the builds
  6240. (e.g. setting
  6241. <ulink url='var-DEFAULTTUNE'><filename>DEFAULTTUNE</filename></ulink>
  6242. specifically for each machine's build).
  6243. Rather than "max out" each build's tunings, you can take steps that
  6244. cause the OpenEmbedded build system to reuse software across the
  6245. various machines where it makes sense.
  6246. </para>
  6247. <para>
  6248. If build speed and package feed maintenance are considerations,
  6249. you should consider the points in this section that can help you
  6250. optimize your tunings to best consider build times and package
  6251. feed maintenance.
  6252. <itemizedlist>
  6253. <listitem><para><emphasis>Share the Build Directory:</emphasis>
  6254. If at all possible, share the
  6255. <ulink url='&YOCTO_DOCS_REF_URL;#var-TMPDIR'><filename>TMPDIR</filename></ulink>
  6256. across builds.
  6257. The Yocto Project supports switching between different
  6258. <ulink url='&YOCTO_DOCS_REF_URL;#var-MACHINE'><filename>MACHINE</filename></ulink>
  6259. values in the same <filename>TMPDIR</filename>.
  6260. This practice is well supported and regularly used by
  6261. developers when building for multiple machines.
  6262. When you use the same <filename>TMPDIR</filename> for
  6263. multiple machine builds, the OpenEmbedded build system can
  6264. reuse the existing native and often cross-recipes for
  6265. multiple machines.
  6266. Thus, build time decreases.
  6267. <note>
  6268. If
  6269. <ulink url='&YOCTO_DOCS_REF_URL;#var-DISTRO'><filename>DISTRO</filename></ulink>
  6270. settings change or fundamental configuration settings
  6271. such as the filesystem layout, you need to work with
  6272. a clean <filename>TMPDIR</filename>.
  6273. Sharing <filename>TMPDIR</filename> under these
  6274. circumstances might work but since it is not
  6275. guaranteed, you should use a clean
  6276. <filename>TMPDIR</filename>.
  6277. </note>
  6278. </para></listitem>
  6279. <listitem><para><emphasis>Enable the Appropriate Package Architecture:</emphasis>
  6280. By default, the OpenEmbedded build system enables three
  6281. levels of package architectures: "all", "tune" or "package",
  6282. and "machine".
  6283. Any given recipe usually selects one of these package
  6284. architectures (types) for its output.
  6285. Depending for what a given recipe creates packages, making
  6286. sure you enable the appropriate package architecture can
  6287. directly impact the build time.</para>
  6288. <para>A recipe that just generates scripts can enable
  6289. "all" architecture because there are no binaries to build.
  6290. To specifically enable "all" architecture, be sure your
  6291. recipe inherits the
  6292. <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-allarch'><filename>allarch</filename></ulink>
  6293. class.
  6294. This class is useful for "all" architectures because it
  6295. configures many variables so packages can be used across
  6296. multiple architectures.</para>
  6297. <para>If your recipe needs to generate packages that are
  6298. machine-specific or when one of the build or runtime
  6299. dependencies is already machine-architecture dependent,
  6300. which makes your recipe also machine-architecture dependent,
  6301. make sure your recipe enables the "machine" package
  6302. architecture through the
  6303. <ulink url='&YOCTO_DOCS_REF_URL;#var-MACHINE_ARCH'><filename>MACHINE_ARCH</filename></ulink>
  6304. variable:
  6305. <literallayout class='monospaced'>
  6306. PACKAGE_ARCH = "${MACHINE_ARCH}"
  6307. </literallayout>
  6308. When you do not specifically enable a package
  6309. architecture through the
  6310. <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_ARCH'><filename>PACKAGE_ARCH</filename></ulink>,
  6311. The OpenEmbedded build system defaults to the
  6312. <ulink url='&YOCTO_DOCS_REF_URL;#var-TUNE_PKGARCH'><filename>TUNE_PKGARCH</filename></ulink>
  6313. setting:
  6314. <literallayout class='monospaced'>
  6315. PACKAGE_ARCH = "${TUNE_PKGARCH}"
  6316. </literallayout>
  6317. </para></listitem>
  6318. <listitem><para><emphasis>Choose a Generic Tuning File if Possible:</emphasis>
  6319. Some tunes are more generic and can run on multiple targets
  6320. (e.g. an <filename>armv5</filename> set of packages could
  6321. run on <filename>armv6</filename> and
  6322. <filename>armv7</filename> processors in most cases).
  6323. Similarly, <filename>i486</filename> binaries could work
  6324. on <filename>i586</filename> and higher processors.
  6325. You should realize, however, that advances on newer
  6326. processor versions would not be used.</para>
  6327. <para>If you select the same tune for several different
  6328. machines, the OpenEmbedded build system reuses software
  6329. previously built, thus speeding up the overall build time.
  6330. Realize that even though a new sysroot for each machine is
  6331. generated, the software is not recompiled and only one
  6332. package feed exists.
  6333. </para></listitem>
  6334. <listitem><para><emphasis>Manage Granular Level Packaging:</emphasis>
  6335. Sometimes cases exist where injecting another level
  6336. of package architecture beyond the three higher levels
  6337. noted earlier can be useful.
  6338. For example, consider the <filename>emgd</filename>
  6339. graphics stack in the
  6340. <filename>meta-intel</filename> layer.
  6341. In this layer, a subset of software exists that is
  6342. compiled against something different from the rest of the
  6343. generic packages.
  6344. You can examine the key code in the
  6345. <ulink url='http://git.yoctoproject.org/cgit/cgit.cgi'>Source Repositories</ulink>
  6346. "daisy" branch in
  6347. <filename>classes/emgd-gl.bbclass</filename>.
  6348. For a specific set of packages, the code redefines
  6349. <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_ARCH'><filename>PACKAGE_ARCH</filename></ulink>.
  6350. <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_EXTRA_ARCHS'><filename>PACKAGE_EXTRA_ARCHS</filename></ulink>
  6351. is then appended with this extra tune name in
  6352. <filename>meta-intel-emgd.inc</filename>.
  6353. The result is that when searching for packages, the
  6354. build system uses a four-level search and the packages
  6355. in this new level are preferred as compared to the standard
  6356. tune.
  6357. The overall result is that the build system reuses most
  6358. software from the common tune except for specific cases
  6359. as needed.
  6360. </para></listitem>
  6361. <listitem><para><emphasis>Use Tools to Debug Issues:</emphasis>
  6362. Sometimes you can run into situations where software is
  6363. being rebuilt when you think it should not be.
  6364. For example, the OpenEmbedded build system might not be
  6365. using shared state between machines when you think it
  6366. should be.
  6367. These types of situations are usually due to references
  6368. to machine-specific variables such as
  6369. <ulink url='&YOCTO_DOCS_REF_URL;#var-MACHINE'><filename>MACHINE</filename></ulink>,
  6370. <ulink url='&YOCTO_DOCS_REF_URL;#var-SERIAL_CONSOLE'><filename>SERIAL_CONSOLE</filename></ulink>,
  6371. <ulink url='&YOCTO_DOCS_REF_URL;#var-XSERVER'><filename>XSERVER</filename></ulink>,
  6372. <ulink url='&YOCTO_DOCS_REF_URL;#var-MACHINE_FEATURES'><filename>MACHINE_FEATURES</filename></ulink>,
  6373. and so forth in code that is supposed to only be
  6374. tune-specific or when the recipe depends
  6375. (<ulink url='&YOCTO_DOCS_REF_URL;#var-DEPENDS'><filename>DEPENDS</filename></ulink>,
  6376. <ulink url='&YOCTO_DOCS_REF_URL;#var-RDEPENDS'><filename>RDEPENDS</filename></ulink>,
  6377. <ulink url='&YOCTO_DOCS_REF_URL;#var-RRECOMMENDS'><filename>RRECOMMENDS</filename></ulink>,
  6378. <ulink url='&YOCTO_DOCS_REF_URL;#var-RSUGGESTS'><filename>RSUGGESTS</filename></ulink>,
  6379. and so forth) on some other recipe that already has
  6380. <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_ARCH'><filename>PACKAGE_ARCH</filename></ulink>
  6381. defined as "${MACHINE_ARCH}".
  6382. <note>
  6383. Patches to fix any issues identified are most welcome
  6384. as these issues occasionally do occur.
  6385. </note></para>
  6386. <para>For such cases, you can use some tools to help you
  6387. sort out the situation:
  6388. <itemizedlist>
  6389. <listitem><para><emphasis><filename>sstate-diff-machines.sh</filename>:</emphasis>
  6390. You can find this tool in the
  6391. <filename>scripts</filename> directory of the
  6392. Source Repositories.
  6393. See the comments in the script for information on
  6394. how to use the tool.
  6395. </para></listitem>
  6396. <listitem><para><emphasis>BitBake's "-S printdiff" Option:</emphasis>
  6397. Using this option causes BitBake to try to
  6398. establish the closest signature match it can
  6399. (e.g. in the shared state cache) and then run
  6400. <filename>bitbake-diffsigs</filename> over the
  6401. matches to determine the stamps and delta where
  6402. these two stamp trees diverge.
  6403. </para></listitem>
  6404. </itemizedlist>
  6405. </para></listitem>
  6406. </itemizedlist>
  6407. </para>
  6408. </section>
  6409. <section id='working-with-packages'>
  6410. <title>Working with Packages</title>
  6411. <para>
  6412. This section describes a few tasks that involve packages:
  6413. <itemizedlist>
  6414. <listitem><para>
  6415. <link linkend='excluding-packages-from-an-image'>Excluding packages from an image</link>
  6416. </para></listitem>
  6417. <listitem><para>
  6418. <link linkend='incrementing-a-package-revision-number'>Incrementing a package revision number</link>
  6419. </para></listitem>
  6420. <listitem><para>
  6421. <link linkend='handling-optional-module-packaging'>Handling optional module packaging</link>
  6422. </para></listitem>
  6423. <listitem><para>
  6424. <link linkend='using-runtime-package-management'>Using Runtime Package Management</link>
  6425. </para></listitem>
  6426. <listitem><para>
  6427. <link linkend='testing-packages-with-ptest'>Setting up and running package test (ptest)</link>
  6428. </para></listitem>
  6429. </itemizedlist>
  6430. </para>
  6431. <section id='excluding-packages-from-an-image'>
  6432. <title>Excluding Packages from an Image</title>
  6433. <para>
  6434. You might find it necessary to prevent specific packages
  6435. from being installed into an image.
  6436. If so, you can use several variables to direct the build
  6437. system to essentially ignore installing recommended packages
  6438. or to not install a package at all.
  6439. </para>
  6440. <para>
  6441. The following list introduces variables you can use to
  6442. prevent packages from being installed into your image.
  6443. Each of these variables only works with IPK and RPM
  6444. package types.
  6445. Support for Debian packages does not exist.
  6446. Also, you can use these variables from your
  6447. <filename>local.conf</filename> file or attach them to a
  6448. specific image recipe by using a recipe name override.
  6449. For more detail on the variables, see the descriptions in the
  6450. Yocto Project Reference Manual's glossary chapter.
  6451. <itemizedlist>
  6452. <listitem><para><ulink url='&YOCTO_DOCS_REF_URL;#var-BAD_RECOMMENDATIONS'><filename>BAD_RECOMMENDATIONS</filename></ulink>:
  6453. Use this variable to specify "recommended-only"
  6454. packages that you do not want installed.
  6455. </para></listitem>
  6456. <listitem><para><ulink url='&YOCTO_DOCS_REF_URL;#var-NO_RECOMMENDATIONS'><filename>NO_RECOMMENDATIONS</filename></ulink>:
  6457. Use this variable to prevent all "recommended-only"
  6458. packages from being installed.
  6459. </para></listitem>
  6460. <listitem><para><ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_EXCLUDE'><filename>PACKAGE_EXCLUDE</filename></ulink>:
  6461. Use this variable to prevent specific packages from
  6462. being installed regardless of whether they are
  6463. "recommended-only" or not.
  6464. You need to realize that the build process could
  6465. fail with an error when you
  6466. prevent the installation of a package whose presence
  6467. is required by an installed package.
  6468. </para></listitem>
  6469. </itemizedlist>
  6470. </para>
  6471. </section>
  6472. <section id='incrementing-a-package-revision-number'>
  6473. <title>Incrementing a Package Revision Number</title>
  6474. <para>
  6475. If a committed change results in changing the package output,
  6476. then the value of the
  6477. <ulink url='&YOCTO_DOCS_REF_URL;#var-PR'><filename>PR</filename></ulink>
  6478. variable needs to be increased (or "bumped").
  6479. Increasing <filename>PR</filename> occurs one of two ways:
  6480. <itemizedlist>
  6481. <listitem><para>Automatically using a Package Revision
  6482. Service (PR Service).</para></listitem>
  6483. <listitem><para>Manually incrementing the
  6484. <filename>PR</filename> variable.</para></listitem>
  6485. </itemizedlist>
  6486. </para>
  6487. <para>
  6488. Given that one of the challenges any build system and its
  6489. users face is how to maintain a package feed that is compatible
  6490. with existing package manager applications such as
  6491. RPM, APT, and OPKG, using an automated system is much
  6492. preferred over a manual system.
  6493. In either system, the main requirement is that version
  6494. numbering increases in a linear fashion and that a number of
  6495. version components exist that support that linear progression.
  6496. </para>
  6497. <para>
  6498. The following two sections provide information on the PR Service
  6499. and on manual <filename>PR</filename> bumping.
  6500. </para>
  6501. <section id='working-with-a-pr-service'>
  6502. <title>Working With a PR Service</title>
  6503. <para>
  6504. As mentioned, attempting to maintain revision numbers in the
  6505. <ulink url='&YOCTO_DOCS_DEV_URL;#metadata'>Metadata</ulink>
  6506. is error prone, inaccurate, and causes problems for people
  6507. submitting recipes.
  6508. Conversely, the PR Service automatically generates
  6509. increasing numbers, particularly the revision field,
  6510. which removes the human element.
  6511. <note>
  6512. For additional information on using a PR Service, you
  6513. can see the
  6514. <ulink url='&YOCTO_WIKI_URL;/wiki/PR_Service'>PR Service</ulink>
  6515. wiki page.
  6516. </note>
  6517. </para>
  6518. <para>
  6519. The Yocto Project uses variables in order of
  6520. decreasing priority to facilitate revision numbering (i.e.
  6521. <ulink url='&YOCTO_DOCS_REF_URL;#var-PE'><filename>PE</filename></ulink>,
  6522. <ulink url='&YOCTO_DOCS_REF_URL;#var-PV'><filename>PV</filename></ulink>, and
  6523. <ulink url='&YOCTO_DOCS_REF_URL;#var-PR'><filename>PR</filename></ulink>
  6524. for epoch, version, and revision, respectively).
  6525. The values are highly dependent on the policies and
  6526. procedures of a given distribution and package feed.
  6527. </para>
  6528. <para>
  6529. Because the OpenEmbedded build system uses
  6530. "<ulink url='&YOCTO_DOCS_REF_URL;#checksums'>signatures</ulink>",
  6531. which are unique to a given build, the build system
  6532. knows when to rebuild packages.
  6533. All the inputs into a given task are represented by a
  6534. signature, which can trigger a rebuild when different.
  6535. Thus, the build system itself does not rely on the
  6536. <filename>PR</filename> numbers to trigger a rebuild.
  6537. The signatures, however, can be used to generate
  6538. <filename>PR</filename> values.
  6539. </para>
  6540. <para>
  6541. The PR Service works with both
  6542. <filename>OEBasic</filename> and
  6543. <filename>OEBasicHash</filename> generators.
  6544. The value of <filename>PR</filename> bumps when the
  6545. checksum changes and the different generator mechanisms
  6546. change signatures under different circumstances.
  6547. </para>
  6548. <para>
  6549. As implemented, the build system includes values from
  6550. the PR Service into the <filename>PR</filename> field as
  6551. an addition using the form "<filename>.x</filename>" so
  6552. <filename>r0</filename> becomes <filename>r0.1</filename>,
  6553. <filename>r0.2</filename> and so forth.
  6554. This scheme allows existing <filename>PR</filename> values
  6555. to be used for whatever reasons, which include manual
  6556. <filename>PR</filename> bumps, should it be necessary.
  6557. </para>
  6558. <para>
  6559. By default, the PR Service is not enabled or running.
  6560. Thus, the packages generated are just "self consistent".
  6561. The build system adds and removes packages and
  6562. there are no guarantees about upgrade paths but images
  6563. will be consistent and correct with the latest changes.
  6564. </para>
  6565. <para>
  6566. The simplest form for a PR Service is for it to exist
  6567. for a single host development system that builds the
  6568. package feed (building system).
  6569. For this scenario, you can enable a local PR Service by
  6570. setting
  6571. <ulink url='&YOCTO_DOCS_REF_URL;#var-PRSERV_HOST'><filename>PRSERV_HOST</filename></ulink>
  6572. in your <filename>local.conf</filename> file in the
  6573. <ulink url='&YOCTO_DOCS_DEV_URL;#build-directory'>Build Directory</ulink>:
  6574. <literallayout class='monospaced'>
  6575. PRSERV_HOST = "localhost:0"
  6576. </literallayout>
  6577. Once the service is started, packages will automatically
  6578. get increasing <filename>PR</filename> values and
  6579. BitBake will take care of starting and stopping the server.
  6580. </para>
  6581. <para>
  6582. If you have a more complex setup where multiple host
  6583. development systems work against a common, shared package
  6584. feed, you have a single PR Service running and it is
  6585. connected to each building system.
  6586. For this scenario, you need to start the PR Service using
  6587. the <filename>bitbake-prserv</filename> command:
  6588. <literallayout class='monospaced'>
  6589. bitbake-prserv --host <replaceable>ip</replaceable> --port <replaceable>port</replaceable> --start
  6590. </literallayout>
  6591. In addition to hand-starting the service, you need to
  6592. update the <filename>local.conf</filename> file of each
  6593. building system as described earlier so each system
  6594. points to the server and port.
  6595. </para>
  6596. <para>
  6597. It is also recommended you use build history, which adds
  6598. some sanity checks to package versions, in conjunction with
  6599. the server that is running the PR Service.
  6600. To enable build history, add the following to each building
  6601. system's <filename>local.conf</filename> file:
  6602. <literallayout class='monospaced'>
  6603. # It is recommended to activate "buildhistory" for testing the PR service
  6604. INHERIT += "buildhistory"
  6605. BUILDHISTORY_COMMIT = "1"
  6606. </literallayout>
  6607. For information on build history, see the
  6608. "<ulink url='&YOCTO_DOCS_REF_URL;#maintaining-build-output-quality'>Maintaining Build Output Quality</ulink>"
  6609. section in the Yocto Project Reference Manual.
  6610. </para>
  6611. <note>
  6612. <para>The OpenEmbedded build system does not maintain
  6613. <filename>PR</filename> information as part of the
  6614. shared state (sstate) packages.
  6615. If you maintain an sstate feed, its expected that either
  6616. all your building systems that contribute to the sstate
  6617. feed use a shared PR Service, or you do not run a PR
  6618. Service on any of your building systems.
  6619. Having some systems use a PR Service while others do
  6620. not leads to obvious problems.</para>
  6621. <para>For more information on shared state, see the
  6622. "<ulink url='&YOCTO_DOCS_REF_URL;#shared-state-cache'>Shared State Cache</ulink>"
  6623. section in the Yocto Project Reference Manual.</para>
  6624. </note>
  6625. </section>
  6626. <section id='manually-bumping-pr'>
  6627. <title>Manually Bumping PR</title>
  6628. <para>
  6629. The alternative to setting up a PR Service is to manually
  6630. bump the
  6631. <ulink url='&YOCTO_DOCS_REF_URL;#var-PR'><filename>PR</filename></ulink>
  6632. variable.
  6633. </para>
  6634. <para>
  6635. If a committed change results in changing the package output,
  6636. then the value of the PR variable needs to be increased
  6637. (or "bumped") as part of that commit.
  6638. For new recipes you should add the <filename>PR</filename>
  6639. variable and set its initial value equal to "r0", which is the default.
  6640. Even though the default value is "r0", the practice of adding it to a new recipe makes
  6641. it harder to forget to bump the variable when you make changes
  6642. to the recipe in future.
  6643. </para>
  6644. <para>
  6645. If you are sharing a common <filename>.inc</filename> file with multiple recipes,
  6646. you can also use the
  6647. <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-INC_PR'>INC_PR</ulink></filename>
  6648. variable to ensure that
  6649. the recipes sharing the <filename>.inc</filename> file are rebuilt when the
  6650. <filename>.inc</filename> file itself is changed.
  6651. The <filename>.inc</filename> file must set <filename>INC_PR</filename>
  6652. (initially to "r0"), and all recipes referring to it should set <filename>PR</filename>
  6653. to "$(INC_PR).0" initially, incrementing the last number when the recipe is changed.
  6654. If the <filename>.inc</filename> file is changed then its
  6655. <filename>INC_PR</filename> should be incremented.
  6656. </para>
  6657. <para>
  6658. When upgrading the version of a package, assuming the
  6659. <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-PV'>PV</ulink></filename>
  6660. changes, the <filename>PR</filename> variable should be
  6661. reset to "r0" (or "$(INC_PR).0" if you are using
  6662. <filename>INC_PR</filename>).
  6663. </para>
  6664. <para>
  6665. Usually, version increases occur only to packages.
  6666. However, if for some reason <filename>PV</filename> changes but does not
  6667. increase, you can increase the
  6668. <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-PE'>PE</ulink></filename>
  6669. variable (Package Epoch).
  6670. The <filename>PE</filename> variable defaults to "0".
  6671. </para>
  6672. <para>
  6673. Version numbering strives to follow the
  6674. <ulink url='http://www.debian.org/doc/debian-policy/ch-controlfields.html'>
  6675. Debian Version Field Policy Guidelines</ulink>.
  6676. These guidelines define how versions are compared and what "increasing" a version means.
  6677. </para>
  6678. </section>
  6679. </section>
  6680. <section id='handling-optional-module-packaging'>
  6681. <title>Handling Optional Module Packaging</title>
  6682. <para>
  6683. Many pieces of software split functionality into optional
  6684. modules (or plug-ins) and the plug-ins that are built
  6685. might depend on configuration options.
  6686. To avoid having to duplicate the logic that determines what
  6687. modules are available in your recipe or to avoid having
  6688. to package each module by hand, the OpenEmbedded build system
  6689. provides functionality to handle module packaging dynamically.
  6690. </para>
  6691. <para>
  6692. To handle optional module packaging, you need to do two things:
  6693. <itemizedlist>
  6694. <listitem><para>Ensure the module packaging is actually
  6695. done.</para></listitem>
  6696. <listitem><para>Ensure that any dependencies on optional
  6697. modules from other recipes are satisfied by your recipe.
  6698. </para></listitem>
  6699. </itemizedlist>
  6700. </para>
  6701. <section id='making-sure-the-packaging-is-done'>
  6702. <title>Making Sure the Packaging is Done</title>
  6703. <para>
  6704. To ensure the module packaging actually gets done, you use
  6705. the <filename>do_split_packages</filename> function within
  6706. the <filename>populate_packages</filename> Python function
  6707. in your recipe.
  6708. The <filename>do_split_packages</filename> function
  6709. searches for a pattern of files or directories under a
  6710. specified path and creates a package for each one it finds
  6711. by appending to the
  6712. <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGES'><filename>PACKAGES</filename></ulink>
  6713. variable and setting the appropriate values for
  6714. <filename>FILES_packagename</filename>,
  6715. <filename>RDEPENDS_packagename</filename>,
  6716. <filename>DESCRIPTION_packagename</filename>, and so forth.
  6717. Here is an example from the <filename>lighttpd</filename>
  6718. recipe:
  6719. <literallayout class='monospaced'>
  6720. python populate_packages_prepend () {
  6721. lighttpd_libdir = d.expand('${libdir}')
  6722. do_split_packages(d, lighttpd_libdir, '^mod_(.*)\.so$',
  6723. 'lighttpd-module-%s', 'Lighttpd module for %s',
  6724. extra_depends='')
  6725. }
  6726. </literallayout>
  6727. The previous example specifies a number of things in the
  6728. call to <filename>do_split_packages</filename>.
  6729. <itemizedlist>
  6730. <listitem><para>A directory within the files installed
  6731. by your recipe through <filename>do_install</filename>
  6732. in which to search.</para></listitem>
  6733. <listitem><para>A regular expression used to match module
  6734. files in that directory.
  6735. In the example, note the parentheses () that mark
  6736. the part of the expression from which the module
  6737. name should be derived.</para></listitem>
  6738. <listitem><para>A pattern to use for the package names.
  6739. </para></listitem>
  6740. <listitem><para>A description for each package.
  6741. </para></listitem>
  6742. <listitem><para>An empty string for
  6743. <filename>extra_depends</filename>, which disables
  6744. the default dependency on the main
  6745. <filename>lighttpd</filename> package.
  6746. Thus, if a file in <filename>${libdir}</filename>
  6747. called <filename>mod_alias.so</filename> is found,
  6748. a package called <filename>lighttpd-module-alias</filename>
  6749. is created for it and the
  6750. <ulink url='&YOCTO_DOCS_REF_URL;#var-DESCRIPTION'><filename>DESCRIPTION</filename></ulink>
  6751. is set to "Lighttpd module for alias".</para></listitem>
  6752. </itemizedlist>
  6753. </para>
  6754. <para>
  6755. Often, packaging modules is as simple as the previous
  6756. example.
  6757. However, more advanced options exist that you can use
  6758. within <filename>do_split_packages</filename> to modify its
  6759. behavior.
  6760. And, if you need to, you can add more logic by specifying
  6761. a hook function that is called for each package.
  6762. It is also perfectly acceptable to call
  6763. <filename>do_split_packages</filename> multiple times if
  6764. you have more than one set of modules to package.
  6765. </para>
  6766. <para>
  6767. For more examples that show how to use
  6768. <filename>do_split_packages</filename>, see the
  6769. <filename>connman.inc</filename> file in the
  6770. <filename>meta/recipes-connectivity/connman/</filename>
  6771. directory of the <filename>poky</filename>
  6772. <link linkend='yocto-project-repositories'>source repository</link>.
  6773. You can also find examples in
  6774. <filename>meta/classes/kernel.bbclass</filename>.
  6775. </para>
  6776. <para>
  6777. Following is a reference that shows
  6778. <filename>do_split_packages</filename> mandatory and
  6779. optional arguments:
  6780. <literallayout class='monospaced'>
  6781. Mandatory arguments
  6782. root
  6783. The path in which to search
  6784. file_regex
  6785. Regular expression to match searched files.
  6786. Use parentheses () to mark the part of this
  6787. expression that should be used to derive the
  6788. module name (to be substituted where %s is
  6789. used in other function arguments as noted below)
  6790. output_pattern
  6791. Pattern to use for the package names. Must
  6792. include %s.
  6793. description
  6794. Description to set for each package. Must
  6795. include %s.
  6796. Optional arguments
  6797. postinst
  6798. Postinstall script to use for all packages
  6799. (as a string)
  6800. recursive
  6801. True to perform a recursive search - default
  6802. False
  6803. hook
  6804. A hook function to be called for every match.
  6805. The function will be called with the following
  6806. arguments (in the order listed):
  6807. f
  6808. Full path to the file/directory match
  6809. pkg
  6810. The package name
  6811. file_regex
  6812. As above
  6813. output_pattern
  6814. As above
  6815. modulename
  6816. The module name derived using file_regex
  6817. extra_depends
  6818. Extra runtime dependencies (RDEPENDS) to be
  6819. set for all packages. The default value of None
  6820. causes a dependency on the main package
  6821. (${PN}) - if you do not want this, pass empty
  6822. string '' for this parameter.
  6823. aux_files_pattern
  6824. Extra item(s) to be added to FILES for each
  6825. package. Can be a single string item or a list
  6826. of strings for multiple items. Must include %s.
  6827. postrm
  6828. postrm script to use for all packages (as a
  6829. string)
  6830. allow_dirs
  6831. True to allow directories to be matched -
  6832. default False
  6833. prepend
  6834. If True, prepend created packages to PACKAGES
  6835. instead of the default False which appends them
  6836. match_path
  6837. match file_regex on the whole relative path to
  6838. the root rather than just the file name
  6839. aux_files_pattern_verbatim
  6840. Extra item(s) to be added to FILES for each
  6841. package, using the actual derived module name
  6842. rather than converting it to something legal
  6843. for a package name. Can be a single string item
  6844. or a list of strings for multiple items. Must
  6845. include %s.
  6846. allow_links
  6847. True to allow symlinks to be matched - default
  6848. False
  6849. summary
  6850. Summary to set for each package. Must include %s;
  6851. defaults to description if not set.
  6852. </literallayout>
  6853. </para>
  6854. </section>
  6855. <section id='satisfying-dependencies'>
  6856. <title>Satisfying Dependencies</title>
  6857. <para>
  6858. The second part for handling optional module packaging
  6859. is to ensure that any dependencies on optional modules
  6860. from other recipes are satisfied by your recipe.
  6861. You can be sure these dependencies are satisfied by
  6862. using the
  6863. <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGES_DYNAMIC'><filename>PACKAGES_DYNAMIC</filename></ulink> variable.
  6864. Here is an example that continues with the
  6865. <filename>lighttpd</filename> recipe shown earlier:
  6866. <literallayout class='monospaced'>
  6867. PACKAGES_DYNAMIC = "lighttpd-module-.*"
  6868. </literallayout>
  6869. The name specified in the regular expression can of
  6870. course be anything.
  6871. In this example, it is <filename>lighttpd-module-</filename>
  6872. and is specified as the prefix to ensure that any
  6873. <ulink url='&YOCTO_DOCS_REF_URL;#var-RDEPENDS'><filename>RDEPENDS</filename></ulink>
  6874. and <ulink url='&YOCTO_DOCS_REF_URL;#var-RRECOMMENDS'><filename>RRECOMMENDS</filename></ulink>
  6875. on a package name starting with the prefix are satisfied
  6876. during build time.
  6877. If you are using <filename>do_split_packages</filename>
  6878. as described in the previous section, the value you put in
  6879. <filename>PACKAGES_DYNAMIC</filename> should correspond to
  6880. the name pattern specified in the call to
  6881. <filename>do_split_packages</filename>.
  6882. </para>
  6883. </section>
  6884. </section>
  6885. <section id='using-runtime-package-management'>
  6886. <title>Using Runtime Package Management</title>
  6887. <para>
  6888. During a build, BitBake always transforms a recipe into one or
  6889. more packages.
  6890. For example, BitBake takes the <filename>bash</filename> recipe
  6891. and currently produces the <filename>bash-dbg</filename>,
  6892. <filename>bash-staticdev</filename>,
  6893. <filename>bash-dev</filename>, <filename>bash-doc</filename>,
  6894. <filename>bash-locale</filename>, and
  6895. <filename>bash</filename> packages.
  6896. Not all generated packages are included in an image.
  6897. </para>
  6898. <para>
  6899. In several situations, you might need to update, add, remove,
  6900. or query the packages on a target device at runtime
  6901. (i.e. without having to generate a new image).
  6902. Examples of such situations include:
  6903. <itemizedlist>
  6904. <listitem><para>
  6905. You want to provide in-the-field updates to deployed
  6906. devices (e.g. security updates).
  6907. </para></listitem>
  6908. <listitem><para>
  6909. You want to have a fast turn-around development cycle
  6910. for one or more applications that run on your device.
  6911. </para></listitem>
  6912. <listitem><para>
  6913. You want to temporarily install the "debug" packages
  6914. of various applications on your device so that
  6915. debugging can be greatly improved by allowing
  6916. access to symbols and source debugging.
  6917. </para></listitem>
  6918. <listitem><para>
  6919. You want to deploy a more minimal package selection of
  6920. your device but allow in-the-field updates to add a
  6921. larger selection for customization.
  6922. </para></listitem>
  6923. </itemizedlist>
  6924. </para>
  6925. <para>
  6926. In all these situations, you have something similar to a more
  6927. traditional Linux distribution in that in-field devices
  6928. are able to receive pre-compiled packages from a server for
  6929. installation or update.
  6930. Being able to install these packages on a running,
  6931. in-field device is what is termed "runtime package
  6932. management".
  6933. </para>
  6934. <para>
  6935. In order to use runtime package management, you
  6936. need a host/server machine that serves up the pre-compiled
  6937. packages plus the required metadata.
  6938. You also need package manipulation tools on the target.
  6939. The build machine is a likely candidate to act as the server.
  6940. However, that machine does not necessarily have to be the
  6941. package server.
  6942. The build machine could push its artifacts to another machine
  6943. that acts as the server (e.g. Internet-facing).
  6944. </para>
  6945. <para>
  6946. A simple build that targets just one device produces
  6947. more than one package database.
  6948. In other words, the packages produced by a build are separated
  6949. out into a couple of different package groupings based on
  6950. criteria such as the target's CPU architecture, the target
  6951. board, or the C library used on the target.
  6952. For example, a build targeting the <filename>qemuarm</filename>
  6953. device produces the following three package databases:
  6954. <filename>all</filename>, <filename>armv5te</filename>, and
  6955. <filename>qemuarm</filename>.
  6956. If you wanted your <filename>qemuarm</filename> device to be
  6957. aware of all the packages that were available to it,
  6958. you would need to point it to each of these databases
  6959. individually.
  6960. In a similar way, a traditional Linux distribution usually is
  6961. configured to be aware of a number of software repositories
  6962. from which it retrieves packages.
  6963. </para>
  6964. <para>
  6965. Using runtime package management is completely optional and
  6966. not required for a successful build or deployment in any
  6967. way.
  6968. But if you want to make use of runtime package management,
  6969. you need to do a couple things above and beyond the basics.
  6970. The remainder of this section describes what you need to do.
  6971. </para>
  6972. <section id='runtime-package-management-build'>
  6973. <title>Build Considerations</title>
  6974. <para>
  6975. This section describes build considerations of which you
  6976. need to be aware in order to provide support for runtime
  6977. package management.
  6978. </para>
  6979. <para>
  6980. When BitBake generates packages, it needs to know
  6981. what format or formats to use.
  6982. In your configuration, you use the
  6983. <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_CLASSES'><filename>PACKAGE_CLASSES</filename></ulink>
  6984. variable to specify the format:
  6985. <orderedlist>
  6986. <listitem><para>
  6987. Open the <filename>local.conf</filename> file
  6988. inside your
  6989. <link linkend='build-directory'>Build Directory</link>
  6990. (e.g. <filename>~/poky/build/conf/local.conf</filename>).
  6991. </para></listitem>
  6992. <listitem><para>
  6993. Select the desired package format as follows:
  6994. <literallayout class='monospaced'>
  6995. PACKAGE_CLASSES ?= “package_<replaceable>packageformat</replaceable>”
  6996. </literallayout>
  6997. where <replaceable>packageformat</replaceable>
  6998. can be "ipk", "rpm", and "deb", which are the
  6999. supported package formats.
  7000. <note>
  7001. Because the Yocto Project supports three
  7002. different package formats, you can set the
  7003. variable with more than one argument.
  7004. However, the OpenEmbedded build system only
  7005. uses the first argument when creating an image
  7006. or Software Development Kit (SDK).
  7007. </note>
  7008. </para></listitem>
  7009. </orderedlist>
  7010. </para>
  7011. <para>
  7012. If you would like your image to start off with a basic
  7013. package database containing the packages in your current
  7014. build as well as to have the relevant tools available on the
  7015. target for runtime package management, you can include
  7016. "package-management" in the
  7017. <ulink url='&YOCTO_DOCS_REF_URL;#var-IMAGE_FEATURES'><filename>IMAGE_FEATURES</filename></ulink>
  7018. variable.
  7019. Including "package-management" in this
  7020. configuration variable ensures that when the image
  7021. is assembled for your target, the image includes
  7022. the currently-known package databases as well as
  7023. the target-specific tools required for runtime
  7024. package management to be performed on the target.
  7025. However, this is not strictly necessary.
  7026. You could start your image off without any databases
  7027. but only include the required on-target package
  7028. tool(s).
  7029. As an example, you could include "opkg" in your
  7030. <ulink url='&YOCTO_DOCS_REF_URL;#var-IMAGE_INSTALL'><filename>IMAGE_INSTALL</filename></ulink>
  7031. variable if you are using the IPK package format.
  7032. You can then initialize your target's package database(s)
  7033. later once your image is up and running.
  7034. </para>
  7035. <para>
  7036. Whenever you perform any sort of build step that can
  7037. potentially generate a package or modify an existing
  7038. package, it is always a good idea to re-generate the
  7039. package index with:
  7040. <literallayout class='monospaced'>
  7041. $ bitbake package-index
  7042. </literallayout>
  7043. Realize that it is not sufficient to simply do the
  7044. following:
  7045. <literallayout class='monospaced'>
  7046. $ bitbake <replaceable>some-package</replaceable> package-index
  7047. </literallayout>
  7048. The reason for this restriction is because BitBake does not
  7049. properly schedule the <filename>package-index</filename>
  7050. target fully after any other target has completed.
  7051. Thus, be sure to run the package update step separately.
  7052. </para>
  7053. <para>
  7054. You can use the
  7055. <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_FEED_ARCHS'><filename>PACKAGE_FEED_ARCHS</filename></ulink>,
  7056. <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_FEED_BASE_PATHS'><filename>PACKAGE_FEED_BASE_PATHS</filename></ulink>,
  7057. and
  7058. <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_FEED_URIS'><filename>PACKAGE_FEED_URIS</filename></ulink>
  7059. variables to pre-configure target images to use a package
  7060. feed.
  7061. If you do not define these variables, then manual steps
  7062. as described in the subsequent sections are necessary to
  7063. configure the target.
  7064. You should set these variables before building the image
  7065. in order to produce a correctly configured image.
  7066. </para>
  7067. <para>
  7068. When your build is complete, your packages reside in the
  7069. <filename>${TMPDIR}/deploy/<replaceable>packageformat</replaceable></filename>
  7070. directory.
  7071. For example, if
  7072. <filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-TMPDIR'><filename>TMPDIR</filename></ulink><filename>}</filename>
  7073. is <filename>tmp</filename> and your selected package type
  7074. is IPK, then your IPK packages are available in
  7075. <filename>tmp/deploy/ipk</filename>.
  7076. </para>
  7077. </section>
  7078. <section id='runtime-package-management-server'>
  7079. <title>Host or Server Machine Setup</title>
  7080. <para>
  7081. Although other protocols are possible, a server using HTTP
  7082. typically serves packages.
  7083. If you want to use HTTP, then set up and configure a
  7084. web server such as Apache 2, lighttpd, or
  7085. SimpleHTTPServer on the machine serving the packages.
  7086. </para>
  7087. <para>
  7088. To keep things simple, this section describes how to set
  7089. up a SimpleHTTPServer web server to share package feeds
  7090. from the developer's machine.
  7091. Although this server might not be the best for a production
  7092. environment, the setup is simple and straight forward.
  7093. Should you want to use a different server more suited for
  7094. production (e.g. Apache 2, Lighttpd, or Nginx), take the
  7095. appropriate steps to do so.
  7096. </para>
  7097. <para>
  7098. From within the build directory where you have built an
  7099. image based on your packaging choice (i.e. the
  7100. <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_CLASSES'><filename>PACKAGE_CLASSES</filename></ulink>
  7101. setting), simply start the server.
  7102. The following example assumes a build directory of
  7103. <filename>~/poky/build/tmp/deploy/rpm</filename> and a
  7104. <filename>PACKAGE_CLASSES</filename> setting of
  7105. "package_rpm":
  7106. <literallayout class='monospaced'>
  7107. $ cd ~/poky/build/tmp/deploy/rpm
  7108. $ python -m SimpleHTTPServer
  7109. </literallayout>
  7110. </para>
  7111. </section>
  7112. <section id='runtime-package-management-target'>
  7113. <title>Target Setup</title>
  7114. <para>
  7115. Setting up the target differs depending on the
  7116. package management system.
  7117. This section provides information for RPM, IPK, and DEB.
  7118. </para>
  7119. <section id='runtime-package-management-target-rpm'>
  7120. <title>Using RPM</title>
  7121. <para>
  7122. The <filename>smart</filename> application performs
  7123. runtime package management of RPM packages.
  7124. You must perform an initial setup for
  7125. <filename>smart</filename> on the target machine
  7126. if the
  7127. <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_FEED_ARCHS'><filename>PACKAGE_FEED_ARCHS</filename></ulink>,
  7128. <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_FEED_BASE_PATHS'><filename>PACKAGE_FEED_BASE_PATHS</filename></ulink>, and
  7129. <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_FEED_URIS'><filename>PACKAGE_FEED_URIS</filename></ulink>
  7130. variables have not been set or the target image was
  7131. built before the variables were set.
  7132. </para>
  7133. <para>
  7134. As an example, assume the target is able to use the
  7135. following package databases:
  7136. <filename>all</filename>, <filename>i586</filename>,
  7137. and <filename>qemux86</filename> from a server named
  7138. <filename>my.server</filename>.
  7139. You must inform <filename>smart</filename> of the
  7140. availability of these databases by issuing the
  7141. following commands on the target:
  7142. <literallayout class='monospaced'>
  7143. # smart channel --add i585 type=rpm-md baseurl=http://my.server/rpm/i586
  7144. # smart channel --add qemux86 type=rpm-md baseurl=http://my.server/rpm/qemux86
  7145. # smart channel --add all type=rpm-md baseurl=http://my.server/rpm/all
  7146. </literallayout>
  7147. From the target machine, fetch the repository:
  7148. <literallayout class='monospaced'>
  7149. # smart update
  7150. </literallayout>
  7151. After everything is set up, <filename>smart</filename>
  7152. is able to find, install, and upgrade packages from
  7153. the specified repository.
  7154. </para>
  7155. </section>
  7156. <section id='runtime-package-management-target-ipk'>
  7157. <title>Using IPK</title>
  7158. <para>
  7159. The <filename>opkg</filename> application performs
  7160. runtime package management of IPK packages.
  7161. You must perform an initial setup for
  7162. <filename>opkg</filename> on the target machine
  7163. if the
  7164. <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_FEED_ARCHS'><filename>PACKAGE_FEED_ARCHS</filename></ulink>,
  7165. <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_FEED_BASE_PATHS'><filename>PACKAGE_FEED_BASE_PATHS</filename></ulink>, and
  7166. <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_FEED_URIS'><filename>PACKAGE_FEED_URIS</filename></ulink>
  7167. variables have not been set or the target image was
  7168. built before the variables were set.
  7169. </para>
  7170. <para>
  7171. The <filename>opkg</filename> application uses
  7172. configuration files to find available package
  7173. databases.
  7174. Thus, you need to create a configuration file inside
  7175. the <filename>/etc/opkg/</filename> direction, which
  7176. informs <filename>opkg</filename> of any repository
  7177. you want to use.
  7178. </para>
  7179. <para>
  7180. As an example, suppose you are serving packages from a
  7181. <filename>ipk/</filename> directory containing the
  7182. <filename>i586</filename>,
  7183. <filename>all</filename>, and
  7184. <filename>qemux86</filename> databases through an
  7185. HTTP server named <filename>my.server</filename>.
  7186. On the target, create a configuration file
  7187. (e.g. <filename>my_repo.conf</filename>) inside the
  7188. <filename>/etc/opkg/</filename> directory containing
  7189. the following:
  7190. <literallayout class='monospaced'>
  7191. src/gz all http://my.server/ipk/all
  7192. src/gz i586 http://my.server/ipk/i586
  7193. src/gz qemux86 http://my.server/ipk/qemux86
  7194. </literallayout>
  7195. Next, instruct <filename>opkg</filename> to fetch
  7196. the repository information:
  7197. <literallayout class='monospaced'>
  7198. # opkg update
  7199. </literallayout>
  7200. The <filename>opkg</filename> application is now able
  7201. to find, install, and upgrade packages from the
  7202. specified repository.
  7203. </para>
  7204. </section>
  7205. <section id='runtime-package-management-target-deb'>
  7206. <title>Using DEB</title>
  7207. <para>
  7208. The <filename>apt</filename> application performs
  7209. runtime package management of DEB packages.
  7210. This application uses a source list file to find
  7211. available package databases.
  7212. You must perform an initial setup for
  7213. <filename>apt</filename> on the target machine
  7214. if the
  7215. <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_FEED_ARCHS'><filename>PACKAGE_FEED_ARCHS</filename></ulink>,
  7216. <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_FEED_BASE_PATHS'><filename>PACKAGE_FEED_BASE_PATHS</filename></ulink>, and
  7217. <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_FEED_URIS'><filename>PACKAGE_FEED_URIS</filename></ulink>
  7218. variables have not been set or the target image was
  7219. built before the variables were set.
  7220. </para>
  7221. <para>
  7222. To inform <filename>apt</filename> of the repository
  7223. you want to use, you might create a list file (e.g.
  7224. <filename>my_repo.list</filename>) inside the
  7225. <filename>/etc/apt/sources.list.d/</filename>
  7226. directory.
  7227. As an example, suppose you are serving packages from a
  7228. <filename>deb/</filename> directory containing the
  7229. <filename>i586</filename>,
  7230. <filename>all</filename>, and
  7231. <filename>qemux86</filename> databases through an
  7232. HTTP server named <filename>my.server</filename>.
  7233. The list file should contain:
  7234. <literallayout class='monospaced'>
  7235. deb http://my.server/deb/all ./
  7236. deb http://my.server/deb/i586 ./
  7237. deb http://my.server/deb/qemux86 ./
  7238. </literallayout>
  7239. Next, instruct the <filename>apt</filename>
  7240. application to fetch the repository information:
  7241. <literallayout class='monospaced'>
  7242. # apt-get update
  7243. </literallayout>
  7244. After this step, <filename>apt</filename> is able
  7245. to find, install, and upgrade packages from the
  7246. specified repository.
  7247. </para>
  7248. </section>
  7249. </section>
  7250. </section>
  7251. <section id='testing-packages-with-ptest'>
  7252. <title>Testing Packages With ptest</title>
  7253. <para>
  7254. A Package Test (ptest) runs tests against packages built
  7255. by the OpenEmbedded build system on the target machine.
  7256. A ptest contains at least two items: the actual test, and
  7257. a shell script (<filename>run-ptest</filename>) that starts
  7258. the test.
  7259. The shell script that starts the test must not contain
  7260. the actual test - the script only starts the test.
  7261. On the other hand, the test can be anything from a simple
  7262. shell script that runs a binary and checks the output to
  7263. an elaborate system of test binaries and data files.
  7264. </para>
  7265. <para>
  7266. The test generates output in the format used by
  7267. Automake:
  7268. <literallayout class='monospaced'>
  7269. <replaceable>result</replaceable>: <replaceable>testname</replaceable>
  7270. </literallayout>
  7271. where the result can be <filename>PASS</filename>,
  7272. <filename>FAIL</filename>, or <filename>SKIP</filename>,
  7273. and the testname can be any identifying string.
  7274. </para>
  7275. <para>
  7276. For a list of Yocto Project recipes that are already
  7277. enabled with ptest, see the
  7278. <ulink url='https://wiki.yoctoproject.org/wiki/Ptest'>Ptest</ulink>
  7279. wiki page.
  7280. <note>
  7281. A recipe is "ptest-enabled" if it inherits the
  7282. <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-ptest'><filename>ptest</filename></ulink>
  7283. class.
  7284. </note>
  7285. </para>
  7286. <section id='adding-ptest-to-your-build'>
  7287. <title>Adding ptest to Your Build</title>
  7288. <para>
  7289. To add package testing to your build, add the
  7290. <ulink url='&YOCTO_DOCS_REF_URL;#var-DISTRO_FEATURES'><filename>DISTRO_FEATURES</filename></ulink>
  7291. and <ulink url='&YOCTO_DOCS_REF_URL;#var-EXTRA_IMAGE_FEATURES'><filename>EXTRA_IMAGE_FEATURES</filename></ulink>
  7292. variables to your <filename>local.conf</filename> file,
  7293. which is found in the
  7294. <link linkend='build-directory'>Build Directory</link>:
  7295. <literallayout class='monospaced'>
  7296. DISTRO_FEATURES_append = " ptest"
  7297. EXTRA_IMAGE_FEATURES += "ptest-pkgs"
  7298. </literallayout>
  7299. Once your build is complete, the ptest files are installed
  7300. into the
  7301. <filename>/usr/lib/<replaceable>package</replaceable>/ptest</filename>
  7302. directory within the image, where
  7303. <filename><replaceable>package</replaceable></filename>
  7304. is the name of the package.
  7305. </para>
  7306. </section>
  7307. <section id='running-ptest'>
  7308. <title>Running ptest</title>
  7309. <para>
  7310. The <filename>ptest-runner</filename> package installs a
  7311. shell script that loops through all installed ptest test
  7312. suites and runs them in sequence.
  7313. Consequently, you might want to add this package to
  7314. your image.
  7315. </para>
  7316. </section>
  7317. <section id='getting-your-package-ready'>
  7318. <title>Getting Your Package Ready</title>
  7319. <para>
  7320. In order to enable a recipe to run installed ptests
  7321. on target hardware,
  7322. you need to prepare the recipes that build the packages
  7323. you want to test.
  7324. Here is what you have to do for each recipe:
  7325. <itemizedlist>
  7326. <listitem><para><emphasis>Be sure the recipe
  7327. inherits the
  7328. <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-ptest'><filename>ptest</filename></ulink>
  7329. class:</emphasis>
  7330. Include the following line in each recipe:
  7331. <literallayout class='monospaced'>
  7332. inherit ptest
  7333. </literallayout>
  7334. </para></listitem>
  7335. <listitem><para><emphasis>Create <filename>run-ptest</filename>:</emphasis>
  7336. This script starts your test.
  7337. Locate the script where you will refer to it
  7338. using
  7339. <ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'><filename>SRC_URI</filename></ulink>.
  7340. Here is an example that starts a test for
  7341. <filename>dbus</filename>:
  7342. <literallayout class='monospaced'>
  7343. #!/bin/sh
  7344. cd test
  7345. make -k runtest-TESTS
  7346. </literallayout>
  7347. </para></listitem>
  7348. <listitem><para><emphasis>Ensure dependencies are
  7349. met:</emphasis>
  7350. If the test adds build or runtime dependencies
  7351. that normally do not exist for the package
  7352. (such as requiring "make" to run the test suite),
  7353. use the
  7354. <ulink url='&YOCTO_DOCS_REF_URL;#var-DEPENDS'><filename>DEPENDS</filename></ulink>
  7355. and
  7356. <ulink url='&YOCTO_DOCS_REF_URL;#var-RDEPENDS'><filename>RDEPENDS</filename></ulink>
  7357. variables in your recipe in order for the package
  7358. to meet the dependencies.
  7359. Here is an example where the package has a runtime
  7360. dependency on "make":
  7361. <literallayout class='monospaced'>
  7362. RDEPENDS_${PN}-ptest += "make"
  7363. </literallayout>
  7364. </para></listitem>
  7365. <listitem><para><emphasis>Add a function to build the
  7366. test suite:</emphasis>
  7367. Not many packages support cross-compilation of
  7368. their test suites.
  7369. Consequently, you usually need to add a
  7370. cross-compilation function to the package.
  7371. </para>
  7372. <para>Many packages based on Automake compile and
  7373. run the test suite by using a single command
  7374. such as <filename>make check</filename>.
  7375. However, the host <filename>make check</filename>
  7376. builds and runs on the same computer, while
  7377. cross-compiling requires that the package is built
  7378. on the host but executed for the target
  7379. architecture (though often, as in the case for
  7380. ptest, the execution occurs on the host).
  7381. The built version of Automake that ships with the
  7382. Yocto Project includes a patch that separates
  7383. building and execution.
  7384. Consequently, packages that use the unaltered,
  7385. patched version of <filename>make check</filename>
  7386. automatically cross-compiles.</para>
  7387. <para>Regardless, you still must add a
  7388. <filename>do_compile_ptest</filename> function to
  7389. build the test suite.
  7390. Add a function similar to the following to your
  7391. recipe:
  7392. <literallayout class='monospaced'>
  7393. do_compile_ptest() {
  7394. oe_runmake buildtest-TESTS
  7395. }
  7396. </literallayout>
  7397. </para></listitem>
  7398. <listitem><para><emphasis>Ensure special configurations
  7399. are set:</emphasis>
  7400. If the package requires special configurations
  7401. prior to compiling the test code, you must
  7402. insert a <filename>do_configure_ptest</filename>
  7403. function into the recipe.
  7404. </para></listitem>
  7405. <listitem><para><emphasis>Install the test
  7406. suite:</emphasis>
  7407. The <filename>ptest</filename> class
  7408. automatically copies the file
  7409. <filename>run-ptest</filename> to the target and
  7410. then runs make <filename>install-ptest</filename>
  7411. to run the tests.
  7412. If this is not enough, you need to create a
  7413. <filename>do_install_ptest</filename> function and
  7414. make sure it gets called after the
  7415. "make install-ptest" completes.
  7416. </para></listitem>
  7417. </itemizedlist>
  7418. </para>
  7419. </section>
  7420. </section>
  7421. </section>
  7422. <section id='working-with-source-files'>
  7423. <title>Working with Source Files</title>
  7424. <para>
  7425. The OpenEmbedded build system works with source files located
  7426. through the
  7427. <ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'><filename>SRC_URI</filename></ulink>
  7428. variable.
  7429. When you build something using BitBake, a big part of the operation
  7430. is locating and downloading all the source tarballs.
  7431. For images, downloading all the source for various packages can
  7432. take a significant amount of time.
  7433. </para>
  7434. <para>
  7435. This section presents information for working with source
  7436. files that can lead to more efficient use of resources and
  7437. time.
  7438. </para>
  7439. <section id='setting-up-effective-mirrors'>
  7440. <title>Setting up Effective Mirrors</title>
  7441. <para>
  7442. As mentioned, a good deal that goes into a Yocto Project
  7443. build is simply downloading all of the source tarballs.
  7444. Maybe you have been working with another build system
  7445. (OpenEmbedded or Angstrom) for which you have built up a
  7446. sizable directory of source tarballs.
  7447. Or, perhaps someone else has such a directory for which you
  7448. have read access.
  7449. If so, you can save time by adding statements to your
  7450. configuration file so that the build process checks local
  7451. directories first for existing tarballs before checking the
  7452. Internet.
  7453. </para>
  7454. <para>
  7455. Here is an efficient way to set it up in your
  7456. <filename>local.conf</filename> file:
  7457. <literallayout class='monospaced'>
  7458. SOURCE_MIRROR_URL ?= "file:///home/you/your-download-dir/"
  7459. INHERIT += "own-mirrors"
  7460. BB_GENERATE_MIRROR_TARBALLS = "1"
  7461. # BB_NO_NETWORK = "1"
  7462. </literallayout>
  7463. </para>
  7464. <para>
  7465. In the previous example, the
  7466. <ulink url='&YOCTO_DOCS_REF_URL;#var-BB_GENERATE_MIRROR_TARBALLS'><filename>BB_GENERATE_MIRROR_TARBALLS</filename></ulink>
  7467. variable causes the OpenEmbedded build system to generate
  7468. tarballs of the Git repositories and store them in the
  7469. <ulink url='&YOCTO_DOCS_REF_URL;#var-DL_DIR'><filename>DL_DIR</filename></ulink>
  7470. directory.
  7471. Due to performance reasons, generating and storing these
  7472. tarballs is not the build system's default behavior.
  7473. </para>
  7474. <para>
  7475. You can also use the
  7476. <ulink url='&YOCTO_DOCS_REF_URL;#var-PREMIRRORS'><filename>PREMIRRORS</filename></ulink>
  7477. variable.
  7478. For an example, see the variable's glossary entry in the
  7479. Yocto Project Reference Manual.
  7480. </para>
  7481. </section>
  7482. <section id='getting-source-files-and-suppressing-the-build'>
  7483. <title>Getting Source Files and Suppressing the Build</title>
  7484. <para>
  7485. Another technique you can use to ready yourself for a
  7486. successive string of build operations, is to pre-fetch
  7487. all the source files without actually starting a build.
  7488. This technique lets you work through any download issues
  7489. and ultimately gathers all the source files into your
  7490. download directory
  7491. <ulink url='&YOCTO_DOCS_REF_URL;#structure-build-downloads'><filename>build/downloads</filename></ulink>,
  7492. which is located with
  7493. <ulink url='&YOCTO_DOCS_REF_URL;#var-DL_DIR'><filename>DL_DIR</filename></ulink>.
  7494. </para>
  7495. <para>
  7496. Use the following BitBake command form to fetch all the
  7497. necessary sources without starting the build:
  7498. <literallayout class='monospaced'>
  7499. $ bitbake -c fetchall <replaceable>target</replaceable>
  7500. </literallayout>
  7501. This variation of the BitBake command guarantees that you
  7502. have all the sources for that BitBake target should you
  7503. disconnect from the Internet and want to do the build
  7504. later offline.
  7505. </para>
  7506. </section>
  7507. </section>
  7508. <section id="building-software-from-an-external-source">
  7509. <title>Building Software from an External Source</title>
  7510. <para>
  7511. By default, the OpenEmbedded build system uses the
  7512. <link linkend='build-directory'>Build Directory</link> when
  7513. building source code.
  7514. The build process involves fetching the source files, unpacking
  7515. them, and then patching them if necessary before the build takes
  7516. place.
  7517. </para>
  7518. <para>
  7519. Situations exist where you might want to build software from source
  7520. files that are external to and thus outside of the
  7521. OpenEmbedded build system.
  7522. For example, suppose you have a project that includes a new BSP with
  7523. a heavily customized kernel.
  7524. And, you want to minimize exposing the build system to the
  7525. development team so that they can focus on their project and
  7526. maintain everyone's workflow as much as possible.
  7527. In this case, you want a kernel source directory on the development
  7528. machine where the development occurs.
  7529. You want the recipe's
  7530. <ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'><filename>SRC_URI</filename></ulink>
  7531. variable to point to the external directory and use it as is, not
  7532. copy it.
  7533. </para>
  7534. <para>
  7535. To build from software that comes from an external source, all you
  7536. need to do is inherit the
  7537. <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-externalsrc'><filename>externalsrc</filename></ulink>
  7538. class and then set the
  7539. <ulink url='&YOCTO_DOCS_REF_URL;#var-EXTERNALSRC'><filename>EXTERNALSRC</filename></ulink>
  7540. variable to point to your external source code.
  7541. Here are the statements to put in your
  7542. <filename>local.conf</filename> file:
  7543. <literallayout class='monospaced'>
  7544. INHERIT += "externalsrc"
  7545. EXTERNALSRC_pn-<replaceable>myrecipe</replaceable> = "<replaceable>path-to-your-source-tree</replaceable>"
  7546. </literallayout>
  7547. </para>
  7548. <para>
  7549. This next example shows how to accomplish the same thing by setting
  7550. <filename>EXTERNALSRC</filename> in the recipe itself or in the
  7551. recipe's append file:
  7552. <literallayout class='monospaced'>
  7553. EXTERNALSRC = "<replaceable>path</replaceable>"
  7554. EXTERNALSRC_BUILD = "<replaceable>path</replaceable>"
  7555. </literallayout>
  7556. <note>
  7557. In order for these settings to take effect, you must globally
  7558. or locally inherit the
  7559. <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-externalsrc'><filename>externalsrc</filename></ulink>
  7560. class.
  7561. </note>
  7562. </para>
  7563. <para>
  7564. By default, <filename>externalsrc.bbclass</filename> builds
  7565. the source code in a directory separate from the external source
  7566. directory as specified by
  7567. <ulink url='&YOCTO_DOCS_REF_URL;#var-EXTERNALSRC'><filename>EXTERNALSRC</filename></ulink>.
  7568. If you need to have the source built in the same directory in
  7569. which it resides, or some other nominated directory, you can set
  7570. <ulink url='&YOCTO_DOCS_REF_URL;#var-EXTERNALSRC_BUILD'><filename>EXTERNALSRC_BUILD</filename></ulink>
  7571. to point to that directory:
  7572. <literallayout class='monospaced'>
  7573. EXTERNALSRC_BUILD_pn-<replaceable>myrecipe</replaceable> = "<replaceable>path-to-your-source-tree</replaceable>"
  7574. </literallayout>
  7575. </para>
  7576. </section>
  7577. <section id="selecting-an-initialization-manager">
  7578. <title>Selecting an Initialization Manager</title>
  7579. <para>
  7580. By default, the Yocto Project uses SysVinit as the initialization
  7581. manager.
  7582. However, support also exists for systemd,
  7583. which is a full replacement for init with
  7584. parallel starting of services, reduced shell overhead and other
  7585. features that are used by many distributions.
  7586. </para>
  7587. <para>
  7588. If you want to use SysVinit, you do
  7589. not have to do anything.
  7590. But, if you want to use systemd, you must
  7591. take some steps as described in the following sections.
  7592. </para>
  7593. <section id='using-systemd-exclusively'>
  7594. <title>Using systemd Exclusively</title>
  7595. <para>
  7596. Set the these variables in your distribution configuration
  7597. file as follows:
  7598. <literallayout class='monospaced'>
  7599. DISTRO_FEATURES_append = " systemd"
  7600. VIRTUAL-RUNTIME_init_manager = "systemd"
  7601. </literallayout>
  7602. You can also prevent the SysVinit
  7603. distribution feature from
  7604. being automatically enabled as follows:
  7605. <literallayout class='monospaced'>
  7606. DISTRO_FEATURES_BACKFILL_CONSIDERED = "sysvinit"
  7607. </literallayout>
  7608. Doing so removes any redundant SysVinit scripts.
  7609. </para>
  7610. <para>
  7611. To remove initscripts from your image altogether,
  7612. set this variable also:
  7613. <literallayout class='monospaced'>
  7614. VIRTUAL-RUNTIME_initscripts = ""
  7615. </literallayout>
  7616. </para>
  7617. <para>
  7618. For information on the backfill variable, see
  7619. <ulink url='&YOCTO_DOCS_REF_URL;#var-DISTRO_FEATURES_BACKFILL_CONSIDERED'><filename>DISTRO_FEATURES_BACKFILL_CONSIDERED</filename></ulink>.
  7620. </para>
  7621. </section>
  7622. <section id='using-systemd-for-the-main-image-and-using-sysvinit-for-the-rescue-image'>
  7623. <title>Using systemd for the Main Image and Using SysVinit for the Rescue Image</title>
  7624. <para>
  7625. Set these variables in your distribution configuration
  7626. file as follows:
  7627. <literallayout class='monospaced'>
  7628. DISTRO_FEATURES_append = " systemd"
  7629. VIRTUAL-RUNTIME_init_manager = "systemd"
  7630. </literallayout>
  7631. Doing so causes your main image to use the
  7632. <filename>packagegroup-core-boot.bb</filename> recipe and
  7633. systemd.
  7634. The rescue/minimal image cannot use this package group.
  7635. However, it can install SysVinit
  7636. and the appropriate packages will have support for both
  7637. systemd and SysVinit.
  7638. </para>
  7639. </section>
  7640. </section>
  7641. <section id="selecting-dev-manager">
  7642. <title>Selecting a Device Manager</title>
  7643. <para>
  7644. The Yocto Project provides multiple ways to manage the device
  7645. manager (<filename>/dev</filename>):
  7646. <itemizedlist>
  7647. <listitem><para><emphasis>Persistent and Pre-Populated<filename>/dev</filename>:</emphasis>
  7648. For this case, the <filename>/dev</filename> directory
  7649. is persistent and the required device nodes are created
  7650. during the build.
  7651. </para></listitem>
  7652. <listitem><para><emphasis>Use <filename>devtmpfs</filename> with a Device Manager:</emphasis>
  7653. For this case, the <filename>/dev</filename> directory
  7654. is provided by the kernel as an in-memory file system and
  7655. is automatically populated by the kernel at runtime.
  7656. Additional configuration of device nodes is done in user
  7657. space by a device manager like
  7658. <filename>udev</filename> or
  7659. <filename>busybox-mdev</filename>.
  7660. </para></listitem>
  7661. </itemizedlist>
  7662. </para>
  7663. <section id="static-dev-management">
  7664. <title>Using Persistent and Pre-Populated<filename>/dev</filename></title>
  7665. <para>
  7666. To use the static method for device population, you need to
  7667. set the
  7668. <ulink url='&YOCTO_DOCS_REF_URL;#var-USE_DEVFS'><filename>USE_DEVFS</filename></ulink>
  7669. variable to "0" as follows:
  7670. <literallayout class='monospaced'>
  7671. USE_DEVFS = "0"
  7672. </literallayout>
  7673. </para>
  7674. <para>
  7675. The content of the resulting <filename>/dev</filename>
  7676. directory is defined in a Device Table file.
  7677. The
  7678. <ulink url='&YOCTO_DOCS_REF_URL;#var-IMAGE_DEVICE_TABLES'><filename>IMAGE_DEVICE_TABLES</filename></ulink>
  7679. variable defines the Device Table to use and should be set
  7680. in the machine or distro configuration file.
  7681. Alternatively, you can set this variable in your
  7682. <filename>local.conf</filename> configuration file.
  7683. </para>
  7684. <para>
  7685. If you do not define the
  7686. <filename>IMAGE_DEVICE_TABLES</filename> variable, the default
  7687. <filename>device_table-minimal.txt</filename> is used:
  7688. <literallayout class='monospaced'>
  7689. IMAGE_DEVICE_TABLES = "device_table-mymachine.txt"
  7690. </literallayout>
  7691. </para>
  7692. <para>
  7693. The population is handled by the <filename>makedevs</filename>
  7694. utility during image creation:
  7695. </para>
  7696. </section>
  7697. <section id="devtmpfs-dev-management">
  7698. <title>Using <filename>devtmpfs</filename> and a Device Manager</title>
  7699. <para>
  7700. To use the dynamic method for device population, you need to
  7701. use (or be sure to set) the
  7702. <ulink url='&YOCTO_DOCS_REF_URL;#var-USE_DEVFS'><filename>USE_DEVFS</filename></ulink>
  7703. variable to "1", which is the default:
  7704. <literallayout class='monospaced'>
  7705. USE_DEVFS = "1"
  7706. </literallayout>
  7707. With this setting, the resulting <filename>/dev</filename>
  7708. directory is populated by the kernel using
  7709. <filename>devtmpfs</filename>.
  7710. Make sure the corresponding kernel configuration variable
  7711. <filename>CONFIG_DEVTMPFS</filename> is set when building
  7712. you build a Linux kernel.
  7713. </para>
  7714. <para>
  7715. All devices created by <filename>devtmpfs</filename> will be
  7716. owned by <filename>root</filename> and have permissions
  7717. <filename>0600</filename>.
  7718. </para>
  7719. <para>
  7720. To have more control over the device nodes, you can use a
  7721. device manager like <filename>udev</filename> or
  7722. <filename>busybox-mdev</filename>.
  7723. You choose the device manager by defining the
  7724. <filename>VIRTUAL-RUNTIME_dev_manager</filename> variable
  7725. in your machine or distro configuration file.
  7726. Alternatively, you can set this variable in your
  7727. <filename>local.conf</filename> configuration file:
  7728. <literallayout class='monospaced'>
  7729. VIRTUAL-RUNTIME_dev_manager = "udev"
  7730. # Some alternative values
  7731. # VIRTUAL-RUNTIME_dev_manager = "busybox-mdev"
  7732. # VIRTUAL-RUNTIME_dev_manager = "systemd"
  7733. </literallayout>
  7734. </para>
  7735. </section>
  7736. </section>
  7737. <section id="platdev-appdev-srcrev">
  7738. <title>Using an External SCM</title>
  7739. <para>
  7740. If you're working on a recipe that pulls from an external Source
  7741. Code Manager (SCM), it is possible to have the OpenEmbedded build
  7742. system notice new recipe changes added to the SCM and then build
  7743. the resulting packages that depend on the new recipes by using
  7744. the latest versions.
  7745. This only works for SCMs from which it is possible to get a
  7746. sensible revision number for changes.
  7747. Currently, you can do this with Apache Subversion (SVN), Git, and
  7748. Bazaar (BZR) repositories.
  7749. </para>
  7750. <para>
  7751. To enable this behavior, the
  7752. <ulink url='&YOCTO_DOCS_REF_URL;#var-PV'><filename>PV</filename></ulink>
  7753. of the recipe needs to reference
  7754. <ulink url='&YOCTO_DOCS_REF_URL;#var-SRCPV'><filename>SRCPV</filename></ulink>.
  7755. Here is an example:
  7756. <literallayout class='monospaced'>
  7757. PV = "1.2.3+git${SRCPV}"
  7758. </literallayout>
  7759. Then, you can add the following to your
  7760. <filename>local.conf</filename>:
  7761. <literallayout class='monospaced'>
  7762. SRCREV_pn-<replaceable>PN</replaceable> = "${AUTOREV}"
  7763. </literallayout>
  7764. <ulink url='&YOCTO_DOCS_REF_URL;#var-PN'><filename>PN</filename></ulink>
  7765. is the name of the recipe for which you want to enable automatic source
  7766. revision updating.
  7767. </para>
  7768. <para>
  7769. If you do not want to update your local configuration file, you can
  7770. add the following directly to the recipe to finish enabling
  7771. the feature:
  7772. <literallayout class='monospaced'>
  7773. SRCREV = "${AUTOREV}"
  7774. </literallayout>
  7775. </para>
  7776. <para>
  7777. The Yocto Project provides a distribution named
  7778. <filename>poky-bleeding</filename>, whose configuration
  7779. file contains the line:
  7780. <literallayout class='monospaced'>
  7781. require conf/distro/include/poky-floating-revisions.inc
  7782. </literallayout>
  7783. This line pulls in the listed include file that contains
  7784. numerous lines of exactly that form:
  7785. <literallayout class='monospaced'>
  7786. #SRCREV_pn-opkg-native ?= "${AUTOREV}"
  7787. #SRCREV_pn-opkg-sdk ?= "${AUTOREV}"
  7788. #SRCREV_pn-opkg ?= "${AUTOREV}"
  7789. #SRCREV_pn-opkg-utils-native ?= "${AUTOREV}"
  7790. #SRCREV_pn-opkg-utils ?= "${AUTOREV}"
  7791. SRCREV_pn-gconf-dbus ?= "${AUTOREV}"
  7792. SRCREV_pn-matchbox-common ?= "${AUTOREV}"
  7793. SRCREV_pn-matchbox-config-gtk ?= "${AUTOREV}"
  7794. SRCREV_pn-matchbox-desktop ?= "${AUTOREV}"
  7795. SRCREV_pn-matchbox-keyboard ?= "${AUTOREV}"
  7796. SRCREV_pn-matchbox-panel-2 ?= "${AUTOREV}"
  7797. SRCREV_pn-matchbox-themes-extra ?= "${AUTOREV}"
  7798. SRCREV_pn-matchbox-terminal ?= "${AUTOREV}"
  7799. SRCREV_pn-matchbox-wm ?= "${AUTOREV}"
  7800. SRCREV_pn-settings-daemon ?= "${AUTOREV}"
  7801. SRCREV_pn-screenshot ?= "${AUTOREV}"
  7802. .
  7803. .
  7804. .
  7805. </literallayout>
  7806. These lines allow you to experiment with building a
  7807. distribution that tracks the latest development source
  7808. for numerous packages.
  7809. <note><title>Caution</title>
  7810. The <filename>poky-bleeding</filename> distribution
  7811. is not tested on a regular basis.
  7812. Keep this in mind if you use it.
  7813. </note>
  7814. </para>
  7815. </section>
  7816. <section id='creating-a-read-only-root-filesystem'>
  7817. <title>Creating a Read-Only Root Filesystem</title>
  7818. <para>
  7819. Suppose, for security reasons, you need to disable
  7820. your target device's root filesystem's write permissions
  7821. (i.e. you need a read-only root filesystem).
  7822. Or, perhaps you are running the device's operating system
  7823. from a read-only storage device.
  7824. For either case, you can customize your image for
  7825. that behavior.
  7826. </para>
  7827. <note>
  7828. Supporting a read-only root filesystem requires that the system and
  7829. applications do not try to write to the root filesystem.
  7830. You must configure all parts of the target system to write
  7831. elsewhere, or to gracefully fail in the event of attempting to
  7832. write to the root filesystem.
  7833. </note>
  7834. <section id='creating-the-root-filesystem'>
  7835. <title>Creating the Root Filesystem</title>
  7836. <para>
  7837. To create the read-only root filesystem, simply add the
  7838. "read-only-rootfs" feature to your image.
  7839. Using either of the following statements in your
  7840. image recipe or from within the
  7841. <filename>local.conf</filename> file found in the
  7842. <link linkend='build-directory'>Build Directory</link>
  7843. causes the build system to create a read-only root filesystem:
  7844. <literallayout class='monospaced'>
  7845. IMAGE_FEATURES = "read-only-rootfs"
  7846. </literallayout>
  7847. or
  7848. <literallayout class='monospaced'>
  7849. EXTRA_IMAGE_FEATURES += "read-only-rootfs"
  7850. </literallayout>
  7851. </para>
  7852. <para>
  7853. For more information on how to use these variables, see the
  7854. "<link linkend='usingpoky-extend-customimage-imagefeatures'>Customizing Images Using Custom <filename>IMAGE_FEATURES</filename> and <filename>EXTRA_IMAGE_FEATURES</filename></link>"
  7855. section.
  7856. For information on the variables, see
  7857. <ulink url='&YOCTO_DOCS_REF_URL;#var-IMAGE_FEATURES'><filename>IMAGE_FEATURES</filename></ulink>
  7858. and <ulink url='&YOCTO_DOCS_REF_URL;#var-EXTRA_IMAGE_FEATURES'><filename>EXTRA_IMAGE_FEATURES</filename></ulink>.
  7859. </para>
  7860. </section>
  7861. <section id='post-installation-scripts'>
  7862. <title>Post-Installation Scripts</title>
  7863. <para>
  7864. It is very important that you make sure all
  7865. post-Installation (<filename>pkg_postinst</filename>) scripts
  7866. for packages that are installed into the image can be run
  7867. at the time when the root filesystem is created during the
  7868. build on the host system.
  7869. These scripts cannot attempt to run during first-boot on the
  7870. target device.
  7871. With the "read-only-rootfs" feature enabled,
  7872. the build system checks during root filesystem creation to make
  7873. sure all post-installation scripts succeed.
  7874. If any of these scripts still need to be run after the root
  7875. filesystem is created, the build immediately fails.
  7876. These build-time checks ensure that the build fails
  7877. rather than the target device fails later during its
  7878. initial boot operation.
  7879. </para>
  7880. <para>
  7881. Most of the common post-installation scripts generated by the
  7882. build system for the out-of-the-box Yocto Project are engineered
  7883. so that they can run during root filesystem creation
  7884. (e.g. post-installation scripts for caching fonts).
  7885. However, if you create and add custom scripts, you need
  7886. to be sure they can be run during this file system creation.
  7887. </para>
  7888. <para>
  7889. Here are some common problems that prevent
  7890. post-installation scripts from running during root filesystem
  7891. creation:
  7892. <itemizedlist>
  7893. <listitem><para>
  7894. <emphasis>Not using $D in front of absolute
  7895. paths:</emphasis>
  7896. The build system defines
  7897. <filename>$</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-D'><filename>D</filename></ulink>
  7898. when the root filesystem is created.
  7899. Furthermore, <filename>$D</filename> is blank when the
  7900. script is run on the target device.
  7901. This implies two purposes for <filename>$D</filename>:
  7902. ensuring paths are valid in both the host and target
  7903. environments, and checking to determine which
  7904. environment is being used as a method for taking
  7905. appropriate actions.
  7906. </para></listitem>
  7907. <listitem><para>
  7908. <emphasis>Attempting to run processes that are
  7909. specific to or dependent on the target
  7910. architecture:</emphasis>
  7911. You can work around these attempts by using native
  7912. tools, which run on the host system,
  7913. to accomplish the same tasks, or
  7914. by alternatively running the processes under QEMU,
  7915. which has the <filename>qemu_run_binary</filename>
  7916. function.
  7917. For more information, see the
  7918. <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-qemu'><filename>qemu</filename></ulink>
  7919. class.</para></listitem>
  7920. </itemizedlist>
  7921. </para>
  7922. </section>
  7923. <section id='areas-with-write-access'>
  7924. <title>Areas With Write Access</title>
  7925. <para>
  7926. With the "read-only-rootfs" feature enabled,
  7927. any attempt by the target to write to the root filesystem at
  7928. runtime fails.
  7929. Consequently, you must make sure that you configure processes
  7930. and applications that attempt these types of writes do so
  7931. to directories with write access (e.g.
  7932. <filename>/tmp</filename> or <filename>/var/run</filename>).
  7933. </para>
  7934. </section>
  7935. </section>
  7936. <section id="performing-automated-runtime-testing">
  7937. <title>Performing Automated Runtime Testing</title>
  7938. <para>
  7939. The OpenEmbedded build system makes available a series of automated
  7940. tests for images to verify runtime functionality.
  7941. You can run these tests on either QEMU or actual target hardware.
  7942. Tests are written in Python making use of the
  7943. <filename>unittest</filename> module, and the majority of them
  7944. run commands on the target system over SSH.
  7945. This section describes how you set up the environment to use these
  7946. tests, run available tests, and write and add your own tests.
  7947. </para>
  7948. <section id='enabling-tests'>
  7949. <title>Enabling Tests</title>
  7950. <para>
  7951. Depending on whether you are planning to run tests using
  7952. QEMU or on the hardware, you have to take
  7953. different steps to enable the tests.
  7954. See the following subsections for information on how to
  7955. enable both types of tests.
  7956. </para>
  7957. <section id='qemu-image-enabling-tests'>
  7958. <title>Enabling Runtime Tests on QEMU</title>
  7959. <para>
  7960. In order to run tests, you need to do the following:
  7961. <itemizedlist>
  7962. <listitem><para><emphasis>Set up to avoid interaction
  7963. with <filename>sudo</filename> for networking:</emphasis>
  7964. To accomplish this, you must do one of the
  7965. following:
  7966. <itemizedlist>
  7967. <listitem><para>Add
  7968. <filename>NOPASSWD</filename> for your user
  7969. in <filename>/etc/sudoers</filename> either for
  7970. all commands or just for
  7971. <filename>runqemu-ifup</filename>.
  7972. You must provide the full path as that can
  7973. change if you are using multiple clones of the
  7974. source repository.
  7975. <note>
  7976. On some distributions, you also need to
  7977. comment out "Defaults requiretty" in
  7978. <filename>/etc/sudoers</filename>.
  7979. </note></para></listitem>
  7980. <listitem><para>Manually configure a tap interface
  7981. for your system.</para></listitem>
  7982. <listitem><para>Run as root the script in
  7983. <filename>scripts/runqemu-gen-tapdevs</filename>,
  7984. which should generate a list of tap devices.
  7985. This is the option typically chosen for
  7986. Autobuilder-type environments.
  7987. </para></listitem>
  7988. </itemizedlist></para></listitem>
  7989. <listitem><para><emphasis>Set the
  7990. <filename>DISPLAY</filename> variable:</emphasis>
  7991. You need to set this variable so that you have an X
  7992. server available (e.g. start
  7993. <filename>vncserver</filename> for a headless machine).
  7994. </para></listitem>
  7995. <listitem><para><emphasis>Be sure your host's firewall
  7996. accepts incoming connections from
  7997. 192.168.7.0/24:</emphasis>
  7998. Some of the tests (in particular smart tests) start an
  7999. HTTP server on a random high number port, which is
  8000. used to serve files to the target.
  8001. The smart module serves
  8002. <filename>${DEPLOY_DIR}/rpm</filename> so it can run
  8003. smart channel commands. That means your host's firewall
  8004. must accept incoming connections from 192.168.7.0/24,
  8005. which is the default IP range used for tap devices
  8006. by <filename>runqemu</filename>.</para></listitem>
  8007. <listitem><para><emphasis>Be sure your host has the
  8008. correct packages installed:</emphasis>
  8009. Depending your host's distribution, you need
  8010. to have the following packages installed:
  8011. <itemizedlist>
  8012. <listitem><para>Ubuntu and Debian:
  8013. <filename>sysstat</filename> and
  8014. <filename>iproute2</filename>
  8015. </para></listitem>
  8016. <listitem><para>OpenSUSE:
  8017. <filename>sysstat</filename> and
  8018. <filename>iproute2</filename>
  8019. </para></listitem>
  8020. <listitem><para>Fedora:
  8021. <filename>sysstat</filename> and
  8022. <filename>iproute</filename>
  8023. </para></listitem>
  8024. <listitem><para>CentOS:
  8025. <filename>sysstat</filename> and
  8026. <filename>iproute</filename>
  8027. </para></listitem>
  8028. </itemizedlist>
  8029. </para></listitem>
  8030. </itemizedlist>
  8031. </para>
  8032. <para>
  8033. Once you start running the tests, the following happens:
  8034. <orderedlist>
  8035. <listitem><para>A copy of the root filesystem is written
  8036. to <filename>${WORKDIR}/testimage</filename>.
  8037. </para></listitem>
  8038. <listitem><para>The image is booted under QEMU using the
  8039. standard <filename>runqemu</filename> script.
  8040. </para></listitem>
  8041. <listitem><para>A default timeout of 500 seconds occurs
  8042. to allow for the boot process to reach the login prompt.
  8043. You can change the timeout period by setting
  8044. <ulink url='&YOCTO_DOCS_REF_URL;#var-TEST_QEMUBOOT_TIMEOUT'><filename>TEST_QEMUBOOT_TIMEOUT</filename></ulink>
  8045. in the <filename>local.conf</filename> file.
  8046. </para></listitem>
  8047. <listitem><para>Once the boot process is reached and the
  8048. login prompt appears, the tests run.
  8049. The full boot log is written to
  8050. <filename>${WORKDIR}/testimage/qemu_boot_log</filename>.
  8051. </para></listitem>
  8052. <listitem><para>Each test module loads in the order found
  8053. in <filename>TEST_SUITES</filename>.
  8054. You can find the full output of the commands run over
  8055. SSH in
  8056. <filename>${WORKDIR}/testimgage/ssh_target_log</filename>.
  8057. </para></listitem>
  8058. <listitem><para>If no failures occur, the task running the
  8059. tests ends successfully.
  8060. You can find the output from the
  8061. <filename>unittest</filename> in the task log at
  8062. <filename>${WORKDIR}/temp/log.do_testimage</filename>.
  8063. </para></listitem>
  8064. </orderedlist>
  8065. </para>
  8066. </section>
  8067. <section id='hardware-image-enabling-tests'>
  8068. <title>Enabling Runtime Tests on Hardware</title>
  8069. <para>
  8070. The OpenEmbedded build system can run tests on real
  8071. hardware, and for certain devices it can also deploy
  8072. the image to be tested onto the device beforehand.
  8073. </para>
  8074. <para>
  8075. For automated deployment, a "master image" is installed
  8076. onto the hardware once as part of setup.
  8077. Then, each time tests are to be run, the following
  8078. occurs:
  8079. <orderedlist>
  8080. <listitem><para>The master image is booted into and
  8081. used to write the image to be tested to
  8082. a second partition.
  8083. </para></listitem>
  8084. <listitem><para>The device is then rebooted using an
  8085. external script that you need to provide.
  8086. </para></listitem>
  8087. <listitem><para>The device boots into the image to be
  8088. tested.
  8089. </para></listitem>
  8090. </orderedlist>
  8091. </para>
  8092. <para>
  8093. When running tests (independent of whether the image
  8094. has been deployed automatically or not), the device is
  8095. expected to be connected to a network on a
  8096. pre-determined IP address.
  8097. You can either use static IP addresses written into
  8098. the image, or set the image to use DHCP and have your
  8099. DHCP server on the test network assign a known IP address
  8100. based on the MAC address of the device.
  8101. </para>
  8102. <para>
  8103. In order to run tests on hardware, you need to set
  8104. <filename>TEST_TARGET</filename> to an appropriate value.
  8105. For QEMU, you do not have to change anything, the default
  8106. value is "QemuTarget".
  8107. For running tests on hardware, the following options exist:
  8108. <itemizedlist>
  8109. <listitem><para><emphasis>"SimpleRemoteTarget":</emphasis>
  8110. Choose "SimpleRemoteTarget" if you are going to
  8111. run tests on a target system that is already
  8112. running the image to be tested and is available
  8113. on the network.
  8114. You can use "SimpleRemoteTarget" in conjunction
  8115. with either real hardware or an image running
  8116. within a separately started QEMU or any
  8117. other virtual machine manager.
  8118. </para></listitem>
  8119. <listitem><para><emphasis>"Systemd-bootTarget":</emphasis>
  8120. Choose "Systemd-bootTarget" if your hardware is
  8121. an EFI-based machine with
  8122. <filename>systemd-boot</filename> as bootloader and
  8123. <filename>core-image-testmaster</filename>
  8124. (or something similar) is installed.
  8125. Also, your hardware under test must be in a
  8126. DHCP-enabled network that gives it the same IP
  8127. address for each reboot.</para>
  8128. <para>If you choose "Systemd-bootTarget", there are
  8129. additional requirements and considerations.
  8130. See the
  8131. "<link linkend='selecting-systemd-boottarget'>Selecting Systemd-bootTarget</link>"
  8132. section, which follows, for more information.
  8133. </para></listitem>
  8134. <listitem><para><emphasis>"BeagleBoneTarget":</emphasis>
  8135. Choose "BeagleBoneTarget" if you are deploying
  8136. images and running tests on the BeagleBone
  8137. "Black" or original "White" hardware.
  8138. For information on how to use these tests, see the
  8139. comments at the top of the BeagleBoneTarget
  8140. <filename>meta-yocto-bsp/lib/oeqa/controllers/beaglebonetarget.py</filename>
  8141. file.
  8142. </para></listitem>
  8143. <listitem><para><emphasis>"EdgeRouterTarget":</emphasis>
  8144. Choose "EdgeRouterTarget" is you are deploying
  8145. images and running tests on the Ubiquiti Networks
  8146. EdgeRouter Lite.
  8147. For information on how to use these tests, see the
  8148. comments at the top of the EdgeRouterTarget
  8149. <filename>meta-yocto-bsp/lib/oeqa/controllers/edgeroutertarget.py</filename>
  8150. file.
  8151. </para></listitem>
  8152. <listitem><para><emphasis>"GrubTarget":</emphasis>
  8153. Choose the "supports deploying images and running
  8154. tests on any generic PC that boots using GRUB.
  8155. For information on how to use these tests, see the
  8156. comments at the top of the GrubTarget
  8157. <filename>meta-yocto-bsp/lib/oeqa/controllers/grubtarget.py</filename>
  8158. file.
  8159. </para></listitem>
  8160. <listitem><para><emphasis>"<replaceable>your-target</replaceable>":</emphasis>
  8161. Create your own custom target if you want to run
  8162. tests when you are deploying images and running
  8163. tests on a custom machine within your BSP layer.
  8164. To do this, you need to add a Python unit that
  8165. defines the target class under
  8166. <filename>lib/oeqa/controllers/</filename> within
  8167. your layer.
  8168. You must also provide an empty
  8169. <filename>__init__.py</filename>.
  8170. For examples, see files in
  8171. <filename>meta-yocto-bsp/lib/oeqa/controllers/</filename>.
  8172. </para></listitem>
  8173. </itemizedlist>
  8174. </para>
  8175. </section>
  8176. <section id='selecting-systemd-boottarget'>
  8177. <title>Selecting Systemd-bootTarget</title>
  8178. <para>
  8179. If you did not set <filename>TEST_TARGET</filename> to
  8180. "Systemd-bootTarget", then you do not need any information
  8181. in this section.
  8182. You can skip down to the
  8183. "<link linkend='qemu-image-running-tests'>Running Tests</link>"
  8184. section.
  8185. </para>
  8186. <para>
  8187. If you did set <filename>TEST_TARGET</filename> to
  8188. "Systemd-bootTarget", you also need to perform a one-time
  8189. setup of your master image by doing the following:
  8190. <orderedlist>
  8191. <listitem><para><emphasis>Set <filename>EFI_PROVIDER</filename>:</emphasis>
  8192. Be sure that <filename>EFI_PROVIDER</filename>
  8193. is as follows:
  8194. <literallayout class='monospaced'>
  8195. EFI_PROVIDER = "systemd-boot"
  8196. </literallayout>
  8197. </para></listitem>
  8198. <listitem><para><emphasis>Build the master image:</emphasis>
  8199. Build the <filename>core-image-testmaster</filename>
  8200. image.
  8201. The <filename>core-image-testmaster</filename>
  8202. recipe is provided as an example for a
  8203. "master" image and you can customize the image
  8204. recipe as you would any other recipe.
  8205. </para>
  8206. <para>Here are the image recipe requirements:
  8207. <itemizedlist>
  8208. <listitem><para>Inherits
  8209. <filename>core-image</filename>
  8210. so that kernel modules are installed.
  8211. </para></listitem>
  8212. <listitem><para>Installs normal linux utilities
  8213. not busybox ones (e.g.
  8214. <filename>bash</filename>,
  8215. <filename>coreutils</filename>,
  8216. <filename>tar</filename>,
  8217. <filename>gzip</filename>, and
  8218. <filename>kmod</filename>).
  8219. </para></listitem>
  8220. <listitem><para>Uses a custom
  8221. Initial RAM Disk (initramfs) image with a
  8222. custom installer.
  8223. A normal image that you can install usually
  8224. creates a single rootfs partition.
  8225. This image uses another installer that
  8226. creates a specific partition layout.
  8227. Not all Board Support Packages (BSPs)
  8228. can use an installer.
  8229. For such cases, you need to manually create
  8230. the following partition layout on the
  8231. target:
  8232. <itemizedlist>
  8233. <listitem><para>First partition mounted
  8234. under <filename>/boot</filename>,
  8235. labeled "boot".
  8236. </para></listitem>
  8237. <listitem><para>The main rootfs
  8238. partition where this image gets
  8239. installed, which is mounted under
  8240. <filename>/</filename>.
  8241. </para></listitem>
  8242. <listitem><para>Another partition
  8243. labeled "testrootfs" where test
  8244. images get deployed.
  8245. </para></listitem>
  8246. </itemizedlist>
  8247. </para></listitem>
  8248. </itemizedlist>
  8249. </para></listitem>
  8250. <listitem><para><emphasis>Install image:</emphasis>
  8251. Install the image that you just built on the target
  8252. system.
  8253. </para></listitem>
  8254. </orderedlist>
  8255. </para>
  8256. <para>
  8257. The final thing you need to do when setting
  8258. <filename>TEST_TARGET</filename> to "Systemd-bootTarget" is
  8259. to set up the test image:
  8260. <orderedlist>
  8261. <listitem><para><emphasis>Set up your <filename>local.conf</filename> file:</emphasis>
  8262. Make sure you have the following statements in
  8263. your <filename>local.conf</filename> file:
  8264. <literallayout class='monospaced'>
  8265. IMAGE_FSTYPES += "tar.gz"
  8266. INHERIT += "testimage"
  8267. TEST_TARGET = "Systemd-bootTarget"
  8268. TEST_TARGET_IP = "192.168.2.3"
  8269. </literallayout>
  8270. </para></listitem>
  8271. <listitem><para><emphasis>Build your test image:</emphasis>
  8272. Use BitBake to build the image:
  8273. <literallayout class='monospaced'>
  8274. $ bitbake core-image-sato
  8275. </literallayout>
  8276. </para></listitem>
  8277. </orderedlist>
  8278. </para>
  8279. </section>
  8280. <section id='power-control'>
  8281. <title>Power Control</title>
  8282. <para>
  8283. For most hardware targets other than SimpleRemoteTarget,
  8284. you can control power:
  8285. <itemizedlist>
  8286. <listitem><para>
  8287. You can use
  8288. <filename>TEST_POWERCONTROL_CMD</filename>
  8289. together with
  8290. <filename>TEST_POWERCONTROL_EXTRA_ARGS</filename>
  8291. as a command that runs on the host and does power
  8292. cycling.
  8293. The test code passes one argument to that command:
  8294. off, on or cycle (off then on).
  8295. Here is an example that could appear in your
  8296. <filename>local.conf</filename> file:
  8297. <literallayout class='monospaced'>
  8298. TEST_POWERCONTROL_CMD = "powercontrol.exp test 10.11.12.1 nuc1"
  8299. </literallayout>
  8300. In this example, the expect script does the
  8301. following:
  8302. <literallayout class='monospaced'>
  8303. ssh test@10.11.12.1 "pyctl nuc1 <replaceable>arg</replaceable>"
  8304. </literallayout>
  8305. It then runs a Python script that controls power
  8306. for a label called <filename>nuc1</filename>.
  8307. <note>
  8308. You need to customize
  8309. <filename>TEST_POWERCONTROL_CMD</filename>
  8310. and
  8311. <filename>TEST_POWERCONTROL_EXTRA_ARGS</filename>
  8312. for your own setup.
  8313. The one requirement is that it accepts
  8314. "on", "off", and "cycle" as the last argument.
  8315. </note>
  8316. </para></listitem>
  8317. <listitem><para>
  8318. When no command is defined, it connects to the
  8319. device over SSH and uses the classic reboot command
  8320. to reboot the device.
  8321. Classic reboot is fine as long as the machine
  8322. actually reboots (i.e. the SSH test has not
  8323. failed).
  8324. It is useful for scenarios where you have a simple
  8325. setup, typically with a single board, and where
  8326. some manual interaction is okay from time to time.
  8327. </para></listitem>
  8328. </itemizedlist>
  8329. If you have no hardware to automatically perform power
  8330. control but still wish to experiment with automated
  8331. hardware testing, you can use the dialog-power-control
  8332. script that shows a dialog prompting you to perform the
  8333. required power action.
  8334. This script requires either KDialog or Zenity to be
  8335. installed.
  8336. To use this script, set the
  8337. <ulink url='&YOCTO_DOCS_REF_URL;#var-TEST_POWERCONTROL_CMD'><filename>TEST_POWERCONTROL_CMD</filename></ulink>
  8338. variable as follows:
  8339. <literallayout class='monospaced'>
  8340. TEST_POWERCONTROL_CMD = "${COREBASE}/scripts/contrib/dialog-power-control"
  8341. </literallayout>
  8342. </para>
  8343. </section>
  8344. <section id='serial-console-connection'>
  8345. <title>Serial Console Connection</title>
  8346. <para>
  8347. For test target classes requiring a serial console
  8348. to interact with the bootloader (e.g. BeagleBoneTarget,
  8349. EdgeRouterTarget, and GrubTarget), you need to
  8350. specify a command to use to connect to the serial console
  8351. of the target machine by using the
  8352. <ulink url='&YOCTO_DOCS_REF_URL;#var-TEST_SERIALCONTROL_CMD'><filename>TEST_SERIALCONTROL_CMD</filename></ulink>
  8353. variable and optionally the
  8354. <ulink url='&YOCTO_DOCS_REF_URL;#var-TEST_SERIALCONTROL_EXTRA_ARGS'><filename>TEST_SERIALCONTROL_EXTRA_ARGS</filename></ulink>
  8355. variable.
  8356. </para>
  8357. <para>
  8358. These cases could be a serial terminal program if the
  8359. machine is connected to a local serial port, or a
  8360. <filename>telnet</filename> or
  8361. <filename>ssh</filename> command connecting to a remote
  8362. console server.
  8363. Regardless of the case, the command simply needs to
  8364. connect to the serial console and forward that connection
  8365. to standard input and output as any normal terminal
  8366. program does.
  8367. For example, to use the picocom terminal program on
  8368. serial device <filename>/dev/ttyUSB0</filename>
  8369. at 115200bps, you would set the variable as follows:
  8370. <literallayout class='monospaced'>
  8371. TEST_SERIALCONTROL_CMD = "picocom /dev/ttyUSB0 -b 115200"
  8372. </literallayout>
  8373. For local devices where the serial port device disappears
  8374. when the device reboots, an additional "serdevtry" wrapper
  8375. script is provided.
  8376. To use this wrapper, simply prefix the terminal command
  8377. with
  8378. <filename>${COREBASE}/scripts/contrib/serdevtry</filename>:
  8379. <literallayout class='monospaced'>
  8380. TEST_SERIALCONTROL_CMD = "${COREBASE}/scripts/contrib/serdevtry picocom -b
  8381. 115200 /dev/ttyUSB0"
  8382. </literallayout>
  8383. </para>
  8384. </section>
  8385. </section>
  8386. <section id="qemu-image-running-tests">
  8387. <title>Running Tests</title>
  8388. <para>
  8389. You can start the tests automatically or manually:
  8390. <itemizedlist>
  8391. <listitem><para><emphasis>Automatically running tests:</emphasis>
  8392. To run the tests automatically after the
  8393. OpenEmbedded build system successfully creates an image,
  8394. first set the
  8395. <ulink url='&YOCTO_DOCS_REF_URL;#var-TEST_IMAGE'><filename>TEST_IMAGE</filename></ulink>
  8396. variable to "1" in your <filename>local.conf</filename>
  8397. file in the
  8398. <ulink url='&YOCTO_DOCS_DEV_URL;#build-directory'>Build Directory</ulink>:
  8399. <literallayout class='monospaced'>
  8400. TEST_IMAGE = "1"
  8401. </literallayout>
  8402. Next, build your image.
  8403. If the image successfully builds, the tests will be
  8404. run:
  8405. <literallayout class='monospaced'>
  8406. bitbake core-image-sato
  8407. </literallayout></para></listitem>
  8408. <listitem><para><emphasis>Manually running tests:</emphasis>
  8409. To manually run the tests, first globally inherit the
  8410. <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-testimage*'><filename>testimage</filename></ulink>
  8411. class by editing your <filename>local.conf</filename>
  8412. file:
  8413. <literallayout class='monospaced'>
  8414. INHERIT += "testimage"
  8415. </literallayout>
  8416. Next, use BitBake to run the tests:
  8417. <literallayout class='monospaced'>
  8418. bitbake -c testimage <replaceable>image</replaceable>
  8419. </literallayout></para></listitem>
  8420. </itemizedlist>
  8421. </para>
  8422. <para>
  8423. All test files reside in
  8424. <filename>meta/lib/oeqa/runtime</filename> in the
  8425. <link linkend='source-directory'>Source Directory</link>.
  8426. A test name maps directly to a Python module.
  8427. Each test module may contain a number of individual tests.
  8428. Tests are usually grouped together by the area
  8429. tested (e.g tests for systemd reside in
  8430. <filename>meta/lib/oeqa/runtime/systemd.py</filename>).
  8431. </para>
  8432. <para>
  8433. You can add tests to any layer provided you place them in the
  8434. proper area and you extend
  8435. <ulink url='&YOCTO_DOCS_REF_URL;#var-BBPATH'><filename>BBPATH</filename></ulink>
  8436. in the <filename>local.conf</filename> file as normal.
  8437. Be sure that tests reside in
  8438. <filename><replaceable>layer</replaceable>/lib/oeqa/runtime</filename>.
  8439. <note>
  8440. Be sure that module names do not collide with module names
  8441. used in the default set of test modules in
  8442. <filename>meta/lib/oeqa/runtime</filename>.
  8443. </note>
  8444. </para>
  8445. <para>
  8446. You can change the set of tests run by appending or overriding
  8447. <ulink url='&YOCTO_DOCS_REF_URL;#var-TEST_SUITES'><filename>TEST_SUITES</filename></ulink>
  8448. variable in <filename>local.conf</filename>.
  8449. Each name in <filename>TEST_SUITES</filename> represents a
  8450. required test for the image.
  8451. Test modules named within <filename>TEST_SUITES</filename>
  8452. cannot be skipped even if a test is not suitable for an image
  8453. (e.g. running the RPM tests on an image without
  8454. <filename>rpm</filename>).
  8455. Appending "auto" to <filename>TEST_SUITES</filename> causes the
  8456. build system to try to run all tests that are suitable for the
  8457. image (i.e. each test module may elect to skip itself).
  8458. </para>
  8459. <para>
  8460. The order you list tests in <filename>TEST_SUITES</filename>
  8461. is important and influences test dependencies.
  8462. Consequently, tests that depend on other tests should be added
  8463. after the test on which they depend.
  8464. For example, since the <filename>ssh</filename> test
  8465. depends on the
  8466. <filename>ping</filename> test, "ssh" needs to come after
  8467. "ping" in the list.
  8468. The test class provides no re-ordering or dependency handling.
  8469. <note>
  8470. Each module can have multiple classes with multiple test
  8471. methods.
  8472. And, Python <filename>unittest</filename> rules apply.
  8473. </note>
  8474. </para>
  8475. <para>
  8476. Here are some things to keep in mind when running tests:
  8477. <itemizedlist>
  8478. <listitem><para>The default tests for the image are defined
  8479. as:
  8480. <literallayout class='monospaced'>
  8481. DEFAULT_TEST_SUITES_pn-<replaceable>image</replaceable> = "ping ssh df connman syslog xorg scp vnc date rpm smart dmesg"
  8482. </literallayout></para></listitem>
  8483. <listitem><para>Add your own test to the list of the
  8484. by using the following:
  8485. <literallayout class='monospaced'>
  8486. TEST_SUITES_append = " mytest"
  8487. </literallayout></para></listitem>
  8488. <listitem><para>Run a specific list of tests as follows:
  8489. <literallayout class='monospaced'>
  8490. TEST_SUITES = "test1 test2 test3"
  8491. </literallayout>
  8492. Remember, order is important.
  8493. Be sure to place a test that is dependent on another test
  8494. later in the order.</para></listitem>
  8495. </itemizedlist>
  8496. </para>
  8497. </section>
  8498. <section id="exporting-tests">
  8499. <title>Exporting Tests</title>
  8500. <para>
  8501. You can export tests so that they can run independently of
  8502. the build system.
  8503. Exporting tests is required if you want to be able to hand
  8504. the test execution off to a scheduler.
  8505. You can only export tests that are defined in
  8506. <ulink url='&YOCTO_DOCS_REF_URL;#var-TEST_SUITES'><filename>TEST_SUITES</filename></ulink>.
  8507. </para>
  8508. <para>
  8509. If your image is already built, make sure the following are set
  8510. in your <filename>local.conf</filename> file.
  8511. Be sure to provide the IP address you need:
  8512. <literallayout class='monospaced'>
  8513. INHERIT +="testexport"
  8514. TEST_TARGET_IP = "192.168.7.2"
  8515. TEST_SERVER_IP = "192.168.7.1"
  8516. </literallayout>
  8517. You can then export the tests with the following:
  8518. <literallayout class='monospaced'>
  8519. $ bitbake core-image-sato -c testexport
  8520. </literallayout>
  8521. Exporting the tests places them in the
  8522. <link linkend='build-directory'>Build Directory</link> in
  8523. <filename>tmp/testexport/core-image-sato</filename>, which
  8524. is controlled by the
  8525. <filename>TEST_EXPORT_DIR</filename> variable.
  8526. </para>
  8527. <para>
  8528. You can now run the tests outside of the build environment:
  8529. <literallayout class='monospaced'>
  8530. $ cd tmp/testexport/core-image-sato
  8531. $ ./runexported.py testdata.json
  8532. </literallayout>
  8533. </para>
  8534. </section>
  8535. <section id="qemu-image-writing-new-tests">
  8536. <title>Writing New Tests</title>
  8537. <para>
  8538. As mentioned previously, all new test files need to be in the
  8539. proper place for the build system to find them.
  8540. New tests for additional functionality outside of the core
  8541. should be added to the layer that adds the functionality, in
  8542. <filename><replaceable>layer</replaceable>/lib/oeqa/runtime</filename>
  8543. (as long as
  8544. <ulink url='&YOCTO_DOCS_REF_URL;#var-BBPATH'><filename>BBPATH</filename></ulink>
  8545. is extended in the layer's
  8546. <filename>layer.conf</filename> file as normal).
  8547. Just remember the following:
  8548. <itemizedlist>
  8549. <listitem><para>Filenames need to map directly to test
  8550. (module) names.
  8551. </para></listitem>
  8552. <listitem><para>Do not use module names that
  8553. collide with existing core tests.
  8554. </para></listitem>
  8555. <listitem><para>Minimally, an empty
  8556. <filename>__init__.py</filename> file must exist
  8557. in the runtime directory.
  8558. </para></listitem>
  8559. </itemizedlist>
  8560. </para>
  8561. <para>
  8562. To create a new test, start by copying an existing module
  8563. (e.g. <filename>syslog.py</filename> or
  8564. <filename>gcc.py</filename> are good ones to use).
  8565. Test modules can use code from
  8566. <filename>meta/lib/oeqa/utils</filename>, which are helper
  8567. classes.
  8568. </para>
  8569. <note>
  8570. Structure shell commands such that you rely on them and they
  8571. return a single code for success.
  8572. Be aware that sometimes you will need to parse the output.
  8573. See the <filename>df.py</filename> and
  8574. <filename>date.py</filename> modules for examples.
  8575. </note>
  8576. <para>
  8577. You will notice that all test classes inherit
  8578. <filename>oeRuntimeTest</filename>, which is found in
  8579. <filename>meta/lib/oetest.py</filename>.
  8580. This base class offers some helper attributes, which are
  8581. described in the following sections:
  8582. </para>
  8583. <section id='qemu-image-writing-tests-class-methods'>
  8584. <title>Class Methods</title>
  8585. <para>
  8586. Class methods are as follows:
  8587. <itemizedlist>
  8588. <listitem><para><emphasis><filename>hasPackage(pkg)</filename>:</emphasis>
  8589. Returns "True" if <filename>pkg</filename> is in the
  8590. installed package list of the image, which is based
  8591. on the manifest file that is generated during the
  8592. <filename>do_rootfs</filename> task.
  8593. </para></listitem>
  8594. <listitem><para><emphasis><filename>hasFeature(feature)</filename>:</emphasis>
  8595. Returns "True" if the feature is in
  8596. <ulink url='&YOCTO_DOCS_REF_URL;#var-IMAGE_FEATURES'><filename>IMAGE_FEATURES</filename></ulink>
  8597. or
  8598. <ulink url='&YOCTO_DOCS_REF_URL;#var-DISTRO_FEATURES'><filename>DISTRO_FEATURES</filename></ulink>.
  8599. </para></listitem>
  8600. </itemizedlist>
  8601. </para>
  8602. </section>
  8603. <section id='qemu-image-writing-tests-class-attributes'>
  8604. <title>Class Attributes</title>
  8605. <para>
  8606. Class attributes are as follows:
  8607. <itemizedlist>
  8608. <listitem><para><emphasis><filename>pscmd</filename>:</emphasis>
  8609. Equals "ps -ef" if <filename>procps</filename> is
  8610. installed in the image.
  8611. Otherwise, <filename>pscmd</filename> equals
  8612. "ps" (busybox).
  8613. </para></listitem>
  8614. <listitem><para><emphasis><filename>tc</filename>:</emphasis>
  8615. The called test context, which gives access to the
  8616. following attributes:
  8617. <itemizedlist>
  8618. <listitem><para><emphasis><filename>d</filename>:</emphasis>
  8619. The BitBake datastore, which allows you to
  8620. use stuff such as
  8621. <filename>oeRuntimeTest.tc.d.getVar("VIRTUAL-RUNTIME_init_manager")</filename>.
  8622. </para></listitem>
  8623. <listitem><para><emphasis><filename>testslist</filename> and <filename>testsrequired</filename>:</emphasis>
  8624. Used internally.
  8625. The tests do not need these.
  8626. </para></listitem>
  8627. <listitem><para><emphasis><filename>filesdir</filename>:</emphasis>
  8628. The absolute path to
  8629. <filename>meta/lib/oeqa/runtime/files</filename>,
  8630. which contains helper files for tests meant
  8631. for copying on the target such as small
  8632. files written in C for compilation.
  8633. </para></listitem>
  8634. <listitem><para><emphasis><filename>target</filename>:</emphasis>
  8635. The target controller object used to deploy
  8636. and start an image on a particular target
  8637. (e.g. QemuTarget, SimpleRemote, and
  8638. Systemd-bootTarget).
  8639. Tests usually use the following:
  8640. <itemizedlist>
  8641. <listitem><para><emphasis><filename>ip</filename>:</emphasis>
  8642. The target's IP address.
  8643. </para></listitem>
  8644. <listitem><para><emphasis><filename>server_ip</filename>:</emphasis>
  8645. The host's IP address, which is
  8646. usually used by the "smart" test
  8647. suite.
  8648. </para></listitem>
  8649. <listitem><para><emphasis><filename>run(cmd, timeout=None)</filename>:</emphasis>
  8650. The single, most used method.
  8651. This command is a wrapper for:
  8652. <filename>ssh root@host "cmd"</filename>.
  8653. The command returns a tuple:
  8654. (status, output), which are what
  8655. their names imply - the return code
  8656. of "cmd" and whatever output
  8657. it produces.
  8658. The optional timeout argument
  8659. represents the number of seconds the
  8660. test should wait for "cmd" to
  8661. return.
  8662. If the argument is "None", the
  8663. test uses the default instance's
  8664. timeout period, which is 300
  8665. seconds.
  8666. If the argument is "0", the test
  8667. runs until the command returns.
  8668. </para></listitem>
  8669. <listitem><para><emphasis><filename>copy_to(localpath, remotepath)</filename>:</emphasis>
  8670. <filename>scp localpath root@ip:remotepath</filename>.
  8671. </para></listitem>
  8672. <listitem><para><emphasis><filename>copy_from(remotepath, localpath)</filename>:</emphasis>
  8673. <filename>scp root@host:remotepath localpath</filename>.
  8674. </para></listitem>
  8675. </itemizedlist></para></listitem>
  8676. </itemizedlist></para></listitem>
  8677. </itemizedlist>
  8678. </para>
  8679. </section>
  8680. <section id='qemu-image-writing-tests-instance-attributes'>
  8681. <title>Instance Attributes</title>
  8682. <para>
  8683. A single instance attribute exists, which is
  8684. <filename>target</filename>.
  8685. The <filename>target</filename> instance attribute is
  8686. identical to the class attribute of the same name, which
  8687. is described in the previous section.
  8688. This attribute exists as both an instance and class
  8689. attribute so tests can use
  8690. <filename>self.target.run(cmd)</filename> in instance
  8691. methods instead of
  8692. <filename>oeRuntimeTest.tc.target.run(cmd)</filename>.
  8693. </para>
  8694. </section>
  8695. </section>
  8696. <section id='installing-packages-in-the-dut-without-the-package-manager'>
  8697. <title>Installing Packages in the DUT Without the Package Manager</title>
  8698. <para>
  8699. When a test requires a package built by BitBake, it is possible
  8700. to install that package.
  8701. Installing the package does not require a package manager be
  8702. installed in the device under test (DUT).
  8703. It does, however, require an SSH connection and the target must
  8704. be using the <filename>sshcontrol</filename> class.
  8705. <note>
  8706. This method uses <filename>scp</filename> to copy files
  8707. from the host to the target, which causes permissions and
  8708. special attributes to be lost.
  8709. </note>
  8710. </para>
  8711. <para>
  8712. A JSON file is used to define the packages needed by a test.
  8713. This file must be in the same path as the file used to define
  8714. the tests.
  8715. Furthermore, the filename must map directly to the test
  8716. module name with a <filename>.json</filename> extension.
  8717. </para>
  8718. <para>
  8719. The JSON file must include an object with the test name as
  8720. keys of an object or an array.
  8721. This object (or array of objects) uses the following data:
  8722. <itemizedlist>
  8723. <listitem><para>"pkg" - A mandatory string that is the
  8724. name of the package to be installed.
  8725. </para></listitem>
  8726. <listitem><para>"rm" - An optional boolean, which defaults
  8727. to "false", that specifies to remove the package after
  8728. the test.
  8729. </para></listitem>
  8730. <listitem><para>"extract" - An optional boolean, which
  8731. defaults to "false", that specifies if the package must
  8732. be extracted from the package format.
  8733. When set to "true", the package is not automatically
  8734. installed into the DUT.
  8735. </para></listitem>
  8736. </itemizedlist>
  8737. </para>
  8738. <para>
  8739. Following is an example JSON file that handles test "foo"
  8740. installing package "bar" and test "foobar" installing
  8741. packages "foo" and "bar".
  8742. Once the test is complete, the packages are removed from the
  8743. DUT.
  8744. <literallayout class='monospaced'>
  8745. {
  8746. "foo": {
  8747. "pkg": "bar"
  8748. },
  8749. "foobar": [
  8750. {
  8751. "pkg": "foo",
  8752. "rm": true
  8753. },
  8754. {
  8755. "pkg": "bar",
  8756. "rm": true
  8757. }
  8758. ]
  8759. }
  8760. </literallayout>
  8761. </para>
  8762. </section>
  8763. </section>
  8764. <section id="platdev-gdb-remotedebug">
  8765. <title>Debugging With the GNU Project Debugger (GDB) Remotely</title>
  8766. <para>
  8767. GDB allows you to examine running programs, which in turn helps you to understand and fix problems.
  8768. It also allows you to perform post-mortem style analysis of program crashes.
  8769. GDB is available as a package within the Yocto Project and is
  8770. installed in SDK images by default.
  8771. See the "<ulink url='&YOCTO_DOCS_REF_URL;#ref-images'>Images</ulink>" chapter
  8772. in the Yocto Project Reference Manual for a description of these images.
  8773. You can find information on GDB at <ulink url="http://sourceware.org/gdb/"/>.
  8774. </para>
  8775. <tip>
  8776. For best results, install debug (<filename>-dbg</filename>) packages
  8777. for the applications you are going to debug.
  8778. Doing so makes extra debug symbols available that give you more
  8779. meaningful output.
  8780. </tip>
  8781. <para>
  8782. Sometimes, due to memory or disk space constraints, it is not possible
  8783. to use GDB directly on the remote target to debug applications.
  8784. These constraints arise because GDB needs to load the debugging information and the
  8785. binaries of the process being debugged.
  8786. Additionally, GDB needs to perform many computations to locate information such as function
  8787. names, variable names and values, stack traces and so forth - even before starting the
  8788. debugging process.
  8789. These extra computations place more load on the target system and can alter the
  8790. characteristics of the program being debugged.
  8791. </para>
  8792. <para>
  8793. To help get past the previously mentioned constraints, you can use Gdbserver.
  8794. Gdbserver runs on the remote target and does not load any debugging information
  8795. from the debugged process.
  8796. Instead, a GDB instance processes the debugging information that is run on a
  8797. remote computer - the host GDB.
  8798. The host GDB then sends control commands to Gdbserver to make it stop or start the debugged
  8799. program, as well as read or write memory regions of that debugged program.
  8800. All the debugging information loaded and processed as well
  8801. as all the heavy debugging is done by the host GDB.
  8802. Offloading these processes gives the Gdbserver running on the target a chance to remain
  8803. small and fast.
  8804. <note>
  8805. By default, source files are part of the
  8806. <filename>*-dbg</filename> packages in order to enable GDB
  8807. to show source lines in its output.
  8808. You can save further space on the target by setting the
  8809. <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_DEBUG_SPLIT_STYLE'><filename>PACKAGE_DEBUG_SPLIT_STYLE</filename></ulink>
  8810. variable to "debug-without-src" so that these packages do not
  8811. include the source files.
  8812. </note>
  8813. </para>
  8814. <para>
  8815. Because the host GDB is responsible for loading the debugging information and
  8816. for doing the necessary processing to make actual debugging happen,
  8817. you have to make sure the host can access the unstripped binaries complete
  8818. with their debugging information and also be sure the target is compiled with no optimizations.
  8819. The host GDB must also have local access to all the libraries used by the
  8820. debugged program.
  8821. Because Gdbserver does not need any local debugging information, the binaries on
  8822. the remote target can remain stripped.
  8823. However, the binaries must also be compiled without optimization
  8824. so they match the host's binaries.
  8825. </para>
  8826. <para>
  8827. To remain consistent with GDB documentation and terminology, the binary being debugged
  8828. on the remote target machine is referred to as the "inferior" binary.
  8829. For documentation on GDB see the
  8830. <ulink url="http://sourceware.org/gdb/documentation/">GDB site</ulink>.
  8831. </para>
  8832. <para>
  8833. The remainder of this section describes the steps you need to take
  8834. to debug using the GNU project debugger.
  8835. </para>
  8836. <section id='platdev-gdb-remotedebug-setup'>
  8837. <title>Set Up the Cross-Development Debugging Environment</title>
  8838. <para>
  8839. Before you can initiate a remote debugging session, you need
  8840. to be sure you have set up the cross-development environment,
  8841. toolchain, and sysroot.
  8842. The <ulink url='&YOCTO_DOCS_SDK_URL;#sdk-intro'>Yocto Project Software Development Kit (SDK) Developer's Guide</ulink>
  8843. describes this process.
  8844. </para>
  8845. </section>
  8846. <section id="platdev-gdb-remotedebug-launch-gdbserver">
  8847. <title>Launch Gdbserver on the Target</title>
  8848. <para>
  8849. Make sure Gdbserver is installed on the target.
  8850. If it is not, install the package
  8851. <filename>gdbserver</filename>, which needs the
  8852. <filename>libthread-db1</filename> package.
  8853. </para>
  8854. <para>
  8855. Here is an example, that when entered from the host,
  8856. connects to the target and launches Gdbserver in order to
  8857. "debug" a binary named <filename>helloworld</filename>:
  8858. <literallayout class='monospaced'>
  8859. $ gdbserver localhost:2345 /usr/bin/helloworld
  8860. </literallayout>
  8861. Gdbserver should now be listening on port 2345 for debugging
  8862. commands coming from a remote GDB process that is running on
  8863. the host computer.
  8864. Communication between Gdbserver and the host GDB are done
  8865. using TCP.
  8866. To use other communication protocols, please refer to the
  8867. <ulink url='http://www.gnu.org/software/gdb/'>Gdbserver documentation</ulink>.
  8868. </para>
  8869. </section>
  8870. <section id="platdev-gdb-remotedebug-launch-gdb">
  8871. <title>Launch GDB on the Host Computer</title>
  8872. <para>
  8873. Running GDB on the host computer takes a number of stages, which
  8874. this section describes.
  8875. </para>
  8876. <section id="platdev-gdb-remotedebug-launch-gdb-buildcross">
  8877. <title>Build the Cross-GDB Package</title>
  8878. <para>
  8879. A suitable GDB cross-binary is required that runs on your
  8880. host computer but also knows about the the ABI of the
  8881. remote target.
  8882. You can get this binary from the
  8883. <link linkend='cross-development-toolchain'>Cross-Development Toolchain</link>.
  8884. Here is an example where the toolchain has been installed
  8885. in the default directory
  8886. <filename>/opt/poky/&DISTRO;</filename>:
  8887. <literallayout class='monospaced'>
  8888. /opt/poky/&DISTRO;/sysroots/i686-pokysdk-linux/usr/bin/armv7a-vfp-neon-poky-linux-gnueabi/arm-poky-linux-gnueabi-gdb
  8889. </literallayout>
  8890. where <filename>arm</filename> is the target architecture
  8891. and <filename>linux-gnueabi</filename> is the target ABI.
  8892. </para>
  8893. <para>
  8894. Alternatively, you can use BitBake to build the
  8895. <filename>gdb-cross</filename> binary.
  8896. Here is an example:
  8897. <literallayout class='monospaced'>
  8898. $ bitbake gdb-cross
  8899. </literallayout>
  8900. Once the binary is built, you can find it here:
  8901. <literallayout class='monospaced'>
  8902. tmp/sysroots/<replaceable>host-arch</replaceable>/usr/bin/<replaceable>target-platform</replaceable>/<replaceable>target-abi</replaceable>-gdb
  8903. </literallayout>
  8904. </para>
  8905. </section>
  8906. <section id='create-the-gdb-initialization-file'>
  8907. <title>Create the GDB Initialization File and Point to Your Root Filesystem</title>
  8908. <para>
  8909. Aside from the GDB cross-binary, you also need a GDB
  8910. initialization file in the same top directory in which
  8911. your binary resides.
  8912. When you start GDB on your host development system, GDB
  8913. finds this initialization file and executes all the
  8914. commands within.
  8915. For information on the <filename>.gdbinit</filename>, see
  8916. "<ulink url='http://sourceware.org/gdb/onlinedocs/gdb/'>Debugging with GDB</ulink>",
  8917. which is maintained by
  8918. <ulink url='http://www.sourceware.org'>sourceware.org</ulink>.
  8919. </para>
  8920. <para>
  8921. You need to add a statement in the
  8922. <filename>~/.gdbinit</filename> file that points to your
  8923. root filesystem.
  8924. Here is an example that points to the root filesystem for
  8925. an ARM-based target device:
  8926. <literallayout class='monospaced'>
  8927. set sysroot ~/sysroot_arm
  8928. </literallayout>
  8929. </para>
  8930. </section>
  8931. <section id="platdev-gdb-remotedebug-launch-gdb-launchhost">
  8932. <title>Launch the Host GDB</title>
  8933. <para>
  8934. Before launching the host GDB, you need to be sure
  8935. you have sourced the cross-debugging environment script,
  8936. which if you installed the root filesystem in the default
  8937. location is at <filename>/opt/poky/&DISTRO;</filename>
  8938. and begins with the string "environment-setup".
  8939. For more information, see the
  8940. <ulink url='&YOCTO_DOCS_SDK_URL;#sdk-manual'>Yocto Project Software Development Kit (SDK) Developer's
  8941. Guide</ulink>.
  8942. </para>
  8943. <para>
  8944. Finally, switch to the directory where the binary resides
  8945. and run the <filename>cross-gdb</filename> binary.
  8946. Provide the binary file you are going to debug.
  8947. For example, the following command continues with the
  8948. example used in the previous section by loading
  8949. the <filename>helloworld</filename> binary as well as the
  8950. debugging information:
  8951. <literallayout class='monospaced'>
  8952. $ arm-poky-linux-gnuabi-gdb helloworld
  8953. </literallayout>
  8954. The commands in your <filename>.gdbinit</filename> execute
  8955. and the GDB prompt appears.
  8956. </para>
  8957. </section>
  8958. </section>
  8959. <section id='platdev-gdb-connect-to-the-remote-gdb-server'>
  8960. <title>Connect to the Remote GDB Server</title>
  8961. <para>
  8962. From the target, you need to connect to the remote GDB
  8963. server that is running on the host.
  8964. You need to specify the remote host and port.
  8965. Here is the command continuing with the example:
  8966. <literallayout class='monospaced'>
  8967. target remote 192.168.7.2:2345
  8968. </literallayout>
  8969. </para>
  8970. </section>
  8971. <section id="platdev-gdb-remotedebug-launch-gdb-using">
  8972. <title>Use the Debugger</title>
  8973. <para>
  8974. You can now proceed with debugging as normal - as if you were debugging
  8975. on the local machine.
  8976. For example, to instruct GDB to break in the "main" function and then
  8977. continue with execution of the inferior binary use the following commands
  8978. from within GDB:
  8979. <literallayout class='monospaced'>
  8980. (gdb) break main
  8981. (gdb) continue
  8982. </literallayout>
  8983. </para>
  8984. <para>
  8985. For more information about using GDB, see the project's online documentation at
  8986. <ulink url="http://sourceware.org/gdb/download/onlinedocs/"/>.
  8987. </para>
  8988. </section>
  8989. </section>
  8990. <section id='debugging-parallel-make-races'>
  8991. <title>Debugging Parallel Make Races</title>
  8992. <para>
  8993. A parallel <filename>make</filename> race occurs when the build
  8994. consists of several parts that are run simultaneously and
  8995. a situation occurs when the output or result of one
  8996. part is not ready for use with a different part of the build that
  8997. depends on that output.
  8998. Parallel make races are annoying and can sometimes be difficult
  8999. to reproduce and fix.
  9000. However, some simple tips and tricks exist that can help
  9001. you debug and fix them.
  9002. This section presents a real-world example of an error encountered
  9003. on the Yocto Project autobuilder and the process used to fix it.
  9004. <note>
  9005. If you cannot properly fix a <filename>make</filename> race
  9006. condition, you can work around it by clearing either the
  9007. <ulink url='&YOCTO_DOCS_REF_URL;#var-PARALLEL_MAKE'><filename>PARALLEL_MAKE</filename></ulink>
  9008. or
  9009. <ulink url='&YOCTO_DOCS_REF_URL;#var-PARALLEL_MAKEINST'><filename>PARALLEL_MAKEINST</filename></ulink>
  9010. variables.
  9011. </note>
  9012. </para>
  9013. <section id='the-failure'>
  9014. <title>The Failure</title>
  9015. <para>
  9016. For this example, assume that you are building an image that
  9017. depends on the "neard" package.
  9018. And, during the build, BitBake runs into problems and
  9019. creates the following output.
  9020. <note>
  9021. This example log file has longer lines artificially
  9022. broken to make the listing easier to read.
  9023. </note>
  9024. If you examine the output or the log file, you see the
  9025. failure during <filename>make</filename>:
  9026. <literallayout class='monospaced'>
  9027. | DEBUG: SITE files ['endian-little', 'bit-32', 'ix86-common', 'common-linux', 'common-glibc', 'i586-linux', 'common']
  9028. | DEBUG: Executing shell function do_compile
  9029. | NOTE: make -j 16
  9030. | make --no-print-directory all-am
  9031. | /bin/mkdir -p include/near
  9032. | /bin/mkdir -p include/near
  9033. | /bin/mkdir -p include/near
  9034. | ln -s /home/pokybuild/yocto-autobuilder/yocto-slave/nightly-x86/build/build/tmp/work/i586-poky-linux/neard/
  9035. 0.14-r0/neard-0.14/include/types.h include/near/types.h
  9036. | ln -s /home/pokybuild/yocto-autobuilder/yocto-slave/nightly-x86/build/build/tmp/work/i586-poky-linux/neard/
  9037. 0.14-r0/neard-0.14/include/log.h include/near/log.h
  9038. | ln -s /home/pokybuild/yocto-autobuilder/yocto-slave/nightly-x86/build/build/tmp/work/i586-poky-linux/neard/
  9039. 0.14-r0/neard-0.14/include/plugin.h include/near/plugin.h
  9040. | /bin/mkdir -p include/near
  9041. | /bin/mkdir -p include/near
  9042. | /bin/mkdir -p include/near
  9043. | ln -s /home/pokybuild/yocto-autobuilder/yocto-slave/nightly-x86/build/build/tmp/work/i586-poky-linux/neard/
  9044. 0.14-r0/neard-0.14/include/tag.h include/near/tag.h
  9045. | /bin/mkdir -p include/near
  9046. | ln -s /home/pokybuild/yocto-autobuilder/yocto-slave/nightly-x86/build/build/tmp/work/i586-poky-linux/neard/
  9047. 0.14-r0/neard-0.14/include/adapter.h include/near/adapter.h
  9048. | /bin/mkdir -p include/near
  9049. | ln -s /home/pokybuild/yocto-autobuilder/yocto-slave/nightly-x86/build/build/tmp/work/i586-poky-linux/neard/
  9050. 0.14-r0/neard-0.14/include/ndef.h include/near/ndef.h
  9051. | ln -s /home/pokybuild/yocto-autobuilder/yocto-slave/nightly-x86/build/build/tmp/work/i586-poky-linux/neard/
  9052. 0.14-r0/neard-0.14/include/tlv.h include/near/tlv.h
  9053. | /bin/mkdir -p include/near
  9054. | /bin/mkdir -p include/near
  9055. | ln -s /home/pokybuild/yocto-autobuilder/yocto-slave/nightly-x86/build/build/tmp/work/i586-poky-linux/neard/
  9056. 0.14-r0/neard-0.14/include/setting.h include/near/setting.h
  9057. | /bin/mkdir -p include/near
  9058. | /bin/mkdir -p include/near
  9059. | /bin/mkdir -p include/near
  9060. | ln -s /home/pokybuild/yocto-autobuilder/yocto-slave/nightly-x86/build/build/tmp/work/i586-poky-linux/neard/
  9061. 0.14-r0/neard-0.14/include/device.h include/near/device.h
  9062. | ln -s /home/pokybuild/yocto-autobuilder/yocto-slave/nightly-x86/build/build/tmp/work/i586-poky-linux/neard/
  9063. 0.14-r0/neard-0.14/include/nfc_copy.h include/near/nfc_copy.h
  9064. | ln -s /home/pokybuild/yocto-autobuilder/yocto-slave/nightly-x86/build/build/tmp/work/i586-poky-linux/neard/
  9065. 0.14-r0/neard-0.14/include/snep.h include/near/snep.h
  9066. | ln -s /home/pokybuild/yocto-autobuilder/yocto-slave/nightly-x86/build/build/tmp/work/i586-poky-linux/neard/
  9067. 0.14-r0/neard-0.14/include/version.h include/near/version.h
  9068. | ln -s /home/pokybuild/yocto-autobuilder/yocto-slave/nightly-x86/build/build/tmp/work/i586-poky-linux/neard/
  9069. 0.14-r0/neard-0.14/include/dbus.h include/near/dbus.h
  9070. | ./src/genbuiltin nfctype1 nfctype2 nfctype3 nfctype4 p2p > src/builtin.h
  9071. | i586-poky-linux-gcc -m32 -march=i586 --sysroot=/home/pokybuild/yocto-autobuilder/yocto-slave/nightly-x86/
  9072. build/build/tmp/sysroots/qemux86 -DHAVE_CONFIG_H -I. -I./include -I./src -I./gdbus -I/home/pokybuild/
  9073. yocto-autobuilder/yocto-slave/nightly-x86/build/build/tmp/sysroots/qemux86/usr/include/glib-2.0
  9074. -I/home/pokybuild/yocto-autobuilder/yocto-slave/nightly-x86/build/build/tmp/sysroots/qemux86/usr/
  9075. lib/glib-2.0/include -I/home/pokybuild/yocto-autobuilder/yocto-slave/nightly-x86/build/build/
  9076. tmp/sysroots/qemux86/usr/include/dbus-1.0 -I/home/pokybuild/yocto-autobuilder/yocto-slave/
  9077. nightly-x86/build/build/tmp/sysroots/qemux86/usr/lib/dbus-1.0/include -I/home/pokybuild/yocto-autobuilder/
  9078. yocto-slave/nightly-x86/build/build/tmp/sysroots/qemux86/usr/include/libnl3
  9079. -DNEAR_PLUGIN_BUILTIN -DPLUGINDIR=\""/usr/lib/near/plugins"\"
  9080. -DCONFIGDIR=\""/etc/neard\"" -O2 -pipe -g -feliminate-unused-debug-types -c
  9081. -o tools/snep-send.o tools/snep-send.c
  9082. | In file included from tools/snep-send.c:16:0:
  9083. | tools/../src/near.h:41:23: fatal error: near/dbus.h: No such file or directory
  9084. | #include &lt;near/dbus.h&gt;
  9085. | ^
  9086. | compilation terminated.
  9087. | make[1]: *** [tools/snep-send.o] Error 1
  9088. | make[1]: *** Waiting for unfinished jobs....
  9089. | make: *** [all] Error 2
  9090. | ERROR: oe_runmake failed
  9091. </literallayout>
  9092. </para>
  9093. </section>
  9094. <section id='reproducing-the-error'>
  9095. <title>Reproducing the Error</title>
  9096. <para>
  9097. Because race conditions are intermittent, they do not
  9098. manifest themselves every time you do the build.
  9099. In fact, most times the build will complete without problems
  9100. even though the potential race condition exists.
  9101. Thus, once the error surfaces, you need a way to reproduce it.
  9102. </para>
  9103. <para>
  9104. In this example, compiling the "neard" package is causing the
  9105. problem.
  9106. So the first thing to do is build "neard" locally.
  9107. Before you start the build, set the
  9108. <ulink url='&YOCTO_DOCS_REF_URL;#var-PARALLEL_MAKE'><filename>PARALLEL_MAKE</filename></ulink>
  9109. variable in your <filename>local.conf</filename> file to
  9110. a high number (e.g. "-j 20").
  9111. Using a high value for <filename>PARALLEL_MAKE</filename>
  9112. increases the chances of the race condition showing up:
  9113. <literallayout class='monospaced'>
  9114. $ bitbake neard
  9115. </literallayout>
  9116. </para>
  9117. <para>
  9118. Once the local build for "neard" completes, start a
  9119. <filename>devshell</filename> build:
  9120. <literallayout class='monospaced'>
  9121. $ bitbake neard -c devshell
  9122. </literallayout>
  9123. For information on how to use a
  9124. <filename>devshell</filename>, see the
  9125. "<link linkend='platdev-appdev-devshell'>Using a Development Shell</link>"
  9126. section.
  9127. </para>
  9128. <para>
  9129. In the <filename>devshell</filename>, do the following:
  9130. <literallayout class='monospaced'>
  9131. $ make clean
  9132. $ make tools/snep-send.o
  9133. </literallayout>
  9134. The <filename>devshell</filename> commands cause the failure
  9135. to clearly be visible.
  9136. In this case, a missing dependency exists for the "neard"
  9137. Makefile target.
  9138. Here is some abbreviated, sample output with the
  9139. missing dependency clearly visible at the end:
  9140. <literallayout class='monospaced'>
  9141. i586-poky-linux-gcc -m32 -march=i586 --sysroot=/home/scott-lenovo/......
  9142. .
  9143. .
  9144. .
  9145. tools/snep-send.c
  9146. In file included from tools/snep-send.c:16:0:
  9147. tools/../src/near.h:41:23: fatal error: near/dbus.h: No such file or directory
  9148. #include &lt;near/dbus.h&gt;
  9149. ^
  9150. compilation terminated.
  9151. make: *** [tools/snep-send.o] Error 1
  9152. $
  9153. </literallayout>
  9154. </para>
  9155. </section>
  9156. <section id='creating-a-patch-for-the-fix'>
  9157. <title>Creating a Patch for the Fix</title>
  9158. <para>
  9159. Because there is a missing dependency for the Makefile
  9160. target, you need to patch the
  9161. <filename>Makefile.am</filename> file, which is generated
  9162. from <filename>Makefile.in</filename>.
  9163. You can use Quilt to create the patch:
  9164. <literallayout class='monospaced'>
  9165. $ quilt new parallelmake.patch
  9166. Patch patches/parallelmake.patch is now on top
  9167. $ quilt add Makefile.am
  9168. File Makefile.am added to patch patches/parallelmake.patch
  9169. </literallayout>
  9170. For more information on using Quilt, see the
  9171. "<link linkend='using-a-quilt-workflow'>Using Quilt in Your Workflow</link>"
  9172. section.
  9173. </para>
  9174. <para>
  9175. At this point you need to make the edits to
  9176. <filename>Makefile.am</filename> to add the missing
  9177. dependency.
  9178. For our example, you have to add the following line
  9179. to the file:
  9180. <literallayout class='monospaced'>
  9181. tools/snep-send.$(OBJEXT): include/near/dbus.h
  9182. </literallayout>
  9183. </para>
  9184. <para>
  9185. Once you have edited the file, use the
  9186. <filename>refresh</filename> command to create the patch:
  9187. <literallayout class='monospaced'>
  9188. $ quilt refresh
  9189. Refreshed patch patches/parallelmake.patch
  9190. </literallayout>
  9191. Once the patch file exists, you need to add it back to the
  9192. originating recipe folder.
  9193. Here is an example assuming a top-level
  9194. <link linkend='source-directory'>Source Directory</link>
  9195. named <filename>poky</filename>:
  9196. <literallayout class='monospaced'>
  9197. $ cp patches/parallelmake.patch poky/meta/recipes-connectivity/neard/neard
  9198. </literallayout>
  9199. The final thing you need to do to implement the fix in the
  9200. build is to update the "neard" recipe (i.e.
  9201. <filename>neard-0.14.bb</filename>) so that the
  9202. <ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'><filename>SRC_URI</filename></ulink>
  9203. statement includes the patch file.
  9204. The recipe file is in the folder above the patch.
  9205. Here is what the edited <filename>SRC_URI</filename>
  9206. statement would look like:
  9207. <literallayout class='monospaced'>
  9208. SRC_URI = "${KERNELORG_MIRROR}/linux/network/nfc/${BPN}-${PV}.tar.xz \
  9209. file://neard.in \
  9210. file://neard.service.in \
  9211. file://parallelmake.patch \
  9212. "
  9213. </literallayout>
  9214. </para>
  9215. <para>
  9216. With the patch complete and moved to the correct folder and
  9217. the <filename>SRC_URI</filename> statement updated, you can
  9218. exit the <filename>devshell</filename>:
  9219. <literallayout class='monospaced'>
  9220. $ exit
  9221. </literallayout>
  9222. </para>
  9223. </section>
  9224. <section id='testing-the-build'>
  9225. <title>Testing the Build</title>
  9226. <para>
  9227. With everything in place, you can get back to trying the
  9228. build again locally:
  9229. <literallayout class='monospaced'>
  9230. $ bitbake neard
  9231. </literallayout>
  9232. This build should succeed.
  9233. </para>
  9234. <para>
  9235. Now you can open up a <filename>devshell</filename> again
  9236. and repeat the clean and make operations as follows:
  9237. <literallayout class='monospaced'>
  9238. $ bitbake neard -c devshell
  9239. $ make clean
  9240. $ make tools/snep-send.o
  9241. </literallayout>
  9242. The build should work without issue.
  9243. </para>
  9244. <para>
  9245. As with all solved problems, if they originated upstream, you
  9246. need to submit the fix for the recipe in OE-Core and upstream
  9247. so that the problem is taken care of at its source.
  9248. See the
  9249. "<link linkend='how-to-submit-a-change'>How to Submit a Change</link>"
  9250. section for more information.
  9251. </para>
  9252. </section>
  9253. </section>
  9254. <!--
  9255. <section id="platdev-oprofile">
  9256. <title>Profiling with OProfile</title>
  9257. <para>
  9258. <ulink url="http://oprofile.sourceforge.net/">OProfile</ulink> is a
  9259. statistical profiler well suited for finding performance
  9260. bottlenecks in both user-space software and in the kernel.
  9261. This profiler provides answers to questions like "Which functions does my application spend
  9262. the most time in when doing X?"
  9263. Because the OpenEmbedded build system is well integrated with OProfile, it makes profiling
  9264. applications on target hardware straight forward.
  9265. <note>
  9266. For more information on how to set up and run OProfile, see the
  9267. "<ulink url='&YOCTO_DOCS_PROF_URL;#profile-manual-oprofile'>oprofile</ulink>"
  9268. section in the Yocto Project Profiling and Tracing Manual.
  9269. </note>
  9270. </para>
  9271. <para>
  9272. To use OProfile, you need an image that has OProfile installed.
  9273. The easiest way to do this is with "tools-profile" in the
  9274. <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-IMAGE_FEATURES'>IMAGE_FEATURES</ulink></filename> variable.
  9275. You also need debugging symbols to be available on the system where the analysis
  9276. takes place.
  9277. You can gain access to the symbols by using "dbg-pkgs" in the
  9278. <filename>IMAGE_FEATURES</filename> variable or by
  9279. installing the appropriate debug (<filename>-dbg</filename>)
  9280. packages.
  9281. </para>
  9282. <para>
  9283. For successful call graph analysis, the binaries must preserve the frame
  9284. pointer register and should also be compiled with the
  9285. <filename>-fno-omit-framepointer</filename> flag.
  9286. You can achieve this by setting the
  9287. <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-SELECTED_OPTIMIZATION'>SELECTED_OPTIMIZATION</ulink></filename>
  9288. variable with the following options:
  9289. <literallayout class='monospaced'>
  9290. -fexpensive-optimizations
  9291. -fno-omit-framepointer
  9292. -frename-registers
  9293. -O2
  9294. </literallayout>
  9295. You can also achieve it by setting the
  9296. <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-DEBUG_BUILD'>DEBUG_BUILD</ulink></filename>
  9297. variable to "1" in the <filename>local.conf</filename> configuration file.
  9298. If you use the <filename>DEBUG_BUILD</filename> variable,
  9299. you also add extra debugging information that can make the debug
  9300. packages large.
  9301. </para>
  9302. <section id="platdev-oprofile-target">
  9303. <title>Profiling on the Target</title>
  9304. <para>
  9305. Using OProfile, you can perform all the profiling work on the target device.
  9306. A simple OProfile session might look like the following:
  9307. </para>
  9308. <para>
  9309. <literallayout class='monospaced'>
  9310. # opcontrol &dash;&dash;reset
  9311. # opcontrol &dash;&dash;start &dash;&dash;separate=lib &dash;&dash;no-vmlinux -c 5
  9312. .
  9313. .
  9314. [do whatever is being profiled]
  9315. .
  9316. .
  9317. # opcontrol &dash;&dash;stop
  9318. $ opreport -cl
  9319. </literallayout>
  9320. </para>
  9321. <para>
  9322. In this example, the <filename>reset</filename> command clears any previously profiled data.
  9323. The next command starts OProfile.
  9324. The options used when starting the profiler separate dynamic library data
  9325. within applications, disable kernel profiling, and enable callgraphing up to
  9326. five levels deep.
  9327. <note>
  9328. To profile the kernel, you would specify the
  9329. <filename>&dash;&dash;vmlinux=/path/to/vmlinux</filename> option.
  9330. The <filename>vmlinux</filename> file is usually in the source directory in the
  9331. <filename>/boot/</filename> directory and must match the running kernel.
  9332. </note>
  9333. </para>
  9334. <para>
  9335. After you perform your profiling tasks, the next command stops the profiler.
  9336. After that, you can view results with the <filename>opreport</filename> command with options
  9337. to see the separate library symbols and callgraph information.
  9338. </para>
  9339. <para>
  9340. Callgraphing logs information about time spent in functions and about a function's
  9341. calling function (parent) and called functions (children).
  9342. The higher the callgraphing depth, the more accurate the results.
  9343. However, higher depths also increase the logging overhead.
  9344. Consequently, you should take care when setting the callgraphing depth.
  9345. <note>
  9346. On ARM, binaries need to have the frame pointer enabled for callgraphing to work.
  9347. To accomplish this use the <filename>-fno-omit-framepointer</filename> option
  9348. with <filename>gcc</filename>.
  9349. </note>
  9350. </para>
  9351. <para>
  9352. For more information on using OProfile, see the OProfile
  9353. online documentation at
  9354. <ulink url="http://oprofile.sourceforge.net/docs/"/>.
  9355. </para>
  9356. </section>
  9357. <section id="platdev-oprofile-oprofileui">
  9358. <title>Using OProfileUI</title>
  9359. <para>
  9360. A graphical user interface for OProfile is also available.
  9361. You can download and build this interface from the Yocto Project at
  9362. <ulink url="&YOCTO_GIT_URL;/cgit.cgi/oprofileui/"></ulink>.
  9363. If the "tools-profile" image feature is selected, all necessary binaries
  9364. are installed onto the target device for OProfileUI interaction.
  9365. For a list of image features that ship with the Yocto Project,
  9366. see the
  9367. "<ulink url='&YOCTO_DOCS_REF_URL;#ref-features-image'>Image Features</ulink>"
  9368. section in the Yocto Project Reference Manual.
  9369. </para>
  9370. <para>
  9371. Even though the source directory usually includes all needed patches on the target device, you
  9372. might find you need other OProfile patches for recent OProfileUI features.
  9373. If so, see the <ulink url='&YOCTO_GIT_URL;/cgit.cgi/oprofileui/tree/README'>
  9374. OProfileUI README</ulink> for the most recent information.
  9375. </para>
  9376. <section id="platdev-oprofile-oprofileui-online">
  9377. <title>Online Mode</title>
  9378. <para>
  9379. Using OProfile in online mode assumes a working network connection with the target
  9380. hardware.
  9381. With this connection, you just need to run "oprofile-server" on the device.
  9382. By default, OProfile listens on port 4224.
  9383. <note>
  9384. You can change the port using the <filename>&dash;&dash;port</filename> command-line
  9385. option.
  9386. </note>
  9387. </para>
  9388. <para>
  9389. The client program is called <filename>oprofile-viewer</filename> and its UI is relatively
  9390. straight forward.
  9391. You access key functionality through the buttons on the toolbar, which
  9392. are duplicated in the menus.
  9393. Here are the buttons:
  9394. <itemizedlist>
  9395. <listitem><para><emphasis>Connect:</emphasis> Connects to the remote host.
  9396. You can also supply the IP address or hostname.</para></listitem>
  9397. <listitem><para><emphasis>Disconnect:</emphasis> Disconnects from the target.
  9398. </para></listitem>
  9399. <listitem><para><emphasis>Start:</emphasis> Starts profiling on the device.
  9400. </para></listitem>
  9401. <listitem><para><emphasis>Stop:</emphasis> Stops profiling on the device and
  9402. downloads the data to the local host.
  9403. Stopping the profiler generates the profile and displays it in the viewer.
  9404. </para></listitem>
  9405. <listitem><para><emphasis>Download:</emphasis> Downloads the data from the
  9406. target and generates the profile, which appears in the viewer.</para></listitem>
  9407. <listitem><para><emphasis>Reset:</emphasis> Resets the sample data on the device.
  9408. Resetting the data removes sample information collected from previous
  9409. sampling runs.
  9410. Be sure you reset the data if you do not want to include old sample information.
  9411. </para></listitem>
  9412. <listitem><para><emphasis>Save:</emphasis> Saves the data downloaded from the
  9413. target to another directory for later examination.</para></listitem>
  9414. <listitem><para><emphasis>Open:</emphasis> Loads previously saved data.
  9415. </para></listitem>
  9416. </itemizedlist>
  9417. </para>
  9418. <para>
  9419. The client downloads the complete profile archive from
  9420. the target to the host for processing.
  9421. This archive is a directory that contains the sample data, the object files,
  9422. and the debug information for the object files.
  9423. The archive is then converted using the <filename>oparchconv</filename> script, which is
  9424. included in this distribution.
  9425. The script uses <filename>opimport</filename> to convert the archive from
  9426. the target to something that can be processed on the host.
  9427. </para>
  9428. <para>
  9429. Downloaded archives reside in the
  9430. <link linkend='build-directory'>Build Directory</link> in
  9431. <filename>tmp</filename> and are cleared up when they are no longer in use.
  9432. </para>
  9433. <para>
  9434. If you wish to perform kernel profiling, you need to be sure
  9435. a <filename>vmlinux</filename> file that matches the running kernel is available.
  9436. In the source directory, that file is usually located in
  9437. <filename>/boot/vmlinux-<replaceable>kernelversion</replaceable></filename>, where
  9438. <filename><replaceable>kernelversion</replaceable></filename> is the version of the kernel.
  9439. The OpenEmbedded build system generates separate <filename>vmlinux</filename>
  9440. packages for each kernel it builds.
  9441. Thus, it should just be a question of making sure a matching package is
  9442. installed (e.g. <filename>opkg install kernel-vmlinux</filename>).
  9443. The files are automatically installed into development and profiling images
  9444. alongside OProfile.
  9445. A configuration option exists within the OProfileUI settings page that you can use to
  9446. enter the location of the <filename>vmlinux</filename> file.
  9447. </para>
  9448. <para>
  9449. Waiting for debug symbols to transfer from the device can be slow, and it
  9450. is not always necessary to actually have them on the device for OProfile use.
  9451. All that is needed is a copy of the filesystem with the debug symbols present
  9452. on the viewer system.
  9453. The "<link linkend='platdev-gdb-remotedebug-launch-gdb'>Launch GDB on the Host Computer</link>"
  9454. section covers how to create such a directory within
  9455. the source directory and how to use the OProfileUI Settings
  9456. Dialog to specify the location.
  9457. If you specify the directory, it will be used when the file checksums
  9458. match those on the system you are profiling.
  9459. </para>
  9460. </section>
  9461. <section id="platdev-oprofile-oprofileui-offline">
  9462. <title>Offline Mode</title>
  9463. <para>
  9464. If network access to the target is unavailable, you can generate
  9465. an archive for processing in <filename>oprofile-viewer</filename> as follows:
  9466. <literallayout class='monospaced'>
  9467. # opcontrol &dash;&dash;reset
  9468. # opcontrol &dash;&dash;start &dash;&dash;separate=lib &dash;&dash;no-vmlinux -c 5
  9469. .
  9470. .
  9471. [do whatever is being profiled]
  9472. .
  9473. .
  9474. # opcontrol &dash;&dash;stop
  9475. # oparchive -o my_archive
  9476. </literallayout>
  9477. </para>
  9478. <para>
  9479. In the above example, <filename>my_archive</filename> is the name of the
  9480. archive directory where you would like the profile archive to be kept.
  9481. After the directory is created, you can copy it to another host and load it
  9482. using <filename>oprofile-viewer</filename> open functionality.
  9483. If necessary, the archive is converted.
  9484. </para>
  9485. </section>
  9486. </section>
  9487. </section>
  9488. -->
  9489. <section id='maintaining-open-source-license-compliance-during-your-products-lifecycle'>
  9490. <title>Maintaining Open Source License Compliance During Your Product's Lifecycle</title>
  9491. <para>
  9492. One of the concerns for a development organization using open source
  9493. software is how to maintain compliance with various open source
  9494. licensing during the lifecycle of the product.
  9495. While this section does not provide legal advice or
  9496. comprehensively cover all scenarios, it does
  9497. present methods that you can use to
  9498. assist you in meeting the compliance requirements during a software
  9499. release.
  9500. </para>
  9501. <para>
  9502. With hundreds of different open source licenses that the Yocto
  9503. Project tracks, it is difficult to know the requirements of each
  9504. and every license.
  9505. However, the requirements of the major FLOSS licenses can begin
  9506. to be covered by
  9507. assuming that three main areas of concern exist:
  9508. <itemizedlist>
  9509. <listitem><para>Source code must be provided.</para></listitem>
  9510. <listitem><para>License text for the software must be
  9511. provided.</para></listitem>
  9512. <listitem><para>Compilation scripts and modifications to the
  9513. source code must be provided.
  9514. </para></listitem>
  9515. </itemizedlist>
  9516. There are other requirements beyond the scope of these
  9517. three and the methods described in this section
  9518. (e.g. the mechanism through which source code is distributed).
  9519. </para>
  9520. <para>
  9521. As different organizations have different methods of complying with
  9522. open source licensing, this section is not meant to imply that
  9523. there is only one single way to meet your compliance obligations,
  9524. but rather to describe one method of achieving compliance.
  9525. The remainder of this section describes methods supported to meet the
  9526. previously mentioned three requirements.
  9527. Once you take steps to meet these requirements,
  9528. and prior to releasing images, sources, and the build system,
  9529. you should audit all artifacts to ensure completeness.
  9530. <note>
  9531. The Yocto Project generates a license manifest during
  9532. image creation that is located
  9533. in <filename>${DEPLOY_DIR}/licenses/<replaceable>image_name-datestamp</replaceable></filename>
  9534. to assist with any audits.
  9535. </note>
  9536. </para>
  9537. <section id='providing-the-source-code'>
  9538. <title>Providing the Source Code</title>
  9539. <para>
  9540. Compliance activities should begin before you generate the
  9541. final image.
  9542. The first thing you should look at is the requirement that
  9543. tops the list for most compliance groups - providing
  9544. the source.
  9545. The Yocto Project has a few ways of meeting this
  9546. requirement.
  9547. </para>
  9548. <para>
  9549. One of the easiest ways to meet this requirement is
  9550. to provide the entire
  9551. <ulink url='&YOCTO_DOCS_REF_URL;#var-DL_DIR'><filename>DL_DIR</filename></ulink>
  9552. used by the build.
  9553. This method, however, has a few issues.
  9554. The most obvious is the size of the directory since it includes
  9555. all sources used in the build and not just the source used in
  9556. the released image.
  9557. It will include toolchain source, and other artifacts, which
  9558. you would not generally release.
  9559. However, the more serious issue for most companies is accidental
  9560. release of proprietary software.
  9561. The Yocto Project provides an
  9562. <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-archiver'><filename>archiver</filename></ulink>
  9563. class to help avoid some of these concerns.
  9564. </para>
  9565. <para>
  9566. Before you employ <filename>DL_DIR</filename> or the
  9567. archiver class, you need to decide how you choose to
  9568. provide source.
  9569. The source archiver class can generate tarballs and SRPMs
  9570. and can create them with various levels of compliance in mind.
  9571. </para>
  9572. <para>
  9573. One way of doing this (but certainly not the only way) is to
  9574. release just the source as a tarball.
  9575. You can do this by adding the following to the
  9576. <filename>local.conf</filename> file found in the
  9577. <link linkend='build-directory'>Build Directory</link>:
  9578. <literallayout class='monospaced'>
  9579. INHERIT += "archiver"
  9580. ARCHIVER_MODE[src] = "original"
  9581. </literallayout>
  9582. During the creation of your image, the source from all
  9583. recipes that deploy packages to the image is placed within
  9584. subdirectories of
  9585. <filename>DEPLOY_DIR/sources</filename> based on the
  9586. <ulink url='&YOCTO_DOCS_REF_URL;#var-LICENSE'><filename>LICENSE</filename></ulink>
  9587. for each recipe.
  9588. Releasing the entire directory enables you to comply with
  9589. requirements concerning providing the unmodified source.
  9590. It is important to note that the size of the directory can
  9591. get large.
  9592. </para>
  9593. <para>
  9594. A way to help mitigate the size issue is to only release
  9595. tarballs for licenses that require the release of
  9596. source.
  9597. Let us assume you are only concerned with GPL code as
  9598. identified with the following:
  9599. <literallayout class='monospaced'>
  9600. $ cd poky/build/tmp/deploy/sources
  9601. $ mkdir ~/gpl_source_release
  9602. $ for dir in */*GPL*; do cp -r $dir ~/gpl_source_release; done
  9603. </literallayout>
  9604. At this point, you could create a tarball from the
  9605. <filename>gpl_source_release</filename> directory and
  9606. provide that to the end user.
  9607. This method would be a step toward achieving compliance
  9608. with section 3a of GPLv2 and with section 6 of GPLv3.
  9609. </para>
  9610. </section>
  9611. <section id='providing-license-text'>
  9612. <title>Providing License Text</title>
  9613. <para>
  9614. One requirement that is often overlooked is inclusion
  9615. of license text.
  9616. This requirement also needs to be dealt with prior to
  9617. generating the final image.
  9618. Some licenses require the license text to accompany
  9619. the binary.
  9620. You can achieve this by adding the following to your
  9621. <filename>local.conf</filename> file:
  9622. <literallayout class='monospaced'>
  9623. COPY_LIC_MANIFEST = "1"
  9624. COPY_LIC_DIRS = "1"
  9625. LICENSE_CREATE_PACKAGE = "1"
  9626. </literallayout>
  9627. Adding these statements to the configuration file ensures
  9628. that the licenses collected during package generation
  9629. are included on your image.
  9630. <note>
  9631. <para>Setting all three variables to "1" results in the
  9632. image having two copies of the same license file.
  9633. One copy resides in
  9634. <filename>/usr/share/common-licenses</filename> and
  9635. the other resides in
  9636. <filename>/usr/share/license</filename>.</para>
  9637. <para>The reason for this behavior is because
  9638. <ulink url='&YOCTO_DOCS_REF_URL;#var-COPY_LIC_DIRS'><filename>COPY_LIC_DIRS</filename></ulink>
  9639. and
  9640. <ulink url='&YOCTO_DOCS_REF_URL;#var-COPY_LIC_MANIFEST'><filename>COPY_LIC_MANIFEST</filename></ulink>
  9641. add a copy of the license when the image is built but do not
  9642. offer a path for adding licenses for newly installed packages
  9643. to an image.
  9644. <ulink url='&YOCTO_DOCS_REF_URL;#var-LICENSE_CREATE_PACKAGE'><filename>LICENSE_CREATE_PACKAGE</filename></ulink>
  9645. adds a separate package and an upgrade path for adding
  9646. licenses to an image.</para>
  9647. </note>
  9648. </para>
  9649. <para>
  9650. As the source archiver has already archived the original
  9651. unmodified source that contains the license files,
  9652. you would have already met the requirements for inclusion
  9653. of the license information with source as defined by the GPL
  9654. and other open source licenses.
  9655. </para>
  9656. </section>
  9657. <section id='providing-compilation-scripts-and-source-code-modifications'>
  9658. <title>Providing Compilation Scripts and Source Code Modifications</title>
  9659. <para>
  9660. At this point, we have addressed all we need to address
  9661. prior to generating the image.
  9662. The next two requirements are addressed during the final
  9663. packaging of the release.
  9664. </para>
  9665. <para>
  9666. By releasing the version of the OpenEmbedded build system
  9667. and the layers used during the build, you will be providing both
  9668. compilation scripts and the source code modifications in one
  9669. step.
  9670. </para>
  9671. <para>
  9672. If the deployment team has a
  9673. <ulink url='&YOCTO_DOCS_BSP_URL;#bsp-layers'>BSP layer</ulink>
  9674. and a distro layer, and those those layers are used to patch,
  9675. compile, package, or modify (in any way) any open source
  9676. software included in your released images, you
  9677. might be required to to release those layers under section 3 of
  9678. GPLv2 or section 1 of GPLv3.
  9679. One way of doing that is with a clean
  9680. checkout of the version of the Yocto Project and layers used
  9681. during your build.
  9682. Here is an example:
  9683. <literallayout class='monospaced'>
  9684. # We built using the &DISTRO_NAME_NO_CAP; branch of the poky repo
  9685. $ git clone -b &DISTRO_NAME_NO_CAP; git://git.yoctoproject.org/poky
  9686. $ cd poky
  9687. # We built using the release_branch for our layers
  9688. $ git clone -b release_branch git://git.mycompany.com/meta-my-bsp-layer
  9689. $ git clone -b release_branch git://git.mycompany.com/meta-my-software-layer
  9690. # clean up the .git repos
  9691. $ find . -name ".git" -type d -exec rm -rf {} \;
  9692. </literallayout>
  9693. One thing a development organization might want to consider
  9694. for end-user convenience is to modify
  9695. <filename>meta-poky/conf/bblayers.conf.sample</filename> to
  9696. ensure that when the end user utilizes the released build
  9697. system to build an image, the development organization's
  9698. layers are included in the <filename>bblayers.conf</filename>
  9699. file automatically:
  9700. <literallayout class='monospaced'>
  9701. # LAYER_CONF_VERSION is increased each time build/conf/bblayers.conf
  9702. # changes incompatibly
  9703. LCONF_VERSION = "6"
  9704. BBPATH = "${TOPDIR}"
  9705. BBFILES ?= ""
  9706. BBLAYERS ?= " \
  9707. ##OEROOT##/meta \
  9708. ##OEROOT##/meta-poky \
  9709. ##OEROOT##/meta-yocto-bsp \
  9710. ##OEROOT##/meta-mylayer \
  9711. "
  9712. </literallayout>
  9713. Creating and providing an archive of the
  9714. <link linkend='metadata'>Metadata</link> layers
  9715. (recipes, configuration files, and so forth)
  9716. enables you to meet your
  9717. requirements to include the scripts to control compilation
  9718. as well as any modifications to the original source.
  9719. </para>
  9720. </section>
  9721. </section>
  9722. <section id='using-the-error-reporting-tool'>
  9723. <title>Using the Error Reporting Tool</title>
  9724. <para>
  9725. The error reporting tool allows you to
  9726. submit errors encountered during builds to a central database.
  9727. Outside of the build environment, you can use a web interface to
  9728. browse errors, view statistics, and query for errors.
  9729. The tool works using a client-server system where the client
  9730. portion is integrated with the installed Yocto Project
  9731. <link linkend='source-directory'>Source Directory</link>
  9732. (e.g. <filename>poky</filename>).
  9733. The server receives the information collected and saves it in a
  9734. database.
  9735. </para>
  9736. <para>
  9737. A live instance of the error reporting server exists at
  9738. <ulink url='http://errors.yoctoproject.org'></ulink>.
  9739. This server exists so that when you want to get help with
  9740. build failures, you can submit all of the information on the
  9741. failure easily and then point to the URL in your bug report
  9742. or send an email to the mailing list.
  9743. <note>
  9744. If you send error reports to this server, the reports become
  9745. publicly visible.
  9746. </note>
  9747. </para>
  9748. <section id='enabling-and-using-the-tool'>
  9749. <title>Enabling and Using the Tool</title>
  9750. <para>
  9751. By default, the error reporting tool is disabled.
  9752. You can enable it by inheriting the
  9753. <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-report-error'><filename>report-error</filename></ulink>
  9754. class by adding the following statement to the end of
  9755. your <filename>local.conf</filename> file in your
  9756. <link linkend='build-directory'>Build Directory</link>.
  9757. <literallayout class='monospaced'>
  9758. INHERIT += "report-error"
  9759. </literallayout>
  9760. </para>
  9761. <para>
  9762. By default, the error reporting feature stores information in
  9763. <filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-LOG_DIR'><filename>LOG_DIR</filename></ulink><filename>}/error-report</filename>.
  9764. However, you can specify a directory to use by adding the following
  9765. to your <filename>local.conf</filename> file:
  9766. <literallayout class='monospaced'>
  9767. ERR_REPORT_DIR = "path"
  9768. </literallayout>
  9769. Enabling error reporting causes the build process to collect
  9770. the errors and store them in a file as previously described.
  9771. When the build system encounters an error, it includes a
  9772. command as part of the console output.
  9773. You can run the command to send the error file to the server.
  9774. For example, the following command sends the errors to an
  9775. upstream server:
  9776. <literallayout class='monospaced'>
  9777. $ send-error-report /home/brandusa/project/poky/build/tmp/log/error-report/error_report_201403141617.txt
  9778. </literallayout>
  9779. In the previous example, the errors are sent to a public
  9780. database available at
  9781. <ulink url='http://errors.yoctoproject.org'></ulink>, which is
  9782. used by the entire community.
  9783. If you specify a particular server, you can send the errors
  9784. to a different database.
  9785. Use the following command for more information on available
  9786. options:
  9787. <literallayout class='monospaced'>
  9788. $ send-error-report --help
  9789. </literallayout>
  9790. </para>
  9791. <para>
  9792. When sending the error file, you are prompted to review the
  9793. data being sent as well as to provide a name and optional
  9794. email address.
  9795. Once you satisfy these prompts, the command returns a link
  9796. from the server that corresponds to your entry in the database.
  9797. For example, here is a typical link:
  9798. <literallayout class='monospaced'>
  9799. http://errors.yoctoproject.org/Errors/Details/9522/
  9800. </literallayout>
  9801. Following the link takes you to a web interface where you can
  9802. browse, query the errors, and view statistics.
  9803. </para>
  9804. </section>
  9805. <section id='disabling-the-tool'>
  9806. <title>Disabling the Tool</title>
  9807. <para>
  9808. To disable the error reporting feature, simply remove or comment
  9809. out the following statement from the end of your
  9810. <filename>local.conf</filename> file in your
  9811. <link linkend='build-directory'>Build Directory</link>.
  9812. <literallayout class='monospaced'>
  9813. INHERIT += "report-error"
  9814. </literallayout>
  9815. </para>
  9816. </section>
  9817. <section id='setting-up-your-own-error-reporting-server'>
  9818. <title>Setting Up Your Own Error Reporting Server</title>
  9819. <para>
  9820. If you want to set up your own error reporting server, you
  9821. can obtain the code from the Git repository at
  9822. <ulink url='http://git.yoctoproject.org/cgit/cgit.cgi/error-report-web/'></ulink>.
  9823. Instructions on how to set it up are in the README document.
  9824. </para>
  9825. </section>
  9826. </section>
  9827. </chapter>
  9828. <!--
  9829. vim: expandtab tw=80 ts=4
  9830. -->