overview-manual-concepts.xml 172 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231
  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=' overview-manual-concepts'>
  5. <title>Yocto Project Concepts</title>
  6. <para>
  7. This chapter provides explanations for Yocto Project concepts that
  8. go beyond the surface of "how-to" information and reference (or
  9. look-up) material.
  10. Concepts such as components, the
  11. <ulink url='&YOCTO_DOCS_REF_URL;#build-system-term'>OpenEmbedded build system</ulink>
  12. workflow, cross-development toolchains, shared state cache, and so
  13. forth are explained.
  14. </para>
  15. <section id='yocto-project-components'>
  16. <title>Yocto Project Components</title>
  17. <para>
  18. The
  19. <ulink url='&YOCTO_DOCS_REF_URL;#bitbake-term'>BitBake</ulink>
  20. task executor together with various types of configuration files
  21. form the
  22. <ulink url='&YOCTO_DOCS_REF_URL;#oe-core'>OpenEmbedded-Core</ulink>.
  23. This section overviews these components by describing their use and
  24. how they interact.
  25. </para>
  26. <para>
  27. BitBake handles the parsing and execution of the data files.
  28. The data itself is of various types:
  29. <itemizedlist>
  30. <listitem><para>
  31. <emphasis>Recipes:</emphasis>
  32. Provides details about particular pieces of software.
  33. </para></listitem>
  34. <listitem><para>
  35. <emphasis>Class Data:</emphasis>
  36. Abstracts common build information (e.g. how to build a
  37. Linux kernel).
  38. </para></listitem>
  39. <listitem><para>
  40. <emphasis>Configuration Data:</emphasis>
  41. Defines machine-specific settings, policy decisions, and
  42. so forth.
  43. Configuration data acts as the glue to bind everything
  44. together.
  45. </para></listitem>
  46. </itemizedlist>
  47. </para>
  48. <para>
  49. BitBake knows how to combine multiple data sources together and
  50. refers to each data source as a layer.
  51. For information on layers, see the
  52. "<ulink url='&YOCTO_DOCS_DEV_URL;#understanding-and-creating-layers'>Understanding and Creating Layers</ulink>"
  53. section of the Yocto Project Development Tasks Manual.
  54. </para>
  55. <para>
  56. Following are some brief details on these core components.
  57. For additional information on how these components interact during
  58. a build, see the
  59. "<link linkend='openembedded-build-system-build-concepts'>OpenEmbedded Build System Concepts</link>"
  60. section.
  61. </para>
  62. <section id='usingpoky-components-bitbake'>
  63. <title>BitBake</title>
  64. <para>
  65. BitBake is the tool at the heart of the
  66. <ulink url='&YOCTO_DOCS_REF_URL;#build-system-term'>OpenEmbedded build system</ulink>
  67. and is responsible for parsing the
  68. <ulink url='&YOCTO_DOCS_REF_URL;#metadata'>Metadata</ulink>,
  69. generating a list of tasks from it, and then executing those
  70. tasks.
  71. </para>
  72. <para>
  73. This section briefly introduces BitBake.
  74. If you want more information on BitBake, see the
  75. <ulink url='&YOCTO_DOCS_BB_URL;#bitbake-user-manual'>BitBake User Manual</ulink>.
  76. </para>
  77. <para>
  78. To see a list of the options BitBake supports, use either of
  79. the following commands:
  80. <literallayout class='monospaced'>
  81. $ bitbake -h
  82. $ bitbake --help
  83. </literallayout>
  84. </para>
  85. <para>
  86. The most common usage for BitBake is
  87. <filename>bitbake <replaceable>packagename</replaceable></filename>,
  88. where <filename>packagename</filename> is the name of the
  89. package you want to build (referred to as the "target").
  90. The target often equates to the first part of a recipe's
  91. filename (e.g. "foo" for a recipe named
  92. <filename>foo_1.3.0-r0.bb</filename>).
  93. So, to process the
  94. <filename>matchbox-desktop_1.2.3.bb</filename> recipe file, you
  95. might type the following:
  96. <literallayout class='monospaced'>
  97. $ bitbake matchbox-desktop
  98. </literallayout>
  99. Several different versions of
  100. <filename>matchbox-desktop</filename> might exist.
  101. BitBake chooses the one selected by the distribution
  102. configuration.
  103. You can get more details about how BitBake chooses between
  104. different target versions and providers in the
  105. "<ulink url='&YOCTO_DOCS_BB_URL;#bb-bitbake-preferences'>Preferences</ulink>"
  106. section of the BitBake User Manual.
  107. </para>
  108. <para>
  109. BitBake also tries to execute any dependent tasks first.
  110. So for example, before building
  111. <filename>matchbox-desktop</filename>, BitBake would build a
  112. cross compiler and <filename>glibc</filename> if they had not
  113. already been built.
  114. </para>
  115. <para>
  116. A useful BitBake option to consider is the
  117. <filename>-k</filename> or <filename>--continue</filename>
  118. option.
  119. This option instructs BitBake to try and continue processing
  120. the job as long as possible even after encountering an error.
  121. When an error occurs, the target that failed and those that
  122. depend on it cannot be remade.
  123. However, when you use this option other dependencies can
  124. still be processed.
  125. </para>
  126. </section>
  127. <section id='overview-components-recipes'>
  128. <title>Recipes</title>
  129. <para>
  130. Files that have the <filename>.bb</filename> suffix are
  131. "recipes" files.
  132. In general, a recipe contains information about a single piece
  133. of software.
  134. This information includes the location from which to download
  135. the unaltered source, any source patches to be applied to that
  136. source (if needed), which special configuration options to
  137. apply, how to compile the source files, and how to package the
  138. compiled output.
  139. </para>
  140. <para>
  141. The term "package" is sometimes used to refer to recipes.
  142. However, since the word "package" is used for the packaged
  143. output from the OpenEmbedded build system (i.e.
  144. <filename>.ipk</filename> or <filename>.deb</filename> files),
  145. this document avoids using the term "package" when referring
  146. to recipes.
  147. </para>
  148. </section>
  149. <section id='overview-components-classes'>
  150. <title>Classes</title>
  151. <para>
  152. Class files (<filename>.bbclass</filename>) contain information
  153. that is useful to share between recipes files.
  154. An example is the
  155. <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-autotools'><filename>autotools</filename></ulink>
  156. class, which contains common settings for any application that
  157. Autotools uses.
  158. The
  159. "<ulink url='&YOCTO_DOCS_REF_URL;#ref-classes'>Classes</ulink>"
  160. chapter in the Yocto Project Reference Manual provides
  161. details about classes and how to use them.
  162. </para>
  163. </section>
  164. <section id='overview-components-configurations'>
  165. <title>Configurations</title>
  166. <para>
  167. The configuration files (<filename>.conf</filename>) define
  168. various configuration variables that govern the OpenEmbedded
  169. build process.
  170. These files fall into several areas that define machine
  171. configuration options, distribution configuration options,
  172. compiler tuning options, general common configuration options,
  173. and user configuration options in
  174. <filename>conf/local.conf</filename>, which is found in the
  175. <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink>.
  176. </para>
  177. </section>
  178. </section>
  179. <section id='overview-layers'>
  180. <title>Layers</title>
  181. <para>
  182. Layers are repositories that contain related metadata (i.e.
  183. sets of instructions) that tell the OpenEmbedded build system how
  184. to build a target.
  185. Yocto Project's
  186. <link linkend='the-yocto-project-layer-model'>layer model</link>
  187. facilitates collaboration, sharing, customization, and reuse
  188. within the Yocto Project development environment.
  189. Layers logically separate information for your project.
  190. For example, you can use a layer to hold all the configurations
  191. for a particular piece of hardware.
  192. Isolating hardware-specific configurations allows you to share
  193. other metadata by using a different layer where that metadata
  194. might be common across several pieces of hardware.
  195. </para>
  196. <para>
  197. Many layers exist that work in the Yocto Project development
  198. environment.
  199. The
  200. <ulink url='https://caffelli-staging.yoctoproject.org/software-overview/layers/'>Yocto Project Curated Layer Index</ulink>
  201. and
  202. <ulink url='http://layers.openembedded.org/layerindex/branch/master/layers/'>OpenEmbedded Layer Index</ulink>
  203. both contain layers from which you can use or leverage.
  204. </para>
  205. <para>
  206. By convention, layers in the Yocto Project follow a specific form.
  207. Conforming to a known structure allows BitBake to make assumptions
  208. during builds on where to find types of metadata.
  209. You can find procedures and learn about tools (i.e.
  210. <filename>bitbake-layers</filename>) for creating layers suitable
  211. for the Yocto Project in the
  212. "<ulink url='&YOCTO_DOCS_DEV_URL;#understanding-and-creating-layers'>Understanding and Creating Layers</ulink>"
  213. section of the Yocto Project Development Tasks Manual.
  214. </para>
  215. </section>
  216. <section id="openembedded-build-system-build-concepts">
  217. <title>OpenEmbedded Build System Concepts</title>
  218. <para>
  219. This section takes a more detailed look inside the build
  220. process used by the
  221. <ulink url='&YOCTO_DOCS_REF_URL;#build-system-term'>OpenEmbedded build system</ulink>,
  222. which is the build system specific to the Yocto Project.
  223. At the heart of the build system is BitBake, the task executor.
  224. </para>
  225. <para>
  226. The following diagram represents the high-level workflow of a
  227. build.
  228. The remainder of this section expands on the fundamental input,
  229. output, process, and metadata logical blocks that make up the
  230. workflow.
  231. </para>
  232. <para id='general-workflow-figure'>
  233. <imagedata fileref="figures/YP-flow-diagram.png" format="PNG" align='center' width="8in"/>
  234. </para>
  235. <para>
  236. In general, the build's workflow consists of several functional
  237. areas:
  238. <itemizedlist>
  239. <listitem><para>
  240. <emphasis>User Configuration:</emphasis>
  241. metadata you can use to control the build process.
  242. </para></listitem>
  243. <listitem><para>
  244. <emphasis>Metadata Layers:</emphasis>
  245. Various layers that provide software, machine, and
  246. distro metadata.
  247. </para></listitem>
  248. <listitem><para>
  249. <emphasis>Source Files:</emphasis>
  250. Upstream releases, local projects, and SCMs.
  251. </para></listitem>
  252. <listitem><para>
  253. <emphasis>Build System:</emphasis>
  254. Processes under the control of
  255. <ulink url='&YOCTO_DOCS_REF_URL;#bitbake-term'>BitBake</ulink>.
  256. This block expands on how BitBake fetches source, applies
  257. patches, completes compilation, analyzes output for package
  258. generation, creates and tests packages, generates images,
  259. and generates cross-development tools.
  260. </para></listitem>
  261. <listitem><para>
  262. <emphasis>Package Feeds:</emphasis>
  263. Directories containing output packages (RPM, DEB or IPK),
  264. which are subsequently used in the construction of an
  265. image or Software Development Kit (SDK), produced by the
  266. build system.
  267. These feeds can also be copied and shared using a web
  268. server or other means to facilitate extending or updating
  269. existing images on devices at runtime if runtime package
  270. management is enabled.
  271. </para></listitem>
  272. <listitem><para>
  273. <emphasis>Images:</emphasis>
  274. Images produced by the workflow.
  275. </para></listitem>
  276. <listitem><para>
  277. <emphasis>Application Development SDK:</emphasis>
  278. Cross-development tools that are produced along with
  279. an image or separately with BitBake.
  280. </para></listitem>
  281. </itemizedlist>
  282. </para>
  283. <section id="user-configuration">
  284. <title>User Configuration</title>
  285. <para>
  286. User configuration helps define the build.
  287. Through user configuration, you can tell BitBake the
  288. target architecture for which you are building the image,
  289. where to store downloaded source, and other build properties.
  290. </para>
  291. <para>
  292. The following figure shows an expanded representation of the
  293. "User Configuration" box of the
  294. <link linkend='general-workflow-figure'>general workflow figure</link>:
  295. </para>
  296. <para>
  297. <imagedata fileref="figures/user-configuration.png" align="center" width="8in" depth="4.5in" />
  298. </para>
  299. <para>
  300. BitBake needs some basic configuration files in order to
  301. complete a build.
  302. These files are <filename>*.conf</filename> files.
  303. The minimally necessary ones reside as example files in the
  304. <filename>build/conf</filename> directory of the
  305. <ulink url='&YOCTO_DOCS_REF_URL;#source-directory'>Source Directory</ulink>.
  306. For simplicity, this section refers to the Source Directory as
  307. the "Poky Directory."
  308. </para>
  309. <para>
  310. When you clone the
  311. <ulink url='&YOCTO_DOCS_REF_URL;#poky'>Poky</ulink>
  312. Git repository or you download and unpack a Yocto Project
  313. release, you can set up the Source Directory to be named
  314. anything you want.
  315. For this discussion, the cloned repository uses the default
  316. name <filename>poky</filename>.
  317. <note>
  318. The Poky repository is primarily an aggregation of existing
  319. repositories.
  320. It is not a canonical upstream source.
  321. </note>
  322. </para>
  323. <para>
  324. The <filename>meta-poky</filename> layer inside Poky contains
  325. a <filename>conf</filename> directory that has example
  326. configuration files.
  327. These example files are used as a basis for creating actual
  328. configuration files when you source
  329. <ulink url='&YOCTO_DOCS_REF_URL;#structure-core-script'><filename>&OE_INIT_FILE;</filename></ulink>,
  330. which is the build environment script.
  331. </para>
  332. <para>
  333. Sourcing the build environment script creates a
  334. <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink>
  335. if one does not already exist.
  336. BitBake uses the Build Directory for all its work during
  337. builds.
  338. The Build Directory has a <filename>conf</filename> directory
  339. that contains default versions of your
  340. <filename>local.conf</filename> and
  341. <filename>bblayers.conf</filename> configuration files.
  342. These default configuration files are created only if versions
  343. do not already exist in the Build Directory at the time you
  344. source the build environment setup script.
  345. </para>
  346. <para>
  347. Because the Poky repository is fundamentally an aggregation of
  348. existing repositories, some users might be familiar with
  349. running the <filename>&OE_INIT_FILE;</filename> script
  350. in the context of separate
  351. <ulink url='&YOCTO_DOCS_REF_URL;#oe-core'>OpenEmbedded-Core</ulink>
  352. and BitBake repositories rather than a single Poky repository.
  353. This discussion assumes the script is executed from
  354. within a cloned or unpacked version of Poky.
  355. </para>
  356. <para>
  357. Depending on where the script is sourced, different
  358. sub-scripts are called to set up the Build Directory
  359. (Yocto or OpenEmbedded).
  360. Specifically, the script
  361. <filename>scripts/oe-setup-builddir</filename> inside the
  362. poky directory sets up the Build Directory and seeds the
  363. directory (if necessary) with configuration files appropriate
  364. for the Yocto Project development environment.
  365. <note>
  366. The <filename>scripts/oe-setup-builddir</filename> script
  367. uses the <filename>$TEMPLATECONF</filename> variable to
  368. determine which sample configuration files to locate.
  369. </note>
  370. </para>
  371. <para>
  372. The <filename>local.conf</filename> file provides many
  373. basic variables that define a build environment.
  374. Here is a list of a few.
  375. To see the default configurations in a
  376. <filename>local.conf</filename> file created by the build
  377. environment script, see the
  378. <ulink url='&YOCTO_GIT_URL;/cgit/cgit.cgi/poky/tree/meta-poky/conf/local.conf.sample'><filename>local.conf.sample</filename></ulink>
  379. in the <filename>meta-poky</filename> layer:
  380. <itemizedlist>
  381. <listitem><para>
  382. <emphasis>Target Machine Selection:</emphasis>
  383. Controlled by the
  384. <ulink url='&YOCTO_DOCS_REF_URL;#var-MACHINE'><filename>MACHINE</filename></ulink>
  385. variable.
  386. </para></listitem>
  387. <listitem><para>
  388. <emphasis>Download Directory:</emphasis>
  389. Controlled by the
  390. <ulink url='&YOCTO_DOCS_REF_URL;#var-DL_DIR'><filename>DL_DIR</filename></ulink>
  391. variable.
  392. </para></listitem>
  393. <listitem><para>
  394. <emphasis>Shared State Directory:</emphasis>
  395. Controlled by the
  396. <ulink url='&YOCTO_DOCS_REF_URL;#var-SSTATE_DIR'><filename>SSTATE_DIR</filename></ulink>
  397. variable.
  398. </para></listitem>
  399. <listitem><para>
  400. <emphasis>Build Output:</emphasis>
  401. Controlled by the
  402. <ulink url='&YOCTO_DOCS_REF_URL;#var-TMPDIR'><filename>TMPDIR</filename></ulink>
  403. variable.
  404. </para></listitem>
  405. <listitem><para>
  406. <emphasis>Distribution Policy:</emphasis>
  407. Controlled by the
  408. <ulink url='&YOCTO_DOCS_REF_URL;#var-DISTRO'><filename>DISTRO</filename></ulink>
  409. variable.
  410. </para></listitem>
  411. <listitem><para>
  412. <emphasis>Packaging Format:</emphasis>
  413. Controlled by the
  414. <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_CLASSES'><filename>PACKAGE_CLASSES</filename></ulink>
  415. variable.
  416. </para></listitem>
  417. <listitem><para>
  418. <emphasis>SDK Target Architecture:</emphasis>
  419. Controlled by the
  420. <ulink url='&YOCTO_DOCS_REF_URL;#var-SDKMACHINE'><filename>SDKMACHINE</filename></ulink>
  421. variable.
  422. </para></listitem>
  423. <listitem><para>
  424. <emphasis>Extra Image Packages:</emphasis>
  425. Controlled by the
  426. <ulink url='&YOCTO_DOCS_REF_URL;#var-EXTRA_IMAGE_FEATURES'><filename>EXTRA_IMAGE_FEATURES</filename></ulink>
  427. variable.
  428. </para></listitem>
  429. </itemizedlist>
  430. <note>
  431. Configurations set in the
  432. <filename>conf/local.conf</filename> file can also be set
  433. in the <filename>conf/site.conf</filename> and
  434. <filename>conf/auto.conf</filename> configuration files.
  435. </note>
  436. </para>
  437. <para>
  438. The <filename>bblayers.conf</filename> file tells BitBake what
  439. layers you want considered during the build.
  440. By default, the layers listed in this file include layers
  441. minimally needed by the build system.
  442. However, you must manually add any custom layers you have
  443. created.
  444. You can find more information on working with the
  445. <filename>bblayers.conf</filename> file in the
  446. "<ulink url='&YOCTO_DOCS_DEV_URL;#enabling-your-layer'>Enabling Your Layer</ulink>"
  447. section in the Yocto Project Development Tasks Manual.
  448. </para>
  449. <para>
  450. The files <filename>site.conf</filename> and
  451. <filename>auto.conf</filename> are not created by the
  452. environment initialization script.
  453. If you want the <filename>site.conf</filename> file, you
  454. need to create that yourself.
  455. The <filename>auto.conf</filename> file is typically created by
  456. an autobuilder:
  457. <itemizedlist>
  458. <listitem><para>
  459. <emphasis><filename>site.conf</filename>:</emphasis>
  460. You can use the <filename>conf/site.conf</filename>
  461. configuration file to configure multiple
  462. build directories.
  463. For example, suppose you had several build environments
  464. and they shared some common features.
  465. You can set these default build properties here.
  466. A good example is perhaps the packaging format to use
  467. through the
  468. <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_CLASSES'><filename>PACKAGE_CLASSES</filename></ulink>
  469. variable.</para>
  470. <para>One useful scenario for using the
  471. <filename>conf/site.conf</filename> file is to extend
  472. your
  473. <ulink url='&YOCTO_DOCS_REF_URL;#var-BBPATH'><filename>BBPATH</filename></ulink>
  474. variable to include the path to a
  475. <filename>conf/site.conf</filename>.
  476. Then, when BitBake looks for Metadata using
  477. <filename>BBPATH</filename>, it finds the
  478. <filename>conf/site.conf</filename> file and applies
  479. your common configurations found in the file.
  480. To override configurations in a particular build
  481. directory, alter the similar configurations within
  482. that build directory's
  483. <filename>conf/local.conf</filename> file.
  484. </para></listitem>
  485. <listitem><para>
  486. <emphasis><filename>auto.conf</filename>:</emphasis>
  487. The file is usually created and written to by
  488. an autobuilder.
  489. The settings put into the file are typically the
  490. same as you would find in the
  491. <filename>conf/local.conf</filename> or the
  492. <filename>conf/site.conf</filename> files.
  493. </para></listitem>
  494. </itemizedlist>
  495. </para>
  496. <para>
  497. You can edit all configuration files to further define
  498. any particular build environment.
  499. This process is represented by the "User Configuration Edits"
  500. box in the figure.
  501. </para>
  502. <para>
  503. When you launch your build with the
  504. <filename>bitbake <replaceable>target</replaceable></filename>
  505. command, BitBake sorts out the configurations to ultimately
  506. define your build environment.
  507. It is important to understand that the
  508. <ulink url='&YOCTO_DOCS_REF_URL;#build-system-term'>OpenEmbedded build system</ulink>
  509. reads the configuration files in a specific order:
  510. <filename>site.conf</filename>, <filename>auto.conf</filename>,
  511. and <filename>local.conf</filename>.
  512. And, the build system applies the normal assignment statement
  513. rules as described in the
  514. "<ulink url='&YOCTO_DOCS_BB_URL;#bitbake-user-manual-metadata'>Syntax and Operators</ulink>"
  515. chapter of the BitBake User Manual.
  516. Because the files are parsed in a specific order, variable
  517. assignments for the same variable could be affected.
  518. For example, if the <filename>auto.conf</filename> file and
  519. the <filename>local.conf</filename> set
  520. <replaceable>variable1</replaceable> to different values,
  521. because the build system parses <filename>local.conf</filename>
  522. after <filename>auto.conf</filename>,
  523. <replaceable>variable1</replaceable> is assigned the value from
  524. the <filename>local.conf</filename> file.
  525. </para>
  526. </section>
  527. <section id="metadata-machine-configuration-and-policy-configuration">
  528. <title>Metadata, Machine Configuration, and Policy Configuration</title>
  529. <para>
  530. The previous section described the user configurations that
  531. define BitBake's global behavior.
  532. This section takes a closer look at the layers the build system
  533. uses to further control the build.
  534. These layers provide Metadata for the software, machine, and
  535. policies.
  536. </para>
  537. <para>
  538. In general, three types of layer input exists.
  539. You can see them below the "User Configuration" box in the
  540. <link linkend='general-workflow-figure'>general workflow figure</link>:
  541. <itemizedlist>
  542. <listitem><para>
  543. <emphasis>Metadata (<filename>.bb</filename> + Patches):</emphasis>
  544. Software layers containing user-supplied recipe files,
  545. patches, and append files.
  546. A good example of a software layer might be the
  547. <ulink url='https://github.com/meta-qt5/meta-qt5'><filename>meta-qt5</filename></ulink>
  548. layer from the
  549. <ulink url='http://layers.openembedded.org/layerindex/branch/master/layers/'>OpenEmbedded Layer Index</ulink>.
  550. This layer is for version 5.0 of the popular
  551. <ulink url='https://wiki.qt.io/About_Qt'>Qt</ulink>
  552. cross-platform application development framework for
  553. desktop, embedded and mobile.
  554. </para></listitem>
  555. <listitem><para>
  556. <emphasis>Machine BSP Configuration:</emphasis>
  557. Board Support Package (BSP) layers (i.e. "BSP Layer"
  558. in the following figure) providing machine-specific
  559. configurations.
  560. This type of information is specific to a particular
  561. target architecture.
  562. A good example of a BSP layer from the
  563. <link linkend='gs-reference-distribution-poky'>Poky Reference Distribution</link>
  564. is the
  565. <ulink url='&YOCTO_GIT_URL;/cgit/cgit.cgi/poky/tree/meta-yocto-bsp'><filename>meta-yocto-bsp</filename></ulink>
  566. layer.
  567. </para></listitem>
  568. <listitem><para>
  569. <emphasis>Policy Configuration:</emphasis>
  570. Distribution Layers (i.e. "Distro Layer" in the
  571. following figure) providing top-level or general
  572. policies for the images or SDKs being built for a
  573. particular distribution.
  574. For example, in the Poky Reference Distribution the
  575. distro layer is the
  576. <ulink url='&YOCTO_GIT_URL;/cgit/cgit.cgi/poky/tree/meta-poky'><filename>meta-poky</filename></ulink>
  577. layer.
  578. Within the distro layer is a
  579. <filename>conf/distro</filename> directory that
  580. contains distro configuration files (e.g.
  581. <ulink url='&YOCTO_GIT_URL;/cgit/cgit.cgi/poky/tree/meta-poky/conf/distro/poky.conf'><filename>poky.conf</filename></ulink>
  582. that contain many policy configurations for the
  583. Poky distribution.
  584. </para></listitem>
  585. </itemizedlist>
  586. </para>
  587. <para>
  588. The following figure shows an expanded representation of
  589. these three layers from the
  590. <link linkend='general-workflow-figure'>general workflow figure</link>:
  591. </para>
  592. <para>
  593. <imagedata fileref="figures/layer-input.png" align="center" width="8in" depth="8in" />
  594. </para>
  595. <para>
  596. In general, all layers have a similar structure.
  597. They all contain a licensing file
  598. (e.g. <filename>COPYING.MIT</filename>) if the layer is to be
  599. distributed, a <filename>README</filename> file as good
  600. practice and especially if the layer is to be distributed, a
  601. configuration directory, and recipe directories.
  602. You can learn about the general structure for layers used with
  603. the Yocto Project in the
  604. "<ulink url='&YOCTO_DOCS_DEV_URL;#creating-your-own-layer'>Creating Your Own Layer</ulink>"
  605. section in the Yocto Project Development Tasks Manual.
  606. For a general discussion on layers and the many layers from
  607. which you can draw, see the
  608. "<link linkend='overview-layers'>Layers</link>" and
  609. "<link linkend='the-yocto-project-layer-model'>The Yocto Project Layer Model</link>"
  610. sections both earlier in this manual.
  611. </para>
  612. <para>
  613. If you explored the previous links, you discovered some
  614. areas where many layers that work with the Yocto Project
  615. exist.
  616. The
  617. <ulink url="http://git.yoctoproject.org/">Source Repositories</ulink>
  618. also shows layers categorized under "Yocto Metadata Layers."
  619. <note>
  620. Layers exist in the Yocto Project Source Repositories that
  621. cannot be found in the OpenEmbedded Layer Index.
  622. These layers are either deprecated or experimental
  623. in nature.
  624. </note>
  625. </para>
  626. <para>
  627. BitBake uses the <filename>conf/bblayers.conf</filename> file,
  628. which is part of the user configuration, to find what layers it
  629. should be using as part of the build.
  630. </para>
  631. <section id="distro-layer">
  632. <title>Distro Layer</title>
  633. <para>
  634. The distribution layer provides policy configurations for
  635. your distribution.
  636. Best practices dictate that you isolate these types of
  637. configurations into their own layer.
  638. Settings you provide in
  639. <filename>conf/distro/<replaceable>distro</replaceable>.conf</filename> override
  640. similar settings that BitBake finds in your
  641. <filename>conf/local.conf</filename> file in the Build
  642. Directory.
  643. </para>
  644. <para>
  645. The following list provides some explanation and references
  646. for what you typically find in the distribution layer:
  647. <itemizedlist>
  648. <listitem><para>
  649. <emphasis>classes:</emphasis>
  650. Class files (<filename>.bbclass</filename>) hold
  651. common functionality that can be shared among
  652. recipes in the distribution.
  653. When your recipes inherit a class, they take on the
  654. settings and functions for that class.
  655. You can read more about class files in the
  656. "<ulink url='&YOCTO_DOCS_REF_URL;#ref-classes'>Classes</ulink>"
  657. chapter of the Yocto Reference Manual.
  658. </para></listitem>
  659. <listitem><para>
  660. <emphasis>conf:</emphasis>
  661. This area holds configuration files for the
  662. layer (<filename>conf/layer.conf</filename>),
  663. the distribution
  664. (<filename>conf/distro/<replaceable>distro</replaceable>.conf</filename>),
  665. and any distribution-wide include files.
  666. </para></listitem>
  667. <listitem><para>
  668. <emphasis>recipes-*:</emphasis>
  669. Recipes and append files that affect common
  670. functionality across the distribution.
  671. This area could include recipes and append files
  672. to add distribution-specific configuration,
  673. initialization scripts, custom image recipes,
  674. and so forth.
  675. Examples of <filename>recipes-*</filename>
  676. directories are <filename>recipes-core</filename>
  677. and <filename>recipes-extra</filename>.
  678. Hierarchy and contents within a
  679. <filename>recipes-*</filename> directory can vary.
  680. Generally, these directories contain recipe files
  681. (<filename>*.bb</filename>), recipe append files
  682. (<filename>*.bbappend</filename>), directories
  683. that are distro-specific for configuration files,
  684. and so forth.
  685. </para></listitem>
  686. </itemizedlist>
  687. </para>
  688. </section>
  689. <section id="bsp-layer">
  690. <title>BSP Layer</title>
  691. <para>
  692. The BSP Layer provides machine configurations that
  693. target specific hardware.
  694. Everything in this layer is specific to the machine for
  695. which you are building the image or the SDK.
  696. A common structure or form is defined for BSP layers.
  697. You can learn more about this structure in the
  698. <ulink url='&YOCTO_DOCS_BSP_URL;'>Yocto Project Board Support Package (BSP) Developer's Guide</ulink>.
  699. <note>
  700. In order for a BSP layer to be considered compliant
  701. with the Yocto Project, it must meet some structural
  702. requirements.
  703. </note>
  704. </para>
  705. <para>
  706. The BSP Layer's configuration directory contains
  707. configuration files for the machine
  708. (<filename>conf/machine/<replaceable>machine</replaceable>.conf</filename>)
  709. and, of course, the layer
  710. (<filename>conf/layer.conf</filename>).
  711. </para>
  712. <para>
  713. The remainder of the layer is dedicated to specific recipes
  714. by function: <filename>recipes-bsp</filename>,
  715. <filename>recipes-core</filename>,
  716. <filename>recipes-graphics</filename>,
  717. <filename>recipes-kernel</filename>, and so forth.
  718. Metadata can exist for multiple formfactors, graphics
  719. support systems, and so forth.
  720. <note>
  721. While the figure shows several
  722. <filename>recipes-*</filename> directories, not all
  723. these directories appear in all BSP layers.
  724. </note>
  725. </para>
  726. </section>
  727. <section id="software-layer">
  728. <title>Software Layer</title>
  729. <para>
  730. The software layer provides the Metadata for additional
  731. software packages used during the build.
  732. This layer does not include Metadata that is specific to
  733. the distribution or the machine, which are found in their
  734. respective layers.
  735. </para>
  736. <para>
  737. This layer contains any recipes, append files, and
  738. patches, that your project needs.
  739. </para>
  740. </section>
  741. </section>
  742. <section id="sources-dev-environment">
  743. <title>Sources</title>
  744. <para>
  745. In order for the OpenEmbedded build system to create an
  746. image or any target, it must be able to access source files.
  747. The
  748. <link linkend='general-workflow-figure'>general workflow figure</link>
  749. represents source files using the "Upstream Project Releases",
  750. "Local Projects", and "SCMs (optional)" boxes.
  751. The figure represents mirrors, which also play a role in
  752. locating source files, with the "Source Materials" box.
  753. </para>
  754. <para>
  755. The method by which source files are ultimately organized is
  756. a function of the project.
  757. For example, for released software, projects tend to use
  758. tarballs or other archived files that can capture the
  759. state of a release guaranteeing that it is statically
  760. represented.
  761. On the other hand, for a project that is more dynamic or
  762. experimental in nature, a project might keep source files in a
  763. repository controlled by a Source Control Manager (SCM) such as
  764. Git.
  765. Pulling source from a repository allows you to control
  766. the point in the repository (the revision) from which you
  767. want to build software.
  768. Finally, a combination of the two might exist, which would
  769. give the consumer a choice when deciding where to get
  770. source files.
  771. </para>
  772. <para>
  773. BitBake uses the
  774. <ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'><filename>SRC_URI</filename></ulink>
  775. variable to point to source files regardless of their location.
  776. Each recipe must have a <filename>SRC_URI</filename> variable
  777. that points to the source.
  778. </para>
  779. <para>
  780. Another area that plays a significant role in where source
  781. files come from is pointed to by the
  782. <ulink url='&YOCTO_DOCS_REF_URL;#var-DL_DIR'><filename>DL_DIR</filename></ulink>
  783. variable.
  784. This area is a cache that can hold previously downloaded
  785. source.
  786. You can also instruct the OpenEmbedded build system to create
  787. tarballs from Git repositories, which is not the default
  788. behavior, and store them in the <filename>DL_DIR</filename>
  789. by using the
  790. <ulink url='&YOCTO_DOCS_REF_URL;#var-BB_GENERATE_MIRROR_TARBALLS'><filename>BB_GENERATE_MIRROR_TARBALLS</filename></ulink>
  791. variable.
  792. </para>
  793. <para>
  794. Judicious use of a <filename>DL_DIR</filename> directory can
  795. save the build system a trip across the Internet when looking
  796. for files.
  797. A good method for using a download directory is to have
  798. <filename>DL_DIR</filename> point to an area outside of your
  799. Build Directory.
  800. Doing so allows you to safely delete the Build Directory
  801. if needed without fear of removing any downloaded source file.
  802. </para>
  803. <para>
  804. The remainder of this section provides a deeper look into the
  805. source files and the mirrors.
  806. Here is a more detailed look at the source file area of the
  807. <link linkend='general-workflow-figure'>general workflow figure</link>:
  808. </para>
  809. <para>
  810. <imagedata fileref="figures/source-input.png" width="6in" depth="6in" align="center" />
  811. </para>
  812. <section id='upstream-project-releases'>
  813. <title>Upstream Project Releases</title>
  814. <para>
  815. Upstream project releases exist anywhere in the form of an
  816. archived file (e.g. tarball or zip file).
  817. These files correspond to individual recipes.
  818. For example, the figure uses specific releases each for
  819. BusyBox, Qt, and Dbus.
  820. An archive file can be for any released product that can be
  821. built using a recipe.
  822. </para>
  823. </section>
  824. <section id='local-projects'>
  825. <title>Local Projects</title>
  826. <para>
  827. Local projects are custom bits of software the user
  828. provides.
  829. These bits reside somewhere local to a project - perhaps
  830. a directory into which the user checks in items (e.g.
  831. a local directory containing a development source tree
  832. used by the group).
  833. </para>
  834. <para>
  835. The canonical method through which to include a local
  836. project is to use the
  837. <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-externalsrc'><filename>externalsrc</filename></ulink>
  838. class to include that local project.
  839. You use either the <filename>local.conf</filename> or a
  840. recipe's append file to override or set the
  841. recipe to point to the local directory on your disk to pull
  842. in the whole source tree.
  843. </para>
  844. </section>
  845. <section id='scms'>
  846. <title>Source Control Managers (Optional)</title>
  847. <para>
  848. Another place the build system can get source files from is
  849. through an SCM such as Git or Subversion.
  850. In this case, a repository is cloned or checked out.
  851. The
  852. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-fetch'><filename>do_fetch</filename></ulink>
  853. task inside BitBake uses
  854. the <ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'><filename>SRC_URI</filename></ulink>
  855. variable and the argument's prefix to determine the correct
  856. fetcher module.
  857. <note>
  858. For information on how to have the OpenEmbedded build
  859. system generate tarballs for Git repositories and place
  860. them in the
  861. <ulink url='&YOCTO_DOCS_REF_URL;#var-DL_DIR'><filename>DL_DIR</filename></ulink>
  862. directory, see the
  863. <ulink url='&YOCTO_DOCS_REF_URL;#var-BB_GENERATE_MIRROR_TARBALLS'><filename>BB_GENERATE_MIRROR_TARBALLS</filename></ulink>
  864. variable.
  865. </note>
  866. </para>
  867. <para>
  868. When fetching a repository, BitBake uses the
  869. <ulink url='&YOCTO_DOCS_REF_URL;#var-SRCREV'><filename>SRCREV</filename></ulink>
  870. variable to determine the specific revision from which to
  871. build.
  872. </para>
  873. </section>
  874. <section id='source-mirrors'>
  875. <title>Source Mirror(s)</title>
  876. <para>
  877. Two kinds of mirrors exist: pre-mirrors and regular
  878. mirrors.
  879. The
  880. <ulink url='&YOCTO_DOCS_REF_URL;#var-PREMIRRORS'><filename>PREMIRRORS</filename></ulink>
  881. and
  882. <ulink url='&YOCTO_DOCS_REF_URL;#var-MIRRORS'><filename>MIRRORS</filename></ulink>
  883. variables point to these, respectively.
  884. BitBake checks pre-mirrors before looking upstream for any
  885. source files.
  886. Pre-mirrors are appropriate when you have a shared
  887. directory that is not a directory defined by the
  888. <ulink url='&YOCTO_DOCS_REF_URL;#var-DL_DIR'><filename>DL_DIR</filename></ulink>
  889. variable.
  890. A Pre-mirror typically points to a shared directory that is
  891. local to your organization.
  892. </para>
  893. <para>
  894. Regular mirrors can be any site across the Internet
  895. that is used as an alternative location for source
  896. code should the primary site not be functioning for
  897. some reason or another.
  898. </para>
  899. </section>
  900. </section>
  901. <section id="package-feeds-dev-environment">
  902. <title>Package Feeds</title>
  903. <para>
  904. When the OpenEmbedded build system generates an image or an
  905. SDK, it gets the packages from a package feed area located
  906. in the
  907. <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink>.
  908. The
  909. <link linkend='general-workflow-figure'>general workflow figure</link>
  910. shows this package feeds area in the upper-right corner.
  911. </para>
  912. <para>
  913. This section looks a little closer into the package feeds
  914. area used by the build system.
  915. Here is a more detailed look at the area:
  916. <imagedata fileref="figures/package-feeds.png" align="center" width="7in" depth="6in" />
  917. </para>
  918. <para>
  919. Package feeds are an intermediary step in the build process.
  920. The OpenEmbedded build system provides classes to generate
  921. different package types, and you specify which classes to
  922. enable through the
  923. <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_CLASSES'><filename>PACKAGE_CLASSES</filename></ulink>
  924. variable.
  925. Before placing the packages into package feeds,
  926. the build process validates them with generated output quality
  927. assurance checks through the
  928. <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-insane'><filename>insane</filename></ulink>
  929. class.
  930. </para>
  931. <para>
  932. The package feed area resides in the Build Directory.
  933. The directory the build system uses to temporarily store
  934. packages is determined by a combination of variables and the
  935. particular package manager in use.
  936. See the "Package Feeds" box in the illustration and note the
  937. information to the right of that area.
  938. In particular, the following defines where package files are
  939. kept:
  940. <itemizedlist>
  941. <listitem><para>
  942. <ulink url='&YOCTO_DOCS_REF_URL;#var-DEPLOY_DIR'><filename>DEPLOY_DIR</filename></ulink>:
  943. Defined as <filename>tmp/deploy</filename> in the Build
  944. Directory.
  945. </para></listitem>
  946. <listitem><para>
  947. <filename>DEPLOY_DIR_*</filename>:
  948. Depending on the package manager used, the package type
  949. sub-folder.
  950. Given RPM, IPK, or DEB packaging and tarball creation,
  951. the
  952. <ulink url='&YOCTO_DOCS_REF_URL;#var-DEPLOY_DIR_RPM'><filename>DEPLOY_DIR_RPM</filename></ulink>,
  953. <ulink url='&YOCTO_DOCS_REF_URL;#var-DEPLOY_DIR_IPK'><filename>DEPLOY_DIR_IPK</filename></ulink>,
  954. <ulink url='&YOCTO_DOCS_REF_URL;#var-DEPLOY_DIR_DEB'><filename>DEPLOY_DIR_DEB</filename></ulink>,
  955. or
  956. <ulink url='&YOCTO_DOCS_REF_URL;#var-DEPLOY_DIR_TAR'><filename>DEPLOY_DIR_TAR</filename></ulink>,
  957. variables are used, respectively.
  958. </para></listitem>
  959. <listitem><para>
  960. <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_ARCH'><filename>PACKAGE_ARCH</filename></ulink>:
  961. Defines architecture-specific sub-folders.
  962. For example, packages could exist for the i586 or
  963. qemux86 architectures.
  964. </para></listitem>
  965. </itemizedlist>
  966. </para>
  967. <para>
  968. BitBake uses the
  969. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-package_write_deb'><filename>do_package_write_*</filename></ulink>
  970. tasks to generate packages and place them into the package
  971. holding area (e.g. <filename>do_package_write_ipk</filename>
  972. for IPK packages).
  973. See the
  974. "<ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-package_write_deb'><filename>do_package_write_deb</filename></ulink>",
  975. "<ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-package_write_ipk'><filename>do_package_write_ipk</filename></ulink>",
  976. "<ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-package_write_rpm'><filename>do_package_write_rpm</filename></ulink>",
  977. and
  978. "<ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-package_write_tar'><filename>do_package_write_tar</filename></ulink>"
  979. sections in the Yocto Project Reference Manual
  980. for additional information.
  981. As an example, consider a scenario where an IPK packaging
  982. manager is being used and package architecture support for
  983. both i586 and qemux86 exist.
  984. Packages for the i586 architecture are placed in
  985. <filename>build/tmp/deploy/ipk/i586</filename>, while packages
  986. for the qemux86 architecture are placed in
  987. <filename>build/tmp/deploy/ipk/qemux86</filename>.
  988. </para>
  989. </section>
  990. <section id='bitbake-dev-environment'>
  991. <title>BitBake</title>
  992. <para>
  993. The OpenEmbedded build system uses
  994. <ulink url='&YOCTO_DOCS_REF_URL;#bitbake-term'>BitBake</ulink>
  995. to produce images and Software Development Kits (SDKs).
  996. You can see from the
  997. <link linkend='general-workflow-figure'>general workflow figure</link>,
  998. the BitBake area consists of several functional areas.
  999. This section takes a closer look at each of those areas.
  1000. <note>
  1001. Separate documentation exists for the BitBake tool.
  1002. See the
  1003. <ulink url='&YOCTO_DOCS_BB_URL;#bitbake-user-manual'>BitBake User Manual</ulink>
  1004. for reference material on BitBake.
  1005. </note>
  1006. </para>
  1007. <section id='source-fetching-dev-environment'>
  1008. <title>Source Fetching</title>
  1009. <para>
  1010. The first stages of building a recipe are to fetch and
  1011. unpack the source code:
  1012. <imagedata fileref="figures/source-fetching.png" align="center" width="6.5in" depth="5in" />
  1013. </para>
  1014. <para>
  1015. The
  1016. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-fetch'><filename>do_fetch</filename></ulink>
  1017. and
  1018. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-unpack'><filename>do_unpack</filename></ulink>
  1019. tasks fetch the source files and unpack them into the
  1020. <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink>.
  1021. <note>
  1022. For every local file (e.g. <filename>file://</filename>)
  1023. that is part of a recipe's
  1024. <ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'><filename>SRC_URI</filename></ulink>
  1025. statement, the OpenEmbedded build system takes a
  1026. checksum of the file for the recipe and inserts the
  1027. checksum into the signature for the
  1028. <filename>do_fetch</filename> task.
  1029. If any local file has been modified, the
  1030. <filename>do_fetch</filename> task and all tasks that
  1031. depend on it are re-executed.
  1032. </note>
  1033. By default, everything is accomplished in the Build
  1034. Directory, which has a defined structure.
  1035. For additional general information on the Build Directory,
  1036. see the
  1037. "<ulink url='&YOCTO_DOCS_REF_URL;#structure-core-build'><filename>build/</filename></ulink>"
  1038. section in the Yocto Project Reference Manual.
  1039. </para>
  1040. <para>
  1041. Each recipe has an area in the Build Directory where the
  1042. unpacked source code resides.
  1043. The
  1044. <ulink url='&YOCTO_DOCS_REF_URL;#var-S'><filename>S</filename></ulink>
  1045. variable points to this area for a recipe's unpacked source
  1046. code.
  1047. The name of that directory for any given recipe is defined
  1048. from several different variables.
  1049. The preceding figure and the following list describe
  1050. the Build Directory's hierarchy:
  1051. <itemizedlist>
  1052. <listitem><para>
  1053. <ulink url='&YOCTO_DOCS_REF_URL;#var-TMPDIR'><filename>TMPDIR</filename></ulink>:
  1054. The base directory where the OpenEmbedded build
  1055. system performs all its work during the build.
  1056. The default base directory is the
  1057. <filename>tmp</filename> directory.
  1058. </para></listitem>
  1059. <listitem><para>
  1060. <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_ARCH'><filename>PACKAGE_ARCH</filename></ulink>:
  1061. The architecture of the built package or packages.
  1062. Depending on the eventual destination of the
  1063. package or packages (i.e. machine architecture,
  1064. <ulink url='&YOCTO_DOCS_REF_URL;#hardware-build-system-term'>build host</ulink>,
  1065. SDK, or specific machine),
  1066. <filename>PACKAGE_ARCH</filename> varies.
  1067. See the variable's description for details.
  1068. </para></listitem>
  1069. <listitem><para>
  1070. <ulink url='&YOCTO_DOCS_REF_URL;#var-TARGET_OS'><filename>TARGET_OS</filename></ulink>:
  1071. The operating system of the target device.
  1072. A typical value would be "linux" (e.g.
  1073. "qemux86-poky-linux").
  1074. </para></listitem>
  1075. <listitem><para>
  1076. <ulink url='&YOCTO_DOCS_REF_URL;#var-PN'><filename>PN</filename></ulink>:
  1077. The name of the recipe used to build the package.
  1078. This variable can have multiple meanings.
  1079. However, when used in the context of input files,
  1080. <filename>PN</filename> represents the the name
  1081. of the recipe.
  1082. </para></listitem>
  1083. <listitem><para>
  1084. <ulink url='&YOCTO_DOCS_REF_URL;#var-WORKDIR'><filename>WORKDIR</filename></ulink>:
  1085. The location where the OpenEmbedded build system
  1086. builds a recipe (i.e. does the work to create the
  1087. package).
  1088. <itemizedlist>
  1089. <listitem><para>
  1090. <ulink url='&YOCTO_DOCS_REF_URL;#var-PV'><filename>PV</filename></ulink>:
  1091. The version of the recipe used to build the
  1092. package.
  1093. </para></listitem>
  1094. <listitem><para>
  1095. <ulink url='&YOCTO_DOCS_REF_URL;#var-PR'><filename>PR</filename></ulink>:
  1096. The revision of the recipe used to build the
  1097. package.
  1098. </para></listitem>
  1099. </itemizedlist>
  1100. </para></listitem>
  1101. <listitem><para>
  1102. <ulink url='&YOCTO_DOCS_REF_URL;#var-S'><filename>S</filename></ulink>:
  1103. Contains the unpacked source files for a given
  1104. recipe.
  1105. <itemizedlist>
  1106. <listitem><para>
  1107. <ulink url='&YOCTO_DOCS_REF_URL;#var-BPN'><filename>BPN</filename></ulink>:
  1108. The name of the recipe used to build the
  1109. package.
  1110. The <filename>BPN</filename> variable is
  1111. a version of the <filename>PN</filename>
  1112. variable but with common prefixes and
  1113. suffixes removed.
  1114. </para></listitem>
  1115. <listitem><para>
  1116. <ulink url='&YOCTO_DOCS_REF_URL;#var-PV'><filename>PV</filename></ulink>:
  1117. The version of the recipe used to build the
  1118. package.
  1119. </para></listitem>
  1120. </itemizedlist>
  1121. </para></listitem>
  1122. </itemizedlist>
  1123. <note>
  1124. In the previous figure, notice that two sample
  1125. hierarchies exist: one based on package architecture (i.e.
  1126. <filename>PACKAGE_ARCH</filename>) and one based on a
  1127. machine (i.e. <filename>MACHINE</filename>).
  1128. The underlying structures are identical.
  1129. The differentiator being what the OpenEmbedded build
  1130. system is using as a build target (e.g. general
  1131. architecture, a build host, an SDK, or a specific
  1132. machine).
  1133. </note>
  1134. </para>
  1135. </section>
  1136. <section id='patching-dev-environment'>
  1137. <title>Patching</title>
  1138. <para>
  1139. Once source code is fetched and unpacked, BitBake locates
  1140. patch files and applies them to the source files:
  1141. <imagedata fileref="figures/patching.png" align="center" width="7in" depth="6in" />
  1142. </para>
  1143. <para>
  1144. The
  1145. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-patch'><filename>do_patch</filename></ulink>
  1146. task uses a recipe's
  1147. <ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'><filename>SRC_URI</filename></ulink>
  1148. statements and the
  1149. <ulink url='&YOCTO_DOCS_REF_URL;#var-FILESPATH'><filename>FILESPATH</filename></ulink>
  1150. variable to locate applicable patch files.
  1151. </para>
  1152. <para>
  1153. Default processing for patch files assumes the files have
  1154. either <filename>*.patch</filename> or
  1155. <filename>*.diff</filename> file types.
  1156. You can use <filename>SRC_URI</filename> parameters to
  1157. change the way the build system recognizes patch files.
  1158. See the
  1159. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-patch'><filename>do_patch</filename></ulink>
  1160. task for more information.
  1161. </para>
  1162. <para>
  1163. BitBake finds and applies multiple patches for a single
  1164. recipe in the order in which it locates the patches.
  1165. The <filename>FILESPATH</filename> variable defines the
  1166. default set of directories that the build system uses to
  1167. search for patch files.
  1168. Once found, patches are applied to the recipe's source
  1169. files, which are located in the
  1170. <ulink url='&YOCTO_DOCS_REF_URL;#var-S'><filename>S</filename></ulink>
  1171. directory.
  1172. </para>
  1173. <para>
  1174. For more information on how the source directories are
  1175. created, see the
  1176. "<link linkend='source-fetching-dev-environment'>Source Fetching</link>"
  1177. section.
  1178. For more information on how to create patches and how the
  1179. build system processes patches, see the
  1180. "<ulink url='&YOCTO_DOCS_DEV_URL;#new-recipe-patching-code'>Patching Code</ulink>"
  1181. section in the Yocto Project Development Tasks Manual.
  1182. You can also see the
  1183. "<ulink url='&YOCTO_DOCS_SDK_URL;#sdk-devtool-use-devtool-modify-to-modify-the-source-of-an-existing-component'>Use <filename>devtool modify</filename> to Modify the Source of an Existing Component</ulink>"
  1184. section in the Yocto Project Application Development and
  1185. the Extensible Software Development Kit (SDK) manual and
  1186. the
  1187. "<ulink url='&YOCTO_DOCS_KERNEL_DEV_URL;#using-traditional-kernel-development-to-patch-the-kernel'>Using Traditional Kernel Development to Patch the Kernel</ulink>"
  1188. section in the Yocto Project Linux Kernel Development
  1189. Manual.
  1190. </para>
  1191. </section>
  1192. <section id='configuration-compilation-and-staging-dev-environment'>
  1193. <title>Configuration, Compilation, and Staging</title>
  1194. <para>
  1195. After source code is patched, BitBake executes tasks that
  1196. configure and compile the source code.
  1197. Once compilation occurs, the files are copied to a holding
  1198. area (staged) in preparation for packaging:
  1199. <imagedata fileref="figures/configuration-compile-autoreconf.png" align="center" width="7in" depth="5in" />
  1200. </para>
  1201. <para>
  1202. This step in the build process consists of the following
  1203. tasks:
  1204. <itemizedlist>
  1205. <listitem><para>
  1206. <emphasis><ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-prepare_recipe_sysroot'><filename>do_prepare_recipe_sysroot</filename></ulink></emphasis>:
  1207. This task sets up the two sysroots in
  1208. <filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-WORKDIR'><filename>WORKDIR</filename></ulink><filename>}</filename>
  1209. (i.e. <filename>recipe-sysroot</filename> and
  1210. <filename>recipe-sysroot-native</filename>) so that
  1211. during the packaging phase the sysroots can contain
  1212. the contents of the
  1213. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-populate_sysroot'><filename>do_populate_sysroot</filename></ulink>
  1214. tasks of the recipes on which the recipe
  1215. containing the tasks depends.
  1216. A sysroot exists for both the target and for the
  1217. native binaries, which run on the host system.
  1218. </para></listitem>
  1219. <listitem><para>
  1220. <emphasis><filename>do_configure</filename></emphasis>:
  1221. This task configures the source by enabling and
  1222. disabling any build-time and configuration options
  1223. for the software being built.
  1224. Configurations can come from the recipe itself as
  1225. well as from an inherited class.
  1226. Additionally, the software itself might configure
  1227. itself depending on the target for which it is
  1228. being built.</para>
  1229. <para>The configurations handled by the
  1230. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-configure'><filename>do_configure</filename></ulink>
  1231. task are specific to configurations for the source
  1232. code being built by the recipe.</para>
  1233. <para>If you are using the
  1234. <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-autotools'><filename>autotools</filename></ulink>
  1235. class, you can add additional configuration options
  1236. by using the
  1237. <ulink url='&YOCTO_DOCS_REF_URL;#var-EXTRA_OECONF'><filename>EXTRA_OECONF</filename></ulink>
  1238. or
  1239. <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGECONFIG_CONFARGS'><filename>PACKAGECONFIG_CONFARGS</filename></ulink>
  1240. variables.
  1241. For information on how this variable works within
  1242. that class, see the
  1243. <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-autotools'><filename>autotools</filename></ulink>
  1244. class
  1245. <ulink url='&YOCTO_GIT_URL;/cgit/cgit.cgi/poky/tree/meta/classes/autotools.bbclass'>here</ulink>.
  1246. </para></listitem>
  1247. <listitem><para>
  1248. <emphasis><filename>do_compile</filename></emphasis>:
  1249. Once a configuration task has been satisfied,
  1250. BitBake compiles the source using the
  1251. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-compile'><filename>do_compile</filename></ulink>
  1252. task.
  1253. Compilation occurs in the directory pointed to by
  1254. the
  1255. <ulink url='&YOCTO_DOCS_REF_URL;#var-B'><filename>B</filename></ulink>
  1256. variable.
  1257. Realize that the <filename>B</filename> directory
  1258. is, by default, the same as the
  1259. <ulink url='&YOCTO_DOCS_REF_URL;#var-S'><filename>S</filename></ulink>
  1260. directory.
  1261. </para></listitem>
  1262. <listitem><para>
  1263. <emphasis><filename>do_install</filename></emphasis>:
  1264. After compilation completes, BitBake executes the
  1265. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-install'><filename>do_install</filename></ulink>
  1266. task.
  1267. This task copies files from the
  1268. <filename>B</filename> directory and places them
  1269. in a holding area pointed to by the
  1270. <ulink url='&YOCTO_DOCS_REF_URL;#var-D'><filename>D</filename></ulink>
  1271. variable.
  1272. Packaging occurs later using files from this
  1273. holding directory.
  1274. </para></listitem>
  1275. </itemizedlist>
  1276. </para>
  1277. </section>
  1278. <section id='package-splitting-dev-environment'>
  1279. <title>Package Splitting</title>
  1280. <para>
  1281. After source code is configured, compiled, and staged, the
  1282. build system analyzes the results and splits the output
  1283. into packages:
  1284. <imagedata fileref="figures/analysis-for-package-splitting.png" align="center" width="7in" depth="7in" />
  1285. </para>
  1286. <para>
  1287. The
  1288. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-package'><filename>do_package</filename></ulink>
  1289. and
  1290. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-packagedata'><filename>do_packagedata</filename></ulink>
  1291. tasks combine to analyze the files found in the
  1292. <ulink url='&YOCTO_DOCS_REF_URL;#var-D'><filename>D</filename></ulink>
  1293. directory and split them into subsets based on available
  1294. packages and files.
  1295. Analysis involves the following as well as other items:
  1296. splitting out debugging symbols, looking at shared library
  1297. dependencies between packages, and looking at package
  1298. relationships.
  1299. </para>
  1300. <para>
  1301. The <filename>do_packagedata</filename> task creates
  1302. package metadata based on the analysis such that the
  1303. build system can generate the final packages.
  1304. The
  1305. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-populate_sysroot'><filename>do_populate_sysroot</filename></ulink>
  1306. task stages (copies) a subset of the files installed by
  1307. the
  1308. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-install'><filename>do_install</filename></ulink>
  1309. task into the appropriate sysroot.
  1310. Working, staged, and intermediate results of the analysis
  1311. and package splitting process use several areas:
  1312. <itemizedlist>
  1313. <listitem><para>
  1314. <ulink url='&YOCTO_DOCS_REF_URL;#var-PKGD'><filename>PKGD</filename></ulink>:
  1315. The destination directory
  1316. (i.e. <filename>package</filename>) for packages
  1317. before they are split into individual packages.
  1318. </para></listitem>
  1319. <listitem><para>
  1320. <ulink url='&YOCTO_DOCS_REF_URL;#var-PKGDESTWORK'><filename>PKGDESTWORK</filename></ulink>:
  1321. A temporary work area (i.e.
  1322. <filename>pkgdata</filename>) used by the
  1323. <filename>do_package</filename> task to save
  1324. package metadata.
  1325. </para></listitem>
  1326. <listitem><para>
  1327. <ulink url='&YOCTO_DOCS_REF_URL;#var-PKGDEST'><filename>PKGDEST</filename></ulink>:
  1328. The parent directory (i.e.
  1329. <filename>packages-split</filename>) for packages
  1330. after they have been split.
  1331. </para></listitem>
  1332. <listitem><para>
  1333. <ulink url='&YOCTO_DOCS_REF_URL;#var-PKGDATA_DIR'><filename>PKGDATA_DIR</filename></ulink>:
  1334. A shared, global-state directory that holds
  1335. packaging metadata generated during the packaging
  1336. process.
  1337. The packaging process copies metadata from
  1338. <filename>PKGDESTWORK</filename> to the
  1339. <filename>PKGDATA_DIR</filename> area where it
  1340. becomes globally available.
  1341. </para></listitem>
  1342. <listitem><para>
  1343. <ulink url='&YOCTO_DOCS_REF_URL;#var-STAGING_DIR_HOST'><filename>STAGING_DIR_HOST</filename></ulink>:
  1344. The path for the sysroot for the system on which
  1345. a component is built to run (i.e.
  1346. <filename>recipe-sysroot</filename>).
  1347. </para></listitem>
  1348. <listitem><para>
  1349. <ulink url='&YOCTO_DOCS_REF_URL;#var-STAGING_DIR_NATIVE'><filename>STAGING_DIR_NATIVE</filename></ulink>:
  1350. The path for the sysroot used when building
  1351. components for the build host (i.e.
  1352. <filename>recipe-sysroot-native</filename>).
  1353. </para></listitem>
  1354. <listitem><para>
  1355. <ulink url='&YOCTO_DOCS_REF_URL;#var-STAGING_DIR_TARGET'><filename>STAGING_DIR_TARGET</filename></ulink>:
  1356. The path for the sysroot used when a component that
  1357. is built to execute on a system and it generates
  1358. code for yet another machine (e.g. cross-canadian
  1359. recipes).
  1360. </para></listitem>
  1361. </itemizedlist>
  1362. The
  1363. <ulink url='&YOCTO_DOCS_REF_URL;#var-FILES'><filename>FILES</filename></ulink>
  1364. variable defines the files that go into each package in
  1365. <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGES'><filename>PACKAGES</filename></ulink>.
  1366. If you want details on how this is accomplished, you can
  1367. look at
  1368. <ulink url='&YOCTO_GIT_URL;/cgit/cgit.cgi/poky/tree/meta/classes/package.bbclass'><filename>package.bbclass</filename></ulink>.
  1369. </para>
  1370. <para>
  1371. Depending on the type of packages being created (RPM, DEB,
  1372. or IPK), the
  1373. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-package_write_deb'><filename>do_package_write_*</filename></ulink>
  1374. task creates the actual packages and places them in the
  1375. Package Feed area, which is
  1376. <filename>${TMPDIR}/deploy</filename>.
  1377. You can see the
  1378. "<link linkend='package-feeds-dev-environment'>Package Feeds</link>"
  1379. section for more detail on that part of the build process.
  1380. <note>
  1381. Support for creating feeds directly from the
  1382. <filename>deploy/*</filename> directories does not
  1383. exist.
  1384. Creating such feeds usually requires some kind of feed
  1385. maintenance mechanism that would upload the new
  1386. packages into an official package feed (e.g. the
  1387. Ångström distribution).
  1388. This functionality is highly distribution-specific
  1389. and thus is not provided out of the box.
  1390. </note>
  1391. </para>
  1392. </section>
  1393. <section id='image-generation-dev-environment'>
  1394. <title>Image Generation</title>
  1395. <para>
  1396. Once packages are split and stored in the Package Feeds
  1397. area, the build system uses BitBake to generate the root
  1398. filesystem image:
  1399. <imagedata fileref="figures/image-generation.png" align="center" width="7.5in" depth="7.5in" />
  1400. </para>
  1401. <para>
  1402. The image generation process consists of several stages and
  1403. depends on several tasks and variables.
  1404. The
  1405. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-rootfs'><filename>do_rootfs</filename></ulink>
  1406. task creates the root filesystem (file and directory
  1407. structure) for an image.
  1408. This task uses several key variables to help create the
  1409. list of packages to actually install:
  1410. <itemizedlist>
  1411. <listitem><para>
  1412. <ulink url='&YOCTO_DOCS_REF_URL;#var-IMAGE_INSTALL'><filename>IMAGE_INSTALL</filename></ulink>:
  1413. Lists out the base set of packages from which to
  1414. install from the Package Feeds area.
  1415. </para></listitem>
  1416. <listitem><para>
  1417. <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_EXCLUDE'><filename>PACKAGE_EXCLUDE</filename></ulink>:
  1418. Specifies packages that should not be installed
  1419. into the image.
  1420. </para></listitem>
  1421. <listitem><para>
  1422. <ulink url='&YOCTO_DOCS_REF_URL;#var-IMAGE_FEATURES'><filename>IMAGE_FEATURES</filename></ulink>:
  1423. Specifies features to include in the image.
  1424. Most of these features map to additional packages
  1425. for installation.
  1426. </para></listitem>
  1427. <listitem><para>
  1428. <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_CLASSES'><filename>PACKAGE_CLASSES</filename></ulink>:
  1429. Specifies the package backend (e.g. RPM, DEB, or
  1430. IPK) to use and consequently helps determine where
  1431. to locate packages within the Package Feeds area.
  1432. </para></listitem>
  1433. <listitem><para>
  1434. <ulink url='&YOCTO_DOCS_REF_URL;#var-IMAGE_LINGUAS'><filename>IMAGE_LINGUAS</filename></ulink>:
  1435. Determines the language(s) for which additional
  1436. language support packages are installed.
  1437. </para></listitem>
  1438. <listitem><para>
  1439. <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_INSTALL'><filename>PACKAGE_INSTALL</filename></ulink>:
  1440. The final list of packages passed to the package
  1441. manager for installation into the image.
  1442. </para></listitem>
  1443. </itemizedlist>
  1444. </para>
  1445. <para>
  1446. With
  1447. <ulink url='&YOCTO_DOCS_REF_URL;#var-IMAGE_ROOTFS'><filename>IMAGE_ROOTFS</filename></ulink>
  1448. pointing to the location of the filesystem under
  1449. construction and the <filename>PACKAGE_INSTALL</filename>
  1450. variable providing the final list of packages to install,
  1451. the root file system is created.
  1452. </para>
  1453. <para>
  1454. Package installation is under control of the package
  1455. manager (e.g. dnf/rpm, opkg, or apt/dpkg) regardless of
  1456. whether or not package management is enabled for the
  1457. target.
  1458. At the end of the process, if package management is not
  1459. enabled for the target, the package manager's data files
  1460. are deleted from the root filesystem.
  1461. As part of the final stage of package installation,
  1462. post installation scripts that are part of the packages
  1463. are run.
  1464. Any scripts that fail to run on the build host are run on
  1465. the target when the target system is first booted.
  1466. If you are using a
  1467. <ulink url='&YOCTO_DOCS_DEV_URL;#creating-a-read-only-root-filesystem'>read-only root filesystem</ulink>,
  1468. all the post installation scripts must succeed on the
  1469. build host during the package installation phase since the
  1470. root filesystem on the target is read-only.
  1471. </para>
  1472. <para>
  1473. The final stages of the <filename>do_rootfs</filename> task
  1474. handle post processing.
  1475. Post processing includes creation of a manifest file and
  1476. optimizations.
  1477. </para>
  1478. <para>
  1479. The manifest file (<filename>.manifest</filename>) resides
  1480. in the same directory as the root filesystem image.
  1481. This file lists out, line-by-line, the installed packages.
  1482. The manifest file is useful for the
  1483. <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-testimage*'><filename>testimage</filename></ulink>
  1484. class, for example, to determine whether or not to run
  1485. specific tests.
  1486. See the
  1487. <ulink url='&YOCTO_DOCS_REF_URL;#var-IMAGE_MANIFEST'><filename>IMAGE_MANIFEST</filename></ulink>
  1488. variable for additional information.
  1489. </para>
  1490. <para>
  1491. Optimizing processes that are run across the image include
  1492. <filename>mklibs</filename>, <filename>prelink</filename>,
  1493. and any other post-processing commands as defined by the
  1494. <ulink url='&YOCTO_DOCS_REF_URL;#var-ROOTFS_POSTPROCESS_COMMAND'><filename>ROOTFS_POSTPROCESS_COMMAND</filename></ulink>
  1495. variable.
  1496. The <filename>mklibs</filename> process optimizes the size
  1497. of the libraries, while the <filename>prelink</filename>
  1498. process optimizes the dynamic linking of shared libraries
  1499. to reduce start up time of executables.
  1500. </para>
  1501. <para>
  1502. After the root filesystem is built, processing begins on
  1503. the image through the
  1504. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-image'><filename>do_image</filename></ulink>
  1505. task.
  1506. The build system runs any pre-processing commands as
  1507. defined by the
  1508. <ulink url='&YOCTO_DOCS_REF_URL;#var-IMAGE_PREPROCESS_COMMAND'><filename>IMAGE_PREPROCESS_COMMAND</filename></ulink>
  1509. variable.
  1510. This variable specifies a list of functions to call before
  1511. the build system creates the final image output files.
  1512. </para>
  1513. <para>
  1514. The build system dynamically creates
  1515. <filename>do_image_*</filename> tasks as needed, based
  1516. on the image types specified in the
  1517. <ulink url='&YOCTO_DOCS_REF_URL;#var-IMAGE_FSTYPES'><filename>IMAGE_FSTYPES</filename></ulink>
  1518. variable.
  1519. The process turns everything into an image file or a set of
  1520. image files and can compress the root filesystem image to
  1521. reduce the overall size of the image.
  1522. The formats used for the root filesystem depend on the
  1523. <filename>IMAGE_FSTYPES</filename> variable.
  1524. Compression depends on whether the formats support
  1525. compression.
  1526. </para>
  1527. <para>
  1528. As an example, a dynamically created task when creating a
  1529. particular image <replaceable>type</replaceable> would
  1530. take the following form:
  1531. <literallayout class='monospaced'>
  1532. do_image_<replaceable>type</replaceable>
  1533. </literallayout>
  1534. So, if the <replaceable>type</replaceable> as specified by
  1535. the <filename>IMAGE_FSTYPES</filename> were
  1536. <filename>ext4</filename>, the dynamically generated task
  1537. would be as follows:
  1538. <literallayout class='monospaced'>
  1539. do_image_ext4
  1540. </literallayout>
  1541. </para>
  1542. <para>
  1543. The final task involved in image creation is the
  1544. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-image-complete'><filename>do_image_complete</filename></ulink>
  1545. task.
  1546. This task completes the image by applying any image
  1547. post processing as defined through the
  1548. <ulink url='&YOCTO_DOCS_REF_URL;#var-IMAGE_POSTPROCESS_COMMAND'><filename>IMAGE_POSTPROCESS_COMMAND</filename></ulink>
  1549. variable.
  1550. The variable specifies a list of functions to call once the
  1551. build system has created the final image output files.
  1552. <note>
  1553. The entire image generation process is run under
  1554. <link linkend='fakeroot-and-pseudo'>Pseudo</link>.
  1555. Running under Pseudo ensures that the files in the
  1556. root filesystem have correct ownership.
  1557. </note>
  1558. </para>
  1559. </section>
  1560. <section id='sdk-generation-dev-environment'>
  1561. <title>SDK Generation</title>
  1562. <para>
  1563. The OpenEmbedded build system uses BitBake to generate the
  1564. Software Development Kit (SDK) installer scripts for both
  1565. the standard SDK and the extensible SDK (eSDK):
  1566. </para>
  1567. <para>
  1568. <imagedata fileref="figures/sdk-generation.png" width="9in" align="center" />
  1569. <note>
  1570. For more information on the cross-development toolchain
  1571. generation, see the
  1572. "<link linkend='cross-development-toolchain-generation'>Cross-Development Toolchain Generation</link>"
  1573. section.
  1574. For information on advantages gained when building a
  1575. cross-development toolchain using the
  1576. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-populate_sdk'><filename>do_populate_sdk</filename></ulink>
  1577. task, see the
  1578. "<ulink url='&YOCTO_DOCS_SDK_URL;#sdk-building-an-sdk-installer'>Building an SDK Installer</ulink>"
  1579. section in the Yocto Project Application Development
  1580. and the Extensible Software Development Kit (eSDK)
  1581. manual.
  1582. </note>
  1583. </para>
  1584. <para>
  1585. Like image generation, the SDK script process consists of
  1586. several stages and depends on many variables.
  1587. The
  1588. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-populate_sdk'><filename>do_populate_sdk</filename></ulink>
  1589. and
  1590. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-populate_sdk_ext'><filename>do_populate_sdk_ext</filename></ulink>
  1591. tasks use these key variables to help create the list of
  1592. packages to actually install.
  1593. For information on the variables listed in the figure,
  1594. see the
  1595. "<link linkend='sdk-dev-environment'>Application Development SDK</link>"
  1596. section.
  1597. </para>
  1598. <para>
  1599. The <filename>do_populate_sdk</filename> task helps create
  1600. the standard SDK and handles two parts: a target part and a
  1601. host part.
  1602. The target part is the part built for the target hardware
  1603. and includes libraries and headers.
  1604. The host part is the part of the SDK that runs on the
  1605. <ulink url='&YOCTO_DOCS_REF_URL;#var-SDKMACHINE'><filename>SDKMACHINE</filename></ulink>.
  1606. </para>
  1607. <para>
  1608. The <filename>do_populate_sdk_ext</filename> task helps
  1609. create the extensible SDK and handles host and target parts
  1610. differently than its counter part does for the standard SDK.
  1611. For the extensible SDK, the task encapsulates the build
  1612. system, which includes everything needed (host and target)
  1613. for the SDK.
  1614. </para>
  1615. <para>
  1616. Regardless of the type of SDK being constructed, the
  1617. tasks perform some cleanup after which a cross-development
  1618. environment setup script and any needed configuration files
  1619. are created.
  1620. The final output is the Cross-development
  1621. toolchain installation script (<filename>.sh</filename>
  1622. file), which includes the environment setup script.
  1623. </para>
  1624. </section>
  1625. <section id='stamp-files-and-the-rerunning-of-tasks'>
  1626. <title>Stamp Files and the Rerunning of Tasks</title>
  1627. <para>
  1628. For each task that completes successfully, BitBake writes a
  1629. stamp file into the
  1630. <ulink url='&YOCTO_DOCS_REF_URL;#var-STAMPS_DIR'><filename>STAMPS_DIR</filename></ulink>
  1631. directory.
  1632. The beginning of the stamp file's filename is determined
  1633. by the
  1634. <ulink url='&YOCTO_DOCS_REF_URL;#var-STAMP'><filename>STAMP</filename></ulink>
  1635. variable, and the end of the name consists of the task's
  1636. name and current
  1637. <link linkend='overview-checksums'>input checksum</link>.
  1638. <note>
  1639. This naming scheme assumes that
  1640. <ulink url='&YOCTO_DOCS_BB_URL;#var-BB_SIGNATURE_HANDLER'><filename>BB_SIGNATURE_HANDLER</filename></ulink>
  1641. is "OEBasicHash", which is almost always the case in
  1642. current OpenEmbedded.
  1643. </note>
  1644. To determine if a task needs to be rerun, BitBake checks
  1645. if a stamp file with a matching input checksum exists
  1646. for the task.
  1647. If such a stamp file exists, the task's output is
  1648. assumed to exist and still be valid.
  1649. If the file does not exist, the task is rerun.
  1650. <note>
  1651. <para>The stamp mechanism is more general than the
  1652. shared state (sstate) cache mechanism described in the
  1653. "<link linkend='setscene-tasks-and-shared-state'>Setscene Tasks and Shared State</link>"
  1654. section.
  1655. BitBake avoids rerunning any task that has a valid
  1656. stamp file, not just tasks that can be accelerated
  1657. through the sstate cache.</para>
  1658. <para>However, you should realize that stamp files only
  1659. serve as a marker that some work has been done and that
  1660. these files do not record task output.
  1661. The actual task output would usually be somewhere in
  1662. <ulink url='&YOCTO_DOCS_REF_URL;#var-TMPDIR'><filename>TMPDIR</filename></ulink>
  1663. (e.g. in some recipe's
  1664. <ulink url='&YOCTO_DOCS_REF_URL;#var-WORKDIR'><filename>WORKDIR</filename></ulink>.)
  1665. What the sstate cache mechanism adds is a way to cache
  1666. task output that can then be shared between build
  1667. machines.</para>
  1668. </note>
  1669. Since <filename>STAMPS_DIR</filename> is usually a
  1670. subdirectory of <filename>TMPDIR</filename>, removing
  1671. <filename>TMPDIR</filename> will also remove
  1672. <filename>STAMPS_DIR</filename>, which means tasks will
  1673. properly be rerun to repopulate
  1674. <filename>TMPDIR</filename>.
  1675. </para>
  1676. <para>
  1677. If you want some task to always be considered "out of
  1678. date", you can mark it with the
  1679. <ulink url='&YOCTO_DOCS_BB_URL;#variable-flags'><filename>nostamp</filename></ulink>
  1680. varflag.
  1681. If some other task depends on such a task, then that
  1682. task will also always be considered out of date, which
  1683. might not be what you want.
  1684. </para>
  1685. <para>
  1686. For details on how to view information about a task's
  1687. signature, see the
  1688. "<ulink url='&YOCTO_DOCS_DEV_URL;#dev-viewing-task-variable-dependencies'>Viewing Task Variable Dependencies</ulink>"
  1689. section in the Yocto Project Development Tasks Manual.
  1690. </para>
  1691. </section>
  1692. <section id='setscene-tasks-and-shared-state'>
  1693. <title>Setscene Tasks and Shared State</title>
  1694. <para>
  1695. The description of tasks so far assumes that BitBake needs
  1696. to build everything and no available prebuilt objects
  1697. exist.
  1698. BitBake does support skipping tasks if prebuilt objects are
  1699. available.
  1700. These objects are usually made available in the form of a
  1701. shared state (sstate) cache.
  1702. <note>
  1703. For information on variables affecting sstate, see the
  1704. <ulink url='&YOCTO_DOCS_REF_URL;#var-SSTATE_DIR'><filename>SSTATE_DIR</filename></ulink>
  1705. and
  1706. <ulink url='&YOCTO_DOCS_REF_URL;#var-SSTATE_MIRRORS'><filename>SSTATE_MIRRORS</filename></ulink>
  1707. variables.
  1708. </note>
  1709. </para>
  1710. <para>
  1711. The idea of a setscene task (i.e
  1712. <filename>do_</filename><replaceable>taskname</replaceable><filename>_setscene</filename>)
  1713. is a version of the task where
  1714. instead of building something, BitBake can skip to the end
  1715. result and simply place a set of files into specific
  1716. locations as needed.
  1717. In some cases, it makes sense to have a setscene task
  1718. variant (e.g. generating package files in the
  1719. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-package_write_deb'><filename>do_package_write_*</filename></ulink>
  1720. task).
  1721. In other cases, it does not make sense (e.g. a
  1722. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-patch'><filename>do_patch</filename></ulink>
  1723. task or a
  1724. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-unpack'><filename>do_unpack</filename></ulink>
  1725. task) since the work involved would be equal to or greater
  1726. than the underlying task.
  1727. </para>
  1728. <para>
  1729. In the build system, the common tasks that have setscene
  1730. variants are
  1731. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-package'><filename>do_package</filename></ulink>,
  1732. <filename>do_package_write_*</filename>,
  1733. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-deploy'><filename>do_deploy</filename></ulink>,
  1734. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-packagedata'><filename>do_packagedata</filename></ulink>,
  1735. and
  1736. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-populate_sysroot'><filename>do_populate_sysroot</filename></ulink>.
  1737. Notice that these tasks represent most of the tasks whose
  1738. output is an end result.
  1739. </para>
  1740. <para>
  1741. The build system has knowledge of the relationship between
  1742. these tasks and other preceding tasks.
  1743. For example, if BitBake runs
  1744. <filename>do_populate_sysroot_setscene</filename> for
  1745. something, it does not make sense to run any of the
  1746. <filename>do_fetch</filename>,
  1747. <filename>do_unpack</filename>,
  1748. <filename>do_patch</filename>,
  1749. <filename>do_configure</filename>,
  1750. <filename>do_compile</filename>, and
  1751. <filename>do_install</filename> tasks.
  1752. However, if <filename>do_package</filename> needs to be
  1753. run, BitBake needs to run those other tasks.
  1754. </para>
  1755. <para>
  1756. It becomes more complicated if everything can come
  1757. from an sstate cache because some objects are simply
  1758. not required at all.
  1759. For example, you do not need a compiler or native tools,
  1760. such as quilt, if nothing exists to compile or patch.
  1761. If the <filename>do_package_write_*</filename> packages
  1762. are available from sstate, BitBake does not need the
  1763. <filename>do_package</filename> task data.
  1764. </para>
  1765. <para>
  1766. To handle all these complexities, BitBake runs in two
  1767. phases.
  1768. The first is the "setscene" stage.
  1769. During this stage, BitBake first checks the sstate cache
  1770. for any targets it is planning to build.
  1771. BitBake does a fast check to see if the object exists
  1772. rather than a complete download.
  1773. If nothing exists, the second phase, which is the setscene
  1774. stage, completes and the main build proceeds.
  1775. </para>
  1776. <para>
  1777. If objects are found in the sstate cache, the build system
  1778. works backwards from the end targets specified by the user.
  1779. For example, if an image is being built, the build system
  1780. first looks for the packages needed for that image and the
  1781. tools needed to construct an image.
  1782. If those are available, the compiler is not needed.
  1783. Thus, the compiler is not even downloaded.
  1784. If something was found to be unavailable, or the
  1785. download or setscene task fails, the build system then
  1786. tries to install dependencies, such as the compiler, from
  1787. the cache.
  1788. </para>
  1789. <para>
  1790. The availability of objects in the sstate cache is
  1791. handled by the function specified by the
  1792. <ulink url='&YOCTO_DOCS_BB_URL;#var-BB_HASHCHECK_FUNCTION'><filename>BB_HASHCHECK_FUNCTION</filename></ulink>
  1793. variable and returns a list of available objects.
  1794. The function specified by the
  1795. <ulink url='&YOCTO_DOCS_BB_URL;#var-BB_SETSCENE_DEPVALID'><filename>BB_SETSCENE_DEPVALID</filename></ulink>
  1796. variable is the function that determines whether a given
  1797. dependency needs to be followed, and whether for any given
  1798. relationship the function needs to be passed.
  1799. The function returns a True or False value.
  1800. </para>
  1801. </section>
  1802. </section>
  1803. <section id='images-dev-environment'>
  1804. <title>Images</title>
  1805. <para>
  1806. The images produced by the build system are compressed forms
  1807. of the root filesystem and are ready to boot on a target
  1808. device.
  1809. You can see from the
  1810. <link linkend='general-workflow-figure'>general workflow figure</link>
  1811. that BitBake output, in part, consists of images.
  1812. This section takes a closer look at this output:
  1813. <imagedata fileref="figures/images.png" align="center" width="5.5in" depth="5.5in" />
  1814. </para>
  1815. <note>
  1816. For a list of example images that the Yocto Project provides,
  1817. see the
  1818. "<ulink url='&YOCTO_DOCS_REF_URL;#ref-images'>Images</ulink>"
  1819. chapter in the Yocto Project Reference Manual.
  1820. </note>
  1821. <para>
  1822. The build process writes images out to the
  1823. <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink>
  1824. inside the
  1825. <filename>tmp/deploy/images/<replaceable>machine</replaceable>/</filename>
  1826. folder as shown in the figure.
  1827. This folder contains any files expected to be loaded on the
  1828. target device.
  1829. The
  1830. <ulink url='&YOCTO_DOCS_REF_URL;#var-DEPLOY_DIR'><filename>DEPLOY_DIR</filename></ulink>
  1831. variable points to the <filename>deploy</filename> directory,
  1832. while the
  1833. <ulink url='&YOCTO_DOCS_REF_URL;#var-DEPLOY_DIR_IMAGE'><filename>DEPLOY_DIR_IMAGE</filename></ulink>
  1834. variable points to the appropriate directory containing images
  1835. for the current configuration.
  1836. <itemizedlist>
  1837. <listitem><para>
  1838. <replaceable>kernel-image</replaceable>:
  1839. A kernel binary file.
  1840. The
  1841. <ulink url='&YOCTO_DOCS_REF_URL;#var-KERNEL_IMAGETYPE'><filename>KERNEL_IMAGETYPE</filename></ulink>
  1842. variable determines the naming scheme for the
  1843. kernel image file.
  1844. Depending on this variable, the file could begin with
  1845. a variety of naming strings.
  1846. The
  1847. <filename>deploy/images/</filename><replaceable>machine</replaceable>
  1848. directory can contain multiple image files for the
  1849. machine.
  1850. </para></listitem>
  1851. <listitem><para>
  1852. <replaceable>root-filesystem-image</replaceable>:
  1853. Root filesystems for the target device (e.g.
  1854. <filename>*.ext3</filename> or
  1855. <filename>*.bz2</filename> files).
  1856. The
  1857. <ulink url='&YOCTO_DOCS_REF_URL;#var-IMAGE_FSTYPES'><filename>IMAGE_FSTYPES</filename></ulink>
  1858. variable determines the root filesystem image type.
  1859. The
  1860. <filename>deploy/images/</filename><replaceable>machine</replaceable>
  1861. directory can contain multiple root filesystems for the
  1862. machine.
  1863. </para></listitem>
  1864. <listitem><para>
  1865. <replaceable>kernel-modules</replaceable>:
  1866. Tarballs that contain all the modules built for the
  1867. kernel.
  1868. Kernel module tarballs exist for legacy purposes and
  1869. can be suppressed by setting the
  1870. <ulink url='&YOCTO_DOCS_REF_URL;#var-MODULE_TARBALL_DEPLOY'><filename>MODULE_TARBALL_DEPLOY</filename></ulink>
  1871. variable to "0".
  1872. The
  1873. <filename>deploy/images/</filename><replaceable>machine</replaceable>
  1874. directory can contain multiple kernel module tarballs
  1875. for the machine.
  1876. </para></listitem>
  1877. <listitem><para>
  1878. <replaceable>bootloaders</replaceable>:
  1879. If applicable to the target machine, bootloaders
  1880. supporting the image.
  1881. The <filename>deploy/images/</filename><replaceable>machine</replaceable>
  1882. directory can contain multiple bootloaders for the
  1883. machine.
  1884. </para></listitem>
  1885. <listitem><para>
  1886. <replaceable>symlinks</replaceable>:
  1887. The
  1888. <filename>deploy/images/</filename><replaceable>machine</replaceable>
  1889. folder contains a symbolic link that points to the
  1890. most recently built file for each machine.
  1891. These links might be useful for external scripts that
  1892. need to obtain the latest version of each file.
  1893. </para></listitem>
  1894. </itemizedlist>
  1895. </para>
  1896. </section>
  1897. <section id='sdk-dev-environment'>
  1898. <title>Application Development SDK</title>
  1899. <para>
  1900. In the
  1901. <link linkend='general-workflow-figure'>general workflow figure</link>,
  1902. the output labeled "Application Development SDK" represents an
  1903. SDK.
  1904. The SDK generation process differs depending on whether you
  1905. build an extensible SDK (e.g.
  1906. <filename>bitbake -c populate_sdk_ext</filename> <replaceable>imagename</replaceable>)
  1907. or a standard SDK (e.g.
  1908. <filename>bitbake -c populate_sdk</filename> <replaceable>imagename</replaceable>).
  1909. This section takes a closer look at this output:
  1910. <imagedata fileref="figures/sdk.png" align="center" width="9in" depth="7.25in" />
  1911. </para>
  1912. <para>
  1913. The specific form of this output is a set of files that
  1914. includes a self-extracting SDK installer
  1915. (<filename>*.sh</filename>), host and target manifest files,
  1916. and files used for SDK testing.
  1917. When the SDK installer file is run, it installs the SDK.
  1918. The SDK consists of a cross-development toolchain, a set of
  1919. libraries and headers, and an SDK environment setup script.
  1920. Running this installer essentially sets up your
  1921. cross-development environment.
  1922. You can think of the cross-toolchain as the "host"
  1923. part because it runs on the SDK machine.
  1924. You can think of the libraries and headers as the "target"
  1925. part because they are built for the target hardware.
  1926. The environment setup script is added so that you can
  1927. initialize the environment before using the tools.
  1928. </para>
  1929. <note><title>Notes</title>
  1930. <itemizedlist>
  1931. <listitem><para>
  1932. The Yocto Project supports several methods by which
  1933. you can set up this cross-development environment.
  1934. These methods include downloading pre-built SDK
  1935. installers or building and installing your own SDK
  1936. installer.
  1937. </para></listitem>
  1938. <listitem><para>
  1939. For background information on cross-development
  1940. toolchains in the Yocto Project development
  1941. environment, see the
  1942. "<link linkend='cross-development-toolchain-generation'>Cross-Development Toolchain Generation</link>"
  1943. section.
  1944. </para></listitem>
  1945. <listitem><para>
  1946. For information on setting up a cross-development
  1947. environment, see the
  1948. <ulink url='&YOCTO_DOCS_SDK_URL;'>Yocto Project Application Development and the Extensible Software Development Kit (eSDK)</ulink>
  1949. manual.
  1950. </para></listitem>
  1951. </itemizedlist>
  1952. </note>
  1953. <para>
  1954. All the output files for an SDK are written to the
  1955. <filename>deploy/sdk</filename> folder inside the
  1956. <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink>
  1957. as shown in the previous figure.
  1958. Depending on the type of SDK, several variables exist that help
  1959. configure these files.
  1960. The following list shows the variables associated with an
  1961. extensible SDK:
  1962. <itemizedlist>
  1963. <listitem><para>
  1964. <ulink url='&YOCTO_DOCS_REF_URL;#var-DEPLOY_DIR'><filename>DEPLOY_DIR</filename></ulink>:
  1965. Points to the <filename>deploy</filename> directory.
  1966. </para></listitem>
  1967. <listitem><para>
  1968. <ulink url='&YOCTO_DOCS_REF_URL;#var-SDK_EXT_TYPE'><filename>SDK_EXT_TYPE</filename></ulink>:
  1969. Controls whether or not shared state artifacts are
  1970. copied into the extensible SDK.
  1971. By default, all required shared state artifacts are
  1972. copied into the SDK.
  1973. </para></listitem>
  1974. <listitem><para>
  1975. <ulink url='&YOCTO_DOCS_REF_URL;#var-SDK_INCLUDE_PKGDATA'><filename>SDK_INCLUDE_PKGDATA</filename></ulink>:
  1976. Specifies whether or not packagedata is included in the
  1977. extensible SDK for all recipes in the "world" target.
  1978. </para></listitem>
  1979. <listitem><para>
  1980. <ulink url='&YOCTO_DOCS_REF_URL;#var-SDK_INCLUDE_TOOLCHAIN'><filename>SDK_INCLUDE_TOOLCHAIN</filename></ulink>:
  1981. Specifies whether or not the toolchain is included
  1982. when building the extensible SDK.
  1983. </para></listitem>
  1984. <listitem><para>
  1985. <ulink url='&YOCTO_DOCS_REF_URL;#var-SDK_LOCAL_CONF_WHITELIST'><filename>SDK_LOCAL_CONF_WHITELIST</filename></ulink>:
  1986. A list of variables allowed through from the build
  1987. system configuration into the extensible SDK
  1988. configuration.
  1989. </para></listitem>
  1990. <listitem><para>
  1991. <ulink url='&YOCTO_DOCS_REF_URL;#var-SDK_LOCAL_CONF_BLACKLIST'><filename>SDK_LOCAL_CONF_BLACKLIST</filename></ulink>:
  1992. A list of variables not allowed through from the build
  1993. system configuration into the extensible SDK
  1994. configuration.
  1995. </para></listitem>
  1996. <listitem><para>
  1997. <ulink url='&YOCTO_DOCS_REF_URL;#var-SDK_INHERIT_BLACKLIST'><filename>SDK_INHERIT_BLACKLIST</filename></ulink>:
  1998. A list of classes to remove from the
  1999. <ulink url='&YOCTO_DOCS_REF_URL;#var-INHERIT'><filename>INHERIT</filename></ulink>
  2000. value globally within the extensible SDK configuration.
  2001. </para></listitem>
  2002. </itemizedlist>
  2003. This next list, shows the variables associated with a standard
  2004. SDK:
  2005. <itemizedlist>
  2006. <listitem><para>
  2007. <ulink url='&YOCTO_DOCS_REF_URL;#var-DEPLOY_DIR'><filename>DEPLOY_DIR</filename></ulink>:
  2008. Points to the <filename>deploy</filename> directory.
  2009. </para></listitem>
  2010. <listitem><para>
  2011. <ulink url='&YOCTO_DOCS_REF_URL;#var-SDKMACHINE'><filename>SDKMACHINE</filename></ulink>:
  2012. Specifies the architecture of the machine on which the
  2013. cross-development tools are run to create packages for
  2014. the target hardware.
  2015. </para></listitem>
  2016. <listitem><para>
  2017. <ulink url='&YOCTO_DOCS_REF_URL;#var-SDKIMAGE_FEATURES'><filename>SDKIMAGE_FEATURES</filename></ulink>:
  2018. Lists the features to include in the "target" part
  2019. of the SDK.
  2020. </para></listitem>
  2021. <listitem><para>
  2022. <ulink url='&YOCTO_DOCS_REF_URL;#var-TOOLCHAIN_HOST_TASK'><filename>TOOLCHAIN_HOST_TASK</filename></ulink>:
  2023. Lists packages that make up the host part of the SDK
  2024. (i.e. the part that runs on the
  2025. <filename>SDKMACHINE</filename>).
  2026. When you use
  2027. <filename>bitbake -c populate_sdk <replaceable>imagename</replaceable></filename>
  2028. to create the SDK, a set of default packages apply.
  2029. This variable allows you to add more packages.
  2030. </para></listitem>
  2031. <listitem><para>
  2032. <ulink url='&YOCTO_DOCS_REF_URL;#var-TOOLCHAIN_TARGET_TASK'><filename>TOOLCHAIN_TARGET_TASK</filename></ulink>:
  2033. Lists packages that make up the target part of the SDK
  2034. (i.e. the part built for the target hardware).
  2035. </para></listitem>
  2036. <listitem><para>
  2037. <ulink url='&YOCTO_DOCS_REF_URL;#var-SDKPATH'><filename>SDKPATH</filename></ulink>:
  2038. Defines the default SDK installation path offered by
  2039. the installation script.
  2040. </para></listitem>
  2041. <listitem><para>
  2042. <ulink url='&YOCTO_DOCS_REF_URL;#var-SDK_HOST_MANIFEST'><filename>SDK_HOST_MANIFEST</filename></ulink>:
  2043. Lists all the installed packages that make up the host
  2044. part of the SDK.
  2045. This variable also plays a minor role for extensible
  2046. SDK development as well.
  2047. However, it is mainly used for the standard SDK.
  2048. </para></listitem>
  2049. <listitem><para>
  2050. <ulink url='&YOCTO_DOCS_REF_URL;#var-SDK_TARGET_MANIFEST'><filename>SDK_TARGET_MANIFEST</filename></ulink>:
  2051. Lists all the installed packages that make up the
  2052. target part of the SDK.
  2053. This variable also plays a minor role for extensible
  2054. SDK development as well.
  2055. However, it is mainly used for the standard SDK.
  2056. </para></listitem>
  2057. </itemizedlist>
  2058. </para>
  2059. </section>
  2060. </section>
  2061. <section id="cross-development-toolchain-generation">
  2062. <title>Cross-Development Toolchain Generation</title>
  2063. <para>
  2064. The Yocto Project does most of the work for you when it comes to
  2065. creating
  2066. <ulink url='&YOCTO_DOCS_REF_URL;#cross-development-toolchain'>cross-development toolchains</ulink>.
  2067. This section provides some technical background on how
  2068. cross-development toolchains are created and used.
  2069. For more information on toolchains, you can also see the
  2070. <ulink url='&YOCTO_DOCS_SDK_URL;'>Yocto Project Application Development and the Extensible Software Development Kit (eSDK)</ulink>
  2071. manual.
  2072. </para>
  2073. <para>
  2074. In the Yocto Project development environment, cross-development
  2075. toolchains are used to build images and applications that run
  2076. on the target hardware.
  2077. With just a few commands, the OpenEmbedded build system creates
  2078. these necessary toolchains for you.
  2079. </para>
  2080. <para>
  2081. The following figure shows a high-level build environment regarding
  2082. toolchain construction and use.
  2083. </para>
  2084. <para>
  2085. <imagedata fileref="figures/cross-development-toolchains.png" width="8in" depth="6in" align="center" />
  2086. </para>
  2087. <para>
  2088. Most of the work occurs on the Build Host.
  2089. This is the machine used to build images and generally work within
  2090. the the Yocto Project environment.
  2091. When you run
  2092. <ulink url='&YOCTO_DOCS_REF_URL;#bitbake-term'>BitBake</ulink>
  2093. to create an image, the OpenEmbedded build system
  2094. uses the host <filename>gcc</filename> compiler to bootstrap a
  2095. cross-compiler named <filename>gcc-cross</filename>.
  2096. The <filename>gcc-cross</filename> compiler is what BitBake uses to
  2097. compile source files when creating the target image.
  2098. You can think of <filename>gcc-cross</filename> simply as an
  2099. automatically generated cross-compiler that is used internally
  2100. within BitBake only.
  2101. <note>
  2102. The extensible SDK does not use
  2103. <filename>gcc-cross-canadian</filename> since this SDK
  2104. ships a copy of the OpenEmbedded build system and the sysroot
  2105. within it contains <filename>gcc-cross</filename>.
  2106. </note>
  2107. </para>
  2108. <para>
  2109. The chain of events that occurs when <filename>gcc-cross</filename> is
  2110. bootstrapped is as follows:
  2111. <literallayout class='monospaced'>
  2112. gcc -> binutils-cross -> gcc-cross-initial -> linux-libc-headers -> glibc-initial -> glibc -> gcc-cross -> gcc-runtime
  2113. </literallayout>
  2114. <itemizedlist>
  2115. <listitem><para>
  2116. <filename>gcc</filename>:
  2117. The build host's GNU Compiler Collection (GCC).
  2118. </para></listitem>
  2119. <listitem><para>
  2120. <filename>binutils-cross</filename>:
  2121. The bare minimum binary utilities needed in order to run
  2122. the <filename>gcc-cross-initial</filename> phase of the
  2123. bootstrap operation.
  2124. </para></listitem>
  2125. <listitem><para>
  2126. <filename>gcc-cross-initial</filename>:
  2127. An early stage of the bootstrap process for creating
  2128. the cross-compiler.
  2129. This stage builds enough of the <filename>gcc-cross</filename>,
  2130. the C library, and other pieces needed to finish building the
  2131. final cross-compiler in later stages.
  2132. This tool is a "native" package (i.e. it is designed to run on
  2133. the build host).
  2134. </para></listitem>
  2135. <listitem><para>
  2136. <filename>linux-libc-headers</filename>:
  2137. Headers needed for the cross-compiler.
  2138. </para></listitem>
  2139. <listitem><para>
  2140. <filename>glibc-initial</filename>:
  2141. An initial version of the Embedded GNU C Library
  2142. (GLIBC) needed to bootstrap <filename>glibc</filename>.
  2143. </para></listitem>
  2144. <listitem><para>
  2145. <filename>glibc</filename>:
  2146. The GNU C Library.
  2147. </para></listitem>
  2148. <listitem><para>
  2149. <filename>gcc-cross</filename>:
  2150. The final stage of the bootstrap process for the
  2151. cross-compiler.
  2152. This stage results in the actual cross-compiler that
  2153. BitBake uses when it builds an image for a targeted
  2154. device.
  2155. <note>
  2156. If you are replacing this cross compiler toolchain
  2157. with a custom version, you must replace
  2158. <filename>gcc-cross</filename>.
  2159. </note>
  2160. This tool is also a "native" package (i.e. it is
  2161. designed to run on the build host).
  2162. </para></listitem>
  2163. <listitem><para>
  2164. <filename>gcc-runtime</filename>:
  2165. Runtime libraries resulting from the toolchain bootstrapping
  2166. process.
  2167. This tool produces a binary that consists of the
  2168. runtime libraries need for the targeted device.
  2169. </para></listitem>
  2170. </itemizedlist>
  2171. </para>
  2172. <para>
  2173. You can use the OpenEmbedded build system to build an installer for
  2174. the relocatable SDK used to develop applications.
  2175. When you run the installer, it installs the toolchain, which
  2176. contains the development tools (e.g.,
  2177. <filename>gcc-cross-canadian</filename>,
  2178. <filename>binutils-cross-canadian</filename>, and other
  2179. <filename>nativesdk-*</filename> tools),
  2180. which are tools native to the SDK (i.e. native to
  2181. <ulink url='&YOCTO_DOCS_REF_URL;#var-SDK_ARCH'><filename>SDK_ARCH</filename></ulink>),
  2182. you need to cross-compile and test your software.
  2183. The figure shows the commands you use to easily build out this
  2184. toolchain.
  2185. This cross-development toolchain is built to execute on the
  2186. <ulink url='&YOCTO_DOCS_REF_URL;#var-SDKMACHINE'><filename>SDKMACHINE</filename></ulink>,
  2187. which might or might not be the same
  2188. machine as the Build Host.
  2189. <note>
  2190. If your target architecture is supported by the Yocto Project,
  2191. you can take advantage of pre-built images that ship with the
  2192. Yocto Project and already contain cross-development toolchain
  2193. installers.
  2194. </note>
  2195. </para>
  2196. <para>
  2197. Here is the bootstrap process for the relocatable toolchain:
  2198. <literallayout class='monospaced'>
  2199. gcc -> binutils-crosssdk -> gcc-crosssdk-initial -> linux-libc-headers ->
  2200. glibc-initial -> nativesdk-glibc -> gcc-crosssdk -> gcc-cross-canadian
  2201. </literallayout>
  2202. <itemizedlist>
  2203. <listitem><para>
  2204. <filename>gcc</filename>:
  2205. The build host's GNU Compiler Collection (GCC).
  2206. </para></listitem>
  2207. <listitem><para>
  2208. <filename>binutils-crosssdk</filename>:
  2209. The bare minimum binary utilities needed in order to run
  2210. the <filename>gcc-crosssdk-initial</filename> phase of the
  2211. bootstrap operation.
  2212. </para></listitem>
  2213. <listitem><para>
  2214. <filename>gcc-crosssdk-initial</filename>:
  2215. An early stage of the bootstrap process for creating
  2216. the cross-compiler.
  2217. This stage builds enough of the
  2218. <filename>gcc-crosssdk</filename> and supporting pieces so that
  2219. the final stage of the bootstrap process can produce the
  2220. finished cross-compiler.
  2221. This tool is a "native" binary that runs on the build host.
  2222. </para></listitem>
  2223. <listitem><para>
  2224. <filename>linux-libc-headers</filename>:
  2225. Headers needed for the cross-compiler.
  2226. </para></listitem>
  2227. <listitem><para>
  2228. <filename>glibc-initial</filename>:
  2229. An initial version of the Embedded GLIBC needed to bootstrap
  2230. <filename>nativesdk-glibc</filename>.
  2231. </para></listitem>
  2232. <listitem><para>
  2233. <filename>nativesdk-glibc</filename>:
  2234. The Embedded GLIBC needed to bootstrap the
  2235. <filename>gcc-crosssdk</filename>.
  2236. </para></listitem>
  2237. <listitem><para>
  2238. <filename>gcc-crosssdk</filename>:
  2239. The final stage of the bootstrap process for the
  2240. relocatable cross-compiler.
  2241. The <filename>gcc-crosssdk</filename> is a transitory
  2242. compiler and never leaves the build host.
  2243. Its purpose is to help in the bootstrap process to create
  2244. the eventual <filename>gcc-cross-canadian</filename>
  2245. compiler, which is relocatable.
  2246. This tool is also a "native" package (i.e. it is
  2247. designed to run on the build host).
  2248. </para></listitem>
  2249. <listitem><para>
  2250. <filename>gcc-cross-canadian</filename>:
  2251. The final relocatable cross-compiler.
  2252. When run on the
  2253. <ulink url='&YOCTO_DOCS_REF_URL;#var-SDKMACHINE'><filename>SDKMACHINE</filename></ulink>,
  2254. this tool
  2255. produces executable code that runs on the target device.
  2256. Only one cross-canadian compiler is produced per architecture
  2257. since they can be targeted at different processor optimizations
  2258. using configurations passed to the compiler through the
  2259. compile commands.
  2260. This circumvents the need for multiple compilers and thus
  2261. reduces the size of the toolchains.
  2262. </para></listitem>
  2263. </itemizedlist>
  2264. </para>
  2265. <note>
  2266. For information on advantages gained when building a
  2267. cross-development toolchain installer, see the
  2268. "<ulink url='&YOCTO_DOCS_SDK_URL;#sdk-building-an-sdk-installer'>Building an SDK Installer</ulink>"
  2269. appendix in the Yocto Project Application Development and the
  2270. Extensible Software Development Kit (eSDK) manual.
  2271. </note>
  2272. </section>
  2273. <section id="shared-state-cache">
  2274. <title>Shared State Cache</title>
  2275. <para>
  2276. By design, the OpenEmbedded build system builds everything from
  2277. scratch unless
  2278. <ulink url='&YOCTO_DOCS_REF_URL;#bitbake-term'>BitBake</ulink>
  2279. can determine that parts do not need to be rebuilt.
  2280. Fundamentally, building from scratch is attractive as it means all
  2281. parts are built fresh and no possibility of stale data exists that
  2282. can cause problems.
  2283. When developers hit problems, they typically default back to
  2284. building from scratch so they have a know state from the
  2285. start.
  2286. </para>
  2287. <para>
  2288. Building an image from scratch is both an advantage and a
  2289. disadvantage to the process.
  2290. As mentioned in the previous paragraph, building from scratch
  2291. ensures that everything is current and starts from a known state.
  2292. However, building from scratch also takes much longer as it
  2293. generally means rebuilding things that do not necessarily need
  2294. to be rebuilt.
  2295. </para>
  2296. <para>
  2297. The Yocto Project implements shared state code that supports
  2298. incremental builds.
  2299. The implementation of the shared state code answers the following
  2300. questions that were fundamental roadblocks within the OpenEmbedded
  2301. incremental build support system:
  2302. <itemizedlist>
  2303. <listitem><para>
  2304. What pieces of the system have changed and what pieces have
  2305. not changed?
  2306. </para></listitem>
  2307. <listitem><para>
  2308. How are changed pieces of software removed and replaced?
  2309. </para></listitem>
  2310. <listitem><para>
  2311. How are pre-built components that do not need to be rebuilt
  2312. from scratch used when they are available?
  2313. </para></listitem>
  2314. </itemizedlist>
  2315. </para>
  2316. <para>
  2317. For the first question, the build system detects changes in the
  2318. "inputs" to a given task by creating a checksum (or signature) of
  2319. the task's inputs.
  2320. If the checksum changes, the system assumes the inputs have changed
  2321. and the task needs to be rerun.
  2322. For the second question, the shared state (sstate) code tracks
  2323. which tasks add which output to the build process.
  2324. This means the output from a given task can be removed, upgraded
  2325. or otherwise manipulated.
  2326. The third question is partly addressed by the solution for the
  2327. second question assuming the build system can fetch the sstate
  2328. objects from remote locations and install them if they are deemed
  2329. to be valid.
  2330. <note><title>Notes</title>
  2331. <itemizedlist>
  2332. <listitem><para>
  2333. The build system does not maintain
  2334. <ulink url='&YOCTO_DOCS_REF_URL;#var-PR'><filename>PR</filename></ulink>
  2335. information as part of the shared state packages.
  2336. Consequently, considerations exist that affect
  2337. maintaining shared state feeds.
  2338. For information on how the build system works with
  2339. packages and can track incrementing
  2340. <filename>PR</filename> information, see the
  2341. "<ulink url='&YOCTO_DOCS_DEV_URL;#automatically-incrementing-a-binary-package-revision-number'>Automatically Incrementing a Binary Package Revision Number</ulink>"
  2342. section in the Yocto Project Development Tasks Manual.
  2343. </para></listitem>
  2344. <listitem><para>
  2345. The code in the build system that supports incremental
  2346. builds is not simple code.
  2347. For techniques that help you work around issues related
  2348. to shared state code, see the
  2349. "<ulink url='&YOCTO_DOCS_DEV_URL;#dev-viewing-metadata-used-to-create-the-input-signature-of-a-shared-state-task'>Viewing Metadata Used to Create the Input Signature of a Shared State Task</ulink>"
  2350. and
  2351. "<ulink url='&YOCTO_DOCS_DEV_URL;#dev-invalidating-shared-state-to-force-a-task-to-run'>Invalidating Shared State to Force a Task to Run</ulink>"
  2352. sections both in the Yocto Project Development Tasks
  2353. Manual.
  2354. </para></listitem>
  2355. </itemizedlist>
  2356. </note>
  2357. </para>
  2358. <para>
  2359. The rest of this section goes into detail about the overall
  2360. incremental build architecture, the checksums (signatures), and
  2361. shared state.
  2362. </para>
  2363. <section id='concepts-overall-architecture'>
  2364. <title>Overall Architecture</title>
  2365. <para>
  2366. When determining what parts of the system need to be built,
  2367. BitBake works on a per-task basis rather than a per-recipe
  2368. basis.
  2369. You might wonder why using a per-task basis is preferred over
  2370. a per-recipe basis.
  2371. To help explain, consider having the IPK packaging backend
  2372. enabled and then switching to DEB.
  2373. In this case, the
  2374. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-install'><filename>do_install</filename></ulink>
  2375. and
  2376. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-package'><filename>do_package</filename></ulink>
  2377. task outputs are still valid.
  2378. However, with a per-recipe approach, the build would not
  2379. include the <filename>.deb</filename> files.
  2380. Consequently, you would have to invalidate the whole build and
  2381. rerun it.
  2382. Rerunning everything is not the best solution.
  2383. Also, in this case, the core must be "taught" much about
  2384. specific tasks.
  2385. This methodology does not scale well and does not allow users
  2386. to easily add new tasks in layers or as external recipes
  2387. without touching the packaged-staging core.
  2388. </para>
  2389. </section>
  2390. <section id='overview-checksums'>
  2391. <title>Checksums (Signatures)</title>
  2392. <para>
  2393. The shared state code uses a checksum, which is a unique
  2394. signature of a task's inputs, to determine if a task needs to
  2395. be run again.
  2396. Because it is a change in a task's inputs that triggers a
  2397. rerun, the process needs to detect all the inputs to a given
  2398. task.
  2399. For shell tasks, this turns out to be fairly easy because
  2400. the build process generates a "run" shell script for each task
  2401. and it is possible to create a checksum that gives you a good
  2402. idea of when the task's data changes.
  2403. </para>
  2404. <para>
  2405. To complicate the problem, there are things that should not be
  2406. included in the checksum.
  2407. First, there is the actual specific build path of a given
  2408. task - the
  2409. <ulink url='&YOCTO_DOCS_REF_URL;#var-WORKDIR'><filename>WORKDIR</filename></ulink>.
  2410. It does not matter if the work directory changes because it
  2411. should not affect the output for target packages.
  2412. Also, the build process has the objective of making native
  2413. or cross packages relocatable.
  2414. <note>
  2415. Both native and cross packages run on the
  2416. <ulink url='&YOCTO_DOCS_REF_URL;#hardware-build-system-term'>build host</ulink>.
  2417. However, cross packages generate output for the target
  2418. architecture.
  2419. </note>
  2420. The checksum therefore needs to exclude
  2421. <filename>WORKDIR</filename>.
  2422. The simplistic approach for excluding the work directory is to
  2423. set <filename>WORKDIR</filename> to some fixed value and
  2424. create the checksum for the "run" script.
  2425. </para>
  2426. <para>
  2427. Another problem results from the "run" scripts containing
  2428. functions that might or might not get called.
  2429. The incremental build solution contains code that figures out
  2430. dependencies between shell functions.
  2431. This code is used to prune the "run" scripts down to the
  2432. minimum set, thereby alleviating this problem and making the
  2433. "run" scripts much more readable as a bonus.
  2434. </para>
  2435. <para>
  2436. So far, solutions for shell scripts exist.
  2437. What about Python tasks?
  2438. The same approach applies even though these tasks are more
  2439. difficult.
  2440. The process needs to figure out what variables a Python
  2441. function accesses and what functions it calls.
  2442. Again, the incremental build solution contains code that first
  2443. figures out the variable and function dependencies, and then
  2444. creates a checksum for the data used as the input to the task.
  2445. </para>
  2446. <para>
  2447. Like the <filename>WORKDIR</filename> case, situations exist
  2448. where dependencies should be ignored.
  2449. For these situations, you can instruct the build process to
  2450. ignore a dependency by using a line like the following:
  2451. <literallayout class='monospaced'>
  2452. PACKAGE_ARCHS[vardepsexclude] = "MACHINE"
  2453. </literallayout>
  2454. This example ensures that the
  2455. <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_ARCHS'><filename>PACKAGE_ARCHS</filename></ulink>
  2456. variable does not depend on the value of
  2457. <ulink url='&YOCTO_DOCS_REF_URL;#var-MACHINE'><filename>MACHINE</filename></ulink>,
  2458. even if it does reference it.
  2459. </para>
  2460. <para>
  2461. Equally, there are cases where you need to add dependencies
  2462. BitBake is not able to find.
  2463. You can accomplish this by using a line like the following:
  2464. <literallayout class='monospaced'>
  2465. PACKAGE_ARCHS[vardeps] = "MACHINE"
  2466. </literallayout>
  2467. This example explicitly adds the <filename>MACHINE</filename>
  2468. variable as a dependency for
  2469. <filename>PACKAGE_ARCHS</filename>.
  2470. </para>
  2471. <para>
  2472. As an example, consider a case with in-line Python where
  2473. BitBake is not able to figure out dependencies.
  2474. When running in debug mode (i.e. using
  2475. <filename>-DDD</filename>), BitBake produces output when it
  2476. discovers something for which it cannot figure out dependencies.
  2477. The Yocto Project team has currently not managed to cover
  2478. those dependencies in detail and is aware of the need to fix
  2479. this situation.
  2480. </para>
  2481. <para>
  2482. Thus far, this section has limited discussion to the direct
  2483. inputs into a task.
  2484. Information based on direct inputs is referred to as the
  2485. "basehash" in the code.
  2486. However, the question of a task's indirect inputs still
  2487. exits - items already built and present in the
  2488. <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink>.
  2489. The checksum (or signature) for a particular task needs to add
  2490. the hashes of all the tasks on which the particular task
  2491. depends.
  2492. Choosing which dependencies to add is a policy decision.
  2493. However, the effect is to generate a master checksum that
  2494. combines the basehash and the hashes of the task's
  2495. dependencies.
  2496. </para>
  2497. <para>
  2498. At the code level, a variety of ways exist by which both the
  2499. basehash and the dependent task hashes can be influenced.
  2500. Within the BitBake configuration file, you can give BitBake
  2501. some extra information to help it construct the basehash.
  2502. The following statement effectively results in a list of
  2503. global variable dependency excludes (i.e. variables never
  2504. included in any checksum):
  2505. <literallayout class='monospaced'>
  2506. BB_HASHBASE_WHITELIST ?= "TMPDIR FILE PATH PWD BB_TASKHASH BBPATH DL_DIR \
  2507. SSTATE_DIR THISDIR FILESEXTRAPATHS FILE_DIRNAME HOME LOGNAME SHELL TERM \
  2508. USER FILESPATH STAGING_DIR_HOST STAGING_DIR_TARGET COREBASE PRSERV_HOST \
  2509. PRSERV_DUMPDIR PRSERV_DUMPFILE PRSERV_LOCKDOWN PARALLEL_MAKE \
  2510. CCACHE_DIR EXTERNAL_TOOLCHAIN CCACHE CCACHE_DISABLE LICENSE_PATH SDKPKGSUFFIX"
  2511. </literallayout>
  2512. The previous example excludes
  2513. <ulink url='&YOCTO_DOCS_REF_URL;#var-WORKDIR'><filename>WORKDIR</filename></ulink>
  2514. since that variable is actually constructed as a path within
  2515. <ulink url='&YOCTO_DOCS_REF_URL;#var-TMPDIR'><filename>TMPDIR</filename></ulink>,
  2516. which is on the whitelist.
  2517. </para>
  2518. <para>
  2519. The rules for deciding which hashes of dependent tasks to
  2520. include through dependency chains are more complex and are
  2521. generally accomplished with a Python function.
  2522. The code in <filename>meta/lib/oe/sstatesig.py</filename> shows
  2523. two examples of this and also illustrates how you can insert
  2524. your own policy into the system if so desired.
  2525. This file defines the two basic signature generators
  2526. <ulink url='&YOCTO_DOCS_REF_URL;#oe-core'>OE-Core</ulink>
  2527. uses: "OEBasic" and "OEBasicHash".
  2528. By default, a dummy "noop" signature handler is enabled
  2529. in BitBake.
  2530. This means that behavior is unchanged from previous versions.
  2531. OE-Core uses the "OEBasicHash" signature handler by default
  2532. through this setting in the <filename>bitbake.conf</filename>
  2533. file:
  2534. <literallayout class='monospaced'>
  2535. BB_SIGNATURE_HANDLER ?= "OEBasicHash"
  2536. </literallayout>
  2537. The "OEBasicHash" <filename>BB_SIGNATURE_HANDLER</filename>
  2538. is the same as the "OEBasic" version but adds the task hash to
  2539. the
  2540. <link linkend='stamp-files-and-the-rerunning-of-tasks'>stamp files</link>.
  2541. This results in any metadata change that changes the task hash,
  2542. automatically causing the task to be run again.
  2543. This removes the need to bump
  2544. <ulink url='&YOCTO_DOCS_REF_URL;#var-PR'><filename>PR</filename></ulink>
  2545. values, and changes to metadata automatically ripple across
  2546. the build.
  2547. </para>
  2548. <para>
  2549. It is also worth noting that the end result of these
  2550. signature generators is to make some dependency and hash
  2551. information available to the build.
  2552. This information includes:
  2553. <itemizedlist>
  2554. <listitem><para>
  2555. <filename>BB_BASEHASH_task-</filename><replaceable>taskname</replaceable>:
  2556. The base hashes for each task in the recipe.
  2557. </para></listitem>
  2558. <listitem><para>
  2559. <filename>BB_BASEHASH_</filename><replaceable>filename</replaceable><filename>:</filename><replaceable>taskname</replaceable>:
  2560. The base hashes for each dependent task.
  2561. </para></listitem>
  2562. <listitem><para>
  2563. <filename>BBHASHDEPS_</filename><replaceable>filename</replaceable><filename>:</filename><replaceable>taskname</replaceable>:
  2564. The task dependencies for each task.
  2565. </para></listitem>
  2566. <listitem><para>
  2567. <filename>BB_TASKHASH</filename>:
  2568. The hash of the currently running task.
  2569. </para></listitem>
  2570. </itemizedlist>
  2571. </para>
  2572. </section>
  2573. <section id='shared-state'>
  2574. <title>Shared State</title>
  2575. <para>
  2576. Checksums and dependencies, as discussed in the previous
  2577. section, solve half the problem of supporting a shared state.
  2578. The other half of the problem is being able to use checksum
  2579. information during the build and being able to reuse or rebuild
  2580. specific components.
  2581. </para>
  2582. <para>
  2583. The
  2584. <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-sstate'><filename>sstate</filename></ulink>
  2585. class is a relatively generic implementation of how to
  2586. "capture" a snapshot of a given task.
  2587. The idea is that the build process does not care about the
  2588. source of a task's output.
  2589. Output could be freshly built or it could be downloaded and
  2590. unpacked from somewhere.
  2591. In other words, the build process does not need to worry about
  2592. its origin.
  2593. </para>
  2594. <para>
  2595. Two types of output exist.
  2596. One type is just about creating a directory in
  2597. <ulink url='&YOCTO_DOCS_REF_URL;#var-WORKDIR'><filename>WORKDIR</filename></ulink>.
  2598. A good example is the output of either
  2599. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-install'><filename>do_install</filename></ulink>
  2600. or
  2601. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-package'><filename>do_package</filename></ulink>.
  2602. The other type of output occurs when a set of data is merged
  2603. into a shared directory tree such as the sysroot.
  2604. </para>
  2605. <para>
  2606. The Yocto Project team has tried to keep the details of the
  2607. implementation hidden in <filename>sstate</filename> class.
  2608. From a user's perspective, adding shared state wrapping to a
  2609. task is as simple as this
  2610. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-deploy'><filename>do_deploy</filename></ulink>
  2611. example taken from the
  2612. <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-deploy'><filename>deploy</filename></ulink>
  2613. class:
  2614. <literallayout class='monospaced'>
  2615. DEPLOYDIR = "${WORKDIR}/deploy-${PN}"
  2616. SSTATETASKS += "do_deploy"
  2617. do_deploy[sstate-inputdirs] = "${DEPLOYDIR}"
  2618. do_deploy[sstate-outputdirs] = "${DEPLOY_DIR_IMAGE}"
  2619. python do_deploy_setscene () {
  2620. sstate_setscene(d)
  2621. }
  2622. addtask do_deploy_setscene
  2623. do_deploy[dirs] = "${DEPLOYDIR} ${B}"
  2624. do_deploy[stamp-extra-info] = "${MACHINE_ARCH}"
  2625. </literallayout>
  2626. The following list explains the previous example:
  2627. <itemizedlist>
  2628. <listitem><para>
  2629. Adding "do_deploy" to <filename>SSTATETASKS</filename>
  2630. adds some required sstate-related processing, which is
  2631. implemented in the
  2632. <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-sstate'><filename>sstate</filename></ulink>
  2633. class, to before and after the
  2634. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-deploy'><filename>do_deploy</filename></ulink>
  2635. task.
  2636. </para></listitem>
  2637. <listitem><para>
  2638. The
  2639. <filename>do_deploy[sstate-inputdirs] = "${DEPLOYDIR}"</filename>
  2640. declares that <filename>do_deploy</filename> places its
  2641. output in <filename>${DEPLOYDIR}</filename> when run
  2642. normally (i.e. when not using the sstate cache).
  2643. This output becomes the input to the shared state cache.
  2644. </para></listitem>
  2645. <listitem><para>
  2646. The
  2647. <filename>do_deploy[sstate-outputdirs] = "${DEPLOY_DIR_IMAGE}"</filename>
  2648. line causes the contents of the shared state cache to be
  2649. copied to <filename>${DEPLOY_DIR_IMAGE}</filename>.
  2650. <note>
  2651. If <filename>do_deploy</filename> is not already in
  2652. the shared state cache or if its input checksum
  2653. (signature) has changed from when the output was
  2654. cached, the task runs to populate the shared
  2655. state cache, after which the contents of the shared
  2656. state cache is copied to
  2657. <filename>${DEPLOY_DIR_IMAGE}</filename>.
  2658. If <filename>do_deploy</filename> is in the shared
  2659. state cache and its signature indicates that the
  2660. cached output is still valid (i.e. if no
  2661. relevant task inputs have changed), then the
  2662. contents of the shared state cache copies
  2663. directly to
  2664. <filename>${DEPLOY_DIR_IMAGE}</filename> by the
  2665. <filename>do_deploy_setscene</filename> task
  2666. instead, skipping the
  2667. <filename>do_deploy</filename> task.
  2668. </note>
  2669. </para></listitem>
  2670. <listitem><para>
  2671. The following task definition is glue logic needed to
  2672. make the previous settings effective:
  2673. <literallayout class='monospaced'>
  2674. python do_deploy_setscene () {
  2675. sstate_setscene(d)
  2676. }
  2677. addtask do_deploy_setscene
  2678. </literallayout>
  2679. <filename>sstate_setscene()</filename> takes the flags
  2680. above as input and accelerates the
  2681. <filename>do_deploy</filename> task through the
  2682. shared state cache if possible.
  2683. If the task was accelerated,
  2684. <filename>sstate_setscene()</filename> returns True.
  2685. Otherwise, it returns False, and the normal
  2686. <filename>do_deploy</filename> task runs.
  2687. For more information, see the
  2688. "<ulink url='&YOCTO_DOCS_BB_URL;#setscene'>setscene</ulink>"
  2689. section in the BitBake User Manual.
  2690. </para></listitem>
  2691. <listitem><para>
  2692. The <filename>do_deploy[dirs] = "${DEPLOYDIR} ${B}"</filename>
  2693. line creates <filename>${DEPLOYDIR}</filename> and
  2694. <filename>${B}</filename> before the
  2695. <filename>do_deploy</filename> task runs, and also sets
  2696. the current working directory of
  2697. <filename>do_deploy</filename> to
  2698. <filename>${B}</filename>.
  2699. For more information, see the
  2700. "<ulink url='&YOCTO_DOCS_BB_URL;#variable-flags'>Variable Flags</ulink>"
  2701. section in the BitBake User Manual.
  2702. <note>
  2703. In cases where
  2704. <filename>sstate-inputdirs</filename> and
  2705. <filename>sstate-outputdirs</filename> would be the
  2706. same, you can use
  2707. <filename>sstate-plaindirs</filename>.
  2708. For example, to preserve the
  2709. <filename>${PKGD}</filename> and
  2710. <filename>${PKGDEST}</filename> output from the
  2711. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-package'><filename>do_package</filename></ulink>
  2712. task, use the following:
  2713. <literallayout class='monospaced'>
  2714. do_package[sstate-plaindirs] = "${PKGD} ${PKGDEST}"
  2715. </literallayout>
  2716. </note>
  2717. </para></listitem>
  2718. <listitem><para>
  2719. The <filename>do_deploy[stamp-extra-info] = "${MACHINE_ARCH}"</filename>
  2720. line appends extra metadata to the
  2721. <link linkend='stamp-files-and-the-rerunning-of-tasks'>stamp file</link>.
  2722. In this case, the metadata makes the task specific
  2723. to a machine's architecture.
  2724. See
  2725. "<ulink url='&YOCTO_DOCS_BB_URL;#ref-bitbake-tasklist'>The Task List</ulink>"
  2726. section in the BitBake User Manual for more
  2727. information on the <filename>stamp-extra-info</filename>
  2728. flag.
  2729. </para></listitem>
  2730. <listitem><para>
  2731. <filename>sstate-inputdirs</filename> and
  2732. <filename>sstate-outputdirs</filename> can also be used
  2733. with multiple directories.
  2734. For example, the following declares
  2735. <filename>PKGDESTWORK</filename> and
  2736. <filename>SHLIBWORK</filename> as shared state
  2737. input directories, which populates the shared state
  2738. cache, and <filename>PKGDATA_DIR</filename> and
  2739. <filename>SHLIBSDIR</filename> as the corresponding
  2740. shared state output directories:
  2741. <literallayout class='monospaced'>
  2742. do_package[sstate-inputdirs] = "${PKGDESTWORK} ${SHLIBSWORKDIR}"
  2743. do_package[sstate-outputdirs] = "${PKGDATA_DIR} ${SHLIBSDIR}"
  2744. </literallayout>
  2745. </para></listitem>
  2746. <listitem><para>
  2747. These methods also include the ability to take a
  2748. lockfile when manipulating shared state directory
  2749. structures, for cases where file additions or removals
  2750. are sensitive:
  2751. <literallayout class='monospaced'>
  2752. do_package[sstate-lockfile] = "${PACKAGELOCK}"
  2753. </literallayout>
  2754. </para></listitem>
  2755. </itemizedlist>
  2756. </para>
  2757. <para>
  2758. Behind the scenes, the shared state code works by looking in
  2759. <ulink url='&YOCTO_DOCS_REF_URL;#var-SSTATE_DIR'><filename>SSTATE_DIR</filename></ulink>
  2760. and
  2761. <ulink url='&YOCTO_DOCS_REF_URL;#var-SSTATE_MIRRORS'><filename>SSTATE_MIRRORS</filename></ulink>
  2762. for shared state files.
  2763. Here is an example:
  2764. <literallayout class='monospaced'>
  2765. SSTATE_MIRRORS ?= "\
  2766. file://.* http://someserver.tld/share/sstate/PATH;downloadfilename=PATH \n \
  2767. file://.* file:///some/local/dir/sstate/PATH"
  2768. </literallayout>
  2769. <note>
  2770. The shared state directory
  2771. (<filename>SSTATE_DIR</filename>) is organized into
  2772. two-character subdirectories, where the subdirectory
  2773. names are based on the first two characters of the hash.
  2774. If the shared state directory structure for a mirror has the
  2775. same structure as <filename>SSTATE_DIR</filename>, you must
  2776. specify "PATH" as part of the URI to enable the build system
  2777. to map to the appropriate subdirectory.
  2778. </note>
  2779. </para>
  2780. <para>
  2781. The shared state package validity can be detected just by
  2782. looking at the filename since the filename contains the task
  2783. checksum (or signature) as described earlier in this section.
  2784. If a valid shared state package is found, the build process
  2785. downloads it and uses it to accelerate the task.
  2786. </para>
  2787. <para>
  2788. The build processes use the <filename>*_setscene</filename>
  2789. tasks for the task acceleration phase.
  2790. BitBake goes through this phase before the main execution
  2791. code and tries to accelerate any tasks for which it can find
  2792. shared state packages.
  2793. If a shared state package for a task is available, the
  2794. shared state package is used.
  2795. This means the task and any tasks on which it is dependent
  2796. are not executed.
  2797. </para>
  2798. <para>
  2799. As a real world example, the aim is when building an IPK-based
  2800. image, only the
  2801. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-package_write_ipk'><filename>do_package_write_ipk</filename></ulink>
  2802. tasks would have their shared state packages fetched and
  2803. extracted.
  2804. Since the sysroot is not used, it would never get extracted.
  2805. This is another reason why a task-based approach is preferred
  2806. over a recipe-based approach, which would have to install the
  2807. output from every task.
  2808. </para>
  2809. </section>
  2810. </section>
  2811. <section id='automatically-added-runtime-dependencies'>
  2812. <title>Automatically Added Runtime Dependencies</title>
  2813. <para>
  2814. The OpenEmbedded build system automatically adds common types of
  2815. runtime dependencies between packages, which means that you do not
  2816. need to explicitly declare the packages using
  2817. <ulink url='&YOCTO_DOCS_REF_URL;#var-RDEPENDS'><filename>RDEPENDS</filename></ulink>.
  2818. Three automatic mechanisms exist (<filename>shlibdeps</filename>,
  2819. <filename>pcdeps</filename>, and <filename>depchains</filename>)
  2820. that handle shared libraries, package configuration (pkg-config)
  2821. modules, and <filename>-dev</filename> and
  2822. <filename>-dbg</filename> packages, respectively.
  2823. For other types of runtime dependencies, you must manually declare
  2824. the dependencies.
  2825. <itemizedlist>
  2826. <listitem><para>
  2827. <filename>shlibdeps</filename>:
  2828. During the
  2829. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-package'><filename>do_package</filename></ulink>
  2830. task of each recipe, all shared libraries installed by the
  2831. recipe are located.
  2832. For each shared library, the package that contains the
  2833. shared library is registered as providing the shared
  2834. library.
  2835. More specifically, the package is registered as providing
  2836. the
  2837. <ulink url='https://en.wikipedia.org/wiki/Soname'>soname</ulink>
  2838. of the library.
  2839. The resulting shared-library-to-package mapping
  2840. is saved globally in
  2841. <ulink url='&YOCTO_DOCS_REF_URL;#var-PKGDATA_DIR'><filename>PKGDATA_DIR</filename></ulink>
  2842. by the
  2843. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-packagedata'><filename>do_packagedata</filename></ulink>
  2844. task.</para>
  2845. <para>Simultaneously, all executables and shared libraries
  2846. installed by the recipe are inspected to see what shared
  2847. libraries they link against.
  2848. For each shared library dependency that is found,
  2849. <filename>PKGDATA_DIR</filename> is queried to
  2850. see if some package (likely from a different recipe)
  2851. contains the shared library.
  2852. If such a package is found, a runtime dependency is added
  2853. from the package that depends on the shared library to the
  2854. package that contains the library.</para>
  2855. <para>The automatically added runtime dependency also
  2856. includes a version restriction.
  2857. This version restriction specifies that at least the
  2858. current version of the package that provides the shared
  2859. library must be used, as if
  2860. "<replaceable>package</replaceable> (>= <replaceable>version</replaceable>)"
  2861. had been added to <filename>RDEPENDS</filename>.
  2862. This forces an upgrade of the package containing the shared
  2863. library when installing the package that depends on the
  2864. library, if needed.</para>
  2865. <para>If you want to avoid a package being registered as
  2866. providing a particular shared library (e.g. because the library
  2867. is for internal use only), then add the library to
  2868. <ulink url='&YOCTO_DOCS_REF_URL;#var-PRIVATE_LIBS'><filename>PRIVATE_LIBS</filename></ulink>
  2869. inside the package's recipe.
  2870. </para></listitem>
  2871. <listitem><para>
  2872. <filename>pcdeps</filename>:
  2873. During the <filename>do_package</filename> task of each
  2874. recipe, all pkg-config modules
  2875. (<filename>*.pc</filename> files) installed by the recipe
  2876. are located.
  2877. For each module, the package that contains the module is
  2878. registered as providing the module.
  2879. The resulting module-to-package mapping is saved globally in
  2880. <filename>PKGDATA_DIR</filename> by the
  2881. <filename>do_packagedata</filename> task.</para>
  2882. <para>Simultaneously, all pkg-config modules installed by
  2883. the recipe are inspected to see what other pkg-config
  2884. modules they depend on.
  2885. A module is seen as depending on another module if it
  2886. contains a "Requires:" line that specifies the other module.
  2887. For each module dependency,
  2888. <filename>PKGDATA_DIR</filename> is queried to see if some
  2889. package contains the module.
  2890. If such a package is found, a runtime dependency is added
  2891. from the package that depends on the module to the package
  2892. that contains the module.
  2893. <note>
  2894. The <filename>pcdeps</filename> mechanism most often
  2895. infers dependencies between <filename>-dev</filename>
  2896. packages.
  2897. </note>
  2898. </para></listitem>
  2899. <listitem><para>
  2900. <filename>depchains</filename>:
  2901. If a package <filename>foo</filename> depends on a package
  2902. <filename>bar</filename>, then <filename>foo-dev</filename>
  2903. and <filename>foo-dbg</filename> are also made to depend on
  2904. <filename>bar-dev</filename> and
  2905. <filename>bar-dbg</filename>, respectively.
  2906. Taking the <filename>-dev</filename> packages as an
  2907. example, the <filename>bar-dev</filename> package might
  2908. provide headers and shared library symlinks needed by
  2909. <filename>foo-dev</filename>, which shows the need
  2910. for a dependency between the packages.</para>
  2911. <para>The dependencies added by
  2912. <filename>depchains</filename> are in the form of
  2913. <ulink url='&YOCTO_DOCS_REF_URL;#var-RRECOMMENDS'><filename>RRECOMMENDS</filename></ulink>.
  2914. <note>
  2915. By default, <filename>foo-dev</filename> also has an
  2916. <filename>RDEPENDS</filename>-style dependency on
  2917. <filename>foo</filename>, because the default value of
  2918. <filename>RDEPENDS_${PN}-dev</filename> (set in
  2919. <filename>bitbake.conf</filename>) includes
  2920. "${PN}".
  2921. </note></para>
  2922. <para>To ensure that the dependency chain is never broken,
  2923. <filename>-dev</filename> and <filename>-dbg</filename>
  2924. packages are always generated by default, even if the
  2925. packages turn out to be empty.
  2926. See the
  2927. <ulink url='&YOCTO_DOCS_REF_URL;#var-ALLOW_EMPTY'><filename>ALLOW_EMPTY</filename></ulink>
  2928. variable for more information.
  2929. </para></listitem>
  2930. </itemizedlist>
  2931. </para>
  2932. <para>
  2933. The <filename>do_package</filename> task depends on the
  2934. <filename>do_packagedata</filename> task of each recipe in
  2935. <ulink url='&YOCTO_DOCS_REF_URL;#var-DEPENDS'><filename>DEPENDS</filename></ulink>
  2936. through use of a
  2937. <filename>[</filename><ulink url='&YOCTO_DOCS_BB_URL;#variable-flags'><filename>deptask</filename></ulink><filename>]</filename>
  2938. declaration, which guarantees that the required
  2939. shared-library/module-to-package mapping information will be available
  2940. when needed as long as <filename>DEPENDS</filename> has been
  2941. correctly set.
  2942. </para>
  2943. </section>
  2944. <section id='fakeroot-and-pseudo'>
  2945. <title>Fakeroot and Pseudo</title>
  2946. <para>
  2947. Some tasks are easier to implement when allowed to perform certain
  2948. operations that are normally reserved for the root user (e.g.
  2949. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-install'><filename>do_install</filename></ulink>,
  2950. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-package_write_deb'><filename>do_package_write*</filename></ulink>,
  2951. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-rootfs'><filename>do_rootfs</filename></ulink>,
  2952. and
  2953. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-image'><filename>do_image*</filename></ulink>).
  2954. For example, the <filename>do_install</filename> task benefits
  2955. from being able to set the UID and GID of installed files to
  2956. arbitrary values.
  2957. </para>
  2958. <para>
  2959. One approach to allowing tasks to perform root-only operations
  2960. would be to require
  2961. <ulink url='&YOCTO_DOCS_REF_URL;#bitbake-term'>BitBake</ulink>
  2962. to run as root.
  2963. However, this method is cumbersome and has security issues.
  2964. The approach that is actually used is to run tasks that benefit
  2965. from root privileges in a "fake" root environment.
  2966. Within this environment, the task and its child processes believe
  2967. that they are running as the root user, and see an internally
  2968. consistent view of the filesystem.
  2969. As long as generating the final output (e.g. a package or an image)
  2970. does not require root privileges, the fact that some earlier
  2971. steps ran in a fake root environment does not cause problems.
  2972. </para>
  2973. <para>
  2974. The capability to run tasks in a fake root environment is known as
  2975. "<ulink url='http://man.he.net/man1/fakeroot'>fakeroot</ulink>",
  2976. which is derived from the BitBake keyword/variable
  2977. flag that requests a fake root environment for a task.
  2978. </para>
  2979. <para>
  2980. In the
  2981. <ulink url='&YOCTO_DOCS_REF_URL;#build-system-term'>OpenEmbedded build system</ulink>,
  2982. the program that implements fakeroot is known as
  2983. <ulink url='https://www.yoctoproject.org/software-item/pseudo/'>Pseudo</ulink>.
  2984. Pseudo overrides system calls by using the environment variable
  2985. <filename>LD_PRELOAD</filename>, which results in the illusion
  2986. of running as root.
  2987. To keep track of "fake" file ownership and permissions resulting
  2988. from operations that require root permissions, Pseudo uses
  2989. an SQLite 3 database.
  2990. This database is stored in
  2991. <filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-WORKDIR'><filename>WORKDIR</filename></ulink><filename>}/pseudo/files.db</filename>
  2992. for individual recipes.
  2993. Storing the database in a file as opposed to in memory
  2994. gives persistence between tasks and builds, which is not
  2995. accomplished using fakeroot.
  2996. <note><title>Caution</title>
  2997. If you add your own task that manipulates the same files or
  2998. directories as a fakeroot task, then that task also needs to
  2999. run under fakeroot.
  3000. Otherwise, the task cannot run root-only operations, and
  3001. cannot see the fake file ownership and permissions set by the
  3002. other task.
  3003. You need to also add a dependency on
  3004. <filename>virtual/fakeroot-native:do_populate_sysroot</filename>,
  3005. giving the following:
  3006. <literallayout class='monospaced'>
  3007. fakeroot do_mytask () {
  3008. ...
  3009. }
  3010. do_mytask[depends] += "virtual/fakeroot-native:do_populate_sysroot"
  3011. </literallayout>
  3012. </note>
  3013. For more information, see the
  3014. <ulink url='&YOCTO_DOCS_BB_URL;#var-FAKEROOT'><filename>FAKEROOT*</filename></ulink>
  3015. variables in the BitBake User Manual.
  3016. You can also reference the
  3017. "<ulink url='https://github.com/wrpseudo/pseudo/wiki/WhyNotFakeroot'>Why Not Fakeroot?</ulink>"
  3018. article for background information on Fakeroot and Pseudo.
  3019. </para>
  3020. </section>
  3021. </chapter>
  3022. <!--
  3023. vim: expandtab tw=80 ts=4
  3024. -->