Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 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 | |
| 5 | <chapter id='extendpoky'> |
| 6 | |
| 7 | <title>Common Tasks</title> |
| 8 | <para> |
| 9 | This chapter describes fundamental procedures such as creating layers, |
| 10 | adding new software packages, extending or customizing images, |
| 11 | porting work to new hardware (adding a new machine), and so forth. |
| 12 | You will find that the procedures documented here occur often in the |
| 13 | development cycle using the Yocto Project. |
| 14 | </para> |
| 15 | |
| 16 | <section id="understanding-and-creating-layers"> |
| 17 | <title>Understanding and Creating Layers</title> |
| 18 | |
| 19 | <para> |
| 20 | The OpenEmbedded build system supports organizing |
| 21 | <link linkend='metadata'>Metadata</link> into multiple layers. |
| 22 | Layers allow you to isolate different types of customizations from |
| 23 | each other. |
| 24 | You might find it tempting to keep everything in one layer when |
| 25 | working on a single project. |
| 26 | However, the more modular your Metadata, the easier |
| 27 | it is to cope with future changes. |
| 28 | </para> |
| 29 | |
| 30 | <para> |
| 31 | To illustrate how layers are used to keep things modular, consider |
| 32 | machine customizations. |
| 33 | These types of customizations typically reside in a special layer, |
| 34 | rather than a general layer, called a Board Support Package (BSP) |
| 35 | Layer. |
| 36 | Furthermore, the machine customizations should be isolated from |
| 37 | recipes and Metadata that support a new GUI environment, |
| 38 | for example. |
| 39 | This situation gives you a couple of layers: one for the machine |
| 40 | configurations, and one for the GUI environment. |
| 41 | It is important to understand, however, that the BSP layer can |
| 42 | still make machine-specific additions to recipes within the GUI |
| 43 | environment layer without polluting the GUI layer itself |
| 44 | with those machine-specific changes. |
| 45 | You can accomplish this through a recipe that is a BitBake append |
| 46 | (<filename>.bbappend</filename>) file, which is described later |
| 47 | in this section. |
| 48 | </para> |
| 49 | |
| 50 | <para> |
| 51 | </para> |
| 52 | |
| 53 | <section id='yocto-project-layers'> |
| 54 | <title>Layers</title> |
| 55 | |
| 56 | <para> |
| 57 | The <link linkend='source-directory'>Source Directory</link> |
| 58 | contains both general layers and BSP |
| 59 | layers right out of the box. |
| 60 | You can easily identify layers that ship with a |
| 61 | Yocto Project release in the Source Directory by their |
| 62 | folder names. |
| 63 | Folders that represent layers typically have names that begin with |
| 64 | the string <filename>meta-</filename>. |
| 65 | <note> |
| 66 | It is not a requirement that a layer name begin with the |
| 67 | prefix <filename>meta-</filename>, but it is a commonly |
| 68 | accepted standard in the Yocto Project community. |
| 69 | </note> |
| 70 | For example, when you set up the Source Directory structure, |
| 71 | you will see several layers: |
| 72 | <filename>meta</filename>, |
| 73 | <filename>meta-skeleton</filename>, |
| 74 | <filename>meta-selftest</filename>, |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 75 | <filename>meta-poky</filename>, and |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 76 | <filename>meta-yocto-bsp</filename>. |
| 77 | Each of these folders represents a distinct layer. |
| 78 | </para> |
| 79 | |
| 80 | <para> |
| 81 | As another example, if you set up a local copy of the |
| 82 | <filename>meta-intel</filename> Git repository |
| 83 | and then explore the folder of that general layer, |
| 84 | you will discover many Intel-specific BSP layers inside. |
| 85 | For more information on BSP layers, see the |
| 86 | "<ulink url='&YOCTO_DOCS_BSP_URL;#bsp-layers'>BSP Layers</ulink>" |
| 87 | section in the Yocto Project Board Support Package (BSP) |
| 88 | Developer's Guide. |
| 89 | </para> |
| 90 | </section> |
| 91 | |
| 92 | <section id='creating-your-own-layer'> |
| 93 | <title>Creating Your Own Layer</title> |
| 94 | |
| 95 | <para> |
| 96 | It is very easy to create your own layers to use with the |
| 97 | OpenEmbedded build system. |
| 98 | The Yocto Project ships with scripts that speed up creating |
| 99 | general layers and BSP layers. |
| 100 | This section describes the steps you perform by hand to create |
| 101 | a layer so that you can better understand them. |
| 102 | For information about the layer-creation scripts, see the |
| 103 | "<ulink url='&YOCTO_DOCS_BSP_URL;#creating-a-new-bsp-layer-using-the-yocto-bsp-script'>Creating a New BSP Layer Using the yocto-bsp Script</ulink>" |
| 104 | section in the Yocto Project Board Support Package (BSP) |
| 105 | Developer's Guide and the |
| 106 | "<link linkend='creating-a-general-layer-using-the-yocto-layer-script'>Creating a General Layer Using the yocto-layer Script</link>" |
| 107 | section further down in this manual. |
| 108 | </para> |
| 109 | |
| 110 | <para> |
| 111 | Follow these general steps to create your layer: |
| 112 | <orderedlist> |
| 113 | <listitem><para><emphasis>Check Existing Layers:</emphasis> |
| 114 | Before creating a new layer, you should be sure someone |
| 115 | has not already created a layer containing the Metadata |
| 116 | you need. |
| 117 | You can see the |
| 118 | <ulink url='http://layers.openembedded.org/layerindex/layers/'><filename>OpenEmbedded Metadata Index</filename></ulink> |
| 119 | for a list of layers from the OpenEmbedded community |
| 120 | that can be used in the Yocto Project. |
| 121 | </para></listitem> |
| 122 | <listitem><para><emphasis>Create a Directory:</emphasis> |
| 123 | Create the directory for your layer. |
| 124 | While not strictly required, prepend the name of the |
| 125 | folder with the string <filename>meta-</filename>. |
| 126 | For example: |
| 127 | <literallayout class='monospaced'> |
| 128 | meta-mylayer |
| 129 | meta-GUI_xyz |
| 130 | meta-mymachine |
| 131 | </literallayout> |
| 132 | </para></listitem> |
| 133 | <listitem><para><emphasis>Create a Layer Configuration |
| 134 | File:</emphasis> |
| 135 | Inside your new layer folder, you need to create a |
| 136 | <filename>conf/layer.conf</filename> file. |
| 137 | It is easiest to take an existing layer configuration |
| 138 | file and copy that to your layer's |
| 139 | <filename>conf</filename> directory and then modify the |
| 140 | file as needed.</para> |
| 141 | <para>The |
| 142 | <filename>meta-yocto-bsp/conf/layer.conf</filename> file |
| 143 | demonstrates the required syntax: |
| 144 | <literallayout class='monospaced'> |
| 145 | # We have a conf and classes directory, add to BBPATH |
| 146 | BBPATH .= ":${LAYERDIR}" |
| 147 | |
| 148 | # We have recipes-* directories, add to BBFILES |
| 149 | BBFILES += "${LAYERDIR}/recipes-*/*/*.bb \ |
| 150 | ${LAYERDIR}/recipes-*/*/*.bbappend" |
| 151 | |
| 152 | BBFILE_COLLECTIONS += "yoctobsp" |
| 153 | BBFILE_PATTERN_yoctobsp = "^${LAYERDIR}/" |
| 154 | BBFILE_PRIORITY_yoctobsp = "5" |
| 155 | LAYERVERSION_yoctobsp = "3" |
| 156 | </literallayout></para> |
| 157 | <para>Here is an explanation of the example: |
| 158 | <itemizedlist> |
| 159 | <listitem><para>The configuration and |
| 160 | classes directory is appended to |
| 161 | <ulink url='&YOCTO_DOCS_REF_URL;#var-BBPATH'><filename>BBPATH</filename></ulink>. |
| 162 | <note> |
| 163 | All non-distro layers, which include all BSP |
| 164 | layers, are expected to append the layer |
| 165 | directory to the |
| 166 | <filename>BBPATH</filename>. |
| 167 | On the other hand, distro layers, such as |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 168 | <filename>meta-poky</filename>, can choose |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 169 | to enforce their own precedence over |
| 170 | <filename>BBPATH</filename>. |
| 171 | For an example of that syntax, see the |
| 172 | <filename>layer.conf</filename> file for |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 173 | the <filename>meta-poky</filename> layer. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 174 | </note></para></listitem> |
| 175 | <listitem><para>The recipes for the layers are |
| 176 | appended to |
| 177 | <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-BBFILES'>BBFILES</ulink></filename>. |
| 178 | </para></listitem> |
| 179 | <listitem><para>The |
| 180 | <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-BBFILE_COLLECTIONS'>BBFILE_COLLECTIONS</ulink></filename> |
| 181 | variable is then appended with the layer name. |
| 182 | </para></listitem> |
| 183 | <listitem><para>The |
| 184 | <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-BBFILE_PATTERN'>BBFILE_PATTERN</ulink></filename> |
| 185 | variable is set to a regular expression and is |
| 186 | used to match files from |
| 187 | <filename>BBFILES</filename> into a particular |
| 188 | layer. |
| 189 | In this case, |
| 190 | <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-LAYERDIR'>LAYERDIR</ulink></filename> |
| 191 | is used to make <filename>BBFILE_PATTERN</filename> match within the |
| 192 | layer's path.</para></listitem> |
| 193 | <listitem><para>The |
| 194 | <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-BBFILE_PRIORITY'>BBFILE_PRIORITY</ulink></filename> |
| 195 | variable then assigns a priority to the layer. |
| 196 | Applying priorities is useful in situations |
| 197 | where the same recipe might appear in multiple |
| 198 | layers and allows you to choose the layer |
| 199 | that takes precedence.</para></listitem> |
| 200 | <listitem><para>The |
| 201 | <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-LAYERVERSION'>LAYERVERSION</ulink></filename> |
| 202 | variable optionally specifies the version of a |
| 203 | layer as a single number.</para></listitem> |
| 204 | </itemizedlist></para> |
| 205 | <para>Note the use of the |
| 206 | <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-LAYERDIR'>LAYERDIR</ulink></filename> |
| 207 | variable, which expands to the directory of the current |
| 208 | layer.</para> |
| 209 | <para>Through the use of the <filename>BBPATH</filename> |
| 210 | variable, BitBake locates class files |
| 211 | (<filename>.bbclass</filename>), |
| 212 | configuration files, and files that are included |
| 213 | with <filename>include</filename> and |
| 214 | <filename>require</filename> statements. |
| 215 | For these cases, BitBake uses the first file that |
| 216 | matches the name found in <filename>BBPATH</filename>. |
| 217 | This is similar to the way the <filename>PATH</filename> |
| 218 | variable is used for binaries. |
| 219 | It is recommended, therefore, that you use unique |
| 220 | class and configuration |
| 221 | filenames in your custom layer.</para></listitem> |
| 222 | <listitem><para><emphasis>Add Content:</emphasis> Depending |
| 223 | on the type of layer, add the content. |
| 224 | If the layer adds support for a machine, add the machine |
| 225 | configuration in a <filename>conf/machine/</filename> |
| 226 | file within the layer. |
| 227 | If the layer adds distro policy, add the distro |
| 228 | configuration in a <filename>conf/distro/</filename> |
| 229 | file within the layer. |
| 230 | If the layer introduces new recipes, put the recipes |
| 231 | you need in <filename>recipes-*</filename> |
| 232 | subdirectories within the layer. |
| 233 | <note>In order to be compliant with the Yocto Project, |
| 234 | a layer must contain a |
| 235 | <ulink url='&YOCTO_DOCS_BSP_URL;#bsp-filelayout-readme'>README file.</ulink> |
| 236 | </note></para></listitem> |
| 237 | </orderedlist> |
| 238 | </para> |
| 239 | </section> |
| 240 | |
| 241 | <section id='best-practices-to-follow-when-creating-layers'> |
| 242 | <title>Best Practices to Follow When Creating Layers</title> |
| 243 | |
| 244 | <para> |
| 245 | To create layers that are easier to maintain and that will |
| 246 | not impact builds for other machines, you should consider the |
| 247 | information in the following sections. |
| 248 | </para> |
| 249 | |
| 250 | <section id='avoid-overlaying-entire-recipes'> |
| 251 | <title>Avoid "Overlaying" Entire Recipes</title> |
| 252 | |
| 253 | <para> |
| 254 | Avoid "overlaying" entire recipes from other layers in your |
| 255 | configuration. |
| 256 | In other words, do not copy an entire recipe into your |
| 257 | layer and then modify it. |
| 258 | Rather, use an append file (<filename>.bbappend</filename>) |
| 259 | to override |
| 260 | only those parts of the original recipe you need to modify. |
| 261 | </para> |
| 262 | </section> |
| 263 | |
| 264 | <section id='avoid-duplicating-include-files'> |
| 265 | <title>Avoid Duplicating Include Files</title> |
| 266 | |
| 267 | <para> |
| 268 | Avoid duplicating include files. |
| 269 | Use append files (<filename>.bbappend</filename>) |
| 270 | for each recipe |
| 271 | that uses an include file. |
| 272 | Or, if you are introducing a new recipe that requires |
| 273 | the included file, use the path relative to the original |
| 274 | layer directory to refer to the file. |
| 275 | For example, use |
| 276 | <filename>require recipes-core/</filename><replaceable>package</replaceable><filename>/</filename><replaceable>file</replaceable><filename>.inc</filename> |
| 277 | instead of <filename>require </filename><replaceable>file</replaceable><filename>.inc</filename>. |
| 278 | If you're finding you have to overlay the include file, |
| 279 | it could indicate a deficiency in the include file in |
| 280 | the layer to which it originally belongs. |
| 281 | If this is the case, you should try to address that |
| 282 | deficiency instead of overlaying the include file. |
| 283 | For example, you could address this by getting the |
| 284 | maintainer of the include file to add a variable or |
| 285 | variables to make it easy to override the parts needing |
| 286 | to be overridden. |
| 287 | </para> |
| 288 | </section> |
| 289 | |
| 290 | <section id='structure-your-layers'> |
| 291 | <title>Structure Your Layers</title> |
| 292 | |
| 293 | <para> |
| 294 | Proper use of overrides within append files and placement |
| 295 | of machine-specific files within your layer can ensure that |
| 296 | a build is not using the wrong Metadata and negatively |
| 297 | impacting a build for a different machine. |
| 298 | Following are some examples: |
| 299 | <itemizedlist> |
| 300 | <listitem><para><emphasis>Modifying Variables to Support |
| 301 | a Different Machine:</emphasis> |
| 302 | Suppose you have a layer named |
| 303 | <filename>meta-one</filename> that adds support |
| 304 | for building machine "one". |
| 305 | To do so, you use an append file named |
| 306 | <filename>base-files.bbappend</filename> and |
| 307 | create a dependency on "foo" by altering the |
| 308 | <ulink url='&YOCTO_DOCS_REF_URL;#var-DEPENDS'><filename>DEPENDS</filename></ulink> |
| 309 | variable: |
| 310 | <literallayout class='monospaced'> |
| 311 | DEPENDS = "foo" |
| 312 | </literallayout> |
| 313 | The dependency is created during any build that |
| 314 | includes the layer |
| 315 | <filename>meta-one</filename>. |
| 316 | However, you might not want this dependency |
| 317 | for all machines. |
| 318 | For example, suppose you are building for |
| 319 | machine "two" but your |
| 320 | <filename>bblayers.conf</filename> file has the |
| 321 | <filename>meta-one</filename> layer included. |
| 322 | During the build, the |
| 323 | <filename>base-files</filename> for machine |
| 324 | "two" will also have the dependency on |
| 325 | <filename>foo</filename>.</para> |
| 326 | <para>To make sure your changes apply only when |
| 327 | building machine "one", use a machine override |
| 328 | with the <filename>DEPENDS</filename> statement: |
| 329 | <literallayout class='monospaced'> |
| 330 | DEPENDS_one = "foo" |
| 331 | </literallayout> |
| 332 | You should follow the same strategy when using |
| 333 | <filename>_append</filename> and |
| 334 | <filename>_prepend</filename> operations: |
| 335 | <literallayout class='monospaced'> |
| 336 | DEPENDS_append_one = " foo" |
| 337 | DEPENDS_prepend_one = "foo " |
| 338 | </literallayout> |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 339 | As an actual example, here's a line from the recipe |
| 340 | for gnutls, which adds dependencies on |
| 341 | "argp-standalone" when building with the musl C |
| 342 | library: |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 343 | <literallayout class='monospaced'> |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 344 | DEPENDS_append_libc-musl = " argp-standalone" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 345 | </literallayout> |
| 346 | <note> |
| 347 | Avoiding "+=" and "=+" and using |
| 348 | machine-specific |
| 349 | <filename>_append</filename> |
| 350 | and <filename>_prepend</filename> operations |
| 351 | is recommended as well. |
| 352 | </note></para></listitem> |
| 353 | <listitem><para><emphasis>Place Machine-Specific Files |
| 354 | in Machine-Specific Locations:</emphasis> |
| 355 | When you have a base recipe, such as |
| 356 | <filename>base-files.bb</filename>, that |
| 357 | contains a |
| 358 | <ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'><filename>SRC_URI</filename></ulink> |
| 359 | statement to a file, you can use an append file |
| 360 | to cause the build to use your own version of |
| 361 | the file. |
| 362 | For example, an append file in your layer at |
| 363 | <filename>meta-one/recipes-core/base-files/base-files.bbappend</filename> |
| 364 | could extend |
| 365 | <ulink url='&YOCTO_DOCS_REF_URL;#var-FILESPATH'><filename>FILESPATH</filename></ulink> |
| 366 | using |
| 367 | <ulink url='&YOCTO_DOCS_REF_URL;#var-FILESEXTRAPATHS'><filename>FILESEXTRAPATHS</filename></ulink> |
| 368 | as follows: |
| 369 | <literallayout class='monospaced'> |
| 370 | FILESEXTRAPATHS_prepend := "${THISDIR}/${BPN}:" |
| 371 | </literallayout> |
| 372 | The build for machine "one" will pick up your |
| 373 | machine-specific file as long as you have the |
| 374 | file in |
| 375 | <filename>meta-one/recipes-core/base-files/base-files/</filename>. |
| 376 | However, if you are building for a different |
| 377 | machine and the |
| 378 | <filename>bblayers.conf</filename> file includes |
| 379 | the <filename>meta-one</filename> layer and |
| 380 | the location of your machine-specific file is |
| 381 | the first location where that file is found |
| 382 | according to <filename>FILESPATH</filename>, |
| 383 | builds for all machines will also use that |
| 384 | machine-specific file.</para> |
| 385 | <para>You can make sure that a machine-specific |
| 386 | file is used for a particular machine by putting |
| 387 | the file in a subdirectory specific to the |
| 388 | machine. |
| 389 | For example, rather than placing the file in |
| 390 | <filename>meta-one/recipes-core/base-files/base-files/</filename> |
| 391 | as shown above, put it in |
| 392 | <filename>meta-one/recipes-core/base-files/base-files/one/</filename>. |
| 393 | Not only does this make sure the file is used |
| 394 | only when building for machine "one", but the |
| 395 | build process locates the file more quickly.</para> |
| 396 | <para>In summary, you need to place all files |
| 397 | referenced from <filename>SRC_URI</filename> |
| 398 | in a machine-specific subdirectory within the |
| 399 | layer in order to restrict those files to |
| 400 | machine-specific builds.</para></listitem> |
| 401 | </itemizedlist> |
| 402 | </para> |
| 403 | </section> |
| 404 | |
| 405 | <section id='other-recommendations'> |
| 406 | <title>Other Recommendations</title> |
| 407 | |
| 408 | <para> |
| 409 | We also recommend the following: |
| 410 | <itemizedlist> |
| 411 | <listitem><para>Store custom layers in a Git repository |
| 412 | that uses the |
| 413 | <filename>meta-<replaceable>layer_name</replaceable></filename> format. |
| 414 | </para></listitem> |
| 415 | <listitem><para>Clone the repository alongside other |
| 416 | <filename>meta</filename> directories in the |
| 417 | <link linkend='source-directory'>Source Directory</link>. |
| 418 | </para></listitem> |
| 419 | </itemizedlist> |
| 420 | Following these recommendations keeps your Source Directory and |
| 421 | its configuration entirely inside the Yocto Project's core |
| 422 | base. |
| 423 | </para> |
| 424 | </section> |
| 425 | </section> |
| 426 | |
| 427 | <section id='enabling-your-layer'> |
| 428 | <title>Enabling Your Layer</title> |
| 429 | |
| 430 | <para> |
| 431 | Before the OpenEmbedded build system can use your new layer, |
| 432 | you need to enable it. |
| 433 | To enable your layer, simply add your layer's path to the |
| 434 | <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-BBLAYERS'>BBLAYERS</ulink></filename> |
| 435 | variable in your <filename>conf/bblayers.conf</filename> file, |
| 436 | which is found in the |
| 437 | <link linkend='build-directory'>Build Directory</link>. |
| 438 | The following example shows how to enable a layer named |
| 439 | <filename>meta-mylayer</filename>: |
| 440 | <literallayout class='monospaced'> |
| 441 | LCONF_VERSION = "6" |
| 442 | |
| 443 | BBPATH = "${TOPDIR}" |
| 444 | BBFILES ?= "" |
| 445 | |
| 446 | BBLAYERS ?= " \ |
| 447 | $HOME/poky/meta \ |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 448 | $HOME/poky/meta-poky \ |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 449 | $HOME/poky/meta-yocto-bsp \ |
| 450 | $HOME/poky/meta-mylayer \ |
| 451 | " |
| 452 | </literallayout> |
| 453 | </para> |
| 454 | |
| 455 | <para> |
| 456 | BitBake parses each <filename>conf/layer.conf</filename> file |
| 457 | as specified in the <filename>BBLAYERS</filename> variable |
| 458 | within the <filename>conf/bblayers.conf</filename> file. |
| 459 | During the processing of each |
| 460 | <filename>conf/layer.conf</filename> file, BitBake adds the |
| 461 | recipes, classes and configurations contained within the |
| 462 | particular layer to the source directory. |
| 463 | </para> |
| 464 | </section> |
| 465 | |
| 466 | <section id='using-bbappend-files'> |
| 467 | <title>Using .bbappend Files</title> |
| 468 | |
| 469 | <para> |
| 470 | Recipes used to append Metadata to other recipes are called |
| 471 | BitBake append files. |
| 472 | BitBake append files use the <filename>.bbappend</filename> file |
| 473 | type suffix, while the corresponding recipes to which Metadata |
| 474 | is being appended use the <filename>.bb</filename> file type |
| 475 | suffix. |
| 476 | </para> |
| 477 | |
| 478 | <para> |
| 479 | A <filename>.bbappend</filename> file allows your layer to make |
| 480 | additions or changes to the content of another layer's recipe |
| 481 | without having to copy the other recipe into your layer. |
| 482 | Your <filename>.bbappend</filename> file resides in your layer, |
| 483 | while the main <filename>.bb</filename> recipe file to |
| 484 | which you are appending Metadata resides in a different layer. |
| 485 | </para> |
| 486 | |
| 487 | <para> |
| 488 | Append files must have the same root names as their corresponding |
| 489 | recipes. |
| 490 | For example, the append file |
| 491 | <filename>someapp_&DISTRO;.bbappend</filename> must apply to |
| 492 | <filename>someapp_&DISTRO;.bb</filename>. |
| 493 | This means the original recipe and append file names are version |
| 494 | number-specific. |
| 495 | If the corresponding recipe is renamed to update to a newer |
| 496 | version, the corresponding <filename>.bbappend</filename> file must |
| 497 | be renamed (and possibly updated) as well. |
| 498 | During the build process, BitBake displays an error on starting |
| 499 | if it detects a <filename>.bbappend</filename> file that does |
| 500 | not have a corresponding recipe with a matching name. |
| 501 | See the |
| 502 | <ulink url='&YOCTO_DOCS_REF_URL;#var-BB_DANGLINGAPPENDS_WARNONLY'><filename>BB_DANGLINGAPPENDS_WARNONLY</filename></ulink> |
| 503 | variable for information on how to handle this error. |
| 504 | </para> |
| 505 | |
| 506 | <para> |
| 507 | Being able to append information to an existing recipe not only |
| 508 | avoids duplication, but also automatically applies recipe |
| 509 | changes in a different layer to your layer. |
| 510 | If you were copying recipes, you would have to manually merge |
| 511 | changes as they occur. |
| 512 | </para> |
| 513 | |
| 514 | <para> |
| 515 | As an example, consider the main formfactor recipe and a |
| 516 | corresponding formfactor append file both from the |
| 517 | <link linkend='source-directory'>Source Directory</link>. |
| 518 | Here is the main formfactor recipe, which is named |
| 519 | <filename>formfactor_0.0.bb</filename> and located in the |
| 520 | "meta" layer at |
| 521 | <filename>meta/recipes-bsp/formfactor</filename>: |
| 522 | <literallayout class='monospaced'> |
| 523 | SUMMARY = "Device formfactor information" |
| 524 | SECTION = "base" |
| 525 | LICENSE = "MIT" |
| 526 | LIC_FILES_CHKSUM = "file://${COREBASE}/LICENSE;md5=4d92cd373abda3937c2bc47fbc49d690 \ |
| 527 | file://${COREBASE}/meta/COPYING.MIT;md5=3da9cfbcb788c80a0384361b4de20420" |
| 528 | PR = "r45" |
| 529 | |
| 530 | SRC_URI = "file://config file://machconfig" |
| 531 | S = "${WORKDIR}" |
| 532 | |
| 533 | PACKAGE_ARCH = "${MACHINE_ARCH}" |
| 534 | INHIBIT_DEFAULT_DEPS = "1" |
| 535 | |
| 536 | do_install() { |
| 537 | # Install file only if it has contents |
| 538 | install -d ${D}${sysconfdir}/formfactor/ |
| 539 | install -m 0644 ${S}/config ${D}${sysconfdir}/formfactor/ |
| 540 | if [ -s "${S}/machconfig" ]; then |
| 541 | install -m 0644 ${S}/machconfig ${D}${sysconfdir}/formfactor/ |
| 542 | fi |
| 543 | } |
| 544 | </literallayout> |
| 545 | In the main recipe, note the |
| 546 | <ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'><filename>SRC_URI</filename></ulink> |
| 547 | variable, which tells the OpenEmbedded build system where to |
| 548 | find files during the build. |
| 549 | </para> |
| 550 | |
| 551 | <para> |
| 552 | Following is the append file, which is named |
| 553 | <filename>formfactor_0.0.bbappend</filename> and is from the |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 554 | Raspberry Pi BSP Layer named |
| 555 | <filename>meta-raspberrypi</filename>. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 556 | The file is in <filename>recipes-bsp/formfactor</filename>: |
| 557 | <literallayout class='monospaced'> |
| 558 | FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:" |
| 559 | </literallayout> |
| 560 | </para> |
| 561 | |
| 562 | <para> |
| 563 | By default, the build system uses the |
| 564 | <ulink url='&YOCTO_DOCS_REF_URL;#var-FILESPATH'><filename>FILESPATH</filename></ulink> |
| 565 | variable to locate files. |
| 566 | This append file extends the locations by setting the |
| 567 | <ulink url='&YOCTO_DOCS_REF_URL;#var-FILESEXTRAPATHS'><filename>FILESEXTRAPATHS</filename></ulink> |
| 568 | variable. |
| 569 | Setting this variable in the <filename>.bbappend</filename> |
| 570 | file is the most reliable and recommended method for adding |
| 571 | directories to the search path used by the build system |
| 572 | to find files. |
| 573 | </para> |
| 574 | |
| 575 | <para> |
| 576 | The statement in this example extends the directories to include |
| 577 | <filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-THISDIR'><filename>THISDIR</filename></ulink><filename>}/${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-PN'><filename>PN</filename></ulink><filename>}</filename>, |
| 578 | which resolves to a directory named |
| 579 | <filename>formfactor</filename> in the same directory |
| 580 | in which the append file resides (i.e. |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 581 | <filename>meta-raspberrypi/recipes-bsp/formfactor/formfactor</filename>. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 582 | This implies that you must have the supporting directory |
| 583 | structure set up that will contain any files or patches you |
| 584 | will be including from the layer. |
| 585 | </para> |
| 586 | |
| 587 | <para> |
| 588 | Using the immediate expansion assignment operator |
| 589 | <filename>:=</filename> is important because of the reference to |
| 590 | <filename>THISDIR</filename>. |
| 591 | The trailing colon character is important as it ensures that |
| 592 | items in the list remain colon-separated. |
| 593 | <note> |
| 594 | <para> |
| 595 | BitBake automatically defines the |
| 596 | <filename>THISDIR</filename> variable. |
| 597 | You should never set this variable yourself. |
| 598 | Using "_prepend" as part of the |
| 599 | <filename>FILESEXTRAPATHS</filename> ensures your path |
| 600 | will be searched prior to other paths in the final |
| 601 | list. |
| 602 | </para> |
| 603 | |
| 604 | <para> |
| 605 | Also, not all append files add extra files. |
| 606 | Many append files simply exist to add build options |
| 607 | (e.g. <filename>systemd</filename>). |
| 608 | For these cases, your append file would not even |
| 609 | use the <filename>FILESEXTRAPATHS</filename> statement. |
| 610 | </para> |
| 611 | </note> |
| 612 | </para> |
| 613 | </section> |
| 614 | |
| 615 | <section id='prioritizing-your-layer'> |
| 616 | <title>Prioritizing Your Layer</title> |
| 617 | |
| 618 | <para> |
| 619 | Each layer is assigned a priority value. |
| 620 | Priority values control which layer takes precedence if there |
| 621 | are recipe files with the same name in multiple layers. |
| 622 | For these cases, the recipe file from the layer with a higher |
| 623 | priority number takes precedence. |
| 624 | Priority values also affect the order in which multiple |
| 625 | <filename>.bbappend</filename> files for the same recipe are |
| 626 | applied. |
| 627 | You can either specify the priority manually, or allow the |
| 628 | build system to calculate it based on the layer's dependencies. |
| 629 | </para> |
| 630 | |
| 631 | <para> |
| 632 | To specify the layer's priority manually, use the |
| 633 | <ulink url='&YOCTO_DOCS_REF_URL;#var-BBFILE_PRIORITY'><filename>BBFILE_PRIORITY</filename></ulink> |
| 634 | variable. |
| 635 | For example: |
| 636 | <literallayout class='monospaced'> |
| 637 | BBFILE_PRIORITY_mylayer = "1" |
| 638 | </literallayout> |
| 639 | </para> |
| 640 | |
| 641 | <note> |
| 642 | <para>It is possible for a recipe with a lower version number |
| 643 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PV'><filename>PV</filename></ulink> |
| 644 | in a layer that has a higher priority to take precedence.</para> |
| 645 | <para>Also, the layer priority does not currently affect the |
| 646 | precedence order of <filename>.conf</filename> |
| 647 | or <filename>.bbclass</filename> files. |
| 648 | Future versions of BitBake might address this.</para> |
| 649 | </note> |
| 650 | </section> |
| 651 | |
| 652 | <section id='managing-layers'> |
| 653 | <title>Managing Layers</title> |
| 654 | |
| 655 | <para> |
| 656 | You can use the BitBake layer management tool to provide a view |
| 657 | into the structure of recipes across a multi-layer project. |
| 658 | Being able to generate output that reports on configured layers |
| 659 | with their paths and priorities and on |
| 660 | <filename>.bbappend</filename> files and their applicable |
| 661 | recipes can help to reveal potential problems. |
| 662 | </para> |
| 663 | |
| 664 | <para> |
| 665 | Use the following form when running the layer management tool. |
| 666 | <literallayout class='monospaced'> |
| 667 | $ bitbake-layers <replaceable>command</replaceable> [<replaceable>arguments</replaceable>] |
| 668 | </literallayout> |
| 669 | The following list describes the available commands: |
| 670 | <itemizedlist> |
| 671 | <listitem><para><filename><emphasis>help:</emphasis></filename> |
| 672 | Displays general help or help on a specified command. |
| 673 | </para></listitem> |
| 674 | <listitem><para><filename><emphasis>show-layers:</emphasis></filename> |
| 675 | Shows the current configured layers. |
| 676 | </para></listitem> |
| 677 | <listitem><para><filename><emphasis>show-recipes:</emphasis></filename> |
| 678 | Lists available recipes and the layers that provide them. |
| 679 | </para></listitem> |
| 680 | <listitem><para><filename><emphasis>show-overlayed:</emphasis></filename> |
| 681 | Lists overlayed recipes. |
| 682 | A recipe is overlayed when a recipe with the same name |
| 683 | exists in another layer that has a higher layer |
| 684 | priority. |
| 685 | </para></listitem> |
| 686 | <listitem><para><filename><emphasis>show-appends:</emphasis></filename> |
| 687 | Lists <filename>.bbappend</filename> files and the |
| 688 | recipe files to which they apply. |
| 689 | </para></listitem> |
| 690 | <listitem><para><filename><emphasis>show-cross-depends:</emphasis></filename> |
| 691 | Lists dependency relationships between recipes that |
| 692 | cross layer boundaries. |
| 693 | </para></listitem> |
| 694 | <listitem><para><filename><emphasis>add-layer:</emphasis></filename> |
| 695 | Adds a layer to <filename>bblayers.conf</filename>. |
| 696 | </para></listitem> |
| 697 | <listitem><para><filename><emphasis>remove-layer:</emphasis></filename> |
| 698 | Removes a layer from <filename>bblayers.conf</filename> |
| 699 | </para></listitem> |
| 700 | <listitem><para><filename><emphasis>flatten:</emphasis></filename> |
| 701 | Flattens the layer configuration into a separate output |
| 702 | directory. |
| 703 | Flattening your layer configuration builds a "flattened" |
| 704 | directory that contains the contents of all layers, |
| 705 | with any overlayed recipes removed and any |
| 706 | <filename>.bbappend</filename> files appended to the |
| 707 | corresponding recipes. |
| 708 | You might have to perform some manual cleanup of the |
| 709 | flattened layer as follows: |
| 710 | <itemizedlist> |
| 711 | <listitem><para>Non-recipe files (such as patches) |
| 712 | are overwritten. |
| 713 | The flatten command shows a warning for these |
| 714 | files. |
| 715 | </para></listitem> |
| 716 | <listitem><para>Anything beyond the normal layer |
| 717 | setup has been added to the |
| 718 | <filename>layer.conf</filename> file. |
| 719 | Only the lowest priority layer's |
| 720 | <filename>layer.conf</filename> is used. |
| 721 | </para></listitem> |
| 722 | <listitem><para>Overridden and appended items from |
| 723 | <filename>.bbappend</filename> files need to be |
| 724 | cleaned up. |
| 725 | The contents of each |
| 726 | <filename>.bbappend</filename> end up in the |
| 727 | flattened recipe. |
| 728 | However, if there are appended or changed |
| 729 | variable values, you need to tidy these up |
| 730 | yourself. |
| 731 | Consider the following example. |
| 732 | Here, the <filename>bitbake-layers</filename> |
| 733 | command adds the line |
| 734 | <filename>#### bbappended ...</filename> so that |
| 735 | you know where the following lines originate: |
| 736 | <literallayout class='monospaced'> |
| 737 | ... |
| 738 | DESCRIPTION = "A useful utility" |
| 739 | ... |
| 740 | EXTRA_OECONF = "--enable-something" |
| 741 | ... |
| 742 | |
| 743 | #### bbappended from meta-anotherlayer #### |
| 744 | |
| 745 | DESCRIPTION = "Customized utility" |
| 746 | EXTRA_OECONF += "--enable-somethingelse" |
| 747 | </literallayout> |
| 748 | Ideally, you would tidy up these utilities as |
| 749 | follows: |
| 750 | <literallayout class='monospaced'> |
| 751 | ... |
| 752 | DESCRIPTION = "Customized utility" |
| 753 | ... |
| 754 | EXTRA_OECONF = "--enable-something --enable-somethingelse" |
| 755 | ... |
| 756 | </literallayout></para></listitem> |
| 757 | </itemizedlist></para></listitem> |
| 758 | </itemizedlist> |
| 759 | </para> |
| 760 | </section> |
| 761 | |
| 762 | <section id='creating-a-general-layer-using-the-yocto-layer-script'> |
| 763 | <title>Creating a General Layer Using the yocto-layer Script</title> |
| 764 | |
| 765 | <para> |
| 766 | The <filename>yocto-layer</filename> script simplifies |
| 767 | creating a new general layer. |
| 768 | <note> |
| 769 | For information on BSP layers, see the |
| 770 | "<ulink url='&YOCTO_DOCS_BSP_URL;#bsp-layers'>BSP Layers</ulink>" |
| 771 | section in the Yocto Project Board Specific (BSP) |
| 772 | Developer's Guide. |
| 773 | </note> |
| 774 | The default mode of the script's operation is to prompt you for |
| 775 | information needed to generate the layer: |
| 776 | <itemizedlist> |
| 777 | <listitem><para>The layer priority. |
| 778 | </para></listitem> |
| 779 | <listitem><para>Whether or not to create a sample recipe. |
| 780 | </para></listitem> |
| 781 | <listitem><para>Whether or not to create a sample |
| 782 | append file. |
| 783 | </para></listitem> |
| 784 | </itemizedlist> |
| 785 | </para> |
| 786 | |
| 787 | <para> |
| 788 | Use the <filename>yocto-layer create</filename> sub-command |
| 789 | to create a new general layer. |
| 790 | In its simplest form, you can create a layer as follows: |
| 791 | <literallayout class='monospaced'> |
| 792 | $ yocto-layer create mylayer |
| 793 | </literallayout> |
| 794 | The previous example creates a layer named |
| 795 | <filename>meta-mylayer</filename> in the current directory. |
| 796 | </para> |
| 797 | |
| 798 | <para> |
| 799 | As the <filename>yocto-layer create</filename> command runs, |
| 800 | default values for the prompts appear in brackets. |
| 801 | Pressing enter without supplying anything for the prompts |
| 802 | or pressing enter and providing an invalid response causes the |
| 803 | script to accept the default value. |
| 804 | Once the script completes, the new layer |
| 805 | is created in the current working directory. |
| 806 | The script names the layer by prepending |
| 807 | <filename>meta-</filename> to the name you provide. |
| 808 | </para> |
| 809 | |
| 810 | <para> |
| 811 | Minimally, the script creates the following within the layer: |
| 812 | <itemizedlist> |
| 813 | <listitem><para><emphasis>The <filename>conf</filename> |
| 814 | directory:</emphasis> |
| 815 | This directory contains the layer's configuration file. |
| 816 | The root name for the file is the same as the root name |
| 817 | your provided for the layer (e.g. |
| 818 | <filename><replaceable>layer</replaceable>.conf</filename>). |
| 819 | </para></listitem> |
| 820 | <listitem><para><emphasis>The |
| 821 | <filename>COPYING.MIT</filename> file:</emphasis> |
| 822 | The copyright and use notice for the software. |
| 823 | </para></listitem> |
| 824 | <listitem><para><emphasis>The <filename>README</filename> |
| 825 | file:</emphasis> |
| 826 | A file describing the contents of your new layer. |
| 827 | </para></listitem> |
| 828 | </itemizedlist> |
| 829 | </para> |
| 830 | |
| 831 | <para> |
| 832 | If you choose to generate a sample recipe file, the script |
| 833 | prompts you for the name for the recipe and then creates it |
| 834 | in <filename><replaceable>layer</replaceable>/recipes-example/example/</filename>. |
| 835 | The script creates a <filename>.bb</filename> file and a |
| 836 | directory, which contains a sample |
| 837 | <filename>helloworld.c</filename> source file, along with |
| 838 | a sample patch file. |
| 839 | If you do not provide a recipe name, the script uses |
| 840 | "example". |
| 841 | </para> |
| 842 | |
| 843 | <para> |
| 844 | If you choose to generate a sample append file, the script |
| 845 | prompts you for the name for the file and then creates it |
| 846 | in <filename><replaceable>layer</replaceable>/recipes-example-bbappend/example-bbappend/</filename>. |
| 847 | The script creates a <filename>.bbappend</filename> file and a |
| 848 | directory, which contains a sample patch file. |
| 849 | If you do not provide a recipe name, the script uses |
| 850 | "example". |
| 851 | The script also prompts you for the version of the append file. |
| 852 | The version should match the recipe to which the append file |
| 853 | is associated. |
| 854 | </para> |
| 855 | |
| 856 | <para> |
| 857 | The easiest way to see how the <filename>yocto-layer</filename> |
| 858 | script works is to experiment with the script. |
| 859 | You can also read the usage information by entering the |
| 860 | following: |
| 861 | <literallayout class='monospaced'> |
| 862 | $ yocto-layer help |
| 863 | </literallayout> |
| 864 | </para> |
| 865 | |
| 866 | <para> |
| 867 | Once you create your general layer, you must add it to your |
| 868 | <filename>bblayers.conf</filename> file. |
| 869 | Here is an example where a layer named |
| 870 | <filename>meta-mylayer</filename> is added: |
| 871 | <literallayout class='monospaced'> |
| 872 | BBLAYERS = ?" \ |
| 873 | /usr/local/src/yocto/meta \ |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 874 | /usr/local/src/yocto/meta-poky \ |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 875 | /usr/local/src/yocto/meta-yocto-bsp \ |
| 876 | /usr/local/src/yocto/meta-mylayer \ |
| 877 | " |
| 878 | </literallayout> |
| 879 | Adding the layer to this file enables the build system to |
| 880 | locate the layer during the build. |
| 881 | </para> |
| 882 | </section> |
| 883 | </section> |
| 884 | |
| 885 | <section id='usingpoky-extend-customimage'> |
| 886 | <title>Customizing Images</title> |
| 887 | |
| 888 | <para> |
| 889 | You can customize images to satisfy particular requirements. |
| 890 | This section describes several methods and provides guidelines for each. |
| 891 | </para> |
| 892 | |
| 893 | <section id='usingpoky-extend-customimage-localconf'> |
| 894 | <title>Customizing Images Using <filename>local.conf</filename></title> |
| 895 | |
| 896 | <para> |
| 897 | Probably the easiest way to customize an image is to add a |
| 898 | package by way of the <filename>local.conf</filename> |
| 899 | configuration file. |
| 900 | Because it is limited to local use, this method generally only |
| 901 | allows you to add packages and is not as flexible as creating |
| 902 | your own customized image. |
| 903 | When you add packages using local variables this way, you need |
| 904 | to realize that these variable changes are in effect for every |
| 905 | build and consequently affect all images, which might not |
| 906 | be what you require. |
| 907 | </para> |
| 908 | |
| 909 | <para> |
| 910 | To add a package to your image using the local configuration |
| 911 | file, use the |
| 912 | <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-IMAGE_INSTALL'>IMAGE_INSTALL</ulink></filename> |
| 913 | variable with the <filename>_append</filename> operator: |
| 914 | <literallayout class='monospaced'> |
| 915 | IMAGE_INSTALL_append = " strace" |
| 916 | </literallayout> |
| 917 | Use of the syntax is important - specifically, the space between |
| 918 | the quote and the package name, which is |
| 919 | <filename>strace</filename> in this example. |
| 920 | This space is required since the <filename>_append</filename> |
| 921 | operator does not add the space. |
| 922 | </para> |
| 923 | |
| 924 | <para> |
| 925 | Furthermore, you must use <filename>_append</filename> instead |
| 926 | of the <filename>+=</filename> operator if you want to avoid |
| 927 | ordering issues. |
| 928 | The reason for this is because doing so unconditionally appends |
| 929 | to the variable and avoids ordering problems due to the |
| 930 | variable being set in image recipes and |
| 931 | <filename>.bbclass</filename> files with operators like |
| 932 | <filename>?=</filename>. |
| 933 | Using <filename>_append</filename> ensures the operation takes |
| 934 | affect. |
| 935 | </para> |
| 936 | |
| 937 | <para> |
| 938 | As shown in its simplest use, |
| 939 | <filename>IMAGE_INSTALL_append</filename> affects all images. |
| 940 | It is possible to extend the syntax so that the variable |
| 941 | applies to a specific image only. |
| 942 | Here is an example: |
| 943 | <literallayout class='monospaced'> |
| 944 | IMAGE_INSTALL_append_pn-core-image-minimal = " strace" |
| 945 | </literallayout> |
| 946 | This example adds <filename>strace</filename> to the |
| 947 | <filename>core-image-minimal</filename> image only. |
| 948 | </para> |
| 949 | |
| 950 | <para> |
| 951 | You can add packages using a similar approach through the |
| 952 | <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-CORE_IMAGE_EXTRA_INSTALL'>CORE_IMAGE_EXTRA_INSTALL</ulink></filename> |
| 953 | variable. |
| 954 | If you use this variable, only |
| 955 | <filename>core-image-*</filename> images are affected. |
| 956 | </para> |
| 957 | </section> |
| 958 | |
| 959 | <section id='usingpoky-extend-customimage-imagefeatures'> |
| 960 | <title>Customizing Images Using Custom <filename>IMAGE_FEATURES</filename> and |
| 961 | <filename>EXTRA_IMAGE_FEATURES</filename></title> |
| 962 | |
| 963 | <para> |
| 964 | Another method for customizing your image is to enable or |
| 965 | disable high-level image features by using the |
| 966 | <ulink url='&YOCTO_DOCS_REF_URL;#var-IMAGE_FEATURES'><filename>IMAGE_FEATURES</filename></ulink> |
| 967 | and <ulink url='&YOCTO_DOCS_REF_URL;#var-EXTRA_IMAGE_FEATURES'><filename>EXTRA_IMAGE_FEATURES</filename></ulink> |
| 968 | variables. |
| 969 | Although the functions for both variables are nearly equivalent, |
| 970 | best practices dictate using <filename>IMAGE_FEATURES</filename> |
| 971 | from within a recipe and using |
| 972 | <filename>EXTRA_IMAGE_FEATURES</filename> from within |
| 973 | your <filename>local.conf</filename> file, which is found in the |
| 974 | <link linkend='build-directory'>Build Directory</link>. |
| 975 | </para> |
| 976 | |
| 977 | <para> |
| 978 | To understand how these features work, the best reference is |
| 979 | <filename>meta/classes/core-image.bbclass</filename>. |
| 980 | This class lists out the available |
| 981 | <ulink url='&YOCTO_DOCS_REF_URL;#var-IMAGE_FEATURES'><filename>IMAGE_FEATURES</filename></ulink> |
| 982 | of which most map to package groups while some, such as |
| 983 | <filename>debug-tweaks</filename> and |
| 984 | <filename>read-only-rootfs</filename>, resolve as general |
| 985 | configuration settings. |
| 986 | </para> |
| 987 | |
| 988 | <para> |
| 989 | In summary, the file looks at the contents of the |
| 990 | <filename>IMAGE_FEATURES</filename> variable and then maps |
| 991 | or configures the feature accordingly. |
| 992 | Based on this information, the build system automatically |
| 993 | adds the appropriate packages or configurations to the |
| 994 | <ulink url='&YOCTO_DOCS_REF_URL;#var-IMAGE_INSTALL'><filename>IMAGE_INSTALL</filename></ulink> |
| 995 | variable. |
| 996 | Effectively, you are enabling extra features by extending the |
| 997 | class or creating a custom class for use with specialized image |
| 998 | <filename>.bb</filename> files. |
| 999 | </para> |
| 1000 | |
| 1001 | <para> |
| 1002 | Use the <filename>EXTRA_IMAGE_FEATURES</filename> variable |
| 1003 | from within your local configuration file. |
| 1004 | Using a separate area from which to enable features with |
| 1005 | this variable helps you avoid overwriting the features in the |
| 1006 | image recipe that are enabled with |
| 1007 | <filename>IMAGE_FEATURES</filename>. |
| 1008 | The value of <filename>EXTRA_IMAGE_FEATURES</filename> is added |
| 1009 | to <filename>IMAGE_FEATURES</filename> within |
| 1010 | <filename>meta/conf/bitbake.conf</filename>. |
| 1011 | </para> |
| 1012 | |
| 1013 | <para> |
| 1014 | To illustrate how you can use these variables to modify your |
| 1015 | image, consider an example that selects the SSH server. |
| 1016 | The Yocto Project ships with two SSH servers you can use |
| 1017 | with your images: Dropbear and OpenSSH. |
| 1018 | Dropbear is a minimal SSH server appropriate for |
| 1019 | resource-constrained environments, while OpenSSH is a |
| 1020 | well-known standard SSH server implementation. |
| 1021 | By default, the <filename>core-image-sato</filename> image |
| 1022 | is configured to use Dropbear. |
| 1023 | The <filename>core-image-full-cmdline</filename> and |
| 1024 | <filename>core-image-lsb</filename> images both |
| 1025 | include OpenSSH. |
| 1026 | The <filename>core-image-minimal</filename> image does not |
| 1027 | contain an SSH server. |
| 1028 | </para> |
| 1029 | |
| 1030 | <para> |
| 1031 | You can customize your image and change these defaults. |
| 1032 | Edit the <filename>IMAGE_FEATURES</filename> variable |
| 1033 | in your recipe or use the |
| 1034 | <filename>EXTRA_IMAGE_FEATURES</filename> in your |
| 1035 | <filename>local.conf</filename> file so that it configures the |
| 1036 | image you are working with to include |
| 1037 | <filename>ssh-server-dropbear</filename> or |
| 1038 | <filename>ssh-server-openssh</filename>. |
| 1039 | </para> |
| 1040 | |
| 1041 | <note> |
| 1042 | See the |
| 1043 | "<ulink url='&YOCTO_DOCS_REF_URL;#ref-images'>Images</ulink>" |
| 1044 | section in the Yocto Project Reference Manual for a complete |
| 1045 | list of image features that ship with the Yocto Project. |
| 1046 | </note> |
| 1047 | </section> |
| 1048 | |
| 1049 | <section id='usingpoky-extend-customimage-custombb'> |
| 1050 | <title>Customizing Images Using Custom .bb Files</title> |
| 1051 | |
| 1052 | <para> |
| 1053 | You can also customize an image by creating a custom recipe |
| 1054 | that defines additional software as part of the image. |
| 1055 | The following example shows the form for the two lines you need: |
| 1056 | <literallayout class='monospaced'> |
| 1057 | IMAGE_INSTALL = "packagegroup-core-x11-base package1 package2" |
| 1058 | |
| 1059 | inherit core-image |
| 1060 | </literallayout> |
| 1061 | </para> |
| 1062 | |
| 1063 | <para> |
| 1064 | Defining the software using a custom recipe gives you total |
| 1065 | control over the contents of the image. |
| 1066 | It is important to use the correct names of packages in the |
| 1067 | <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-IMAGE_INSTALL'>IMAGE_INSTALL</ulink></filename> |
| 1068 | variable. |
| 1069 | You must use the OpenEmbedded notation and not the Debian notation for the names |
| 1070 | (e.g. <filename>glibc-dev</filename> instead of <filename>libc6-dev</filename>). |
| 1071 | </para> |
| 1072 | |
| 1073 | <para> |
| 1074 | The other method for creating a custom image is to base it on an existing image. |
| 1075 | For example, if you want to create an image based on <filename>core-image-sato</filename> |
| 1076 | but add the additional package <filename>strace</filename> to the image, |
| 1077 | copy the <filename>meta/recipes-sato/images/core-image-sato.bb</filename> to a |
| 1078 | new <filename>.bb</filename> and add the following line to the end of the copy: |
| 1079 | <literallayout class='monospaced'> |
| 1080 | IMAGE_INSTALL += "strace" |
| 1081 | </literallayout> |
| 1082 | </para> |
| 1083 | </section> |
| 1084 | |
| 1085 | <section id='usingpoky-extend-customimage-customtasks'> |
| 1086 | <title>Customizing Images Using Custom Package Groups</title> |
| 1087 | |
| 1088 | <para> |
| 1089 | For complex custom images, the best approach for customizing |
| 1090 | an image is to create a custom package group recipe that is |
| 1091 | used to build the image or images. |
| 1092 | A good example of a package group recipe is |
| 1093 | <filename>meta/recipes-core/packagegroups/packagegroup-base.bb</filename>. |
| 1094 | </para> |
| 1095 | |
| 1096 | <para> |
| 1097 | If you examine that recipe, you see that the |
| 1098 | <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGES'>PACKAGES</ulink></filename> |
| 1099 | variable lists the package group packages to produce. |
| 1100 | The <filename>inherit packagegroup</filename> statement |
| 1101 | sets appropriate default values and automatically adds |
| 1102 | <filename>-dev</filename>, <filename>-dbg</filename>, and |
| 1103 | <filename>-ptest</filename> complementary packages for each |
| 1104 | package specified in the <filename>PACKAGES</filename> |
| 1105 | statement. |
| 1106 | <note> |
| 1107 | The <filename>inherit packages</filename> should be |
| 1108 | located near the top of the recipe, certainly before |
| 1109 | the <filename>PACKAGES</filename> statement. |
| 1110 | </note> |
| 1111 | </para> |
| 1112 | |
| 1113 | <para> |
| 1114 | For each package you specify in <filename>PACKAGES</filename>, |
| 1115 | you can use |
| 1116 | <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-RDEPENDS'>RDEPENDS</ulink></filename> |
| 1117 | and |
| 1118 | <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-RRECOMMENDS'>RRECOMMENDS</ulink></filename> |
| 1119 | entries to provide a list of packages the parent task package |
| 1120 | should contain. |
| 1121 | You can see examples of these further down in the |
| 1122 | <filename>packagegroup-base.bb</filename> recipe. |
| 1123 | </para> |
| 1124 | |
| 1125 | <para> |
| 1126 | Here is a short, fabricated example showing the same basic |
| 1127 | pieces: |
| 1128 | <literallayout class='monospaced'> |
| 1129 | DESCRIPTION = "My Custom Package Groups" |
| 1130 | |
| 1131 | inherit packagegroup |
| 1132 | |
| 1133 | PACKAGES = "\ |
| 1134 | packagegroup-custom-apps \ |
| 1135 | packagegroup-custom-tools \ |
| 1136 | " |
| 1137 | |
| 1138 | RDEPENDS_packagegroup-custom-apps = "\ |
| 1139 | dropbear \ |
| 1140 | portmap \ |
| 1141 | psplash" |
| 1142 | |
| 1143 | RDEPENDS_packagegroup-custom-tools = "\ |
| 1144 | oprofile \ |
| 1145 | oprofileui-server \ |
| 1146 | lttng-tools" |
| 1147 | |
| 1148 | RRECOMMENDS_packagegroup-custom-tools = "\ |
| 1149 | kernel-module-oprofile" |
| 1150 | </literallayout> |
| 1151 | </para> |
| 1152 | |
| 1153 | <para> |
| 1154 | In the previous example, two package group packages are created with their dependencies and their |
| 1155 | recommended package dependencies listed: <filename>packagegroup-custom-apps</filename>, and |
| 1156 | <filename>packagegroup-custom-tools</filename>. |
| 1157 | To build an image using these package group packages, you need to add |
| 1158 | <filename>packagegroup-custom-apps</filename> and/or |
| 1159 | <filename>packagegroup-custom-tools</filename> to |
| 1160 | <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-IMAGE_INSTALL'>IMAGE_INSTALL</ulink></filename>. |
| 1161 | For other forms of image dependencies see the other areas of this section. |
| 1162 | </para> |
| 1163 | </section> |
| 1164 | |
| 1165 | <section id='usingpoky-extend-customimage-image-name'> |
| 1166 | <title>Customizing an Image Hostname</title> |
| 1167 | |
| 1168 | <para> |
| 1169 | By default, the configured hostname (i.e. |
| 1170 | <filename>/etc/hostname</filename>) in an image is the |
| 1171 | same as the machine name. |
| 1172 | For example, if |
| 1173 | <ulink url='&YOCTO_DOCS_REF_URL;#var-MACHINE'><filename>MACHINE</filename></ulink> |
| 1174 | equals "qemux86", the configured hostname written to |
| 1175 | <filename>/etc/hostname</filename> is "qemux86". |
| 1176 | </para> |
| 1177 | |
| 1178 | <para> |
| 1179 | You can customize this name by altering the value of the |
| 1180 | "hostname" variable in the |
| 1181 | <filename>base-files</filename> recipe using either |
| 1182 | an append file or a configuration file. |
| 1183 | Use the following in an append file: |
| 1184 | <literallayout class='monospaced'> |
| 1185 | hostname="myhostname" |
| 1186 | </literallayout> |
| 1187 | Use the following in a configuration file: |
| 1188 | <literallayout class='monospaced'> |
| 1189 | hostname_pn-base-files = "myhostname" |
| 1190 | </literallayout> |
| 1191 | </para> |
| 1192 | |
| 1193 | <para> |
| 1194 | Changing the default value of the variable "hostname" can be |
| 1195 | useful in certain situations. |
| 1196 | For example, suppose you need to do extensive testing on an |
| 1197 | image and you would like to easily identify the image |
| 1198 | under test from existing images with typical default |
| 1199 | hostnames. |
| 1200 | In this situation, you could change the default hostname to |
| 1201 | "testme", which results in all the images using the name |
| 1202 | "testme". |
| 1203 | Once testing is complete and you do not need to rebuild the |
| 1204 | image for test any longer, you can easily reset the default |
| 1205 | hostname. |
| 1206 | </para> |
| 1207 | |
| 1208 | <para> |
| 1209 | Another point of interest is that if you unset the variable, |
| 1210 | the image will have no default hostname in the filesystem. |
| 1211 | Here is an example that unsets the variable in a |
| 1212 | configuration file: |
| 1213 | <literallayout class='monospaced'> |
| 1214 | hostname_pn-base-files = "" |
| 1215 | </literallayout> |
| 1216 | Having no default hostname in the filesystem is suitable for |
| 1217 | environments that use dynamic hostnames such as virtual |
| 1218 | machines. |
| 1219 | </para> |
| 1220 | </section> |
| 1221 | </section> |
| 1222 | |
| 1223 | <section id='new-recipe-writing-a-new-recipe'> |
| 1224 | <title>Writing a New Recipe</title> |
| 1225 | |
| 1226 | <para> |
| 1227 | Recipes (<filename>.bb</filename> files) are fundamental components |
| 1228 | in the Yocto Project environment. |
| 1229 | Each software component built by the OpenEmbedded build system |
| 1230 | requires a recipe to define the component. |
| 1231 | This section describes how to create, write, and test a new |
| 1232 | recipe. |
| 1233 | <note> |
| 1234 | For information on variables that are useful for recipes and |
| 1235 | for information about recipe naming issues, see the |
| 1236 | "<ulink url='&YOCTO_DOCS_REF_URL;#ref-varlocality-recipe-required'>Required</ulink>" |
| 1237 | section of the Yocto Project Reference Manual. |
| 1238 | </note> |
| 1239 | </para> |
| 1240 | |
| 1241 | <section id='new-recipe-overview'> |
| 1242 | <title>Overview</title> |
| 1243 | |
| 1244 | <para> |
| 1245 | The following figure shows the basic process for creating a |
| 1246 | new recipe. |
| 1247 | The remainder of the section provides details for the steps. |
| 1248 | <imagedata fileref="figures/recipe-workflow.png" width="6in" depth="7in" align="center" scalefit="1" /> |
| 1249 | </para> |
| 1250 | </section> |
| 1251 | |
| 1252 | <section id='new-recipe-locate-or-automatically-create-a-base-recipe'> |
| 1253 | <title>Locate or Automatically Create a Base Recipe</title> |
| 1254 | |
| 1255 | <para> |
| 1256 | You can always write a recipe from scratch. |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame^] | 1257 | However, three choices exist that can help you quickly get a |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1258 | start on a new recipe: |
| 1259 | <itemizedlist> |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame^] | 1260 | <listitem><para> |
| 1261 | <emphasis><filename>devtool add</filename>:</emphasis> |
| 1262 | A command that assists in creating a recipe and |
| 1263 | an environment conducive to development. |
| 1264 | </para></listitem> |
| 1265 | <listitem><para> |
| 1266 | <emphasis><filename>recipetool create</filename>:</emphasis> |
| 1267 | A command provided by the Yocto Project that automates |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1268 | creation of a base recipe based on the source |
| 1269 | files. |
| 1270 | </para></listitem> |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame^] | 1271 | <listitem><para> |
| 1272 | <emphasis>Existing Recipes:</emphasis> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1273 | Location and modification of an existing recipe that is |
| 1274 | similar in function to the recipe you need. |
| 1275 | </para></listitem> |
| 1276 | </itemizedlist> |
| 1277 | </para> |
| 1278 | |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame^] | 1279 | <section id='new-recipe-creating-the-base-recipe-using-devtool'> |
| 1280 | <title>Creating the Base Recipe Using <filename>devtool add</filename></title> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1281 | |
| 1282 | <para> |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame^] | 1283 | The <filename>devtool add</filename> command uses the same |
| 1284 | logic for auto-creating the recipe as |
| 1285 | <filename>recipetool create</filename>, which is listed |
| 1286 | below. |
| 1287 | Additionally, however, <filename>devtool add</filename> |
| 1288 | sets up an environment that makes it easy for you to |
| 1289 | patch the source and to make changes to the recipe as |
| 1290 | is often necessary when adding a recipe to build a new |
| 1291 | piece of software to be included in a build. |
| 1292 | </para> |
| 1293 | |
| 1294 | <para> |
| 1295 | You can find a complete description of the |
| 1296 | <filename>devtool add</filename> command in the |
| 1297 | "<link linkend='use-devtool-to-integrate-new-code'>Use <filename>devtool add</filename> to Add an Application</link>" |
| 1298 | section. |
| 1299 | </para> |
| 1300 | </section> |
| 1301 | |
| 1302 | <section id='new-recipe-creating-the-base-recipe-using-recipetool'> |
| 1303 | <title>Creating the Base Recipe Using <filename>recipetool create</filename></title> |
| 1304 | |
| 1305 | <para> |
| 1306 | <filename>recipetool create</filename> automates creation |
| 1307 | of a base recipe given a set of source code files. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1308 | As long as you can extract or point to the source files, |
| 1309 | the tool will construct a recipe and automatically |
| 1310 | configure all pre-build information into the recipe. |
| 1311 | For example, suppose you have an application that builds |
| 1312 | using Autotools. |
| 1313 | Creating the base recipe using |
| 1314 | <filename>recipetool</filename> results in a recipe |
| 1315 | that has the pre-build dependencies, license requirements, |
| 1316 | and checksums configured. |
| 1317 | </para> |
| 1318 | |
| 1319 | <para> |
| 1320 | To run the tool, you just need to be in your |
| 1321 | <link linkend='build-directory'>Build Directory</link> |
| 1322 | and have sourced the build environment setup script |
| 1323 | (i.e. |
| 1324 | <ulink url='&YOCTO_DOCS_REF_URL;#structure-core-script'><filename>oe-init-build-env</filename></ulink> |
| 1325 | or |
| 1326 | <ulink url='&YOCTO_DOCS_REF_URL;#structure-memres-core-script'><filename>oe-init-build-env-memres</filename></ulink>). |
| 1327 | Here is the basic <filename>recipetool</filename> syntax: |
| 1328 | <note> |
| 1329 | Running <filename>recipetool -h</filename> or |
| 1330 | <filename>recipetool create -h</filename> produces the |
| 1331 | Python-generated help, which presented differently |
| 1332 | than what follows here. |
| 1333 | </note> |
| 1334 | <literallayout class='monospaced'> |
| 1335 | recipetool -h |
| 1336 | recipetool create [-h] |
| 1337 | recipetool [-d] [-q] [--color auto | always | never ] create -o <replaceable>OUTFILE</replaceable> [-m] [-x <replaceable>EXTERNALSRC</replaceable>] <replaceable>source</replaceable> |
| 1338 | |
| 1339 | -d Enables debug output. |
| 1340 | -q Outputs only errors (quiet mode). |
| 1341 | --color Colorizes the output automatically, always, or never. |
| 1342 | -h Displays Python generated syntax for recipetool. |
| 1343 | create Causes recipetool to create a base recipe. The create |
| 1344 | command is further defined with these options: |
| 1345 | |
| 1346 | -o <replaceable>OUTFILE</replaceable> Specifies the full path and filename for the generated |
| 1347 | recipe. |
| 1348 | -m Causes the recipe to be machine-specific rather than |
| 1349 | architecture-specific (default). |
| 1350 | -x <replaceable>EXTERNALSRC</replaceable> Fetches and extracts source files from <replaceable>source</replaceable> |
| 1351 | and places them in <replaceable>EXTERNALSRC</replaceable>. |
| 1352 | <replaceable>source</replaceable> must be a URL. |
| 1353 | -h Displays Python-generated syntax for create. |
| 1354 | <replaceable>source</replaceable> Specifies the source code on which to base the |
| 1355 | recipe. |
| 1356 | </literallayout> |
| 1357 | </para> |
| 1358 | |
| 1359 | <para> |
| 1360 | Running <filename>recipetool create -o</filename> <replaceable>OUTFILE</replaceable> |
| 1361 | creates the base recipe and locates it properly in the |
| 1362 | layer that contains your source files. |
| 1363 | Following are some syntax examples: |
| 1364 | </para> |
| 1365 | |
| 1366 | <para> |
| 1367 | Use this syntax to generate a recipe based on <replaceable>source</replaceable>. |
| 1368 | Once generated, the recipe resides in the existing source |
| 1369 | code layer: |
| 1370 | <literallayout class='monospaced'> |
| 1371 | recipetool create -o <replaceable>OUTFILE</replaceable> <replaceable>source</replaceable> |
| 1372 | </literallayout> |
| 1373 | Use this syntax to generate a recipe using code that you |
| 1374 | extract from <replaceable>source</replaceable>. |
| 1375 | The extracted code is placed in its own layer defined |
| 1376 | by <replaceable>EXTERNALSRC</replaceable>. |
| 1377 | <literallayout class='monospaced'> |
| 1378 | recipetool create -o <replaceable>OUTFILE</replaceable> -x <replaceable>EXTERNALSRC</replaceable> <replaceable>source</replaceable> |
| 1379 | </literallayout> |
| 1380 | Use this syntax to generate a recipe based on <replaceable>source</replaceable>. |
| 1381 | The options direct <filename>recipetool</filename> to |
| 1382 | run in "quiet mode" and to generate debugging information. |
| 1383 | Once generated, the recipe resides in the existing source |
| 1384 | code layer: |
| 1385 | <literallayout class='monospaced'> |
| 1386 | recipetool create -o <replaceable>OUTFILE</replaceable> <replaceable>source</replaceable> |
| 1387 | </literallayout> |
| 1388 | </para> |
| 1389 | </section> |
| 1390 | |
| 1391 | <section id='new-recipe-locating-and-using-a-similar-recipe'> |
| 1392 | <title>Locating and Using a Similar Recipe</title> |
| 1393 | |
| 1394 | <para> |
| 1395 | Before writing a recipe from scratch, it is often useful to |
| 1396 | discover whether someone else has already written one that |
| 1397 | meets (or comes close to meeting) your needs. |
| 1398 | The Yocto Project and OpenEmbedded communities maintain many |
| 1399 | recipes that might be candidates for what you are doing. |
| 1400 | You can find a good central index of these recipes in the |
| 1401 | <ulink url='http://layers.openembedded.org'>OpenEmbedded metadata index</ulink>. |
| 1402 | </para> |
| 1403 | |
| 1404 | <para> |
| 1405 | Working from an existing recipe or a skeleton recipe is the |
| 1406 | best way to get started. |
| 1407 | Here are some points on both methods: |
| 1408 | <itemizedlist> |
| 1409 | <listitem><para><emphasis>Locate and modify a recipe that |
| 1410 | is close to what you want to do:</emphasis> |
| 1411 | This method works when you are familiar with the |
| 1412 | current recipe space. |
| 1413 | The method does not work so well for those new to |
| 1414 | the Yocto Project or writing recipes.</para> |
| 1415 | <para>Some risks associated with this method are |
| 1416 | using a recipe that has areas totally unrelated to |
| 1417 | what you are trying to accomplish with your recipe, |
| 1418 | not recognizing areas of the recipe that you might |
| 1419 | have to add from scratch, and so forth. |
| 1420 | All these risks stem from unfamiliarity with the |
| 1421 | existing recipe space.</para></listitem> |
| 1422 | <listitem><para><emphasis>Use and modify the following |
| 1423 | skeleton recipe:</emphasis> |
| 1424 | If for some reason you do not want to use |
| 1425 | <filename>recipetool</filename> and you cannot |
| 1426 | find an existing recipe that is close to meeting |
| 1427 | your needs, you can use the following structure to |
| 1428 | provide the fundamental areas of a new recipe. |
| 1429 | <literallayout class='monospaced'> |
| 1430 | DESCRIPTION = "" |
| 1431 | HOMEPAGE = "" |
| 1432 | LICENSE = "" |
| 1433 | SECTION = "" |
| 1434 | DEPENDS = "" |
| 1435 | LIC_FILES_CHKSUM = "" |
| 1436 | |
| 1437 | SRC_URI = "" |
| 1438 | </literallayout> |
| 1439 | </para></listitem> |
| 1440 | </itemizedlist> |
| 1441 | </para> |
| 1442 | </section> |
| 1443 | </section> |
| 1444 | |
| 1445 | <section id='new-recipe-storing-and-naming-the-recipe'> |
| 1446 | <title>Storing and Naming the Recipe</title> |
| 1447 | |
| 1448 | <para> |
| 1449 | Once you have your base recipe, you should put it in your |
| 1450 | own layer and name it appropriately. |
| 1451 | Locating it correctly ensures that the OpenEmbedded build |
| 1452 | system can find it when you use BitBake to process the |
| 1453 | recipe. |
| 1454 | </para> |
| 1455 | |
| 1456 | <itemizedlist> |
| 1457 | <listitem><para><emphasis>Storing Your Recipe:</emphasis> |
| 1458 | The OpenEmbedded build system locates your recipe |
| 1459 | through the layer's <filename>conf/layer.conf</filename> |
| 1460 | file and the |
| 1461 | <ulink url='&YOCTO_DOCS_REF_URL;#var-BBFILES'><filename>BBFILES</filename></ulink> |
| 1462 | variable. |
| 1463 | This variable sets up a path from which the build system can |
| 1464 | locate recipes. |
| 1465 | Here is the typical use: |
| 1466 | <literallayout class='monospaced'> |
| 1467 | BBFILES += "${LAYERDIR}/recipes-*/*/*.bb \ |
| 1468 | ${LAYERDIR}/recipes-*/*/*.bbappend" |
| 1469 | </literallayout> |
| 1470 | Consequently, you need to be sure you locate your new recipe |
| 1471 | inside your layer such that it can be found.</para> |
| 1472 | <para>You can find more information on how layers are |
| 1473 | structured in the |
| 1474 | "<link linkend='understanding-and-creating-layers'>Understanding and Creating Layers</link>" |
| 1475 | section.</para></listitem> |
| 1476 | <listitem><para><emphasis>Naming Your Recipe:</emphasis> |
| 1477 | When you name your recipe, you need to follow this naming |
| 1478 | convention: |
| 1479 | <literallayout class='monospaced'> |
| 1480 | <replaceable>basename</replaceable>_<replaceable>version</replaceable>.bb |
| 1481 | </literallayout> |
| 1482 | Use lower-cased characters and do not include the reserved |
| 1483 | suffixes <filename>-native</filename>, |
| 1484 | <filename>-cross</filename>, <filename>-initial</filename>, |
| 1485 | or <filename>-dev</filename> casually (i.e. do not use them |
| 1486 | as part of your recipe name unless the string applies). |
| 1487 | Here are some examples: |
| 1488 | <literallayout class='monospaced'> |
| 1489 | cups_1.7.0.bb |
| 1490 | gawk_4.0.2.bb |
| 1491 | irssi_0.8.16-rc1.bb |
| 1492 | </literallayout></para></listitem> |
| 1493 | </itemizedlist> |
| 1494 | </section> |
| 1495 | |
| 1496 | <section id='understanding-recipe-syntax'> |
| 1497 | <title>Understanding Recipe Syntax</title> |
| 1498 | |
| 1499 | <para> |
| 1500 | Understanding recipe file syntax is important for |
| 1501 | writing recipes. |
| 1502 | The following list overviews the basic items that make up a |
| 1503 | BitBake recipe file. |
| 1504 | For more complete BitBake syntax descriptions, see the |
| 1505 | "<ulink url='&YOCTO_DOCS_BB_URL;#bitbake-user-manual-metadata'>Syntax and Operators</ulink>" |
| 1506 | chapter of the BitBake User Manual. |
| 1507 | <itemizedlist> |
| 1508 | <listitem><para><emphasis>Variable Assignments and Manipulations:</emphasis> |
| 1509 | Variable assignments allow a value to be assigned to a |
| 1510 | variable. |
| 1511 | The assignment can be static text or might include |
| 1512 | the contents of other variables. |
| 1513 | In addition to the assignment, appending and prepending |
| 1514 | operations are also supported.</para> |
| 1515 | <para>The following example shows some of the ways |
| 1516 | you can use variables in recipes: |
| 1517 | <literallayout class='monospaced'> |
| 1518 | S = "${WORKDIR}/postfix-${PV}" |
| 1519 | CFLAGS += "-DNO_ASM" |
| 1520 | SRC_URI_append = " file://fixup.patch" |
| 1521 | </literallayout> |
| 1522 | </para></listitem> |
| 1523 | <listitem><para><emphasis>Functions:</emphasis> |
| 1524 | Functions provide a series of actions to be performed. |
| 1525 | You usually use functions to override the default |
| 1526 | implementation of a task function or to complement |
| 1527 | a default function (i.e. append or prepend to an |
| 1528 | existing function). |
| 1529 | Standard functions use <filename>sh</filename> shell |
| 1530 | syntax, although access to OpenEmbedded variables and |
| 1531 | internal methods are also available.</para> |
| 1532 | <para>The following is an example function from the |
| 1533 | <filename>sed</filename> recipe: |
| 1534 | <literallayout class='monospaced'> |
| 1535 | do_install () { |
| 1536 | autotools_do_install |
| 1537 | install -d ${D}${base_bindir} |
| 1538 | mv ${D}${bindir}/sed ${D}${base_bindir}/sed |
| 1539 | rmdir ${D}${bindir}/ |
| 1540 | } |
| 1541 | </literallayout> |
| 1542 | It is also possible to implement new functions that |
| 1543 | are called between existing tasks as long as the |
| 1544 | new functions are not replacing or complementing the |
| 1545 | default functions. |
| 1546 | You can implement functions in Python |
| 1547 | instead of shell. |
| 1548 | Both of these options are not seen in the majority of |
| 1549 | recipes.</para></listitem> |
| 1550 | <listitem><para><emphasis>Keywords:</emphasis> |
| 1551 | BitBake recipes use only a few keywords. |
| 1552 | You use keywords to include common |
| 1553 | functions (<filename>inherit</filename>), load parts |
| 1554 | of a recipe from other files |
| 1555 | (<filename>include</filename> and |
| 1556 | <filename>require</filename>) and export variables |
| 1557 | to the environment (<filename>export</filename>).</para> |
| 1558 | <para>The following example shows the use of some of |
| 1559 | these keywords: |
| 1560 | <literallayout class='monospaced'> |
| 1561 | export POSTCONF = "${STAGING_BINDIR}/postconf" |
| 1562 | inherit autoconf |
| 1563 | require otherfile.inc |
| 1564 | </literallayout> |
| 1565 | </para></listitem> |
| 1566 | <listitem><para><emphasis>Comments:</emphasis> |
| 1567 | Any lines that begin with the hash character |
| 1568 | (<filename>#</filename>) are treated as comment lines |
| 1569 | and are ignored: |
| 1570 | <literallayout class='monospaced'> |
| 1571 | # This is a comment |
| 1572 | </literallayout> |
| 1573 | </para></listitem> |
| 1574 | </itemizedlist> |
| 1575 | </para> |
| 1576 | |
| 1577 | <para> |
| 1578 | This next list summarizes the most important and most commonly |
| 1579 | used parts of the recipe syntax. |
| 1580 | For more information on these parts of the syntax, you can |
| 1581 | reference the |
| 1582 | <ulink url='&YOCTO_DOCS_BB_URL;#bitbake-user-manual-metadata'>Syntax and Operators</ulink> |
| 1583 | chapter in the BitBake User Manual. |
| 1584 | <itemizedlist> |
| 1585 | <listitem><para><emphasis>Line Continuation: <filename>\</filename></emphasis> - |
| 1586 | Use the backward slash (<filename>\</filename>) |
| 1587 | character to split a statement over multiple lines. |
| 1588 | Place the slash character at the end of the line that |
| 1589 | is to be continued on the next line: |
| 1590 | <literallayout class='monospaced'> |
| 1591 | VAR = "A really long \ |
| 1592 | line" |
| 1593 | </literallayout> |
| 1594 | <note> |
| 1595 | You cannot have any characters including spaces |
| 1596 | or tabs after the slash character. |
| 1597 | </note> |
| 1598 | </para></listitem> |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame^] | 1599 | <listitem><para> |
| 1600 | <emphasis>Using Variables: <filename>${...}</filename></emphasis> - |
| 1601 | Use the <filename>${<replaceable>VARNAME</replaceable>}</filename> syntax to |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1602 | access the contents of a variable: |
| 1603 | <literallayout class='monospaced'> |
| 1604 | SRC_URI = "${SOURCEFORGE_MIRROR}/libpng/zlib-${PV}.tar.gz" |
| 1605 | </literallayout> |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame^] | 1606 | <note> |
| 1607 | It is important to understand that the value of a |
| 1608 | variable expressed in this form does not get |
| 1609 | substituted automatically. |
| 1610 | The expansion of these expressions happens |
| 1611 | on-demand later (e.g. usually when a function that |
| 1612 | makes reference to the variable executes). |
| 1613 | This behavior ensures that the values are most |
| 1614 | appropriate for the context in which they are |
| 1615 | finally used. |
| 1616 | On the rare occasion that you do need the variable |
| 1617 | expression to be expanded immediately, you can use |
| 1618 | the <filename>:=</filename> operator instead of |
| 1619 | <filename>=</filename> when you make the |
| 1620 | assignment, but this is not generally needed. |
| 1621 | </note> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1622 | </para></listitem> |
| 1623 | <listitem><para><emphasis>Quote All Assignments: <filename>"<replaceable>value</replaceable>"</filename></emphasis> - |
| 1624 | Use double quotes around the value in all variable |
| 1625 | assignments. |
| 1626 | <literallayout class='monospaced'> |
| 1627 | VAR1 = "${OTHERVAR}" |
| 1628 | VAR2 = "The version is ${PV}" |
| 1629 | </literallayout> |
| 1630 | </para></listitem> |
| 1631 | <listitem><para><emphasis>Conditional Assignment: <filename>?=</filename></emphasis> - |
| 1632 | Conditional assignment is used to assign a value to |
| 1633 | a variable, but only when the variable is currently |
| 1634 | unset. |
| 1635 | Use the question mark followed by the equal sign |
| 1636 | (<filename>?=</filename>) to make a "soft" assignment |
| 1637 | used for conditional assignment. |
| 1638 | Typically, "soft" assignments are used in the |
| 1639 | <filename>local.conf</filename> file for variables |
| 1640 | that are allowed to come through from the external |
| 1641 | environment. |
| 1642 | </para> |
| 1643 | <para>Here is an example where |
| 1644 | <filename>VAR1</filename> is set to "New value" if |
| 1645 | it is currently empty. |
| 1646 | However, if <filename>VAR1</filename> has already been |
| 1647 | set, it remains unchanged: |
| 1648 | <literallayout class='monospaced'> |
| 1649 | VAR1 ?= "New value" |
| 1650 | </literallayout> |
| 1651 | In this next example, <filename>VAR1</filename> |
| 1652 | is left with the value "Original value": |
| 1653 | <literallayout class='monospaced'> |
| 1654 | VAR1 = "Original value" |
| 1655 | VAR1 ?= "New value" |
| 1656 | </literallayout> |
| 1657 | </para></listitem> |
| 1658 | <listitem><para><emphasis>Appending: <filename>+=</filename></emphasis> - |
| 1659 | Use the plus character followed by the equals sign |
| 1660 | (<filename>+=</filename>) to append values to existing |
| 1661 | variables. |
| 1662 | <note> |
| 1663 | This operator adds a space between the existing |
| 1664 | content of the variable and the new content. |
| 1665 | </note></para> |
| 1666 | <para>Here is an example: |
| 1667 | <literallayout class='monospaced'> |
| 1668 | SRC_URI += "file://fix-makefile.patch" |
| 1669 | </literallayout> |
| 1670 | </para></listitem> |
| 1671 | <listitem><para><emphasis>Prepending: <filename>=+</filename></emphasis> - |
| 1672 | Use the equals sign followed by the plus character |
| 1673 | (<filename>=+</filename>) to prepend values to existing |
| 1674 | variables. |
| 1675 | <note> |
| 1676 | This operator adds a space between the new content |
| 1677 | and the existing content of the variable. |
| 1678 | </note></para> |
| 1679 | <para>Here is an example: |
| 1680 | <literallayout class='monospaced'> |
| 1681 | VAR =+ "Starts" |
| 1682 | </literallayout> |
| 1683 | </para></listitem> |
| 1684 | <listitem><para><emphasis>Appending: <filename>_append</filename></emphasis> - |
| 1685 | Use the <filename>_append</filename> operator to |
| 1686 | append values to existing variables. |
| 1687 | This operator does not add any additional space. |
| 1688 | Also, the operator is applied after all the |
| 1689 | <filename>+=</filename>, and |
| 1690 | <filename>=+</filename> operators have been applied and |
| 1691 | after all <filename>=</filename> assignments have |
| 1692 | occurred. |
| 1693 | </para> |
| 1694 | <para>The following example shows the space being |
| 1695 | explicitly added to the start to ensure the appended |
| 1696 | value is not merged with the existing value: |
| 1697 | <literallayout class='monospaced'> |
| 1698 | SRC_URI_append = " file://fix-makefile.patch" |
| 1699 | </literallayout> |
| 1700 | You can also use the <filename>_append</filename> |
| 1701 | operator with overrides, which results in the actions |
| 1702 | only being performed for the specified target or |
| 1703 | machine: |
| 1704 | <literallayout class='monospaced'> |
| 1705 | SRC_URI_append_sh4 = " file://fix-makefile.patch" |
| 1706 | </literallayout> |
| 1707 | </para></listitem> |
| 1708 | <listitem><para><emphasis>Prepending: <filename>_prepend</filename></emphasis> - |
| 1709 | Use the <filename>_prepend</filename> operator to |
| 1710 | prepend values to existing variables. |
| 1711 | This operator does not add any additional space. |
| 1712 | Also, the operator is applied after all the |
| 1713 | <filename>+=</filename>, and |
| 1714 | <filename>=+</filename> operators have been applied and |
| 1715 | after all <filename>=</filename> assignments have |
| 1716 | occurred. |
| 1717 | </para> |
| 1718 | <para>The following example shows the space being |
| 1719 | explicitly added to the end to ensure the prepended |
| 1720 | value is not merged with the existing value: |
| 1721 | <literallayout class='monospaced'> |
| 1722 | CFLAGS_prepend = "-I${S}/myincludes " |
| 1723 | </literallayout> |
| 1724 | You can also use the <filename>_prepend</filename> |
| 1725 | operator with overrides, which results in the actions |
| 1726 | only being performed for the specified target or |
| 1727 | machine: |
| 1728 | <literallayout class='monospaced'> |
| 1729 | CFLAGS_prepend_sh4 = "-I${S}/myincludes " |
| 1730 | </literallayout> |
| 1731 | </para></listitem> |
| 1732 | <listitem><para><emphasis>Overrides:</emphasis> - |
| 1733 | You can use overrides to set a value conditionally, |
| 1734 | typically based on how the recipe is being built. |
| 1735 | For example, to set the |
| 1736 | <ulink url='&YOCTO_DOCS_REF_URL;#var-KBRANCH'><filename>KBRANCH</filename></ulink> |
| 1737 | variable's value to "standard/base" for any target |
| 1738 | <ulink url='&YOCTO_DOCS_REF_URL;#var-MACHINE'><filename>MACHINE</filename></ulink>, |
| 1739 | except for qemuarm where it should be set to |
| 1740 | "standard/arm-versatile-926ejs", you would do the |
| 1741 | following: |
| 1742 | <literallayout class='monospaced'> |
| 1743 | KBRANCH = "standard/base" |
| 1744 | KBRANCH_qemuarm = "standard/arm-versatile-926ejs" |
| 1745 | </literallayout> |
| 1746 | Overrides are also used to separate alternate values |
| 1747 | of a variable in other situations. |
| 1748 | For example, when setting variables such as |
| 1749 | <ulink url='&YOCTO_DOCS_REF_URL;#var-FILES'><filename>FILES</filename></ulink> |
| 1750 | and |
| 1751 | <ulink url='&YOCTO_DOCS_REF_URL;#var-RDEPENDS'><filename>RDEPENDS</filename></ulink> |
| 1752 | that are specific to individual packages produced by |
| 1753 | a recipe, you should always use an override that |
| 1754 | specifies the name of the package. |
| 1755 | </para></listitem> |
| 1756 | <listitem><para><emphasis>Indentation:</emphasis> |
| 1757 | Use spaces for indentation rather than than tabs. |
| 1758 | For shell functions, both currently work. |
| 1759 | However, it is a policy decision of the Yocto Project |
| 1760 | to use tabs in shell functions. |
| 1761 | Realize that some layers have a policy to use spaces |
| 1762 | for all indentation. |
| 1763 | </para></listitem> |
| 1764 | <listitem><para><emphasis>Using Python for Complex Operations: <filename>${@<replaceable>python_code</replaceable>}</filename></emphasis> - |
| 1765 | For more advanced processing, it is possible to use |
| 1766 | Python code during variable assignments (e.g. |
| 1767 | search and replacement on a variable).</para> |
| 1768 | <para>You indicate Python code using the |
| 1769 | <filename>${@<replaceable>python_code</replaceable>}</filename> |
| 1770 | syntax for the variable assignment: |
| 1771 | <literallayout class='monospaced'> |
| 1772 | SRC_URI = "ftp://ftp.info-zip.org/pub/infozip/src/zip${@d.getVar('PV',1).replace('.', '')}.tgz |
| 1773 | </literallayout> |
| 1774 | </para></listitem> |
| 1775 | <listitem><para><emphasis>Shell Function Syntax:</emphasis> |
| 1776 | Write shell functions as if you were writing a shell |
| 1777 | script when you describe a list of actions to take. |
| 1778 | You should ensure that your script works with a generic |
| 1779 | <filename>sh</filename> and that it does not require |
| 1780 | any <filename>bash</filename> or other shell-specific |
| 1781 | functionality. |
| 1782 | The same considerations apply to various system |
| 1783 | utilities (e.g. <filename>sed</filename>, |
| 1784 | <filename>grep</filename>, <filename>awk</filename>, |
| 1785 | and so forth) that you might wish to use. |
| 1786 | If in doubt, you should check with multiple |
| 1787 | implementations - including those from BusyBox. |
| 1788 | </para></listitem> |
| 1789 | </itemizedlist> |
| 1790 | </para> |
| 1791 | </section> |
| 1792 | |
| 1793 | <section id='new-recipe-running-a-build-on-the-recipe'> |
| 1794 | <title>Running a Build on the Recipe</title> |
| 1795 | |
| 1796 | <para> |
| 1797 | Creating a new recipe is usually an iterative process that |
| 1798 | requires using BitBake to process the recipe multiple times in |
| 1799 | order to progressively discover and add information to the |
| 1800 | recipe file. |
| 1801 | </para> |
| 1802 | |
| 1803 | <para> |
| 1804 | Assuming you have sourced a build environment setup script (i.e. |
| 1805 | <ulink url='&YOCTO_DOCS_REF_URL;#structure-core-script'><filename>&OE_INIT_FILE;</filename></ulink> |
| 1806 | or |
| 1807 | <ulink url='&YOCTO_DOCS_REF_URL;#structure-memres-core-script'><filename>oe-init-build-env-memres</filename></ulink>) |
| 1808 | and you are in the |
| 1809 | <link linkend='build-directory'>Build Directory</link>, |
| 1810 | use BitBake to process your recipe. |
| 1811 | All you need to provide is the |
| 1812 | <filename><replaceable>basename</replaceable></filename> of the recipe as described |
| 1813 | in the previous section: |
| 1814 | <literallayout class='monospaced'> |
| 1815 | $ bitbake <replaceable>basename</replaceable> |
| 1816 | </literallayout> |
| 1817 | |
| 1818 | </para> |
| 1819 | |
| 1820 | <para> |
| 1821 | During the build, the OpenEmbedded build system creates a |
| 1822 | temporary work directory for each recipe |
| 1823 | (<filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-WORKDIR'><filename>WORKDIR</filename></ulink><filename>}</filename>) |
| 1824 | where it keeps extracted source files, log files, intermediate |
| 1825 | compilation and packaging files, and so forth. |
| 1826 | </para> |
| 1827 | |
| 1828 | <para> |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame^] | 1829 | The path to the per-recipe temporary work directory depends |
| 1830 | on the context in which it is being built. |
| 1831 | The quickest way to find this path is to have BitBake return it |
| 1832 | by running the following: |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1833 | <literallayout class='monospaced'> |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame^] | 1834 | $ bitbake -e <replaceable>basename</replaceable> | grep ^WORKDIR= |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1835 | </literallayout> |
| 1836 | As an example, assume a Source Directory top-level folder named |
| 1837 | <filename>poky</filename>, a default Build Directory at |
| 1838 | <filename>poky/build</filename>, and a |
| 1839 | <filename>qemux86-poky-linux</filename> machine target system. |
| 1840 | Furthermore, suppose your recipe is named |
| 1841 | <filename>foo_1.3.0.bb</filename>. |
| 1842 | In this case, the work directory the build system uses to |
| 1843 | build the package would be as follows: |
| 1844 | <literallayout class='monospaced'> |
| 1845 | poky/build/tmp/work/qemux86-poky-linux/foo/1.3.0-r0 |
| 1846 | </literallayout> |
| 1847 | Inside this directory you can find sub-directories such as |
| 1848 | <filename>image</filename>, <filename>packages-split</filename>, |
| 1849 | and <filename>temp</filename>. |
| 1850 | After the build, you can examine these to determine how well |
| 1851 | the build went. |
| 1852 | <note> |
| 1853 | You can find log files for each task in the recipe's |
| 1854 | <filename>temp</filename> directory (e.g. |
| 1855 | <filename>poky/build/tmp/work/qemux86-poky-linux/foo/1.3.0-r0/temp</filename>). |
| 1856 | Log files are named <filename>log.<replaceable>taskname</replaceable></filename> |
| 1857 | (e.g. <filename>log.do_configure</filename>, |
| 1858 | <filename>log.do_fetch</filename>, and |
| 1859 | <filename>log.do_compile</filename>). |
| 1860 | </note> |
| 1861 | </para> |
| 1862 | |
| 1863 | <para> |
| 1864 | You can find more information about the build process in the |
| 1865 | "<ulink url='&YOCTO_DOCS_REF_URL;#closer-look'>A Closer Look at the Yocto Project Development Environment</ulink>" |
| 1866 | chapter of the Yocto Project Reference Manual. |
| 1867 | </para> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1868 | </section> |
| 1869 | |
| 1870 | <section id='new-recipe-fetching-code'> |
| 1871 | <title>Fetching Code</title> |
| 1872 | |
| 1873 | <para> |
| 1874 | The first thing your recipe must do is specify how to fetch |
| 1875 | the source files. |
| 1876 | Fetching is controlled mainly through the |
| 1877 | <ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'><filename>SRC_URI</filename></ulink> |
| 1878 | variable. |
| 1879 | Your recipe must have a <filename>SRC_URI</filename> variable |
| 1880 | that points to where the source is located. |
| 1881 | For a graphical representation of source locations, see the |
| 1882 | "<ulink url='&YOCTO_DOCS_REF_URL;#sources-dev-environment'>Sources</ulink>" |
| 1883 | section in the Yocto Project Reference Manual. |
| 1884 | </para> |
| 1885 | |
| 1886 | <para> |
| 1887 | The |
| 1888 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-fetch'><filename>do_fetch</filename></ulink> |
| 1889 | task uses the prefix of each entry in the |
| 1890 | <filename>SRC_URI</filename> variable value to determine which |
| 1891 | fetcher to use to get your source files. |
| 1892 | It is the <filename>SRC_URI</filename> variable that triggers |
| 1893 | the fetcher. |
| 1894 | The |
| 1895 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-patch'><filename>do_patch</filename></ulink> |
| 1896 | task uses the variable after source is fetched to apply |
| 1897 | patches. |
| 1898 | The OpenEmbedded build system uses |
| 1899 | <ulink url='&YOCTO_DOCS_REF_URL;#var-FILESOVERRIDES'><filename>FILESOVERRIDES</filename></ulink> |
| 1900 | for scanning directory locations for local files in |
| 1901 | <filename>SRC_URI</filename>. |
| 1902 | </para> |
| 1903 | |
| 1904 | <para> |
| 1905 | The <filename>SRC_URI</filename> variable in your recipe must |
| 1906 | define each unique location for your source files. |
| 1907 | It is good practice to not hard-code pathnames in an URL used |
| 1908 | in <filename>SRC_URI</filename>. |
| 1909 | Rather than hard-code these paths, use |
| 1910 | <filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-PV'><filename>PV</filename></ulink><filename>}</filename>, |
| 1911 | which causes the fetch process to use the version specified in |
| 1912 | the recipe filename. |
| 1913 | Specifying the version in this manner means that upgrading the |
| 1914 | recipe to a future version is as simple as renaming the recipe |
| 1915 | to match the new version. |
| 1916 | </para> |
| 1917 | |
| 1918 | <para> |
| 1919 | Here is a simple example from the |
| 1920 | <filename>meta/recipes-devtools/cdrtools/cdrtools-native_3.01a20.bb</filename> |
| 1921 | recipe where the source comes from a single tarball. |
| 1922 | Notice the use of the |
| 1923 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PV'><filename>PV</filename></ulink> |
| 1924 | variable: |
| 1925 | <literallayout class='monospaced'> |
| 1926 | SRC_URI = "ftp://ftp.berlios.de/pub/cdrecord/alpha/cdrtools-${PV}.tar.bz2" |
| 1927 | </literallayout> |
| 1928 | </para> |
| 1929 | |
| 1930 | <para> |
| 1931 | Files mentioned in <filename>SRC_URI</filename> whose names end |
| 1932 | in a typical archive extension (e.g. <filename>.tar</filename>, |
| 1933 | <filename>.tar.gz</filename>, <filename>.tar.bz2</filename>, |
| 1934 | <filename>.zip</filename>, and so forth), are automatically |
| 1935 | extracted during the |
| 1936 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-unpack'><filename>do_unpack</filename></ulink> |
| 1937 | task. |
| 1938 | For another example that specifies these types of files, see |
| 1939 | the |
| 1940 | "<link linkend='new-recipe-autotooled-package'>Autotooled Package</link>" |
| 1941 | section. |
| 1942 | </para> |
| 1943 | |
| 1944 | <para> |
| 1945 | Another way of specifying source is from an SCM. |
| 1946 | For Git repositories, you must specify |
| 1947 | <ulink url='&YOCTO_DOCS_REF_URL;#var-SRCREV'><filename>SRCREV</filename></ulink> |
| 1948 | and you should specify |
| 1949 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PV'><filename>PV</filename></ulink> |
| 1950 | to include the revision with |
| 1951 | <ulink url='&YOCTO_DOCS_REF_URL;#var-SRCPV'><filename>SRCPV</filename></ulink>. |
| 1952 | Here is an example from the recipe |
| 1953 | <filename>meta/recipes-kernel/blktrace/blktrace_git.bb</filename>: |
| 1954 | <literallayout class='monospaced'> |
| 1955 | SRCREV = "d6918c8832793b4205ed3bfede78c2f915c23385" |
| 1956 | |
| 1957 | PR = "r6" |
| 1958 | PV = "1.0.5+git${SRCPV}" |
| 1959 | |
| 1960 | SRC_URI = "git://git.kernel.dk/blktrace.git \ |
| 1961 | file://ldflags.patch" |
| 1962 | </literallayout> |
| 1963 | </para> |
| 1964 | |
| 1965 | <para> |
| 1966 | If your <filename>SRC_URI</filename> statement includes |
| 1967 | URLs pointing to individual files fetched from a remote server |
| 1968 | other than a version control system, BitBake attempts to |
| 1969 | verify the files against checksums defined in your recipe to |
| 1970 | ensure they have not been tampered with or otherwise modified |
| 1971 | since the recipe was written. |
| 1972 | Two checksums are used: |
| 1973 | <filename>SRC_URI[md5sum]</filename> and |
| 1974 | <filename>SRC_URI[sha256sum]</filename>. |
| 1975 | </para> |
| 1976 | |
| 1977 | <para> |
| 1978 | If your <filename>SRC_URI</filename> variable points to |
| 1979 | more than a single URL (excluding SCM URLs), you need to |
| 1980 | provide the <filename>md5</filename> and |
| 1981 | <filename>sha256</filename> checksums for each URL. |
| 1982 | For these cases, you provide a name for each URL as part of |
| 1983 | the <filename>SRC_URI</filename> and then reference that name |
| 1984 | in the subsequent checksum statements. |
| 1985 | Here is an example: |
| 1986 | <literallayout class='monospaced'> |
| 1987 | SRC_URI = "${DEBIAN_MIRROR}/main/a/apmd/apmd_3.2.2.orig.tar.gz;name=tarball \ |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame^] | 1988 | ${DEBIAN_MIRROR}/main/a/apmd/apmd_${PV}.diff.gz;name=patch" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1989 | |
| 1990 | SRC_URI[tarball.md5sum] = "b1e6309e8331e0f4e6efd311c2d97fa8" |
| 1991 | SRC_URI[tarball.sha256sum] = "7f7d9f60b7766b852881d40b8ff91d8e39fccb0d1d913102a5c75a2dbb52332d" |
| 1992 | |
| 1993 | SRC_URI[patch.md5sum] = "57e1b689264ea80f78353519eece0c92" |
| 1994 | SRC_URI[patch.sha256sum] = "7905ff96be93d725544d0040e425c42f9c05580db3c272f11cff75b9aa89d430" |
| 1995 | </literallayout> |
| 1996 | </para> |
| 1997 | |
| 1998 | <para> |
| 1999 | Proper values for <filename>md5</filename> and |
| 2000 | <filename>sha256</filename> checksums might be available |
| 2001 | with other signatures on the download page for the upstream |
| 2002 | source (e.g. <filename>md5</filename>, |
| 2003 | <filename>sha1</filename>, <filename>sha256</filename>, |
| 2004 | <filename>GPG</filename>, and so forth). |
| 2005 | Because the OpenEmbedded build system only deals with |
| 2006 | <filename>sha256sum</filename> and <filename>md5sum</filename>, |
| 2007 | you should verify all the signatures you find by hand. |
| 2008 | </para> |
| 2009 | |
| 2010 | <para> |
| 2011 | If no <filename>SRC_URI</filename> checksums are specified |
| 2012 | when you attempt to build the recipe, or you provide an |
| 2013 | incorrect checksum, the build will produce an error for each |
| 2014 | missing or incorrect checksum. |
| 2015 | As part of the error message, the build system provides |
| 2016 | the checksum string corresponding to the fetched file. |
| 2017 | Once you have the correct checksums, you can copy and paste |
| 2018 | them into your recipe and then run the build again to continue. |
| 2019 | <note> |
| 2020 | As mentioned, if the upstream source provides signatures |
| 2021 | for verifying the downloaded source code, you should |
| 2022 | verify those manually before setting the checksum values |
| 2023 | in the recipe and continuing with the build. |
| 2024 | </note> |
| 2025 | </para> |
| 2026 | |
| 2027 | <para> |
| 2028 | This final example is a bit more complicated and is from the |
| 2029 | <filename>meta/recipes-sato/rxvt-unicode/rxvt-unicode_9.20.bb</filename> |
| 2030 | recipe. |
| 2031 | The example's <filename>SRC_URI</filename> statement identifies |
| 2032 | multiple files as the source files for the recipe: a tarball, a |
| 2033 | patch file, a desktop file, and an icon. |
| 2034 | <literallayout class='monospaced'> |
| 2035 | SRC_URI = "http://dist.schmorp.de/rxvt-unicode/Attic/rxvt-unicode-${PV}.tar.bz2 \ |
| 2036 | file://xwc.patch \ |
| 2037 | file://rxvt.desktop \ |
| 2038 | file://rxvt.png" |
| 2039 | </literallayout> |
| 2040 | </para> |
| 2041 | |
| 2042 | <para> |
| 2043 | When you specify local files using the |
| 2044 | <filename>file://</filename> URI protocol, the build system |
| 2045 | fetches files from the local machine. |
| 2046 | The path is relative to the |
| 2047 | <ulink url='&YOCTO_DOCS_REF_URL;#var-FILESPATH'><filename>FILESPATH</filename></ulink> |
| 2048 | variable and searches specific directories in a certain order: |
| 2049 | <filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-BP'><filename>BP</filename></ulink><filename>}</filename>, |
| 2050 | <filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-BPN'><filename>BPN</filename></ulink><filename>}</filename>, |
| 2051 | and <filename>files</filename>. |
| 2052 | The directories are assumed to be subdirectories of the |
| 2053 | directory in which the recipe or append file resides. |
| 2054 | For another example that specifies these types of files, see the |
| 2055 | "<link linkend='new-recipe-single-c-file-package-hello-world'>Single .c File Package (Hello World!)</link>" |
| 2056 | section. |
| 2057 | </para> |
| 2058 | |
| 2059 | <para> |
| 2060 | The previous example also specifies a patch file. |
| 2061 | Patch files are files whose names usually end in |
| 2062 | <filename>.patch</filename> or <filename>.diff</filename> but |
| 2063 | can end with compressed suffixes such as |
| 2064 | <filename>diff.gz</filename> and |
| 2065 | <filename>patch.bz2</filename>, for example. |
| 2066 | The build system automatically applies patches as described |
| 2067 | in the |
| 2068 | "<link linkend='new-recipe-patching-code'>Patching Code</link>" section. |
| 2069 | </para> |
| 2070 | </section> |
| 2071 | |
| 2072 | <section id='new-recipe-unpacking-code'> |
| 2073 | <title>Unpacking Code</title> |
| 2074 | |
| 2075 | <para> |
| 2076 | During the build, the |
| 2077 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-unpack'><filename>do_unpack</filename></ulink> |
| 2078 | task unpacks the source with |
| 2079 | <filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-S'><filename>S</filename></ulink><filename>}</filename> |
| 2080 | pointing to where it is unpacked. |
| 2081 | </para> |
| 2082 | |
| 2083 | <para> |
| 2084 | If you are fetching your source files from an upstream source |
| 2085 | archived tarball and the tarball's internal structure matches |
| 2086 | the common convention of a top-level subdirectory named |
| 2087 | <filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-BPN'><filename>BPN</filename></ulink><filename>}-${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-PV'><filename>PV</filename></ulink><filename>}</filename>, |
| 2088 | then you do not need to set <filename>S</filename>. |
| 2089 | However, if <filename>SRC_URI</filename> specifies to fetch |
| 2090 | source from an archive that does not use this convention, |
| 2091 | or from an SCM like Git or Subversion, your recipe needs to |
| 2092 | define <filename>S</filename>. |
| 2093 | </para> |
| 2094 | |
| 2095 | <para> |
| 2096 | If processing your recipe using BitBake successfully unpacks |
| 2097 | the source files, you need to be sure that the directory |
| 2098 | pointed to by <filename>${S}</filename> matches the structure |
| 2099 | of the source. |
| 2100 | </para> |
| 2101 | </section> |
| 2102 | |
| 2103 | <section id='new-recipe-patching-code'> |
| 2104 | <title>Patching Code</title> |
| 2105 | |
| 2106 | <para> |
| 2107 | Sometimes it is necessary to patch code after it has been |
| 2108 | fetched. |
| 2109 | Any files mentioned in <filename>SRC_URI</filename> whose |
| 2110 | names end in <filename>.patch</filename> or |
| 2111 | <filename>.diff</filename> or compressed versions of these |
| 2112 | suffixes (e.g. <filename>diff.gz</filename> are treated as |
| 2113 | patches. |
| 2114 | The |
| 2115 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-patch'><filename>do_patch</filename></ulink> |
| 2116 | task automatically applies these patches. |
| 2117 | </para> |
| 2118 | |
| 2119 | <para> |
| 2120 | The build system should be able to apply patches with the "-p1" |
| 2121 | option (i.e. one directory level in the path will be stripped |
| 2122 | off). |
| 2123 | If your patch needs to have more directory levels stripped off, |
| 2124 | specify the number of levels using the "striplevel" option in |
| 2125 | the <filename>SRC_URI</filename> entry for the patch. |
| 2126 | Alternatively, if your patch needs to be applied in a specific |
| 2127 | subdirectory that is not specified in the patch file, use the |
| 2128 | "patchdir" option in the entry. |
| 2129 | </para> |
| 2130 | |
| 2131 | <para> |
| 2132 | As with all local files referenced in |
| 2133 | <ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'><filename>SRC_URI</filename></ulink> |
| 2134 | using <filename>file://</filename>, you should place |
| 2135 | patch files in a directory next to the recipe either |
| 2136 | named the same as the base name of the recipe |
| 2137 | (<ulink url='&YOCTO_DOCS_REF_URL;#var-BP'><filename>BP</filename></ulink> |
| 2138 | and |
| 2139 | <ulink url='&YOCTO_DOCS_REF_URL;#var-BPN'><filename>BPN</filename></ulink>) |
| 2140 | or "files". |
| 2141 | </para> |
| 2142 | </section> |
| 2143 | |
| 2144 | <section id='new-recipe-licensing'> |
| 2145 | <title>Licensing</title> |
| 2146 | |
| 2147 | <para> |
| 2148 | Your recipe needs to have both the |
| 2149 | <ulink url='&YOCTO_DOCS_REF_URL;#var-LICENSE'><filename>LICENSE</filename></ulink> |
| 2150 | and |
| 2151 | <ulink url='&YOCTO_DOCS_REF_URL;#var-LIC_FILES_CHKSUM'><filename>LIC_FILES_CHKSUM</filename></ulink> |
| 2152 | variables: |
| 2153 | <itemizedlist> |
| 2154 | <listitem><para><emphasis><filename>LICENSE</filename>:</emphasis> |
| 2155 | This variable specifies the license for the software. |
| 2156 | If you do not know the license under which the software |
| 2157 | you are building is distributed, you should go to the |
| 2158 | source code and look for that information. |
| 2159 | Typical files containing this information include |
| 2160 | <filename>COPYING</filename>, |
| 2161 | <filename>LICENSE</filename>, and |
| 2162 | <filename>README</filename> files. |
| 2163 | You could also find the information near the top of |
| 2164 | a source file. |
| 2165 | For example, given a piece of software licensed under |
| 2166 | the GNU General Public License version 2, you would |
| 2167 | set <filename>LICENSE</filename> as follows: |
| 2168 | <literallayout class='monospaced'> |
| 2169 | LICENSE = "GPLv2" |
| 2170 | </literallayout></para> |
| 2171 | <para>The licenses you specify within |
| 2172 | <filename>LICENSE</filename> can have any name as long |
| 2173 | as you do not use spaces, since spaces are used as |
| 2174 | separators between license names. |
| 2175 | For standard licenses, use the names of the files in |
| 2176 | <filename>meta/files/common-licenses/</filename> |
| 2177 | or the <filename>SPDXLICENSEMAP</filename> flag names |
| 2178 | defined in <filename>meta/conf/licenses.conf</filename>. |
| 2179 | </para></listitem> |
| 2180 | <listitem><para><emphasis><filename>LIC_FILES_CHKSUM</filename>:</emphasis> |
| 2181 | The OpenEmbedded build system uses this variable to |
| 2182 | make sure the license text has not changed. |
| 2183 | If it has, the build produces an error and it affords |
| 2184 | you the chance to figure it out and correct the problem. |
| 2185 | </para> |
| 2186 | <para>You need to specify all applicable licensing |
| 2187 | files for the software. |
| 2188 | At the end of the configuration step, the build process |
| 2189 | will compare the checksums of the files to be sure |
| 2190 | the text has not changed. |
| 2191 | Any differences result in an error with the message |
| 2192 | containing the current checksum. |
| 2193 | For more explanation and examples of how to set the |
| 2194 | <filename>LIC_FILES_CHKSUM</filename> variable, see the |
| 2195 | "<ulink url='&YOCTO_DOCS_REF_URL;#usingpoky-configuring-LIC_FILES_CHKSUM'>Tracking License Changes</ulink>" |
| 2196 | section in the Yocto Project Reference Manual.</para> |
| 2197 | <para>To determine the correct checksum string, you |
| 2198 | can list the appropriate files in the |
| 2199 | <filename>LIC_FILES_CHKSUM</filename> variable with |
| 2200 | incorrect md5 strings, attempt to build the software, |
| 2201 | and then note the resulting error messages that will |
| 2202 | report the correct md5 strings. |
| 2203 | See the |
| 2204 | "<link linkend='new-recipe-fetching-code'>Fetching Code</link>" |
| 2205 | section for additional information. |
| 2206 | </para> |
| 2207 | |
| 2208 | <para> |
| 2209 | Here is an example that assumes the software has a |
| 2210 | <filename>COPYING</filename> file: |
| 2211 | <literallayout class='monospaced'> |
| 2212 | LIC_FILES_CHKSUM = "file://COPYING;md5=xxx" |
| 2213 | </literallayout> |
| 2214 | When you try to build the software, the build system |
| 2215 | will produce an error and give you the correct string |
| 2216 | that you can substitute into the recipe file for a |
| 2217 | subsequent build. |
| 2218 | </para></listitem> |
| 2219 | </itemizedlist> |
| 2220 | </para> |
| 2221 | |
| 2222 | <!-- |
| 2223 | |
| 2224 | <para> |
| 2225 | For trying this out I created a new recipe named |
| 2226 | <filename>htop_1.0.2.bb</filename> and put it in |
| 2227 | <filename>poky/meta/recipes-extended/htop</filename>. |
| 2228 | There are two license type statements in my very simple |
| 2229 | recipe: |
| 2230 | <literallayout class='monospaced'> |
| 2231 | LICENSE = "" |
| 2232 | |
| 2233 | LIC_FILES_CHKSUM = "" |
| 2234 | |
| 2235 | SRC_URI[md5sum] = "" |
| 2236 | SRC_URI[sha256sum] = "" |
| 2237 | </literallayout> |
| 2238 | Evidently, you need to run a <filename>bitbake -c cleanall htop</filename>. |
| 2239 | Next, you delete or comment out the two <filename>SRC_URI</filename> |
| 2240 | lines at the end and then attempt to build the software with |
| 2241 | <filename>bitbake htop</filename>. |
| 2242 | Doing so causes BitBake to report some errors and and give |
| 2243 | you the actual strings you need for the last two |
| 2244 | <filename>SRC_URI</filename> lines. |
| 2245 | Prior to this, you have to dig around in the home page of the |
| 2246 | source for <filename>htop</filename> and determine that the |
| 2247 | software is released under GPLv2. |
| 2248 | You can provide that in the <filename>LICENSE</filename> |
| 2249 | statement. |
| 2250 | Now you edit your recipe to have those two strings for |
| 2251 | the <filename>SRC_URI</filename> statements: |
| 2252 | <literallayout class='monospaced'> |
| 2253 | LICENSE = "GPLv2" |
| 2254 | |
| 2255 | LIC_FILES_CHKSUM = "" |
| 2256 | |
| 2257 | SRC_URI = "${SOURCEFORGE_MIRROR}/htop/htop-${PV}.tar.gz" |
| 2258 | SRC_URI[md5sum] = "0d01cca8df3349c74569cefebbd9919e" |
| 2259 | SRC_URI[sha256sum] = "ee60657b044ece0df096c053060df7abf3cce3a568ab34d260049e6a37ccd8a1" |
| 2260 | </literallayout> |
| 2261 | At this point, you can build the software again using the |
| 2262 | <filename>bitbake htop</filename> command. |
| 2263 | There is just a set of errors now associated with the |
| 2264 | empty <filename>LIC_FILES_CHKSUM</filename> variable now. |
| 2265 | </para> |
| 2266 | --> |
| 2267 | |
| 2268 | </section> |
| 2269 | |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame^] | 2270 | <section id='new-dependencies'> |
| 2271 | <title>Dependencies</title> |
| 2272 | |
| 2273 | <para> |
| 2274 | Most software packages have a short list of other packages |
| 2275 | that they require, which are called dependencies. |
| 2276 | These dependencies fall into two main categories: build-time |
| 2277 | dependencies, which are required when the software is built; |
| 2278 | and runtime dependencies, which are required to be installed |
| 2279 | on the target in order for the software to run. |
| 2280 | </para> |
| 2281 | |
| 2282 | <para> |
| 2283 | Within a recipe, you specify build-time dependencies using the |
| 2284 | <ulink url='&YOCTO_DOCS_REF_URL;#var-DEPENDS'><filename>DEPENDS</filename></ulink> |
| 2285 | variable. |
| 2286 | Although nuances exist, items specified in |
| 2287 | <filename>DEPENDS</filename> should be names of other recipes. |
| 2288 | It is important that you specify all build-time dependencies |
| 2289 | explicitly. |
| 2290 | If you do not, due to the parallel nature of BitBake's |
| 2291 | execution, you can end up with a race condition where the |
| 2292 | dependency is present for one task of a recipe (e.g. |
| 2293 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-configure'><filename>do_configure</filename></ulink>) |
| 2294 | and then gone when the next task runs (e.g. |
| 2295 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-compile'><filename>do_compile</filename></ulink>). |
| 2296 | </para> |
| 2297 | |
| 2298 | <para> |
| 2299 | Another consideration is that configure scripts might |
| 2300 | automatically check for optional dependencies and enable |
| 2301 | corresponding functionality if those dependencies are found. |
| 2302 | This behavior means that to ensure deterministic results and |
| 2303 | thus avoid more race conditions, you need to either explicitly |
| 2304 | specify these dependencies as well, or tell the configure |
| 2305 | script explicitly to disable the functionality. |
| 2306 | If you wish to make a recipe that is more generally useful |
| 2307 | (e.g. publish the recipe in a layer for others to use), |
| 2308 | instead of hard-disabling the functionality, you can use the |
| 2309 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGECONFIG'><filename>PACKAGECONFIG</filename></ulink> |
| 2310 | variable to allow functionality and the corresponding |
| 2311 | dependencies to be enabled and disabled easily by other |
| 2312 | users of the recipe. |
| 2313 | </para> |
| 2314 | |
| 2315 | <para> |
| 2316 | Similar to build-time dependencies, you specify runtime |
| 2317 | dependencies through a variable - |
| 2318 | <ulink url='&YOCTO_DOCS_REF_URL;#var-RDEPENDS'><filename>RDEPENDS</filename></ulink>, |
| 2319 | which is package-specific. |
| 2320 | All variables that are package-specific need to have the name |
| 2321 | of the package added to the end as an override. |
| 2322 | Since the main package for a recipe has the same name as the |
| 2323 | recipe, and the recipe's name can be found through the |
| 2324 | <filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-PN'><filename>PN</filename></ulink><filename>}</filename> |
| 2325 | variable, then you specify the dependencies for the main |
| 2326 | package by setting <filename>RDEPENDS_${PN}</filename>. |
| 2327 | If the package were named <filename>${PN}-tools</filename>, |
| 2328 | then you would set <filename>RDEPENDS_${PN}-tools</filename>, |
| 2329 | and so forth. |
| 2330 | </para> |
| 2331 | |
| 2332 | <para> |
| 2333 | Some runtime dependencies will be set automatically at |
| 2334 | packaging time. |
| 2335 | These dependencies include any shared library dependencies |
| 2336 | (i.e. if a package "example" contains "libexample" and |
| 2337 | another package "mypackage" contains a binary that links to |
| 2338 | "libexample" then the OpenEmbedded build system will |
| 2339 | automatically add a runtime dependency to "mypackage" on |
| 2340 | "example"). |
| 2341 | See the |
| 2342 | "<ulink url='&YOCTO_DOCS_REF_URL;#automatically-added-runtime-dependencies'>Automatically Added Runtime Dependencies</ulink>" |
| 2343 | in the Yocto Project Reference Manual for further details. |
| 2344 | </para> |
| 2345 | </section> |
| 2346 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 2347 | <section id='new-recipe-configuring-the-recipe'> |
| 2348 | <title>Configuring the Recipe</title> |
| 2349 | |
| 2350 | <para> |
| 2351 | Most software provides some means of setting build-time |
| 2352 | configuration options before compilation. |
| 2353 | Typically, setting these options is accomplished by running a |
| 2354 | configure script with some options, or by modifying a build |
| 2355 | configuration file. |
Patrick Williams | f1e5d69 | 2016-03-30 15:21:19 -0500 | [diff] [blame] | 2356 | <note> |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame^] | 2357 | As of Yocto Project Release 1.7, some of the core recipes |
Patrick Williams | f1e5d69 | 2016-03-30 15:21:19 -0500 | [diff] [blame] | 2358 | that package binary configuration scripts now disable the |
| 2359 | scripts due to the scripts previously requiring error-prone |
| 2360 | path substitution. |
| 2361 | The OpenEmbedded build system uses |
| 2362 | <filename>pkg-config</filename> now, which is much more |
| 2363 | robust. |
| 2364 | You can find a list of the <filename>*-config</filename> |
| 2365 | scripts that are disabled list in the |
| 2366 | "<ulink url='&YOCTO_DOCS_REF_URL;#migration-1.7-binary-configuration-scripts-disabled'>Binary Configuration Scripts Disabled</ulink>" |
| 2367 | section in the Yocto Project Reference Manual. |
| 2368 | </note> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 2369 | </para> |
| 2370 | |
| 2371 | <para> |
| 2372 | A major part of build-time configuration is about checking for |
| 2373 | build-time dependencies and possibly enabling optional |
| 2374 | functionality as a result. |
| 2375 | You need to specify any build-time dependencies for the |
| 2376 | software you are building in your recipe's |
| 2377 | <ulink url='&YOCTO_DOCS_REF_URL;#var-DEPENDS'><filename>DEPENDS</filename></ulink> |
| 2378 | value, in terms of other recipes that satisfy those |
| 2379 | dependencies. |
| 2380 | You can often find build-time or runtime |
| 2381 | dependencies described in the software's documentation. |
| 2382 | </para> |
| 2383 | |
| 2384 | <para> |
| 2385 | The following list provides configuration items of note based |
| 2386 | on how your software is built: |
| 2387 | <itemizedlist> |
| 2388 | <listitem><para><emphasis>Autotools:</emphasis> |
| 2389 | If your source files have a |
| 2390 | <filename>configure.ac</filename> file, then your |
| 2391 | software is built using Autotools. |
| 2392 | If this is the case, you just need to worry about |
| 2393 | modifying the configuration.</para> |
| 2394 | <para>When using Autotools, your recipe needs to inherit |
| 2395 | the |
| 2396 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-autotools'><filename>autotools</filename></ulink> |
| 2397 | class and your recipe does not have to contain a |
| 2398 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-configure'><filename>do_configure</filename></ulink> |
| 2399 | task. |
| 2400 | However, you might still want to make some adjustments. |
| 2401 | For example, you can set |
| 2402 | <ulink url='&YOCTO_DOCS_REF_URL;#var-EXTRA_OECONF'><filename>EXTRA_OECONF</filename></ulink> |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame^] | 2403 | or |
| 2404 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGECONFIG_CONFARGS'><filename>PACKAGECONFIG_CONFARGS</filename></ulink> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 2405 | to pass any needed configure options that are specific |
| 2406 | to the recipe.</para></listitem> |
| 2407 | <listitem><para><emphasis>CMake:</emphasis> |
| 2408 | If your source files have a |
| 2409 | <filename>CMakeLists.txt</filename> file, then your |
| 2410 | software is built using CMake. |
| 2411 | If this is the case, you just need to worry about |
| 2412 | modifying the configuration.</para> |
| 2413 | <para>When you use CMake, your recipe needs to inherit |
| 2414 | the |
| 2415 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-cmake'><filename>cmake</filename></ulink> |
| 2416 | class and your recipe does not have to contain a |
| 2417 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-configure'><filename>do_configure</filename></ulink> |
| 2418 | task. |
| 2419 | You can make some adjustments by setting |
| 2420 | <ulink url='&YOCTO_DOCS_REF_URL;#var-EXTRA_OECMAKE'><filename>EXTRA_OECMAKE</filename></ulink> |
| 2421 | to pass any needed configure options that are specific |
| 2422 | to the recipe.</para></listitem> |
| 2423 | <listitem><para><emphasis>Other:</emphasis> |
| 2424 | If your source files do not have a |
| 2425 | <filename>configure.ac</filename> or |
| 2426 | <filename>CMakeLists.txt</filename> file, then your |
| 2427 | software is built using some method other than Autotools |
| 2428 | or CMake. |
| 2429 | If this is the case, you normally need to provide a |
| 2430 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-configure'><filename>do_configure</filename></ulink> |
| 2431 | task in your recipe |
| 2432 | unless, of course, there is nothing to configure. |
| 2433 | </para> |
| 2434 | <para>Even if your software is not being built by |
| 2435 | Autotools or CMake, you still might not need to deal |
| 2436 | with any configuration issues. |
| 2437 | You need to determine if configuration is even a required step. |
| 2438 | You might need to modify a Makefile or some configuration file |
| 2439 | used for the build to specify necessary build options. |
| 2440 | Or, perhaps you might need to run a provided, custom |
| 2441 | configure script with the appropriate options.</para> |
| 2442 | <para>For the case involving a custom configure |
| 2443 | script, you would run |
| 2444 | <filename>./configure --help</filename> and look for |
| 2445 | the options you need to set.</para></listitem> |
| 2446 | </itemizedlist> |
| 2447 | </para> |
| 2448 | |
| 2449 | <para> |
| 2450 | Once configuration succeeds, it is always good practice to |
| 2451 | look at the <filename>log.do_configure</filename> file to |
| 2452 | ensure that the appropriate options have been enabled and no |
| 2453 | additional build-time dependencies need to be added to |
| 2454 | <filename>DEPENDS</filename>. |
| 2455 | For example, if the configure script reports that it found |
| 2456 | something not mentioned in <filename>DEPENDS</filename>, or |
| 2457 | that it did not find something that it needed for some |
| 2458 | desired optional functionality, then you would need to add |
| 2459 | those to <filename>DEPENDS</filename>. |
| 2460 | Looking at the log might also reveal items being checked for, |
| 2461 | enabled, or both that you do not want, or items not being found |
| 2462 | that are in <filename>DEPENDS</filename>, in which case |
| 2463 | you would need to look at passing extra options to the |
| 2464 | configure script as needed. |
| 2465 | For reference information on configure options specific to the |
| 2466 | software you are building, you can consult the output of the |
| 2467 | <filename>./configure --help</filename> command within |
| 2468 | <filename>${S}</filename> or consult the software's upstream |
| 2469 | documentation. |
| 2470 | </para> |
| 2471 | </section> |
| 2472 | |
| 2473 | <section id='new-recipe-compilation'> |
| 2474 | <title>Compilation</title> |
| 2475 | |
| 2476 | <para> |
| 2477 | During a build, the <filename>do_compile</filename> task |
| 2478 | happens after source is fetched, unpacked, and configured. |
| 2479 | If the recipe passes through <filename>do_compile</filename> |
| 2480 | successfully, nothing needs to be done. |
| 2481 | </para> |
| 2482 | |
| 2483 | <para> |
| 2484 | However, if the compile step fails, you need to diagnose the |
| 2485 | failure. |
Patrick Williams | f1e5d69 | 2016-03-30 15:21:19 -0500 | [diff] [blame] | 2486 | Here are some common issues that cause failures. |
| 2487 | <note> |
| 2488 | For cases where improper paths are detected for |
| 2489 | configuration files or for when libraries/headers cannot |
| 2490 | be found, be sure you are using the more robust |
| 2491 | <filename>pkg-config</filename>. |
| 2492 | See the note in section |
| 2493 | "<link linkend='new-recipe-configuring-the-recipe'>Configuring the Recipe</link>" |
| 2494 | for additional information. |
| 2495 | </note> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 2496 | <itemizedlist> |
| 2497 | <listitem><para><emphasis>Parallel build failures:</emphasis> |
| 2498 | These failures manifest themselves as intermittent |
| 2499 | errors, or errors reporting that a file or directory |
| 2500 | that should be created by some other part of the build |
| 2501 | process could not be found. |
| 2502 | This type of failure can occur even if, upon inspection, |
| 2503 | the file or directory does exist after the build has |
| 2504 | failed, because that part of the build process happened |
| 2505 | in the wrong order.</para> |
| 2506 | <para>To fix the problem, you need to either satisfy |
| 2507 | the missing dependency in the Makefile or whatever |
| 2508 | script produced the Makefile, or (as a workaround) |
| 2509 | set |
| 2510 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PARALLEL_MAKE'><filename>PARALLEL_MAKE</filename></ulink> |
| 2511 | to an empty string: |
| 2512 | <literallayout class='monospaced'> |
| 2513 | PARALLEL_MAKE = "" |
| 2514 | </literallayout></para> |
| 2515 | <para> |
| 2516 | For information on parallel Makefile issues, see the |
| 2517 | "<link linkend='debugging-parallel-make-races'>Debugging Parallel Make Races</link>" |
| 2518 | section. |
| 2519 | </para></listitem> |
| 2520 | <listitem><para><emphasis>Improper host path usage:</emphasis> |
| 2521 | This failure applies to recipes building for the target |
| 2522 | or <filename>nativesdk</filename> only. |
| 2523 | The failure occurs when the compilation process uses |
| 2524 | improper headers, libraries, or other files from the |
| 2525 | host system when cross-compiling for the target. |
| 2526 | </para> |
| 2527 | <para>To fix the problem, examine the |
| 2528 | <filename>log.do_compile</filename> file to identify |
| 2529 | the host paths being used (e.g. |
| 2530 | <filename>/usr/include</filename>, |
| 2531 | <filename>/usr/lib</filename>, and so forth) and then |
| 2532 | either add configure options, apply a patch, or do both. |
| 2533 | </para></listitem> |
| 2534 | <listitem><para><emphasis>Failure to find required |
| 2535 | libraries/headers:</emphasis> |
| 2536 | If a build-time dependency is missing because it has |
| 2537 | not been declared in |
| 2538 | <ulink url='&YOCTO_DOCS_REF_URL;#var-DEPENDS'><filename>DEPENDS</filename></ulink>, |
| 2539 | or because the dependency exists but the path used by |
| 2540 | the build process to find the file is incorrect and the |
| 2541 | configure step did not detect it, the compilation |
| 2542 | process could fail. |
| 2543 | For either of these failures, the compilation process |
| 2544 | notes that files could not be found. |
| 2545 | In these cases, you need to go back and add additional |
| 2546 | options to the configure script as well as possibly |
| 2547 | add additional build-time dependencies to |
| 2548 | <filename>DEPENDS</filename>.</para> |
| 2549 | <para>Occasionally, it is necessary to apply a patch |
| 2550 | to the source to ensure the correct paths are used. |
| 2551 | If you need to specify paths to find files staged |
| 2552 | into the sysroot from other recipes, use the variables |
| 2553 | that the OpenEmbedded build system provides |
| 2554 | (e.g. |
| 2555 | <filename>STAGING_BINDIR</filename>, |
| 2556 | <filename>STAGING_INCDIR</filename>, |
| 2557 | <filename>STAGING_DATADIR</filename>, and so forth). |
| 2558 | <!-- |
| 2559 | (e.g. |
| 2560 | <ulink url='&YOCTO_DOCS_REF_URL;#var-STAGING_BINDIR'><filename>STAGING_BINDIR</filename></ulink>, |
| 2561 | <ulink url='&YOCTO_DOCS_REF_URL;#var-STAGING_INCDIR'><filename>STAGING_INCDIR</filename></ulink>, |
| 2562 | <ulink url='&YOCTO_DOCS_REF_URL;#var-STAGING_DATADIR'><filename>STAGING_DATADIR</filename></ulink>, |
| 2563 | and so forth). |
| 2564 | --> |
| 2565 | </para></listitem> |
| 2566 | </itemizedlist> |
| 2567 | </para> |
| 2568 | </section> |
| 2569 | |
| 2570 | <section id='new-recipe-installing'> |
| 2571 | <title>Installing</title> |
| 2572 | |
| 2573 | <para> |
| 2574 | During <filename>do_install</filename>, the task copies the |
| 2575 | built files along with their hierarchy to locations that |
| 2576 | would mirror their locations on the target device. |
| 2577 | The installation process copies files from the |
| 2578 | <filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-S'><filename>S</filename></ulink><filename>}</filename>, |
| 2579 | <filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-B'><filename>B</filename></ulink><filename>}</filename>, |
| 2580 | and |
| 2581 | <filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-WORKDIR'><filename>WORKDIR</filename></ulink><filename>}</filename> |
| 2582 | directories to the |
| 2583 | <filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-D'><filename>D</filename></ulink><filename>}</filename> |
| 2584 | directory to create the structure as it should appear on the |
| 2585 | target system. |
| 2586 | </para> |
| 2587 | |
| 2588 | <para> |
| 2589 | How your software is built affects what you must do to be |
| 2590 | sure your software is installed correctly. |
| 2591 | The following list describes what you must do for installation |
| 2592 | depending on the type of build system used by the software |
| 2593 | being built: |
| 2594 | <itemizedlist> |
| 2595 | <listitem><para><emphasis>Autotools and CMake:</emphasis> |
| 2596 | If the software your recipe is building uses Autotools |
| 2597 | or CMake, the OpenEmbedded build |
| 2598 | system understands how to install the software. |
| 2599 | Consequently, you do not have to have a |
| 2600 | <filename>do_install</filename> task as part of your |
| 2601 | recipe. |
| 2602 | You just need to make sure the install portion of the |
| 2603 | build completes with no issues. |
| 2604 | However, if you wish to install additional files not |
| 2605 | already being installed by |
| 2606 | <filename>make install</filename>, you should do this |
| 2607 | using a <filename>do_install_append</filename> function |
| 2608 | using the install command as described in |
| 2609 | the "Manual" bulleted item later in this list. |
| 2610 | </para></listitem> |
| 2611 | <listitem><para><emphasis>Other (using |
| 2612 | <filename>make install</filename>):</emphasis> |
| 2613 | You need to define a |
| 2614 | <filename>do_install</filename> function in your |
| 2615 | recipe. |
| 2616 | The function should call |
| 2617 | <filename>oe_runmake install</filename> and will likely |
| 2618 | need to pass in the destination directory as well. |
| 2619 | How you pass that path is dependent on how the |
| 2620 | <filename>Makefile</filename> being run is written |
| 2621 | (e.g. <filename>DESTDIR=${D}</filename>, |
| 2622 | <filename>PREFIX=${D}</filename>, |
| 2623 | <filename>INSTALLROOT=${D}</filename>, and so forth). |
| 2624 | </para> |
| 2625 | <para>For an example recipe using |
| 2626 | <filename>make install</filename>, see the |
| 2627 | "<link linkend='new-recipe-makefile-based-package'>Makefile-Based Package</link>" |
| 2628 | section.</para></listitem> |
| 2629 | <listitem><para><emphasis>Manual:</emphasis> |
| 2630 | You need to define a |
| 2631 | <filename>do_install</filename> function in your |
| 2632 | recipe. |
| 2633 | The function must first use |
| 2634 | <filename>install -d</filename> to create the |
| 2635 | directories under |
| 2636 | <filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-D'><filename>D</filename></ulink><filename>}</filename>. |
| 2637 | Once the directories exist, your function can use |
| 2638 | <filename>install</filename> to manually install the |
| 2639 | built software into the directories.</para> |
| 2640 | <para>You can find more information on |
| 2641 | <filename>install</filename> at |
| 2642 | <ulink url='http://www.gnu.org/software/coreutils/manual/html_node/install-invocation.html'></ulink>. |
| 2643 | </para></listitem> |
| 2644 | </itemizedlist> |
| 2645 | </para> |
| 2646 | |
| 2647 | <para> |
| 2648 | For the scenarios that do not use Autotools or |
| 2649 | CMake, you need to track the installation |
| 2650 | and diagnose and fix any issues until everything installs |
| 2651 | correctly. |
| 2652 | You need to look in the default location of |
| 2653 | <filename>${D}</filename>, which is |
| 2654 | <filename>${WORKDIR}/image</filename>, to be sure your |
| 2655 | files have been installed correctly. |
| 2656 | </para> |
| 2657 | |
| 2658 | <note><title>Notes</title> |
| 2659 | <itemizedlist> |
| 2660 | <listitem><para> |
| 2661 | During the installation process, you might need to |
| 2662 | modify some of the installed files to suit the target |
| 2663 | layout. |
| 2664 | For example, you might need to replace hard-coded paths |
| 2665 | in an initscript with values of variables provided by |
| 2666 | the build system, such as replacing |
| 2667 | <filename>/usr/bin/</filename> with |
| 2668 | <filename>${bindir}</filename>. |
| 2669 | If you do perform such modifications during |
| 2670 | <filename>do_install</filename>, be sure to modify the |
| 2671 | destination file after copying rather than before |
| 2672 | copying. |
| 2673 | Modifying after copying ensures that the build system |
| 2674 | can re-execute <filename>do_install</filename> if |
| 2675 | needed. |
| 2676 | </para></listitem> |
| 2677 | <listitem><para> |
| 2678 | <filename>oe_runmake install</filename>, which can be |
| 2679 | run directly or can be run indirectly by the |
| 2680 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-autotools'><filename>autotools</filename></ulink> |
| 2681 | and |
| 2682 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-cmake'><filename>cmake</filename></ulink> |
| 2683 | classes, runs <filename>make install</filename> in |
| 2684 | parallel. |
| 2685 | Sometimes, a Makefile can have missing dependencies |
| 2686 | between targets that can result in race conditions. |
| 2687 | If you experience intermittent failures during |
| 2688 | <filename>do_install</filename>, you might be able to |
| 2689 | work around them by disabling parallel Makefile |
| 2690 | installs by adding the following to the recipe: |
| 2691 | <literallayout class='monospaced'> |
| 2692 | PARALLEL_MAKEINST = "" |
| 2693 | </literallayout> |
| 2694 | See |
| 2695 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PARALLEL_MAKEINST'><filename>PARALLEL_MAKEINST</filename></ulink> |
| 2696 | for additional information. |
| 2697 | </para></listitem> |
| 2698 | </itemizedlist> |
| 2699 | </note> |
| 2700 | </section> |
| 2701 | |
| 2702 | <section id='new-recipe-enabling-system-services'> |
| 2703 | <title>Enabling System Services</title> |
| 2704 | |
| 2705 | <para> |
| 2706 | If you want to install a service, which is a process that |
| 2707 | usually starts on boot and runs in the background, then |
| 2708 | you must include some additional definitions in your recipe. |
| 2709 | </para> |
| 2710 | |
| 2711 | <para> |
| 2712 | If you are adding services and the service initialization |
| 2713 | script or the service file itself is not installed, you must |
| 2714 | provide for that installation in your recipe using a |
| 2715 | <filename>do_install_append</filename> function. |
| 2716 | If your recipe already has a <filename>do_install</filename> |
| 2717 | function, update the function near its end rather than |
| 2718 | adding an additional <filename>do_install_append</filename> |
| 2719 | function. |
| 2720 | </para> |
| 2721 | |
| 2722 | <para> |
| 2723 | When you create the installation for your services, you need |
| 2724 | to accomplish what is normally done by |
| 2725 | <filename>make install</filename>. |
| 2726 | In other words, make sure your installation arranges the output |
| 2727 | similar to how it is arranged on the target system. |
| 2728 | </para> |
| 2729 | |
| 2730 | <para> |
| 2731 | The OpenEmbedded build system provides support for starting |
| 2732 | services two different ways: |
| 2733 | <itemizedlist> |
| 2734 | <listitem><para><emphasis>SysVinit:</emphasis> |
| 2735 | SysVinit is a system and service manager that |
| 2736 | manages the init system used to control the very basic |
| 2737 | functions of your system. |
| 2738 | The init program is the first program |
| 2739 | started by the Linux kernel when the system boots. |
| 2740 | Init then controls the startup, running and shutdown |
| 2741 | of all other programs.</para> |
| 2742 | <para>To enable a service using SysVinit, your recipe |
| 2743 | needs to inherit the |
| 2744 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-update-rc.d'><filename>update-rc.d</filename></ulink> |
| 2745 | class. |
| 2746 | The class helps facilitate safely installing the |
| 2747 | package on the target.</para> |
| 2748 | <para>You will need to set the |
| 2749 | <ulink url='&YOCTO_DOCS_REF_URL;#var-INITSCRIPT_PACKAGES'><filename>INITSCRIPT_PACKAGES</filename></ulink>, |
| 2750 | <ulink url='&YOCTO_DOCS_REF_URL;#var-INITSCRIPT_NAME'><filename>INITSCRIPT_NAME</filename></ulink>, |
| 2751 | and |
| 2752 | <ulink url='&YOCTO_DOCS_REF_URL;#var-INITSCRIPT_PARAMS'><filename>INITSCRIPT_PARAMS</filename></ulink> |
| 2753 | variables within your recipe.</para></listitem> |
| 2754 | <listitem><para><emphasis>systemd:</emphasis> |
| 2755 | System Management Daemon (systemd) was designed to |
| 2756 | replace SysVinit and to provide |
| 2757 | enhanced management of services. |
| 2758 | For more information on systemd, see the systemd |
| 2759 | homepage at |
| 2760 | <ulink url='http://freedesktop.org/wiki/Software/systemd/'></ulink>. |
| 2761 | </para> |
| 2762 | <para>To enable a service using systemd, your recipe |
| 2763 | needs to inherit the |
| 2764 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-systemd'><filename>systemd</filename></ulink> |
| 2765 | class. |
| 2766 | See the <filename>systemd.bbclass</filename> file |
| 2767 | located in your |
| 2768 | <link linkend='source-directory'>Source Directory</link>. |
| 2769 | section for more information. |
| 2770 | </para></listitem> |
| 2771 | </itemizedlist> |
| 2772 | </para> |
| 2773 | </section> |
| 2774 | |
| 2775 | <section id='new-recipe-packaging'> |
| 2776 | <title>Packaging</title> |
| 2777 | |
| 2778 | <para> |
| 2779 | Successful packaging is a combination of automated processes |
| 2780 | performed by the OpenEmbedded build system and some |
| 2781 | specific steps you need to take. |
| 2782 | The following list describes the process: |
| 2783 | <itemizedlist> |
| 2784 | <listitem><para><emphasis>Splitting Files</emphasis>: |
| 2785 | The <filename>do_package</filename> task splits the |
| 2786 | files produced by the recipe into logical components. |
| 2787 | Even software that produces a single binary might |
| 2788 | still have debug symbols, documentation, and other |
| 2789 | logical components that should be split out. |
| 2790 | The <filename>do_package</filename> task ensures |
| 2791 | that files are split up and packaged correctly. |
| 2792 | </para></listitem> |
| 2793 | <listitem><para><emphasis>Running QA Checks</emphasis>: |
| 2794 | The |
| 2795 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-insane'><filename>insane</filename></ulink> |
| 2796 | class adds a step to |
| 2797 | the package generation process so that output quality |
| 2798 | assurance checks are generated by the OpenEmbedded |
| 2799 | build system. |
| 2800 | This step performs a range of checks to be sure the |
| 2801 | build's output is free of common problems that show |
| 2802 | up during runtime. |
| 2803 | For information on these checks, see the |
| 2804 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-insane'><filename>insane</filename></ulink> |
| 2805 | class and the |
| 2806 | "<ulink url='&YOCTO_DOCS_REF_URL;#ref-qa-checks'>QA Error and Warning Messages</ulink>" |
| 2807 | chapter in the Yocto Project Reference Manual. |
| 2808 | </para></listitem> |
| 2809 | <listitem><para><emphasis>Hand-Checking Your Packages</emphasis>: |
| 2810 | After you build your software, you need to be sure |
| 2811 | your packages are correct. |
| 2812 | Examine the |
| 2813 | <filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-WORKDIR'><filename>WORKDIR</filename></ulink><filename>}/packages-split</filename> |
| 2814 | directory and make sure files are where you expect |
| 2815 | them to be. |
| 2816 | If you discover problems, you can set |
| 2817 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGES'><filename>PACKAGES</filename></ulink>, |
| 2818 | <ulink url='&YOCTO_DOCS_REF_URL;#var-FILES'><filename>FILES</filename></ulink>, |
| 2819 | <filename>do_install(_append)</filename>, and so forth as |
| 2820 | needed. |
| 2821 | </para></listitem> |
| 2822 | <listitem><para><emphasis>Splitting an Application into Multiple Packages</emphasis>: |
| 2823 | If you need to split an application into several |
| 2824 | packages, see the |
| 2825 | "<link linkend='splitting-an-application-into-multiple-packages'>Splitting an Application into Multiple Packages</link>" |
| 2826 | section for an example. |
| 2827 | </para></listitem> |
| 2828 | <listitem><para><emphasis>Installing a Post-Installation Script</emphasis>: |
| 2829 | For an example showing how to install a |
| 2830 | post-installation script, see the |
| 2831 | "<link linkend='new-recipe-post-installation-scripts'>Post-Installation Scripts</link>" |
| 2832 | section. |
| 2833 | </para></listitem> |
| 2834 | <listitem><para><emphasis>Marking Package Architecture</emphasis>: |
| 2835 | Depending on what your recipe is building and how it |
| 2836 | is configured, it might be important to mark the |
| 2837 | packages produced as being specific to a particular |
| 2838 | machine, or to mark them as not being specific to |
Patrick Williams | f1e5d69 | 2016-03-30 15:21:19 -0500 | [diff] [blame] | 2839 | a particular machine or architecture at all.</para> |
| 2840 | <para>By default, packages apply to any machine with the |
| 2841 | same architecture as the target machine. |
| 2842 | When a recipe produces packages that are |
| 2843 | machine-specific (e.g. the |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 2844 | <ulink url='&YOCTO_DOCS_REF_URL;#var-MACHINE'><filename>MACHINE</filename></ulink> |
| 2845 | value is passed into the configure script or a patch |
Patrick Williams | f1e5d69 | 2016-03-30 15:21:19 -0500 | [diff] [blame] | 2846 | is applied only for a particular machine), you should |
| 2847 | mark them as such by adding the following to the |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 2848 | recipe: |
| 2849 | <literallayout class='monospaced'> |
| 2850 | PACKAGE_ARCH = "${MACHINE_ARCH}" |
Patrick Williams | f1e5d69 | 2016-03-30 15:21:19 -0500 | [diff] [blame] | 2851 | </literallayout></para> |
| 2852 | <para>On the other hand, if the recipe produces packages |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 2853 | that do not contain anything specific to the target |
| 2854 | machine or architecture at all (e.g. recipes |
| 2855 | that simply package script files or configuration |
| 2856 | files), you should use the |
| 2857 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-allarch'><filename>allarch</filename></ulink> |
| 2858 | class to do this for you by adding this to your |
| 2859 | recipe: |
| 2860 | <literallayout class='monospaced'> |
| 2861 | inherit allarch |
| 2862 | </literallayout> |
| 2863 | Ensuring that the package architecture is correct is |
| 2864 | not critical while you are doing the first few builds |
| 2865 | of your recipe. |
| 2866 | However, it is important in order |
| 2867 | to ensure that your recipe rebuilds (or does not |
| 2868 | rebuild) appropriately in response to changes in |
| 2869 | configuration, and to ensure that you get the |
| 2870 | appropriate packages installed on the target machine, |
| 2871 | particularly if you run separate builds for more |
| 2872 | than one target machine. |
| 2873 | </para></listitem> |
| 2874 | </itemizedlist> |
| 2875 | </para> |
| 2876 | </section> |
| 2877 | |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame^] | 2878 | <section id='new-sharing-files-between-recipes'> |
| 2879 | <title>Sharing Files Between Recipes</title> |
| 2880 | |
| 2881 | <para> |
| 2882 | Recipes often need to use files provided by other recipes on |
| 2883 | the build host. |
| 2884 | For example, an application linking to a common library needs |
| 2885 | access to the library itself and its associated headers. |
| 2886 | The way this access is accomplished is by populating sysroot |
| 2887 | with files. |
| 2888 | One sysroot exists per "machine" for which the image is |
| 2889 | being built. |
| 2890 | In practical terms, this means a sysroot exists for the target |
| 2891 | machine, and a sysroot exists for the build host. |
| 2892 | <note> |
| 2893 | You could find the term "staging" used within the Yocto |
| 2894 | project regarding files populating sysroot. |
| 2895 | The term "staging" was used for previous releases of |
| 2896 | the Yocto Project. |
| 2897 | </note> |
| 2898 | </para> |
| 2899 | |
| 2900 | <para> |
| 2901 | Recipes should never populate the sysroot directly (i.e. write |
| 2902 | files into sysroot). |
| 2903 | Instead, files should be installed into standard locations |
| 2904 | during the |
| 2905 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-install'><filename>do_install</filename></ulink> |
| 2906 | task within the |
| 2907 | <filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-D'><filename>D</filename></ulink><filename>}</filename> |
| 2908 | directory. |
| 2909 | A subset of these files automatically populates the sysroot. |
| 2910 | The reason for this limitation is that almost all files that |
| 2911 | populate the sysroot are cataloged in manifests in order to |
| 2912 | ensure the files can be removed later when a recipe is either |
| 2913 | modified or removed. |
| 2914 | Thus, the sysroot is able to remain free from stale files. |
| 2915 | </para> |
| 2916 | |
| 2917 | <para> |
| 2918 | For information on variables you can use to help control how |
| 2919 | files sysroot is populated, see the |
| 2920 | <ulink url='&YOCTO_DOCS_REF_URL;#var-SYSROOT_DIRS'><filename>SYSROOT_DIRS</filename></ulink>, |
| 2921 | <ulink url='&YOCTO_DOCS_REF_URL;#var-SYSROOT_DIRS_NATIVE'><filename>SYSROOT_DIRS_NATIVE</filename></ulink>, |
| 2922 | and |
| 2923 | <ulink url='&YOCTO_DOCS_REF_URL;#var-SYSROOT_DIRS_BLACKLIST'><filename>SYSROOT_DIRS_BLACKLIST</filename></ulink> |
| 2924 | variables. |
| 2925 | </para> |
| 2926 | </section> |
| 2927 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 2928 | <section id='properly-versioning-pre-release-recipes'> |
| 2929 | <title>Properly Versioning Pre-Release Recipes</title> |
| 2930 | |
| 2931 | <para> |
| 2932 | Sometimes the name of a recipe can lead to versioning |
| 2933 | problems when the recipe is upgraded to a final release. |
| 2934 | For example, consider the |
| 2935 | <filename>irssi_0.8.16-rc1.bb</filename> recipe file in |
| 2936 | the list of example recipes in the |
| 2937 | "<link linkend='new-recipe-storing-and-naming-the-recipe'>Storing and Naming the Recipe</link>" |
| 2938 | section. |
| 2939 | This recipe is at a release candidate stage (i.e. |
| 2940 | "rc1"). |
| 2941 | When the recipe is released, the recipe filename becomes |
| 2942 | <filename>irssi_0.8.16.bb</filename>. |
| 2943 | The version change from <filename>0.8.16-rc1</filename> |
| 2944 | to <filename>0.8.16</filename> is seen as a decrease by the |
| 2945 | build system and package managers, so the resulting packages |
| 2946 | will not correctly trigger an upgrade. |
| 2947 | </para> |
| 2948 | |
| 2949 | <para> |
| 2950 | In order to ensure the versions compare properly, the |
| 2951 | recommended convention is to set |
| 2952 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PV'><filename>PV</filename></ulink> |
| 2953 | within the recipe to |
| 2954 | "<replaceable>previous_version</replaceable>+<replaceable>current_version</replaceable>". |
| 2955 | You can use an additional variable so that you can use the |
| 2956 | current version elsewhere. |
| 2957 | Here is an example: |
| 2958 | <literallayout class='monospaced'> |
| 2959 | REALPV = "0.8.16-rc1" |
| 2960 | PV = "0.8.15+${REALPV}" |
| 2961 | </literallayout> |
| 2962 | </para> |
| 2963 | </section> |
| 2964 | |
| 2965 | <section id='new-recipe-post-installation-scripts'> |
| 2966 | <title>Post-Installation Scripts</title> |
| 2967 | |
| 2968 | <para> |
| 2969 | Post-installation scripts run immediately after installing |
| 2970 | a package on the target or during image creation when a |
| 2971 | package is included in an image. |
| 2972 | To add a post-installation script to a package, add a |
| 2973 | <filename>pkg_postinst_PACKAGENAME()</filename> function to |
| 2974 | the recipe file (<filename>.bb</filename>) and replace |
| 2975 | <filename>PACKAGENAME</filename> with the name of the package |
| 2976 | you want to attach to the <filename>postinst</filename> |
| 2977 | script. |
| 2978 | To apply the post-installation script to the main package |
| 2979 | for the recipe, which is usually what is required, specify |
| 2980 | <filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-PN'><filename>PN</filename></ulink><filename>}</filename> |
| 2981 | in place of <filename>PACKAGENAME</filename>. |
| 2982 | </para> |
| 2983 | |
| 2984 | <para> |
| 2985 | A post-installation function has the following structure: |
| 2986 | <literallayout class='monospaced'> |
| 2987 | pkg_postinst_PACKAGENAME() { |
| 2988 | # Commands to carry out |
| 2989 | } |
| 2990 | </literallayout> |
| 2991 | </para> |
| 2992 | |
| 2993 | <para> |
| 2994 | The script defined in the post-installation function is |
| 2995 | called when the root filesystem is created. |
| 2996 | If the script succeeds, the package is marked as installed. |
| 2997 | If the script fails, the package is marked as unpacked and |
| 2998 | the script is executed when the image boots again. |
| 2999 | </para> |
| 3000 | |
| 3001 | <para> |
| 3002 | Sometimes it is necessary for the execution of a |
| 3003 | post-installation script to be delayed until the first boot. |
| 3004 | For example, the script might need to be executed on the |
| 3005 | device itself. |
| 3006 | To delay script execution until boot time, use the following |
| 3007 | structure in the post-installation script: |
| 3008 | <literallayout class='monospaced'> |
| 3009 | pkg_postinst_PACKAGENAME() { |
| 3010 | if [ x"$D" = "x" ]; then |
| 3011 | # Actions to carry out on the device go here |
| 3012 | else |
| 3013 | exit 1 |
| 3014 | fi |
| 3015 | } |
| 3016 | </literallayout> |
| 3017 | </para> |
| 3018 | |
| 3019 | <para> |
| 3020 | The previous example delays execution until the image boots |
| 3021 | again because the environment variable <filename>D</filename> |
| 3022 | points to the directory containing the image when |
| 3023 | the root filesystem is created at build time but is unset |
| 3024 | when executed on the first boot. |
| 3025 | </para> |
| 3026 | |
| 3027 | <note> |
| 3028 | Equivalent support for pre-install, pre-uninstall, and |
| 3029 | post-uninstall scripts exist by way of |
| 3030 | <filename>pkg_preinst</filename>, |
| 3031 | <filename>pkg_prerm</filename>, and |
| 3032 | <filename>pkg_postrm</filename>, respectively. |
| 3033 | These scrips work in exactly the same way as does |
| 3034 | <filename>pkg_postinst</filename> with the exception that they |
| 3035 | run at different times. |
| 3036 | Also, because of when they run, they are not applicable to |
| 3037 | being run at image creation time like |
| 3038 | <filename>pkg_postinst</filename>. |
| 3039 | </note> |
| 3040 | </section> |
| 3041 | |
| 3042 | <section id='new-recipe-testing'> |
| 3043 | <title>Testing</title> |
| 3044 | |
| 3045 | <para> |
| 3046 | The final step for completing your recipe is to be sure that |
| 3047 | the software you built runs correctly. |
| 3048 | To accomplish runtime testing, add the build's output |
| 3049 | packages to your image and test them on the target. |
| 3050 | </para> |
| 3051 | |
| 3052 | <para> |
| 3053 | For information on how to customize your image by adding |
| 3054 | specific packages, see the |
| 3055 | "<link linkend='usingpoky-extend-customimage'>Customizing Images</link>" |
| 3056 | section. |
| 3057 | </para> |
| 3058 | </section> |
| 3059 | |
| 3060 | <section id='new-recipe-testing-examples'> |
| 3061 | <title>Examples</title> |
| 3062 | |
| 3063 | <para> |
| 3064 | To help summarize how to write a recipe, this section provides |
| 3065 | some examples given various scenarios: |
| 3066 | <itemizedlist> |
| 3067 | <listitem><para>Recipes that use local files</para></listitem> |
| 3068 | <listitem><para>Using an Autotooled package</para></listitem> |
| 3069 | <listitem><para>Using a Makefile-based package</para></listitem> |
| 3070 | <listitem><para>Splitting an application into multiple packages</para></listitem> |
| 3071 | <listitem><para>Adding binaries to an image</para></listitem> |
| 3072 | </itemizedlist> |
| 3073 | </para> |
| 3074 | |
| 3075 | <section id='new-recipe-single-c-file-package-hello-world'> |
| 3076 | <title>Single .c File Package (Hello World!)</title> |
| 3077 | |
| 3078 | <para> |
| 3079 | Building an application from a single file that is stored |
| 3080 | locally (e.g. under <filename>files</filename>) requires |
| 3081 | a recipe that has the file listed in the |
| 3082 | <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'>SRC_URI</ulink></filename> |
| 3083 | variable. |
| 3084 | Additionally, you need to manually write the |
| 3085 | <filename>do_compile</filename> and |
| 3086 | <filename>do_install</filename> tasks. |
| 3087 | The <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-S'>S</ulink></filename> |
| 3088 | variable defines the directory containing the source code, |
| 3089 | which is set to |
| 3090 | <ulink url='&YOCTO_DOCS_REF_URL;#var-WORKDIR'><filename>WORKDIR</filename></ulink> |
| 3091 | in this case - the directory BitBake uses for the build. |
| 3092 | <literallayout class='monospaced'> |
| 3093 | SUMMARY = "Simple helloworld application" |
| 3094 | SECTION = "examples" |
| 3095 | LICENSE = "MIT" |
| 3096 | LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302" |
| 3097 | |
| 3098 | SRC_URI = "file://helloworld.c" |
| 3099 | |
| 3100 | S = "${WORKDIR}" |
| 3101 | |
| 3102 | do_compile() { |
| 3103 | ${CC} helloworld.c -o helloworld |
| 3104 | } |
| 3105 | |
| 3106 | do_install() { |
| 3107 | install -d ${D}${bindir} |
| 3108 | install -m 0755 helloworld ${D}${bindir} |
| 3109 | } |
| 3110 | </literallayout> |
| 3111 | </para> |
| 3112 | |
| 3113 | <para> |
| 3114 | By default, the <filename>helloworld</filename>, |
| 3115 | <filename>helloworld-dbg</filename>, and |
| 3116 | <filename>helloworld-dev</filename> packages are built. |
| 3117 | For information on how to customize the packaging process, |
| 3118 | see the |
| 3119 | "<link linkend='splitting-an-application-into-multiple-packages'>Splitting an Application into Multiple Packages</link>" |
| 3120 | section. |
| 3121 | </para> |
| 3122 | </section> |
| 3123 | |
| 3124 | <section id='new-recipe-autotooled-package'> |
| 3125 | <title>Autotooled Package</title> |
| 3126 | <para> |
| 3127 | Applications that use Autotools such as <filename>autoconf</filename> and |
| 3128 | <filename>automake</filename> require a recipe that has a source archive listed in |
| 3129 | <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'>SRC_URI</ulink></filename> and |
| 3130 | also inherit the |
| 3131 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-autotools'><filename>autotools</filename></ulink> |
| 3132 | class, which contains the definitions of all the steps |
| 3133 | needed to build an Autotool-based application. |
| 3134 | The result of the build is automatically packaged. |
| 3135 | And, if the application uses NLS for localization, packages with local information are |
| 3136 | generated (one package per language). |
| 3137 | Following is one example: (<filename>hello_2.3.bb</filename>) |
| 3138 | <literallayout class='monospaced'> |
| 3139 | SUMMARY = "GNU Helloworld application" |
| 3140 | SECTION = "examples" |
| 3141 | LICENSE = "GPLv2+" |
| 3142 | LIC_FILES_CHKSUM = "file://COPYING;md5=751419260aa954499f7abaabaa882bbe" |
| 3143 | |
| 3144 | SRC_URI = "${GNU_MIRROR}/hello/hello-${PV}.tar.gz" |
| 3145 | |
| 3146 | inherit autotools gettext |
| 3147 | </literallayout> |
| 3148 | </para> |
| 3149 | |
| 3150 | <para> |
| 3151 | The variable |
| 3152 | <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-LIC_FILES_CHKSUM'>LIC_FILES_CHKSUM</ulink></filename> |
| 3153 | is used to track source license changes as described in the |
| 3154 | "<ulink url='&YOCTO_DOCS_REF_URL;#usingpoky-configuring-LIC_FILES_CHKSUM'>Tracking License Changes</ulink>" section. |
| 3155 | You can quickly create Autotool-based recipes in a manner similar to the previous example. |
| 3156 | </para> |
| 3157 | </section> |
| 3158 | |
| 3159 | <section id='new-recipe-makefile-based-package'> |
| 3160 | <title>Makefile-Based Package</title> |
| 3161 | |
| 3162 | <para> |
| 3163 | Applications that use GNU <filename>make</filename> also require a recipe that has |
| 3164 | the source archive listed in |
| 3165 | <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'>SRC_URI</ulink></filename>. |
| 3166 | You do not need to add a <filename>do_compile</filename> step since by default BitBake |
| 3167 | starts the <filename>make</filename> command to compile the application. |
| 3168 | If you need additional <filename>make</filename> options, you should store them in the |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame^] | 3169 | <ulink url='&YOCTO_DOCS_REF_URL;#var-EXTRA_OEMAKE'><filename>EXTRA_OEMAKE</filename></ulink> |
| 3170 | or |
| 3171 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGECONFIG_CONFARGS'><filename>PACKAGECONFIG_CONFARGS</filename></ulink> |
| 3172 | variables. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 3173 | BitBake passes these options into the GNU <filename>make</filename> invocation. |
| 3174 | Note that a <filename>do_install</filename> task is still required. |
| 3175 | Otherwise, BitBake runs an empty <filename>do_install</filename> task by default. |
| 3176 | </para> |
| 3177 | |
| 3178 | <para> |
| 3179 | Some applications might require extra parameters to be passed to the compiler. |
| 3180 | For example, the application might need an additional header path. |
| 3181 | You can accomplish this by adding to the |
| 3182 | <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-CFLAGS'>CFLAGS</ulink></filename> variable. |
| 3183 | The following example shows this: |
| 3184 | <literallayout class='monospaced'> |
| 3185 | CFLAGS_prepend = "-I ${S}/include " |
| 3186 | </literallayout> |
| 3187 | </para> |
| 3188 | |
| 3189 | <para> |
| 3190 | In the following example, <filename>mtd-utils</filename> is a makefile-based package: |
| 3191 | <literallayout class='monospaced'> |
| 3192 | SUMMARY = "Tools for managing memory technology devices" |
| 3193 | SECTION = "base" |
| 3194 | DEPENDS = "zlib lzo e2fsprogs util-linux" |
| 3195 | HOMEPAGE = "http://www.linux-mtd.infradead.org/" |
| 3196 | LICENSE = "GPLv2+" |
| 3197 | LIC_FILES_CHKSUM = "file://COPYING;md5=0636e73ff0215e8d672dc4c32c317bb3 \ |
| 3198 | file://include/common.h;beginline=1;endline=17;md5=ba05b07912a44ea2bf81ce409380049c" |
| 3199 | |
| 3200 | # Use the latest version at 26 Oct, 2013 |
| 3201 | SRCREV = "9f107132a6a073cce37434ca9cda6917dd8d866b" |
| 3202 | SRC_URI = "git://git.infradead.org/mtd-utils.git \ |
| 3203 | file://add-exclusion-to-mkfs-jffs2-git-2.patch \ |
| 3204 | " |
| 3205 | |
| 3206 | PV = "1.5.1+git${SRCPV}" |
| 3207 | |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame^] | 3208 | S = "${WORKDIR}/git" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 3209 | |
| 3210 | EXTRA_OEMAKE = "'CC=${CC}' 'RANLIB=${RANLIB}' 'AR=${AR}' 'CFLAGS=${CFLAGS} -I${S}/include -DWITHOUT_XATTR' 'BUILDDIR=${S}'" |
| 3211 | |
| 3212 | do_install () { |
| 3213 | oe_runmake install DESTDIR=${D} SBINDIR=${sbindir} MANDIR=${mandir} INCLUDEDIR=${includedir} |
| 3214 | } |
| 3215 | |
| 3216 | PACKAGES =+ "mtd-utils-jffs2 mtd-utils-ubifs mtd-utils-misc" |
| 3217 | |
| 3218 | FILES_mtd-utils-jffs2 = "${sbindir}/mkfs.jffs2 ${sbindir}/jffs2dump ${sbindir}/jffs2reader ${sbindir}/sumtool" |
| 3219 | FILES_mtd-utils-ubifs = "${sbindir}/mkfs.ubifs ${sbindir}/ubi*" |
| 3220 | FILES_mtd-utils-misc = "${sbindir}/nftl* ${sbindir}/ftl* ${sbindir}/rfd* ${sbindir}/doc* ${sbindir}/serve_image ${sbindir}/recv_image" |
| 3221 | |
| 3222 | PARALLEL_MAKE = "" |
| 3223 | |
| 3224 | BBCLASSEXTEND = "native" |
| 3225 | </literallayout> |
| 3226 | </para> |
| 3227 | </section> |
| 3228 | |
| 3229 | <section id='splitting-an-application-into-multiple-packages'> |
| 3230 | <title>Splitting an Application into Multiple Packages</title> |
| 3231 | |
| 3232 | <para> |
| 3233 | You can use the variables |
| 3234 | <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGES'>PACKAGES</ulink></filename> and |
| 3235 | <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-FILES'>FILES</ulink></filename> |
| 3236 | to split an application into multiple packages. |
| 3237 | </para> |
| 3238 | |
| 3239 | <para> |
| 3240 | Following is an example that uses the <filename>libxpm</filename> recipe. |
| 3241 | By default, this recipe generates a single package that contains the library along |
| 3242 | with a few binaries. |
| 3243 | You can modify the recipe to split the binaries into separate packages: |
| 3244 | <literallayout class='monospaced'> |
| 3245 | require xorg-lib-common.inc |
| 3246 | |
| 3247 | SUMMARY = "Xpm: X Pixmap extension library" |
| 3248 | LICENSE = "BSD" |
| 3249 | LIC_FILES_CHKSUM = "file://COPYING;md5=51f4270b012ecd4ab1a164f5f4ed6cf7" |
| 3250 | DEPENDS += "libxext libsm libxt" |
| 3251 | PE = "1" |
| 3252 | |
| 3253 | XORG_PN = "libXpm" |
| 3254 | |
| 3255 | PACKAGES =+ "sxpm cxpm" |
| 3256 | FILES_cxpm = "${bindir}/cxpm" |
| 3257 | FILES_sxpm = "${bindir}/sxpm" |
| 3258 | </literallayout> |
| 3259 | </para> |
| 3260 | |
| 3261 | <para> |
| 3262 | In the previous example, we want to ship the <filename>sxpm</filename> |
| 3263 | and <filename>cxpm</filename> binaries in separate packages. |
| 3264 | Since <filename>bindir</filename> would be packaged into the main |
| 3265 | <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-PN'>PN</ulink></filename> |
| 3266 | package by default, we prepend the <filename>PACKAGES</filename> |
| 3267 | variable so additional package names are added to the start of list. |
| 3268 | This results in the extra <filename>FILES_*</filename> |
| 3269 | variables then containing information that define which files and |
| 3270 | directories go into which packages. |
| 3271 | Files included by earlier packages are skipped by latter packages. |
| 3272 | Thus, the main <filename>PN</filename> package |
| 3273 | does not include the above listed files. |
| 3274 | </para> |
| 3275 | </section> |
| 3276 | |
| 3277 | <section id='packaging-externally-produced-binaries'> |
| 3278 | <title>Packaging Externally Produced Binaries</title> |
| 3279 | |
| 3280 | <para> |
| 3281 | Sometimes, you need to add pre-compiled binaries to an |
| 3282 | image. |
| 3283 | For example, suppose that binaries for proprietary code |
| 3284 | exist, which are created by a particular division of a |
| 3285 | company. |
| 3286 | Your part of the company needs to use those binaries as |
| 3287 | part of an image that you are building using the |
| 3288 | OpenEmbedded build system. |
| 3289 | Since you only have the binaries and not the source code, |
| 3290 | you cannot use a typical recipe that expects to fetch the |
| 3291 | source specified in |
| 3292 | <ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'><filename>SRC_URI</filename></ulink> |
| 3293 | and then compile it. |
| 3294 | </para> |
| 3295 | |
| 3296 | <para> |
| 3297 | One method is to package the binaries and then install them |
| 3298 | as part of the image. |
| 3299 | Generally, it is not a good idea to package binaries |
| 3300 | since, among other things, it can hinder the ability to |
| 3301 | reproduce builds and could lead to compatibility problems |
| 3302 | with ABI in the future. |
| 3303 | However, sometimes you have no choice. |
| 3304 | </para> |
| 3305 | |
| 3306 | <para> |
| 3307 | The easiest solution is to create a recipe that uses |
| 3308 | the |
| 3309 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-bin-package'><filename>bin_package</filename></ulink> |
| 3310 | class and to be sure that you are using default locations |
| 3311 | for build artifacts. |
| 3312 | In most cases, the <filename>bin_package</filename> class |
| 3313 | handles "skipping" the configure and compile steps as well |
| 3314 | as sets things up to grab packages from the appropriate |
| 3315 | area. |
| 3316 | In particular, this class sets <filename>noexec</filename> |
| 3317 | on both the |
| 3318 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-configure'><filename>do_configure</filename></ulink> |
| 3319 | and |
| 3320 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-compile'><filename>do_compile</filename></ulink> |
| 3321 | tasks, sets |
| 3322 | <filename>FILES_${PN}</filename> to "/" so that it picks |
| 3323 | up all files, and sets up a |
| 3324 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-install'><filename>do_install</filename></ulink> |
| 3325 | task, which effectively copies all files from |
| 3326 | <filename>${S}</filename> to <filename>${D}</filename>. |
| 3327 | The <filename>bin_package</filename> class works well when |
| 3328 | the files extracted into <filename>${S}</filename> are |
| 3329 | already laid out in the way they should be laid out |
| 3330 | on the target. |
| 3331 | For more information on these variables, see the |
| 3332 | <ulink url='&YOCTO_DOCS_REF_URL;#var-FILES'><filename>FILES</filename></ulink>, |
| 3333 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PN'><filename>PN</filename></ulink>, |
| 3334 | <ulink url='&YOCTO_DOCS_REF_URL;#var-S'><filename>S</filename></ulink>, |
| 3335 | and |
| 3336 | <ulink url='&YOCTO_DOCS_REF_URL;#var-D'><filename>D</filename></ulink> |
| 3337 | variables in the Yocto Project Reference Manual's variable |
| 3338 | glossary. |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame^] | 3339 | <note><title>Notes</title> |
| 3340 | <itemizedlist> |
| 3341 | <listitem><para> |
| 3342 | Using |
| 3343 | <ulink url='&YOCTO_DOCS_REF_URL;#var-DEPENDS'><filename>DEPENDS</filename></ulink> |
| 3344 | is a good idea even for components distributed |
| 3345 | in binary form, and is often necessary for |
| 3346 | shared libraries. |
| 3347 | For a shared library, listing the library |
| 3348 | dependencies in |
| 3349 | <filename>DEPENDS</filename> makes sure that |
| 3350 | the libraries are available in the staging |
| 3351 | sysroot when other recipes link against the |
| 3352 | library, which might be necessary for |
| 3353 | successful linking. |
| 3354 | </para></listitem> |
| 3355 | <listitem><para> |
| 3356 | Using <filename>DEPENDS</filename> also |
| 3357 | allows runtime dependencies between packages |
| 3358 | to be added automatically. |
| 3359 | See the |
| 3360 | "<ulink url='&YOCTO_DOCS_REF_URL;#automatically-added-runtime-dependencies'>Automatically Added Runtime Dependencies</ulink>" |
| 3361 | section in the Yocto Project Reference Manual |
| 3362 | for more information. |
| 3363 | </para></listitem> |
| 3364 | </itemizedlist> |
| 3365 | </note> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 3366 | </para> |
| 3367 | |
| 3368 | <para> |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame^] | 3369 | If you cannot use the <filename>bin_package</filename> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 3370 | class, you need to be sure you are doing the following: |
| 3371 | <itemizedlist> |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame^] | 3372 | <listitem><para> |
| 3373 | Create a recipe where the |
| 3374 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-configure'><filename>do_configure</filename></ulink> |
| 3375 | and |
| 3376 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-compile'><filename>do_compile</filename></ulink> |
| 3377 | tasks do nothing: |
| 3378 | It is usually sufficient to just not define these |
| 3379 | tasks in the recipe, because the default |
| 3380 | implementations do nothing unless a Makefile is |
| 3381 | found in |
| 3382 | <filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-S'><filename>S</filename></ulink><filename>}</filename>. |
| 3383 | </para> |
| 3384 | |
| 3385 | <para>If |
| 3386 | <filename>${S}</filename> might contain a Makefile, |
| 3387 | or if you inherit some class that replaces |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 3388 | <filename>do_configure</filename> and |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame^] | 3389 | <filename>do_compile</filename> with custom |
| 3390 | versions, then you can use the |
| 3391 | <filename>[</filename><ulink url='&YOCTO_DOCS_BB_URL;#variable-flags'><filename>noexec</filename></ulink><filename>]</filename> |
| 3392 | flag to turn the tasks into no-ops, as follows: |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 3393 | <literallayout class='monospaced'> |
| 3394 | do_configure[noexec] = "1" |
| 3395 | do_compile[noexec] = "1" |
| 3396 | </literallayout> |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame^] | 3397 | Unlike |
| 3398 | <ulink url='&YOCTO_DOCS_BB_URL;#deleting-a-task'><filename>deleting the tasks</filename></ulink>, |
| 3399 | using the flag preserves the dependency chain from |
| 3400 | the |
| 3401 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-fetch'><filename>do_fetch</filename></ulink>, <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-unpack'><filename>do_unpack</filename></ulink>, |
| 3402 | and |
| 3403 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-patch'><filename>do_patch</filename></ulink> |
| 3404 | tasks to the |
| 3405 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-install'><filename>do_install</filename></ulink> |
| 3406 | task. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 3407 | </para></listitem> |
| 3408 | <listitem><para>Make sure your |
| 3409 | <filename>do_install</filename> task installs the |
| 3410 | binaries appropriately. |
| 3411 | </para></listitem> |
| 3412 | <listitem><para>Ensure that you set up |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame^] | 3413 | <ulink url='&YOCTO_DOCS_REF_URL;#var-FILES'><filename>FILES</filename></ulink> |
| 3414 | (usually |
| 3415 | <filename>FILES_${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-PN'><filename>PN</filename></ulink><filename>}</filename>) |
| 3416 | to point to the files you have installed, which of |
| 3417 | course depends on where you have installed them |
| 3418 | and whether those files are in different locations |
| 3419 | than the defaults. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 3420 | </para></listitem> |
| 3421 | </itemizedlist> |
| 3422 | </para> |
| 3423 | </section> |
| 3424 | </section> |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame^] | 3425 | |
| 3426 | <section id="following-recipe-style-guidelines"> |
| 3427 | <title>Following Recipe Style Guidelines</title> |
| 3428 | |
| 3429 | <para> |
| 3430 | When writing recipes, it is good to conform to existing |
| 3431 | style guidelines. |
| 3432 | The |
| 3433 | <ulink url='http://www.openembedded.org/wiki/Styleguide'>OpenEmbedded Styleguide</ulink> |
| 3434 | wiki page provides rough guidelines for preferred recipe style. |
| 3435 | </para> |
| 3436 | |
| 3437 | <para> |
| 3438 | It is common for existing recipes to deviate a bit from this |
| 3439 | style. |
| 3440 | However, aiming for at least a consistent style is a good idea. |
| 3441 | Some practices, such as omitting spaces around |
| 3442 | <filename>=</filename> operators in assignments or ordering |
| 3443 | recipe components in an erratic way, are widely seen as poor |
| 3444 | style. |
| 3445 | </para> |
| 3446 | </section> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 3447 | </section> |
| 3448 | |
| 3449 | <section id="platdev-newmachine"> |
| 3450 | <title>Adding a New Machine</title> |
| 3451 | |
| 3452 | <para> |
| 3453 | Adding a new machine to the Yocto Project is a straightforward |
| 3454 | process. |
| 3455 | This section describes how to add machines that are similar |
| 3456 | to those that the Yocto Project already supports. |
| 3457 | <note> |
| 3458 | Although well within the capabilities of the Yocto Project, |
| 3459 | adding a totally new architecture might require |
| 3460 | changes to <filename>gcc/glibc</filename> and to the site |
| 3461 | information, which is beyond the scope of this manual. |
| 3462 | </note> |
| 3463 | </para> |
| 3464 | |
| 3465 | <para> |
| 3466 | For a complete example that shows how to add a new machine, |
| 3467 | see the |
| 3468 | "<ulink url='&YOCTO_DOCS_BSP_URL;#creating-a-new-bsp-layer-using-the-yocto-bsp-script'>Creating a New BSP Layer Using the yocto-bsp Script</ulink>" |
| 3469 | section in the Yocto Project Board Support Package (BSP) Developer's Guide. |
| 3470 | </para> |
| 3471 | |
| 3472 | <section id="platdev-newmachine-conffile"> |
| 3473 | <title>Adding the Machine Configuration File</title> |
| 3474 | |
| 3475 | <para> |
| 3476 | To add a new machine, you need to add a new machine |
| 3477 | configuration file to the layer's |
| 3478 | <filename>conf/machine</filename> directory. |
| 3479 | This configuration file provides details about the device |
| 3480 | you are adding. |
| 3481 | </para> |
| 3482 | |
| 3483 | <para> |
| 3484 | The OpenEmbedded build system uses the root name of the |
| 3485 | machine configuration file to reference the new machine. |
| 3486 | For example, given a machine configuration file named |
| 3487 | <filename>crownbay.conf</filename>, the build system |
| 3488 | recognizes the machine as "crownbay". |
| 3489 | </para> |
| 3490 | |
| 3491 | <para> |
| 3492 | The most important variables you must set in your machine |
| 3493 | configuration file or include from a lower-level configuration |
| 3494 | file are as follows: |
| 3495 | <itemizedlist> |
| 3496 | <listitem><para><filename><ulink url='&YOCTO_DOCS_REF_URL;#var-TARGET_ARCH'>TARGET_ARCH</ulink></filename> |
| 3497 | (e.g. "arm")</para></listitem> |
| 3498 | <listitem><para><filename><ulink url='&YOCTO_DOCS_REF_URL;#var-PREFERRED_PROVIDER'>PREFERRED_PROVIDER</ulink>_virtual/kernel</filename> |
| 3499 | </para></listitem> |
| 3500 | <listitem><para><filename><ulink url='&YOCTO_DOCS_REF_URL;#var-MACHINE_FEATURES'>MACHINE_FEATURES</ulink></filename> |
| 3501 | (e.g. "apm screen wifi")</para></listitem> |
| 3502 | </itemizedlist> |
| 3503 | </para> |
| 3504 | |
| 3505 | <para> |
| 3506 | You might also need these variables: |
| 3507 | <itemizedlist> |
| 3508 | <listitem><para><filename><ulink url='&YOCTO_DOCS_REF_URL;#var-SERIAL_CONSOLES'>SERIAL_CONSOLES</ulink></filename> |
| 3509 | (e.g. "115200;ttyS0 115200;ttyS1")</para></listitem> |
| 3510 | <listitem><para><filename><ulink url='&YOCTO_DOCS_REF_URL;#var-KERNEL_IMAGETYPE'>KERNEL_IMAGETYPE</ulink></filename> |
| 3511 | (e.g. "zImage")</para></listitem> |
| 3512 | <listitem><para><filename><ulink url='&YOCTO_DOCS_REF_URL;#var-IMAGE_FSTYPES'>IMAGE_FSTYPES</ulink></filename> |
| 3513 | (e.g. "tar.gz jffs2")</para></listitem> |
| 3514 | </itemizedlist> |
| 3515 | </para> |
| 3516 | |
| 3517 | <para> |
| 3518 | You can find full details on these variables in the reference |
| 3519 | section. |
| 3520 | You can leverage existing machine <filename>.conf</filename> |
| 3521 | files from <filename>meta-yocto-bsp/conf/machine/</filename>. |
| 3522 | </para> |
| 3523 | </section> |
| 3524 | |
| 3525 | <section id="platdev-newmachine-kernel"> |
| 3526 | <title>Adding a Kernel for the Machine</title> |
| 3527 | |
| 3528 | <para> |
| 3529 | The OpenEmbedded build system needs to be able to build a kernel |
| 3530 | for the machine. |
| 3531 | You need to either create a new kernel recipe for this machine, |
| 3532 | or extend an existing kernel recipe. |
| 3533 | You can find several kernel recipe examples in the |
| 3534 | Source Directory at |
| 3535 | <filename>meta/recipes-kernel/linux</filename> |
| 3536 | that you can use as references. |
| 3537 | </para> |
| 3538 | |
| 3539 | <para> |
| 3540 | If you are creating a new kernel recipe, normal recipe-writing |
| 3541 | rules apply for setting up a |
| 3542 | <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'>SRC_URI</ulink></filename>. |
| 3543 | Thus, you need to specify any necessary patches and set |
| 3544 | <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-S'>S</ulink></filename> |
| 3545 | to point at the source code. |
| 3546 | You need to create a <filename>do_configure</filename> task that |
| 3547 | configures the unpacked kernel with a |
| 3548 | <filename>defconfig</filename> file. |
| 3549 | You can do this by using a <filename>make defconfig</filename> |
| 3550 | command or, more commonly, by copying in a suitable |
| 3551 | <filename>defconfig</filename> file and then running |
| 3552 | <filename>make oldconfig</filename>. |
| 3553 | By making use of <filename>inherit kernel</filename> and |
| 3554 | potentially some of the <filename>linux-*.inc</filename> files, |
| 3555 | most other functionality is centralized and the defaults of the |
| 3556 | class normally work well. |
| 3557 | </para> |
| 3558 | |
| 3559 | <para> |
| 3560 | If you are extending an existing kernel recipe, it is usually |
| 3561 | a matter of adding a suitable <filename>defconfig</filename> |
| 3562 | file. |
| 3563 | The file needs to be added into a location similar to |
| 3564 | <filename>defconfig</filename> files used for other machines |
| 3565 | in a given kernel recipe. |
| 3566 | A possible way to do this is by listing the file in the |
| 3567 | <filename>SRC_URI</filename> and adding the machine to the |
| 3568 | expression in |
| 3569 | <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-COMPATIBLE_MACHINE'>COMPATIBLE_MACHINE</ulink></filename>: |
| 3570 | <literallayout class='monospaced'> |
| 3571 | COMPATIBLE_MACHINE = '(qemux86|qemumips)' |
| 3572 | </literallayout> |
| 3573 | For more information on <filename>defconfig</filename> files, |
| 3574 | see the |
| 3575 | "<ulink url='&YOCTO_DOCS_KERNEL_DEV_URL;#changing-the-configuration'>Changing the Configuration</ulink>" |
| 3576 | section in the Yocto Project Linux Kernel Development Manual. |
| 3577 | </para> |
| 3578 | </section> |
| 3579 | |
| 3580 | <section id="platdev-newmachine-formfactor"> |
| 3581 | <title>Adding a Formfactor Configuration File</title> |
| 3582 | |
| 3583 | <para> |
| 3584 | A formfactor configuration file provides information about the |
| 3585 | target hardware for which the image is being built and information that |
| 3586 | the build system cannot obtain from other sources such as the kernel. |
| 3587 | Some examples of information contained in a formfactor configuration file include |
| 3588 | framebuffer orientation, whether or not the system has a keyboard, |
| 3589 | the positioning of the keyboard in relation to the screen, and |
| 3590 | the screen resolution. |
| 3591 | </para> |
| 3592 | |
| 3593 | <para> |
| 3594 | The build system uses reasonable defaults in most cases. |
| 3595 | However, if customization is |
| 3596 | necessary, you need to create a <filename>machconfig</filename> file |
| 3597 | in the <filename>meta/recipes-bsp/formfactor/files</filename> |
| 3598 | directory. |
| 3599 | This directory contains directories for specific machines such as |
| 3600 | <filename>qemuarm</filename> and <filename>qemux86</filename>. |
| 3601 | For information about the settings available and the defaults, see the |
| 3602 | <filename>meta/recipes-bsp/formfactor/files/config</filename> file found in the |
| 3603 | same area. |
| 3604 | </para> |
| 3605 | |
| 3606 | <para> |
| 3607 | Following is an example for "qemuarm" machine: |
| 3608 | <literallayout class='monospaced'> |
| 3609 | HAVE_TOUCHSCREEN=1 |
| 3610 | HAVE_KEYBOARD=1 |
| 3611 | |
| 3612 | DISPLAY_CAN_ROTATE=0 |
| 3613 | DISPLAY_ORIENTATION=0 |
| 3614 | #DISPLAY_WIDTH_PIXELS=640 |
| 3615 | #DISPLAY_HEIGHT_PIXELS=480 |
| 3616 | #DISPLAY_BPP=16 |
| 3617 | DISPLAY_DPI=150 |
| 3618 | DISPLAY_SUBPIXEL_ORDER=vrgb |
| 3619 | </literallayout> |
| 3620 | </para> |
| 3621 | </section> |
| 3622 | </section> |
| 3623 | |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame^] | 3624 | <section id='platdev-building-targets-with-multiple-configurations'> |
| 3625 | <title>Building Targets with Multiple Configurations</title> |
| 3626 | |
| 3627 | <para> |
| 3628 | Bitbake also has functionality that allows you to build |
| 3629 | multiple targets at the same time, where each target uses |
| 3630 | a different configuration. |
| 3631 | </para> |
| 3632 | |
| 3633 | <para> |
| 3634 | In order to accomplish this, you setup each of the configurations |
| 3635 | you need to use in parallel by placing the configuration files in |
| 3636 | your current build directory alongside the usual |
| 3637 | <filename>local.conf</filename> file. |
| 3638 | </para> |
| 3639 | |
| 3640 | <para> |
| 3641 | Follow these guidelines to create an environment that supports |
| 3642 | multiple configurations: |
| 3643 | <itemizedlist> |
| 3644 | <listitem><para> |
| 3645 | <emphasis>Create Configuration Files</emphasis>: |
| 3646 | You need to create a single configuration file for each |
| 3647 | configuration for which you want to add support. |
| 3648 | These files would contain lines such as the following: |
| 3649 | <literallayout class='monospaced'> |
| 3650 | MACHINE = "A" |
| 3651 | </literallayout> |
| 3652 | The files would contain any other variables that can |
| 3653 | be set and built in the same directory. |
| 3654 | <note> |
| 3655 | You can change the |
| 3656 | <ulink url='&YOCTO_DOCS_REF_URL;#var-TMPDIR'><filename>TMPDIR</filename></ulink> |
| 3657 | to not conflict. |
| 3658 | </note></para> |
| 3659 | |
| 3660 | <para> |
| 3661 | Furthermore, the configuration file must be located in the |
| 3662 | current build directory in a directory named |
| 3663 | <filename>multiconfig</filename> under the build's |
| 3664 | <filename>conf</filename> directory where |
| 3665 | <filename>local.conf</filename> resides. |
| 3666 | The reason for this restriction is because the |
| 3667 | <filename>BBPATH</filename> variable is not constructed |
| 3668 | until the layers are parsed. |
| 3669 | Consequently, using the configuration file as a |
| 3670 | pre-configuration file is not possible unless it is |
| 3671 | located in the current working directory. |
| 3672 | </para></listitem> |
| 3673 | <listitem><para> |
| 3674 | <emphasis>Add the BitBake Multi-Config Variable to you Local Configuration File</emphasis>: |
| 3675 | Use the |
| 3676 | <filename>BBMULTICONFIG</filename> |
| 3677 | variable in your <filename>conf/local.conf</filename> |
| 3678 | configuration file to specify each separate configuration. |
| 3679 | For example, the following line tells BitBake it should load |
| 3680 | <filename>conf/multiconfig/configA.conf</filename>, |
| 3681 | <filename>conf/multiconfig/configB.conf</filename>, and |
| 3682 | <filename>conf/multiconfig/configC.conf</filename>. |
| 3683 | <literallayout class='monospaced'> |
| 3684 | BBMULTICONFIG = "configA configB configC" |
| 3685 | </literallayout> |
| 3686 | </para></listitem> |
| 3687 | <listitem><para> |
| 3688 | <emphasis>Launch BitBake</emphasis>: |
| 3689 | Use the following BitBake command form to launch the |
| 3690 | build: |
| 3691 | <literallayout class='monospaced'> |
| 3692 | $ bitbake [multiconfig:<replaceable>multiconfigname</replaceable>:]<replaceable>target</replaceable> [[[multiconfig:<replaceable>multiconfigname</replaceable>:]<replaceable>target</replaceable>] ... ] |
| 3693 | </literallayout> |
| 3694 | Following is an example that supports building a minimal |
| 3695 | image for configuration A alongside a standard |
| 3696 | <filename>core-image-sato</filename>, which takes its |
| 3697 | configuration from <filename>local.conf</filename>: |
| 3698 | <literallayout class='monospaced'> |
| 3699 | $ bitbake multiconfig:configA:core-image-minimal core-image-sato |
| 3700 | </literallayout> |
| 3701 | </para></listitem> |
| 3702 | </itemizedlist> |
| 3703 | </para> |
| 3704 | |
| 3705 | <para> |
| 3706 | Support for multiple configurations in this current release of |
| 3707 | the Yocto Project (&DISTRO_NAME; &DISTRO;) has some known issues: |
| 3708 | <itemizedlist> |
| 3709 | <listitem><para> |
| 3710 | No inter-multi-configuration dependencies exist. |
| 3711 | </para></listitem> |
| 3712 | <listitem><para> |
| 3713 | Shared State (sstate) optimizations do not exist. |
| 3714 | Consequently, if the build uses the same object twice |
| 3715 | in, for example, two different |
| 3716 | <filename>TMPDIR</filename> directories, the build |
| 3717 | will either load from an existing sstate cache at the |
| 3718 | start or build the object twice. |
| 3719 | </para></listitem> |
| 3720 | </itemizedlist> |
| 3721 | </para> |
| 3722 | </section> |
| 3723 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 3724 | <section id="platdev-working-with-libraries"> |
| 3725 | <title>Working With Libraries</title> |
| 3726 | |
| 3727 | <para> |
| 3728 | Libraries are an integral part of your system. |
| 3729 | This section describes some common practices you might find |
| 3730 | helpful when working with libraries to build your system: |
| 3731 | <itemizedlist> |
| 3732 | <listitem><para><link linkend='including-static-library-files'>How to include static library files</link> |
| 3733 | </para></listitem> |
| 3734 | <listitem><para><link linkend='combining-multiple-versions-library-files-into-one-image'>How to use the Multilib feature to combine multiple versions of library files into a single image</link> |
| 3735 | </para></listitem> |
| 3736 | <listitem><para><link linkend='installing-multiple-versions-of-the-same-library'>How to install multiple versions of the same library in parallel on the same system</link> |
| 3737 | </para></listitem> |
| 3738 | </itemizedlist> |
| 3739 | </para> |
| 3740 | |
| 3741 | <section id='including-static-library-files'> |
| 3742 | <title>Including Static Library Files</title> |
| 3743 | |
| 3744 | <para> |
| 3745 | If you are building a library and the library offers static linking, you can control |
| 3746 | which static library files (<filename>*.a</filename> files) get included in the |
| 3747 | built library. |
| 3748 | </para> |
| 3749 | |
| 3750 | <para> |
| 3751 | The <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGES'><filename>PACKAGES</filename></ulink> |
| 3752 | and <ulink url='&YOCTO_DOCS_REF_URL;#var-FILES'><filename>FILES_*</filename></ulink> |
| 3753 | variables in the |
| 3754 | <filename>meta/conf/bitbake.conf</filename> configuration file define how files installed |
| 3755 | by the <filename>do_install</filename> task are packaged. |
| 3756 | By default, the <filename>PACKAGES</filename> variable includes |
| 3757 | <filename>${PN}-staticdev</filename>, which represents all static library files. |
| 3758 | <note> |
| 3759 | Some previously released versions of the Yocto Project |
| 3760 | defined the static library files through |
| 3761 | <filename>${PN}-dev</filename>. |
| 3762 | </note> |
| 3763 | Following is part of the BitBake configuration file, where |
| 3764 | you can see how the static library files are defined: |
| 3765 | <literallayout class='monospaced'> |
| 3766 | PACKAGE_BEFORE_PN ?= "" |
| 3767 | PACKAGES = "${PN}-dbg ${PN}-staticdev ${PN}-dev ${PN}-doc ${PN}-locale ${PACKAGE_BEFORE_PN} ${PN}" |
| 3768 | PACKAGES_DYNAMIC = "^${PN}-locale-.*" |
| 3769 | FILES = "" |
| 3770 | |
| 3771 | FILES_${PN} = "${bindir}/* ${sbindir}/* ${libexecdir}/* ${libdir}/lib*${SOLIBS} \ |
| 3772 | ${sysconfdir} ${sharedstatedir} ${localstatedir} \ |
| 3773 | ${base_bindir}/* ${base_sbindir}/* \ |
| 3774 | ${base_libdir}/*${SOLIBS} \ |
| 3775 | ${base_prefix}/lib/udev/rules.d ${prefix}/lib/udev/rules.d \ |
| 3776 | ${datadir}/${BPN} ${libdir}/${BPN}/* \ |
| 3777 | ${datadir}/pixmaps ${datadir}/applications \ |
| 3778 | ${datadir}/idl ${datadir}/omf ${datadir}/sounds \ |
| 3779 | ${libdir}/bonobo/servers" |
| 3780 | |
| 3781 | FILES_${PN}-bin = "${bindir}/* ${sbindir}/*" |
| 3782 | |
| 3783 | FILES_${PN}-doc = "${docdir} ${mandir} ${infodir} ${datadir}/gtk-doc \ |
| 3784 | ${datadir}/gnome/help" |
| 3785 | SECTION_${PN}-doc = "doc" |
| 3786 | |
| 3787 | FILES_SOLIBSDEV ?= "${base_libdir}/lib*${SOLIBSDEV} ${libdir}/lib*${SOLIBSDEV}" |
| 3788 | FILES_${PN}-dev = "${includedir} ${FILES_SOLIBSDEV} ${libdir}/*.la \ |
| 3789 | ${libdir}/*.o ${libdir}/pkgconfig ${datadir}/pkgconfig \ |
| 3790 | ${datadir}/aclocal ${base_libdir}/*.o \ |
| 3791 | ${libdir}/${BPN}/*.la ${base_libdir}/*.la" |
| 3792 | SECTION_${PN}-dev = "devel" |
| 3793 | ALLOW_EMPTY_${PN}-dev = "1" |
| 3794 | RDEPENDS_${PN}-dev = "${PN} (= ${EXTENDPKGV})" |
| 3795 | |
| 3796 | FILES_${PN}-staticdev = "${libdir}/*.a ${base_libdir}/*.a ${libdir}/${BPN}/*.a" |
| 3797 | SECTION_${PN}-staticdev = "devel" |
| 3798 | RDEPENDS_${PN}-staticdev = "${PN}-dev (= ${EXTENDPKGV})" |
| 3799 | </literallayout> |
| 3800 | </para> |
| 3801 | </section> |
| 3802 | |
| 3803 | <section id="combining-multiple-versions-library-files-into-one-image"> |
| 3804 | <title>Combining Multiple Versions of Library Files into One Image</title> |
| 3805 | |
| 3806 | <para> |
| 3807 | The build system offers the ability to build libraries with different |
| 3808 | target optimizations or architecture formats and combine these together |
| 3809 | into one system image. |
| 3810 | You can link different binaries in the image |
| 3811 | against the different libraries as needed for specific use cases. |
| 3812 | This feature is called "Multilib." |
| 3813 | </para> |
| 3814 | |
| 3815 | <para> |
| 3816 | An example would be where you have most of a system compiled in 32-bit |
| 3817 | mode using 32-bit libraries, but you have something large, like a database |
| 3818 | engine, that needs to be a 64-bit application and uses 64-bit libraries. |
| 3819 | Multilib allows you to get the best of both 32-bit and 64-bit libraries. |
| 3820 | </para> |
| 3821 | |
| 3822 | <para> |
| 3823 | While the Multilib feature is most commonly used for 32 and 64-bit differences, |
| 3824 | the approach the build system uses facilitates different target optimizations. |
| 3825 | You could compile some binaries to use one set of libraries and other binaries |
| 3826 | to use a different set of libraries. |
| 3827 | The libraries could differ in architecture, compiler options, or other |
| 3828 | optimizations. |
| 3829 | </para> |
| 3830 | |
| 3831 | <para> |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 3832 | Several examples exist in the |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 3833 | <filename>meta-skeleton</filename> layer found in the |
| 3834 | <link linkend='source-directory'>Source Directory</link>: |
| 3835 | <itemizedlist> |
| 3836 | <listitem><para><filename>conf/multilib-example.conf</filename> |
| 3837 | configuration file</para></listitem> |
| 3838 | <listitem><para><filename>conf/multilib-example2.conf</filename> |
| 3839 | configuration file</para></listitem> |
| 3840 | <listitem><para><filename>recipes-multilib/images/core-image-multilib-example.bb</filename> |
| 3841 | recipe</para></listitem> |
| 3842 | </itemizedlist> |
| 3843 | </para> |
| 3844 | |
| 3845 | <section id='preparing-to-use-multilib'> |
| 3846 | <title>Preparing to Use Multilib</title> |
| 3847 | |
| 3848 | <para> |
| 3849 | User-specific requirements drive the Multilib feature. |
| 3850 | Consequently, there is no one "out-of-the-box" configuration that likely |
| 3851 | exists to meet your needs. |
| 3852 | </para> |
| 3853 | |
| 3854 | <para> |
| 3855 | In order to enable Multilib, you first need to ensure your recipe is |
| 3856 | extended to support multiple libraries. |
| 3857 | Many standard recipes are already extended and support multiple libraries. |
| 3858 | You can check in the <filename>meta/conf/multilib.conf</filename> |
| 3859 | configuration file in the |
| 3860 | <link linkend='source-directory'>Source Directory</link> to see how this is |
| 3861 | done using the |
| 3862 | <ulink url='&YOCTO_DOCS_REF_URL;#var-BBCLASSEXTEND'><filename>BBCLASSEXTEND</filename></ulink> |
| 3863 | variable. |
| 3864 | Eventually, all recipes will be covered and this list will |
| 3865 | not be needed. |
| 3866 | </para> |
| 3867 | |
| 3868 | <para> |
| 3869 | For the most part, the Multilib class extension works automatically to |
| 3870 | extend the package name from <filename>${PN}</filename> to |
| 3871 | <filename>${MLPREFIX}${PN}</filename>, where <filename>MLPREFIX</filename> |
| 3872 | is the particular multilib (e.g. "lib32-" or "lib64-"). |
| 3873 | Standard variables such as |
| 3874 | <ulink url='&YOCTO_DOCS_REF_URL;#var-DEPENDS'><filename>DEPENDS</filename></ulink>, |
| 3875 | <ulink url='&YOCTO_DOCS_REF_URL;#var-RDEPENDS'><filename>RDEPENDS</filename></ulink>, |
| 3876 | <ulink url='&YOCTO_DOCS_REF_URL;#var-RPROVIDES'><filename>RPROVIDES</filename></ulink>, |
| 3877 | <ulink url='&YOCTO_DOCS_REF_URL;#var-RRECOMMENDS'><filename>RRECOMMENDS</filename></ulink>, |
| 3878 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGES'><filename>PACKAGES</filename></ulink>, and |
| 3879 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGES_DYNAMIC'><filename>PACKAGES_DYNAMIC</filename></ulink> |
| 3880 | are automatically extended by the system. |
| 3881 | If you are extending any manual code in the recipe, you can use the |
| 3882 | <filename>${MLPREFIX}</filename> variable to ensure those names are extended |
| 3883 | correctly. |
| 3884 | This automatic extension code resides in <filename>multilib.bbclass</filename>. |
| 3885 | </para> |
| 3886 | </section> |
| 3887 | |
| 3888 | <section id='using-multilib'> |
| 3889 | <title>Using Multilib</title> |
| 3890 | |
| 3891 | <para> |
| 3892 | After you have set up the recipes, you need to define the actual |
| 3893 | combination of multiple libraries you want to build. |
| 3894 | You accomplish this through your <filename>local.conf</filename> |
| 3895 | configuration file in the |
| 3896 | <link linkend='build-directory'>Build Directory</link>. |
| 3897 | An example configuration would be as follows: |
| 3898 | <literallayout class='monospaced'> |
| 3899 | MACHINE = "qemux86-64" |
| 3900 | require conf/multilib.conf |
| 3901 | MULTILIBS = "multilib:lib32" |
| 3902 | DEFAULTTUNE_virtclass-multilib-lib32 = "x86" |
Patrick Williams | f1e5d69 | 2016-03-30 15:21:19 -0500 | [diff] [blame] | 3903 | IMAGE_INSTALL_append = " lib32-glib-2.0" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 3904 | </literallayout> |
| 3905 | This example enables an |
| 3906 | additional library named <filename>lib32</filename> alongside the |
| 3907 | normal target packages. |
| 3908 | When combining these "lib32" alternatives, the example uses "x86" for tuning. |
| 3909 | For information on this particular tuning, see |
| 3910 | <filename>meta/conf/machine/include/ia32/arch-ia32.inc</filename>. |
| 3911 | </para> |
| 3912 | |
| 3913 | <para> |
Patrick Williams | f1e5d69 | 2016-03-30 15:21:19 -0500 | [diff] [blame] | 3914 | The example then includes <filename>lib32-glib-2.0</filename> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 3915 | in all the images, which illustrates one method of including a |
| 3916 | multiple library dependency. |
| 3917 | You can use a normal image build to include this dependency, |
| 3918 | for example: |
| 3919 | <literallayout class='monospaced'> |
| 3920 | $ bitbake core-image-sato |
| 3921 | </literallayout> |
| 3922 | You can also build Multilib packages specifically with a command like this: |
| 3923 | <literallayout class='monospaced'> |
Patrick Williams | f1e5d69 | 2016-03-30 15:21:19 -0500 | [diff] [blame] | 3924 | $ bitbake lib32-glib-2.0 |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 3925 | </literallayout> |
| 3926 | </para> |
| 3927 | </section> |
| 3928 | |
| 3929 | <section id='additional-implementation-details'> |
| 3930 | <title>Additional Implementation Details</title> |
| 3931 | |
| 3932 | <para> |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 3933 | Generic implementation details as well as details that are |
| 3934 | specific to package management systems exist. |
| 3935 | Following are implementation details that exist regardless |
| 3936 | of the package management system: |
| 3937 | <itemizedlist> |
| 3938 | <listitem><para>The typical convention used for the |
| 3939 | class extension code as used by |
| 3940 | Multilib assumes that all package names specified |
| 3941 | in |
| 3942 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGES'><filename>PACKAGES</filename></ulink> |
| 3943 | that contain <filename>${PN}</filename> have |
| 3944 | <filename>${PN}</filename> at the start of the name. |
| 3945 | When that convention is not followed and |
| 3946 | <filename>${PN}</filename> appears at |
| 3947 | the middle or the end of a name, problems occur. |
| 3948 | </para></listitem> |
| 3949 | <listitem><para>The |
| 3950 | <ulink url='&YOCTO_DOCS_REF_URL;#var-TARGET_VENDOR'><filename>TARGET_VENDOR</filename></ulink> |
| 3951 | value under Multilib will be extended to |
| 3952 | "-<replaceable>vendor</replaceable>ml<replaceable>multilib</replaceable>" |
| 3953 | (e.g. "-pokymllib32" for a "lib32" Multilib with |
| 3954 | Poky). |
| 3955 | The reason for this slightly unwieldy contraction |
| 3956 | is that any "-" characters in the vendor |
| 3957 | string presently break Autoconf's |
| 3958 | <filename>config.sub</filename>, and |
| 3959 | other separators are problematic for different |
| 3960 | reasons. |
| 3961 | </para></listitem> |
| 3962 | </itemizedlist> |
| 3963 | </para> |
| 3964 | ' |
| 3965 | <para> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 3966 | For the RPM Package Management System, the following implementation details |
| 3967 | exist: |
| 3968 | <itemizedlist> |
| 3969 | <listitem><para>A unique architecture is defined for the Multilib packages, |
| 3970 | along with creating a unique deploy folder under |
| 3971 | <filename>tmp/deploy/rpm</filename> in the |
| 3972 | <link linkend='build-directory'>Build Directory</link>. |
| 3973 | For example, consider <filename>lib32</filename> in a |
| 3974 | <filename>qemux86-64</filename> image. |
| 3975 | The possible architectures in the system are "all", "qemux86_64", |
| 3976 | "lib32_qemux86_64", and "lib32_x86".</para></listitem> |
| 3977 | <listitem><para>The <filename>${MLPREFIX}</filename> variable is stripped from |
| 3978 | <filename>${PN}</filename> during RPM packaging. |
| 3979 | The naming for a normal RPM package and a Multilib RPM package in a |
| 3980 | <filename>qemux86-64</filename> system resolves to something similar to |
| 3981 | <filename>bash-4.1-r2.x86_64.rpm</filename> and |
| 3982 | <filename>bash-4.1.r2.lib32_x86.rpm</filename>, respectively. |
| 3983 | </para></listitem> |
| 3984 | <listitem><para>When installing a Multilib image, the RPM backend first |
| 3985 | installs the base image and then installs the Multilib libraries. |
| 3986 | </para></listitem> |
| 3987 | <listitem><para>The build system relies on RPM to resolve the identical files in the |
| 3988 | two (or more) Multilib packages.</para></listitem> |
| 3989 | </itemizedlist> |
| 3990 | </para> |
| 3991 | |
| 3992 | <para> |
| 3993 | For the IPK Package Management System, the following implementation details exist: |
| 3994 | <itemizedlist> |
| 3995 | <listitem><para>The <filename>${MLPREFIX}</filename> is not stripped from |
| 3996 | <filename>${PN}</filename> during IPK packaging. |
| 3997 | The naming for a normal RPM package and a Multilib IPK package in a |
| 3998 | <filename>qemux86-64</filename> system resolves to something like |
| 3999 | <filename>bash_4.1-r2.x86_64.ipk</filename> and |
| 4000 | <filename>lib32-bash_4.1-rw_x86.ipk</filename>, respectively. |
| 4001 | </para></listitem> |
| 4002 | <listitem><para>The IPK deploy folder is not modified with |
| 4003 | <filename>${MLPREFIX}</filename> because packages with and without |
| 4004 | the Multilib feature can exist in the same folder due to the |
| 4005 | <filename>${PN}</filename> differences.</para></listitem> |
| 4006 | <listitem><para>IPK defines a sanity check for Multilib installation |
| 4007 | using certain rules for file comparison, overridden, etc. |
| 4008 | </para></listitem> |
| 4009 | </itemizedlist> |
| 4010 | </para> |
| 4011 | </section> |
| 4012 | </section> |
| 4013 | |
| 4014 | <section id='installing-multiple-versions-of-the-same-library'> |
| 4015 | <title>Installing Multiple Versions of the Same Library</title> |
| 4016 | |
| 4017 | <para> |
| 4018 | Situations can exist where you need to install and use |
| 4019 | multiple versions of the same library on the same system |
| 4020 | at the same time. |
| 4021 | These situations almost always exist when a library API |
| 4022 | changes and you have multiple pieces of software that |
| 4023 | depend on the separate versions of the library. |
| 4024 | To accommodate these situations, you can install multiple |
| 4025 | versions of the same library in parallel on the same system. |
| 4026 | </para> |
| 4027 | |
| 4028 | <para> |
| 4029 | The process is straightforward as long as the libraries use |
| 4030 | proper versioning. |
| 4031 | With properly versioned libraries, all you need to do to |
| 4032 | individually specify the libraries is create separate, |
| 4033 | appropriately named recipes where the |
| 4034 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PN'><filename>PN</filename></ulink> part of the |
| 4035 | name includes a portion that differentiates each library version |
| 4036 | (e.g.the major part of the version number). |
| 4037 | Thus, instead of having a single recipe that loads one version |
| 4038 | of a library (e.g. <filename>clutter</filename>), you provide |
| 4039 | multiple recipes that result in different versions |
| 4040 | of the libraries you want. |
| 4041 | As an example, the following two recipes would allow the |
| 4042 | two separate versions of the <filename>clutter</filename> |
| 4043 | library to co-exist on the same system: |
| 4044 | <literallayout class='monospaced'> |
| 4045 | clutter-1.6_1.6.20.bb |
| 4046 | clutter-1.8_1.8.4.bb |
| 4047 | </literallayout> |
| 4048 | Additionally, if you have other recipes that depend on a given |
| 4049 | library, you need to use the |
| 4050 | <ulink url='&YOCTO_DOCS_REF_URL;#var-DEPENDS'><filename>DEPENDS</filename></ulink> |
| 4051 | variable to create the dependency. |
| 4052 | Continuing with the same example, if you want to have a recipe |
| 4053 | depend on the 1.8 version of the <filename>clutter</filename> |
| 4054 | library, use the following in your recipe: |
| 4055 | <literallayout class='monospaced'> |
| 4056 | DEPENDS = "clutter-1.8" |
| 4057 | </literallayout> |
| 4058 | </para> |
| 4059 | </section> |
| 4060 | </section> |
| 4061 | |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame^] | 4062 | <section id='enabling-gobject-introspection-support'> |
| 4063 | <title>Enabling GObject Introspection Support</title> |
| 4064 | |
| 4065 | <para> |
| 4066 | <ulink url='https://wiki.gnome.org/Projects/GObjectIntrospection'>GObject introspection</ulink> |
| 4067 | is the standard mechanism for accessing GObject-based software |
| 4068 | from runtime environments. |
| 4069 | GObject is a feature of the GLib library that provides an object |
| 4070 | framework for the GNOME desktop and related software. |
| 4071 | GObject Introspection adds information to GObject that allows |
| 4072 | objects created within it to be represented across different |
| 4073 | programming languages. |
| 4074 | If you want to construct GStreamer pipelines using Python, or |
| 4075 | control UPnP infrastructure using Javascript and GUPnP, |
| 4076 | GObject introspection is the only way to do it. |
| 4077 | </para> |
| 4078 | |
| 4079 | <para> |
| 4080 | This section describes the Yocto Project support for generating |
| 4081 | and packaging GObject introspection data. |
| 4082 | GObject introspection data is a description of the |
| 4083 | API provided by libraries built on top of GLib framework, |
| 4084 | and, in particular, that framework's GObject mechanism. |
| 4085 | GObject Introspection Repository (GIR) files go to |
| 4086 | <filename>-dev</filename> packages, |
| 4087 | <filename>typelib</filename> files go to main packages as they |
| 4088 | are packaged together with libraries that are introspected. |
| 4089 | </para> |
| 4090 | |
| 4091 | <para> |
| 4092 | The data is generated when building such a library, by linking |
| 4093 | the library with a small executable binary that asks the library |
| 4094 | to describe itself, and then executing the binary and |
| 4095 | processing its output. |
| 4096 | </para> |
| 4097 | |
| 4098 | <para> |
| 4099 | Generating this data in a cross-compilation environment |
| 4100 | is difficult because the library is produced for the target |
| 4101 | architecture, but its code needs to be executed on the build host. |
| 4102 | This problem is solved with the OpenEmbedded build system by |
| 4103 | running the code through QEMU, which allows precisely that. |
| 4104 | Unfortunately, QEMU does not always work perfectly as mentioned |
| 4105 | in the xxx section. |
| 4106 | </para> |
| 4107 | |
| 4108 | <section id='enabling-the-generation-of-introspection-data'> |
| 4109 | <title>Enabling the Generation of Introspection Data</title> |
| 4110 | |
| 4111 | <para> |
| 4112 | Enabling the generation of introspection data (GIR files) |
| 4113 | in your library package involves the following: |
| 4114 | <orderedlist> |
| 4115 | <listitem><para> |
| 4116 | Inherit the |
| 4117 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-gobject-introspection'><filename>gobject-introspection</filename></ulink> |
| 4118 | class. |
| 4119 | </para></listitem> |
| 4120 | <listitem><para> |
| 4121 | Make sure introspection is not disabled anywhere in |
| 4122 | the recipe or from anything the recipe includes. |
| 4123 | Also, make sure that "gobject-introspection-data" is |
| 4124 | not in |
| 4125 | <ulink url='&YOCTO_DOCS_REF_URL;#var-DISTRO_FEATURES_BACKFILL_CONSIDERED'><filename>DISTRO_FEATURES_BACKFILL_CONSIDERED</filename></ulink> |
| 4126 | and that "qemu-usermode" is not in |
| 4127 | <ulink url='&YOCTO_DOCS_REF_URL;#var-MACHINE_FEATURES_BACKFILL_CONSIDERED'><filename>MACHINE_FEATURES_BACKFILL_CONSIDERED</filename></ulink>. |
| 4128 | If either of these conditions exist, nothing will |
| 4129 | happen. |
| 4130 | </para></listitem> |
| 4131 | <listitem><para> |
| 4132 | Try to build the recipe. |
| 4133 | If you encounter build errors that look like |
| 4134 | something is unable to find |
| 4135 | <filename>.so</filename> libraries, check where these |
| 4136 | libraries are located in the source tree and add |
| 4137 | the following to the recipe: |
| 4138 | <literallayout class='monospaced'> |
| 4139 | GIR_EXTRA_LIBS_PATH = "${B}/<replaceable>something</replaceable>/.libs" |
| 4140 | </literallayout> |
| 4141 | <note> |
| 4142 | See recipes in the <filename>oe-core</filename> |
| 4143 | repository that use that |
| 4144 | <filename>GIR_EXTRA_LIBS_PATH</filename> variable |
| 4145 | as an example. |
| 4146 | </note> |
| 4147 | </para></listitem> |
| 4148 | <listitem><para> |
| 4149 | Look for any other errors, which probably mean that |
| 4150 | introspection support in a package is not entirely |
| 4151 | standard, and thus breaks down in a cross-compilation |
| 4152 | environment. |
| 4153 | For such cases, custom-made fixes are needed. |
| 4154 | A good place to ask and receive help in these cases |
| 4155 | is the |
| 4156 | <ulink url='&YOCTO_DOCS_REF_URL;#resources-mailinglist'>Yocto Project mailing lists</ulink>. |
| 4157 | </para></listitem> |
| 4158 | </orderedlist> |
| 4159 | <note> |
| 4160 | Using a library that no longer builds against the latest |
| 4161 | Yocto Project release and prints introspection related |
| 4162 | errors is a good candidate for the previous procedure. |
| 4163 | </note> |
| 4164 | </para> |
| 4165 | </section> |
| 4166 | |
| 4167 | <section id='disabling-the-generation-of-introspection-data'> |
| 4168 | <title>Disabling the Generation of Introspection Data</title> |
| 4169 | |
| 4170 | <para> |
| 4171 | You might find that you do not want to generate |
| 4172 | introspection data. |
| 4173 | Or, perhaps QEMU does not work on your build host and |
| 4174 | target architecture combination. |
| 4175 | If so, you can use either of the following methods to |
| 4176 | disable GIR file generations: |
| 4177 | <itemizedlist> |
| 4178 | <listitem><para> |
| 4179 | Add the following to your distro configuration: |
| 4180 | <literallayout class='monospaced'> |
| 4181 | DISTRO_FEATURES_BACKFILL_CONSIDERED = "gobject-introspection-data" |
| 4182 | </literallayout> |
| 4183 | Adding this statement disables generating |
| 4184 | introspection data using QEMU but will still enable |
| 4185 | building introspection tools and libraries |
| 4186 | (i.e. building them does not require the use of QEMU). |
| 4187 | </para></listitem> |
| 4188 | <listitem><para> |
| 4189 | Add the following to your machine configuration: |
| 4190 | <literallayout class='monospaced'> |
| 4191 | MACHINE_FEATURES_BACKFILL_CONSIDERED = "qemu-usermode" |
| 4192 | </literallayout> |
| 4193 | Adding this statement disables the use of QEMU |
| 4194 | when building packages for your machine. |
| 4195 | Currently, this feature is used only by introspection |
| 4196 | recipes and has the same effect as the previously |
| 4197 | described option. |
| 4198 | <note> |
| 4199 | Future releases of the Yocto Project might have |
| 4200 | other features affected by this option. |
| 4201 | </note> |
| 4202 | </para></listitem> |
| 4203 | </itemizedlist> |
| 4204 | If you disable introspection data, you can still |
| 4205 | obtain it through other means such as copying the data |
| 4206 | from a suitable sysroot, or by generating it on the |
| 4207 | target hardware. |
| 4208 | The OpenEmbedded build system does not currently |
| 4209 | provide specific support for these techniques. |
| 4210 | </para> |
| 4211 | </section> |
| 4212 | |
| 4213 | <section id='testing-that-introspection-works-in-an-image'> |
| 4214 | <title>Testing that Introspection Works in an Image</title> |
| 4215 | |
| 4216 | <para> |
| 4217 | Use the following procedure to test if generating |
| 4218 | introspection data is working in an image: |
| 4219 | <orderedlist> |
| 4220 | <listitem><para> |
| 4221 | Make sure that "gobject-introspection-data" is not in |
| 4222 | <ulink url='&YOCTO_DOCS_REF_URL;#var-DISTRO_FEATURES_BACKFILL_CONSIDERED'><filename>DISTRO_FEATURES_BACKFILL_CONSIDERED</filename></ulink> |
| 4223 | and that "qemu-usermode" is not in |
| 4224 | <ulink url='&YOCTO_DOCS_REF_URL;#var-MACHINE_FEATURES_BACKFILL_CONSIDERED'><filename>MACHINE_FEATURES_BACKFILL_CONSIDERED</filename></ulink>. |
| 4225 | </para></listitem> |
| 4226 | <listitem><para> |
| 4227 | Build <filename>core-image-sato</filename>. |
| 4228 | </para></listitem> |
| 4229 | <listitem><para> |
| 4230 | Launch a Terminal and then start Python in the |
| 4231 | terminal. |
| 4232 | </para></listitem> |
| 4233 | <listitem><para> |
| 4234 | Enter the following in the terminal: |
| 4235 | <literallayout class='monospaced'> |
| 4236 | >>> from gi.repository import GLib |
| 4237 | >>> GLib.get_host_name() |
| 4238 | </literallayout> |
| 4239 | </para></listitem> |
| 4240 | <listitem><para> |
| 4241 | For something a little more advanced, enter the |
| 4242 | following: |
| 4243 | <literallayout class='monospaced'> |
| 4244 | http://python-gtk-3-tutorial.readthedocs.org/en/latest/introduction.html |
| 4245 | </literallayout> |
| 4246 | </para></listitem> |
| 4247 | </orderedlist> |
| 4248 | </para> |
| 4249 | </section> |
| 4250 | |
| 4251 | <section id='known-issues'> |
| 4252 | <title>Known Issues</title> |
| 4253 | |
| 4254 | <para> |
| 4255 | The following know issues exist for |
| 4256 | GObject Introspection Support: |
| 4257 | <itemizedlist> |
| 4258 | <listitem><para> |
| 4259 | <filename>qemu-ppc64</filename> immediately crashes. |
| 4260 | Consequently, you cannot build introspection data on |
| 4261 | that architecture. |
| 4262 | </para></listitem> |
| 4263 | <listitem><para> |
| 4264 | x32 is not supported by QEMU. |
| 4265 | Consequently, introspection data is disabled. |
| 4266 | </para></listitem> |
| 4267 | <listitem><para> |
| 4268 | musl causes transient GLib binaries to crash on |
| 4269 | assertion failures. |
| 4270 | Consequently, generating introspection data is |
| 4271 | disabled. |
| 4272 | </para></listitem> |
| 4273 | <listitem><para> |
| 4274 | Because QEMU is not able to run the binaries correctly, |
| 4275 | introspection is disabled for some specific packages |
| 4276 | under specific architectures (e.g. |
| 4277 | <filename>gcr</filename>, |
| 4278 | <filename>libsecret</filename>, and |
| 4279 | <filename>webkit</filename>). |
| 4280 | </para></listitem> |
| 4281 | <listitem><para> |
| 4282 | QEMU usermode might not work properly when running |
| 4283 | 64-bit binaries under 32-bit host machines. |
| 4284 | In particular, "qemumips64" is known to not work under |
| 4285 | i686. |
| 4286 | </para></listitem> |
| 4287 | </itemizedlist> |
| 4288 | </para> |
| 4289 | </section> |
| 4290 | </section> |
| 4291 | |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 4292 | <section id='dev-optionally-using-an-external-toolchain'> |
| 4293 | <title>Optionally Using an External Toolchain</title> |
| 4294 | |
| 4295 | <para> |
| 4296 | You might want to use an external toolchain as part of your |
| 4297 | development. |
| 4298 | If this is the case, the fundamental steps you need to accomplish |
| 4299 | are as follows: |
| 4300 | <itemizedlist> |
| 4301 | <listitem><para> |
| 4302 | Understand where the installed toolchain resides. |
| 4303 | For cases where you need to build the external toolchain, |
| 4304 | you would need to take separate steps to build and install |
| 4305 | the toolchain. |
| 4306 | </para></listitem> |
| 4307 | <listitem><para> |
| 4308 | Make sure you add the layer that contains the toolchain to |
| 4309 | your <filename>bblayers.conf</filename> file through the |
| 4310 | <ulink url='&YOCTO_DOCS_REF_URL;#var-BBLAYERS'><filename>BBLAYERS</filename></ulink> |
| 4311 | variable. |
| 4312 | </para></listitem> |
| 4313 | <listitem><para> |
| 4314 | Set the |
| 4315 | <ulink url='&YOCTO_DOCS_REF_URL;#var-EXTERNAL_TOOLCHAIN'><filename>EXTERNAL_TOOLCHAIN</filename></ulink> |
| 4316 | variable in your <filename>local.conf</filename> file |
| 4317 | to the location in which you installed the toolchain. |
| 4318 | </para></listitem> |
| 4319 | </itemizedlist> |
| 4320 | A good example of an external toolchain used with the Yocto Project |
| 4321 | is <trademark class='registered'>Mentor Graphics</trademark> |
| 4322 | Sourcery G++ Toolchain. |
| 4323 | You can see information on how to use that particular layer in the |
| 4324 | <filename>README</filename> file at |
| 4325 | <ulink url='http://github.com/MentorEmbedded/meta-sourcery/'></ulink>. |
| 4326 | You can find further information by reading about the |
| 4327 | <ulink url='&YOCTO_DOCS_REF_URL;#var-TCMODE'><filename>TCMODE</filename></ulink> |
| 4328 | variable in the Yocto Project Reference Manual's variable glossary. |
| 4329 | </para> |
| 4330 | </section> |
| 4331 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 4332 | <section id='creating-partitioned-images'> |
| 4333 | <title>Creating Partitioned Images</title> |
| 4334 | |
| 4335 | <para> |
| 4336 | Creating an image for a particular hardware target using the |
| 4337 | OpenEmbedded build system does not necessarily mean you can boot |
| 4338 | that image as is on your device. |
| 4339 | Physical devices accept and boot images in various ways depending |
| 4340 | on the specifics of the device. |
| 4341 | Usually, information about the hardware can tell you what image |
| 4342 | format the device requires. |
| 4343 | Should your device require multiple partitions on an SD card, flash, |
| 4344 | or an HDD, you can use the OpenEmbedded Image Creator, |
| 4345 | <filename>wic</filename>, to create the properly partitioned image. |
| 4346 | </para> |
| 4347 | |
| 4348 | <para> |
| 4349 | The <filename>wic</filename> command generates partitioned images |
| 4350 | from existing OpenEmbedded build artifacts. |
| 4351 | Image generation is driven by partitioning commands contained |
| 4352 | in an Openembedded kickstart file (<filename>.wks</filename>) |
| 4353 | specified either directly on the command line or as one of a |
| 4354 | selection of canned <filename>.wks</filename> files as shown |
| 4355 | with the <filename>wic list images</filename> command in the |
| 4356 | "<link linkend='using-a-provided-kickstart_file'>Using an Existing Kickstart File</link>" |
| 4357 | section. |
| 4358 | When applied to a given set of build artifacts, the result is an |
| 4359 | image or set of images that can be directly written onto media and |
| 4360 | used on a particular system. |
| 4361 | </para> |
| 4362 | |
| 4363 | <para> |
| 4364 | The <filename>wic</filename> command and the infrastructure |
| 4365 | it is based on is by definition incomplete. |
| 4366 | Its purpose is to allow the generation of customized images, |
| 4367 | and as such was designed to be completely extensible through a |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame^] | 4368 | plug-in interface. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 4369 | See the |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame^] | 4370 | "<link linkend='openembedded-kickstart-plugins'>Plug-ins</link>" |
| 4371 | section for information on these plug-ins. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 4372 | </para> |
| 4373 | |
| 4374 | <para> |
| 4375 | This section provides some background information on |
| 4376 | <filename>wic</filename>, describes what you need to have in |
| 4377 | place to run the tool, provides instruction on how to use |
| 4378 | <filename>wic</filename>, and provides several examples. |
| 4379 | </para> |
| 4380 | |
| 4381 | <section id='wic-background'> |
| 4382 | <title>Background</title> |
| 4383 | |
| 4384 | <para> |
| 4385 | This section provides some background on the |
| 4386 | <filename>wic</filename> utility. |
| 4387 | While none of this information is required to use |
| 4388 | <filename>wic</filename>, you might find it interesting. |
| 4389 | <itemizedlist> |
| 4390 | <listitem><para> |
| 4391 | The name "wic" is derived from OpenEmbedded |
| 4392 | Image Creator (oeic). |
| 4393 | The "oe" diphthong in "oeic" was promoted to the |
| 4394 | letter "w", because "oeic" is both difficult to remember and |
| 4395 | pronounce.</para></listitem> |
| 4396 | <listitem><para> |
| 4397 | <filename>wic</filename> is loosely based on the |
| 4398 | Meego Image Creator (<filename>mic</filename>) |
| 4399 | framework. |
| 4400 | The <filename>wic</filename> implementation has been |
| 4401 | heavily modified to make direct use of OpenEmbedded |
| 4402 | build artifacts instead of package installation and |
| 4403 | configuration, which are already incorporated within |
| 4404 | the OpenEmbedded artifacts.</para></listitem> |
| 4405 | <listitem><para> |
| 4406 | <filename>wic</filename> is a completely independent |
| 4407 | standalone utility that initially provides |
| 4408 | easier-to-use and more flexible replacements for a |
| 4409 | couple bits of existing functionality in OE Core's |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 4410 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-image-live'><filename>image-live</filename></ulink> |
| 4411 | class and <filename>mkefidisk.sh</filename> script. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 4412 | The difference between |
| 4413 | <filename>wic</filename> and those examples is |
| 4414 | that with <filename>wic</filename> the |
| 4415 | functionality of those scripts is implemented |
| 4416 | by a general-purpose partitioning language, which is |
| 4417 | based on Redhat kickstart syntax.</para></listitem> |
| 4418 | </itemizedlist> |
| 4419 | </para> |
| 4420 | </section> |
| 4421 | |
| 4422 | <section id='wic-requirements'> |
| 4423 | <title>Requirements</title> |
| 4424 | |
| 4425 | <para> |
| 4426 | In order to use the <filename>wic</filename> utility |
| 4427 | with the OpenEmbedded Build system, your system needs |
| 4428 | to meet the following requirements: |
| 4429 | <itemizedlist> |
| 4430 | <listitem><para>The Linux distribution on your |
| 4431 | development host must support the Yocto Project. |
| 4432 | See the |
| 4433 | "<ulink url='&YOCTO_DOCS_REF_URL;#detailed-supported-distros'>Supported Linux Distributions</ulink>" |
| 4434 | section in the Yocto Project Reference Manual for this |
| 4435 | list of distributions.</para></listitem> |
| 4436 | <listitem><para> |
| 4437 | The standard system utilities, such as |
| 4438 | <filename>cp</filename>, must be installed on your |
| 4439 | development host system. |
| 4440 | </para></listitem> |
| 4441 | <listitem><para> |
| 4442 | You need to have the build artifacts already |
| 4443 | available, which typically means that you must |
| 4444 | have already created an image using the |
| 4445 | Openembedded build system (e.g. |
| 4446 | <filename>core-image-minimal</filename>). |
| 4447 | While it might seem redundant to generate an image in |
| 4448 | order to create an image using |
| 4449 | <filename>wic</filename>, the current version of |
| 4450 | <filename>wic</filename> requires the artifacts |
| 4451 | in the form generated by the build system. |
| 4452 | </para></listitem> |
| 4453 | <listitem><para> |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 4454 | You must build several native tools, which are tools |
| 4455 | built to run on the build system: |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 4456 | <literallayout class='monospaced'> |
| 4457 | $ bitbake parted-native dosfstools-native mtools-native |
| 4458 | </literallayout> |
| 4459 | </para></listitem> |
| 4460 | <listitem><para> |
| 4461 | You must have sourced one of the build environment |
| 4462 | setup scripts (i.e. |
| 4463 | <ulink url='&YOCTO_DOCS_REF_URL;#structure-core-script'><filename>&OE_INIT_FILE;</filename></ulink> |
| 4464 | or |
| 4465 | <ulink url='&YOCTO_DOCS_REF_URL;#structure-memres-core-script'><filename>oe-init-build-env-memres</filename></ulink>) |
| 4466 | found in the |
| 4467 | <link linkend='build-directory'>Build Directory</link>. |
| 4468 | </para></listitem> |
| 4469 | </itemizedlist> |
| 4470 | </para> |
| 4471 | </section> |
| 4472 | |
| 4473 | <section id='wic-getting-help'> |
| 4474 | <title>Getting Help</title> |
| 4475 | |
| 4476 | <para> |
| 4477 | You can get general help for the <filename>wic</filename> |
| 4478 | by entering the <filename>wic</filename> command by itself |
| 4479 | or by entering the command with a help argument as follows: |
| 4480 | <literallayout class='monospaced'> |
| 4481 | $ wic -h |
| 4482 | $ wic --help |
| 4483 | </literallayout> |
| 4484 | </para> |
| 4485 | |
| 4486 | <para> |
| 4487 | Currently, <filename>wic</filename> supports two commands: |
| 4488 | <filename>create</filename> and <filename>list</filename>. |
| 4489 | You can get help for these commands as follows: |
| 4490 | <literallayout class='monospaced'> |
| 4491 | $ wic help <replaceable>command</replaceable> |
| 4492 | </literallayout> |
| 4493 | </para> |
| 4494 | |
| 4495 | <para> |
| 4496 | You can also get detailed help on a number of topics |
| 4497 | from the help system. |
| 4498 | The output of <filename>wic --help</filename> |
| 4499 | displays a list of available help |
| 4500 | topics under a "Help topics" heading. |
| 4501 | You can have the help system display the help text for |
| 4502 | a given topic by prefacing the topic with |
| 4503 | <filename>wic help</filename>: |
| 4504 | <literallayout class='monospaced'> |
| 4505 | $ wic help <replaceable>help_topic</replaceable> |
| 4506 | </literallayout> |
| 4507 | </para> |
| 4508 | |
| 4509 | <para> |
| 4510 | You can find out more about the images |
| 4511 | <filename>wic</filename> creates using the existing |
| 4512 | kickstart files with the following form of the command: |
| 4513 | <literallayout class='monospaced'> |
| 4514 | $ wic list <replaceable>image</replaceable> help |
| 4515 | </literallayout> |
| 4516 | where <filename><replaceable>image</replaceable></filename> is either |
| 4517 | <filename>directdisk</filename> or |
| 4518 | <filename>mkefidisk</filename>. |
| 4519 | </para> |
| 4520 | </section> |
| 4521 | |
| 4522 | <section id='operational-modes'> |
| 4523 | <title>Operational Modes</title> |
| 4524 | |
| 4525 | <para> |
| 4526 | You can use <filename>wic</filename> in two different |
| 4527 | modes, depending on how much control you need for |
| 4528 | specifying the Openembedded build artifacts that are |
| 4529 | used for creating the image: Raw and Cooked: |
| 4530 | <itemizedlist> |
| 4531 | <listitem><para><emphasis>Raw Mode:</emphasis> |
| 4532 | You explicitly specify build artifacts through |
| 4533 | command-line arguments.</para></listitem> |
| 4534 | <listitem><para><emphasis>Cooked Mode:</emphasis> |
| 4535 | The current |
| 4536 | <ulink url='&YOCTO_DOCS_REF_URL;#var-MACHINE'><filename>MACHINE</filename></ulink> |
| 4537 | setting and image name are used to automatically locate |
| 4538 | and provide the build artifacts.</para></listitem> |
| 4539 | </itemizedlist> |
| 4540 | </para> |
| 4541 | |
| 4542 | <para> |
| 4543 | Regardless of the mode you use, you need to have the build |
| 4544 | artifacts ready and available. |
| 4545 | Additionally, the environment must be set up using the |
| 4546 | <ulink url='&YOCTO_DOCS_REF_URL;#structure-core-script'><filename>&OE_INIT_FILE;</filename></ulink> |
| 4547 | or |
| 4548 | <ulink url='&YOCTO_DOCS_REF_URL;#structure-memres-core-script'><filename>oe-init-build-env-memres</filename></ulink> |
| 4549 | script found in the |
| 4550 | <link linkend='build-directory'>Build Directory</link>. |
| 4551 | </para> |
| 4552 | |
| 4553 | <section id='raw-mode'> |
| 4554 | <title>Raw Mode</title> |
| 4555 | |
| 4556 | <para> |
| 4557 | The general form of the 'wic' command in raw mode is: |
| 4558 | <literallayout class='monospaced'> |
| 4559 | $ wic create <replaceable>image_name</replaceable>.wks [<replaceable>options</replaceable>] [...] |
| 4560 | |
| 4561 | Where: |
| 4562 | |
| 4563 | <replaceable>image_name</replaceable>.wks |
| 4564 | An OpenEmbedded kickstart file. You can provide |
| 4565 | your own custom file or use a file from a set of |
| 4566 | existing files as described by further options. |
| 4567 | |
| 4568 | -o <replaceable>OUTDIR</replaceable>, --outdir=<replaceable>OUTDIR</replaceable> |
| 4569 | The name of a directory in which to create image. |
| 4570 | |
| 4571 | -i <replaceable>PROPERTIES_FILE</replaceable>, --infile=<replaceable>PROPERTIES_FILE</replaceable> |
| 4572 | The name of a file containing the values for image |
| 4573 | properties as a JSON file. |
| 4574 | |
| 4575 | -e <replaceable>IMAGE_NAME</replaceable>, --image-name=<replaceable>IMAGE_NAME</replaceable> |
| 4576 | The name of the image from which to use the artifacts |
| 4577 | (e.g. <filename>core-image-sato</filename>). |
| 4578 | |
| 4579 | -r <replaceable>ROOTFS_DIR</replaceable>, --rootfs-dir=<replaceable>ROOTFS_DIR</replaceable> |
| 4580 | The path to the <filename>/rootfs</filename> directory to use as the |
| 4581 | <filename>.wks</filename> rootfs source. |
| 4582 | |
| 4583 | -b <replaceable>BOOTIMG_DIR</replaceable>, --bootimg-dir=<replaceable>BOOTIMG_DIR</replaceable> |
| 4584 | The path to the directory containing the boot artifacts |
| 4585 | (e.g. <filename>/EFI</filename> or <filename>/syslinux</filename>) to use as the <filename>.wks</filename> bootimg |
| 4586 | source. |
| 4587 | |
| 4588 | -k <replaceable>KERNEL_DIR</replaceable>, --kernel-dir=<replaceable>KERNEL_DIR</replaceable> |
| 4589 | The path to the directory containing the kernel to use |
| 4590 | in the <filename>.wks</filename> boot image. |
| 4591 | |
| 4592 | -n <replaceable>NATIVE_SYSROOT</replaceable>, --native-sysroot=<replaceable>NATIVE_SYSROOT</replaceable> |
| 4593 | The path to the native sysroot containing the tools to use |
| 4594 | to build the image. |
| 4595 | |
| 4596 | -s, --skip-build-check |
| 4597 | Skips the build check. |
| 4598 | |
| 4599 | -D, --debug |
| 4600 | Output debug information. |
| 4601 | </literallayout> |
| 4602 | <note> |
| 4603 | You do not need root privileges to run |
| 4604 | <filename>wic</filename>. |
| 4605 | In fact, you should not run as root when using the |
| 4606 | utility. |
| 4607 | </note> |
| 4608 | </para> |
| 4609 | </section> |
| 4610 | |
| 4611 | <section id='cooked-mode'> |
| 4612 | <title>Cooked Mode</title> |
| 4613 | |
| 4614 | <para> |
| 4615 | The general form of the <filename>wic</filename> command |
| 4616 | using Cooked Mode is: |
| 4617 | <literallayout class='monospaced'> |
| 4618 | $ wic create <replaceable>kickstart_file</replaceable> -e <replaceable>image_name</replaceable> |
| 4619 | |
| 4620 | Where: |
| 4621 | |
| 4622 | <replaceable>kickstart_file</replaceable> |
| 4623 | An OpenEmbedded kickstart file. You can provide your own |
| 4624 | custom file or supplied file. |
| 4625 | |
| 4626 | <replaceable>image_name</replaceable> |
| 4627 | Specifies the image built using the OpenEmbedded build |
| 4628 | system. |
| 4629 | </literallayout> |
| 4630 | This form is the simplest and most user-friendly, as it |
| 4631 | does not require specifying all individual parameters. |
| 4632 | All you need to provide is your own |
| 4633 | <filename>.wks</filename> file or one provided with the |
| 4634 | release. |
| 4635 | </para> |
| 4636 | </section> |
| 4637 | </section> |
| 4638 | |
| 4639 | <section id='using-a-provided-kickstart_file'> |
| 4640 | <title>Using an Existing Kickstart File</title> |
| 4641 | |
| 4642 | <para> |
| 4643 | If you do not want to create your own |
| 4644 | <filename>.wks</filename> file, you can use an existing |
| 4645 | file provided by the <filename>wic</filename> installation. |
| 4646 | Use the following command to list the available files: |
| 4647 | <literallayout class='monospaced'> |
| 4648 | $ wic list images |
| 4649 | directdisk Create a 'pcbios' direct disk image |
| 4650 | mkefidisk Create an EFI disk image |
| 4651 | </literallayout> |
| 4652 | When you use an existing file, you do not have to use the |
| 4653 | <filename>.wks</filename> extension. |
| 4654 | Here is an example in Raw Mode that uses the |
| 4655 | <filename>directdisk</filename> file: |
| 4656 | <literallayout class='monospaced'> |
| 4657 | $ wic create directdisk -r <replaceable>rootfs_dir</replaceable> -b <replaceable>bootimg_dir</replaceable> \ |
| 4658 | -k <replaceable>kernel_dir</replaceable> -n <replaceable>native_sysroot</replaceable> |
| 4659 | </literallayout> |
| 4660 | </para> |
| 4661 | |
| 4662 | <para> |
| 4663 | Here are the actual partition language commands |
| 4664 | used in the <filename>mkefidisk.wks</filename> file to generate |
| 4665 | an image: |
| 4666 | <literallayout class='monospaced'> |
| 4667 | # short-description: Create an EFI disk image |
| 4668 | # long-description: Creates a partitioned EFI disk image that the user |
| 4669 | # can directly dd to boot media. |
| 4670 | |
| 4671 | part /boot --source bootimg-efi --ondisk sda --label msdos --active --align 1024 |
| 4672 | |
| 4673 | part / --source rootfs --ondisk sda --fstype=ext3 --label platform --align 1024 |
| 4674 | |
| 4675 | part swap --ondisk sda --size 44 --label swap1 --fstype=swap |
| 4676 | |
| 4677 | bootloader --timeout=10 --append="rootwait rootfstype=ext3 console=ttyPCH0,115200 console=tty0 vmalloc=256MB snd-hda-intel.enable_msi=0" |
| 4678 | </literallayout> |
| 4679 | </para> |
| 4680 | </section> |
| 4681 | |
| 4682 | <section id='wic-usage-examples'> |
| 4683 | <title>Examples</title> |
| 4684 | |
| 4685 | <para> |
| 4686 | This section provides several examples that show how to use |
| 4687 | the <filename>wic</filename> utility. |
| 4688 | All the examples assume the list of requirements in the |
| 4689 | "<link linkend='wic-requirements'>Requirements</link>" section |
| 4690 | have been met. |
| 4691 | The examples assume the previously generated image is |
| 4692 | <filename>core-image-minimal</filename>. |
| 4693 | </para> |
| 4694 | |
| 4695 | <section id='generate-an-image-using-a-provided-kickstart-file'> |
| 4696 | <title>Generate an Image using an Existing Kickstart File</title> |
| 4697 | |
| 4698 | <para> |
| 4699 | This example runs in Cooked Mode and uses the |
| 4700 | <filename>mkefidisk</filename> kickstart file: |
| 4701 | <literallayout class='monospaced'> |
| 4702 | $ wic create mkefidisk -e core-image-minimal |
| 4703 | Checking basic build environment... |
| 4704 | Done. |
| 4705 | |
| 4706 | Creating image(s)... |
| 4707 | |
| 4708 | Info: The new image(s) can be found here: |
| 4709 | /var/tmp/wic/build/mkefidisk-201310230946-sda.direct |
| 4710 | |
| 4711 | The following build artifacts were used to create the image(s): |
| 4712 | ROOTFS_DIR: /home/trz/yocto/yocto-image/build/tmp/work/minnow-poky-linux/core-image-minimal/1.0-r0/rootfs |
| 4713 | BOOTIMG_DIR: /home/trz/yocto/yocto-image/build/tmp/work/minnow-poky-linux/core-image-minimal/1.0-r0/core-image-minimal-1.0/hddimg |
| 4714 | KERNEL_DIR: /home/trz/yocto/yocto-image/build/tmp/sysroots/minnow/usr/src/kernel |
| 4715 | NATIVE_SYSROOT: /home/trz/yocto/yocto-image/build/tmp/sysroots/x86_64-linux |
| 4716 | |
| 4717 | |
| 4718 | The image(s) were created using OE kickstart file: |
| 4719 | /home/trz/yocto/yocto-image/scripts/lib/image/canned-wks/mkefidisk.wks |
| 4720 | </literallayout> |
| 4721 | This example shows the easiest way to create an image |
| 4722 | by running in Cooked Mode and using the |
| 4723 | <filename>-e</filename> option with an existing kickstart |
| 4724 | file. |
| 4725 | All that is necessary is to specify the image used to |
| 4726 | generate the artifacts. |
| 4727 | Your <filename>local.conf</filename> needs to have the |
| 4728 | <ulink url='&YOCTO_DOCS_REF_URL;#var-MACHINE'><filename>MACHINE</filename></ulink> |
| 4729 | variable set to the machine you are using, which is |
| 4730 | "minnow" in this example. |
| 4731 | </para> |
| 4732 | |
| 4733 | <para> |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 4734 | The output specifies the exact image created as well as |
| 4735 | where it was created. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 4736 | The output also names the artifacts used and the exact |
| 4737 | <filename>.wks</filename> script that was used to generate |
| 4738 | the image. |
| 4739 | <note> |
| 4740 | You should always verify the details provided in the |
| 4741 | output to make sure that the image was indeed created |
| 4742 | exactly as expected. |
| 4743 | </note> |
| 4744 | </para> |
| 4745 | |
| 4746 | <para> |
| 4747 | Continuing with the example, you can now directly |
| 4748 | <filename>dd</filename> the image to a USB stick, or |
| 4749 | whatever media for which you built your image, |
| 4750 | and boot the resulting media: |
| 4751 | <literallayout class='monospaced'> |
| 4752 | $ sudo dd if=/var/tmp/wic/build/mkefidisk-201310230946-sda.direct of=/dev/sdb |
| 4753 | [sudo] password for trz: |
| 4754 | 182274+0 records in |
| 4755 | 182274+0 records out |
| 4756 | 93324288 bytes (93 MB) copied, 14.4777 s, 6.4 MB/s |
| 4757 | [trz@empanada ~]$ sudo eject /dev/sdb |
| 4758 | </literallayout> |
| 4759 | </para> |
| 4760 | </section> |
| 4761 | |
| 4762 | <section id='using-a-modified-kickstart-file'> |
| 4763 | <title>Using a Modified Kickstart File</title> |
| 4764 | |
| 4765 | <para> |
| 4766 | Because <filename>wic</filename> image creation is driven |
| 4767 | by the kickstart file, it is easy to affect image creation |
| 4768 | by changing the parameters in the file. |
| 4769 | This next example demonstrates that through modification |
| 4770 | of the <filename>directdisk</filename> kickstart file. |
| 4771 | </para> |
| 4772 | |
| 4773 | <para> |
| 4774 | As mentioned earlier, you can use the command |
| 4775 | <filename>wic list images</filename> to show the list |
| 4776 | of existing kickstart files. |
| 4777 | The directory in which these files reside is |
| 4778 | <filename>scripts/lib/image/canned-wks/</filename> |
| 4779 | located in the |
| 4780 | <link linkend='source-directory'>Source Directory</link>. |
| 4781 | Because the available files reside in this directory, you |
| 4782 | can create and add your own custom files to the directory. |
| 4783 | Subsequent use of the <filename>wic list images</filename> |
| 4784 | command would then include your kickstart files. |
| 4785 | </para> |
| 4786 | |
| 4787 | <para> |
| 4788 | In this example, the existing |
| 4789 | <filename>directdisk</filename> file already does most |
| 4790 | of what is needed. |
| 4791 | However, for the hardware in this example, the image will |
| 4792 | need to boot from <filename>sdb</filename> instead of |
| 4793 | <filename>sda</filename>, which is what the |
| 4794 | <filename>directdisk</filename> kickstart file uses. |
| 4795 | </para> |
| 4796 | |
| 4797 | <para> |
| 4798 | The example begins by making a copy of the |
| 4799 | <filename>directdisk.wks</filename> file in the |
| 4800 | <filename>scripts/lib/image/canned-wks</filename> |
| 4801 | directory and then changing the lines that specify the |
| 4802 | target disk from which to boot. |
| 4803 | <literallayout class='monospaced'> |
| 4804 | $ cp /home/trz/yocto/yocto-image/scripts/lib/image/canned-wks/directdisk.wks \ |
| 4805 | /home/trz/yocto/yocto-image/scripts/lib/image/canned-wks/directdisksdb.wks |
| 4806 | </literallayout> |
| 4807 | Next, the example modifies the |
| 4808 | <filename>directdisksdb.wks</filename> file and changes all |
| 4809 | instances of "<filename>--ondisk sda</filename>" |
| 4810 | to "<filename>--ondisk sdb</filename>". |
| 4811 | The example changes the following two lines and leaves the |
| 4812 | remaining lines untouched: |
| 4813 | <literallayout class='monospaced'> |
| 4814 | part /boot --source bootimg-pcbios --ondisk sdb --label boot --active --align 1024 |
| 4815 | part / --source rootfs --ondisk sdb --fstype=ext3 --label platform --align 1024 |
| 4816 | </literallayout> |
| 4817 | Once the lines are changed, the example generates the |
| 4818 | <filename>directdisksdb</filename> image. |
| 4819 | The command points the process at the |
| 4820 | <filename>core-image-minimal</filename> artifacts for the |
| 4821 | Next Unit of Computing (nuc) |
| 4822 | <ulink url='&YOCTO_DOCS_REF_URL;#var-MACHINE'><filename>MACHINE</filename></ulink> |
| 4823 | the <filename>local.conf</filename>. |
| 4824 | <literallayout class='monospaced'> |
| 4825 | $ wic create directdisksdb -e core-image-minimal |
| 4826 | Checking basic build environment... |
| 4827 | Done. |
| 4828 | |
| 4829 | Creating image(s)... |
| 4830 | |
| 4831 | Info: The new image(s) can be found here: |
| 4832 | /var/tmp/wic/build/directdisksdb-201310231131-sdb.direct |
| 4833 | |
| 4834 | The following build artifacts were used to create the image(s): |
| 4835 | ROOTFS_DIR: /home/trz/yocto/yocto-image/build/tmp/work/nuc-poky-linux/core-image-minimal/1.0-r0/rootfs |
| 4836 | BOOTIMG_DIR: /home/trz/yocto/yocto-image/build/tmp/sysroots/nuc/usr/share |
| 4837 | KERNEL_DIR: /home/trz/yocto/yocto-image/build/tmp/sysroots/nuc/usr/src/kernel |
| 4838 | NATIVE_SYSROOT: /home/trz/yocto/yocto-image/build/tmp/sysroots/x86_64-linux |
| 4839 | |
| 4840 | |
| 4841 | The image(s) were created using OE kickstart file: |
| 4842 | /home/trz/yocto/yocto-image/scripts/lib/image/canned-wks/directdisksdb.wks |
| 4843 | </literallayout> |
| 4844 | Continuing with the example, you can now directly |
| 4845 | <filename>dd</filename> the image to a USB stick, or |
| 4846 | whatever media for which you built your image, |
| 4847 | and boot the resulting media: |
| 4848 | <literallayout class='monospaced'> |
| 4849 | $ sudo dd if=/var/tmp/wic/build/directdisksdb-201310231131-sdb.direct of=/dev/sdb |
| 4850 | 86018+0 records in |
| 4851 | 86018+0 records out |
| 4852 | 44041216 bytes (44 MB) copied, 13.0734 s, 3.4 MB/s |
| 4853 | [trz@empanada tmp]$ sudo eject /dev/sdb |
| 4854 | </literallayout> |
| 4855 | </para> |
| 4856 | </section> |
| 4857 | |
| 4858 | <section id='creating-an-image-based-on-core-image-minimal-and-crownbay-noemgd'> |
| 4859 | <title>Creating an Image Based on <filename>core-image-minimal</filename> and <filename>crownbay-noemgd</filename></title> |
| 4860 | |
| 4861 | <para> |
| 4862 | This example creates an image based on |
| 4863 | <filename>core-image-minimal</filename> and a |
| 4864 | <filename>crownbay-noemgd</filename> |
| 4865 | <ulink url='&YOCTO_DOCS_REF_URL;#var-MACHINE'><filename>MACHINE</filename></ulink> |
| 4866 | that works right out of the box. |
| 4867 | <literallayout class='monospaced'> |
| 4868 | $ wic create directdisk -e core-image-minimal |
| 4869 | |
| 4870 | Checking basic build environment... |
| 4871 | Done. |
| 4872 | |
| 4873 | Creating image(s)... |
| 4874 | |
| 4875 | Info: The new image(s) can be found here: |
| 4876 | /var/tmp/wic/build/directdisk-201309252350-sda.direct |
| 4877 | |
| 4878 | The following build artifacts were used to create the image(s): |
| 4879 | |
| 4880 | ROOTFS_DIR: /home/trz/yocto/yocto-image/build/tmp/work/crownbay_noemgd-poky-linux/core-image-minimal/1.0-r0/rootfs |
| 4881 | BOOTIMG_DIR: /home/trz/yocto/yocto-image/build/tmp/sysroots/crownbay-noemgd/usr/share |
| 4882 | KERNEL_DIR: /home/trz/yocto/yocto-image/build/tmp/sysroots/crownbay-noemgd/usr/src/kernel |
| 4883 | NATIVE_SYSROOT: /home/trz/yocto/yocto-image/build/tmp/sysroots/crownbay-noemgd/usr/src/kernel |
| 4884 | |
| 4885 | The image(s) were created using OE kickstart file: |
| 4886 | /home/trz/yocto/yocto-image/scripts/lib/image/canned-wks/directdisk.wks |
| 4887 | </literallayout> |
| 4888 | </para> |
| 4889 | </section> |
| 4890 | |
| 4891 | <section id='using-a-modified-kickstart-file-and-running-in-raw-mode'> |
| 4892 | <title>Using a Modified Kickstart File and Running in Raw Mode</title> |
| 4893 | |
| 4894 | <para> |
| 4895 | This next example manually specifies each build artifact |
| 4896 | (runs in Raw Mode) and uses a modified kickstart file. |
| 4897 | The example also uses the <filename>-o</filename> option |
| 4898 | to cause <filename>wic</filename> to create the output |
| 4899 | somewhere other than the default |
| 4900 | <filename>/var/tmp/wic</filename> directory: |
| 4901 | <literallayout class='monospaced'> |
| 4902 | $ wic create ~/test.wks -o /home/trz/testwic --rootfs-dir \ |
| 4903 | /home/trz/yocto/yocto-image/build/tmp/work/crownbay_noemgd-poky-linux/core-image-minimal/1.0-r0/rootfs \ |
| 4904 | --bootimg-dir /home/trz/yocto/yocto-image/build/tmp/sysroots/crownbay-noemgd/usr/share \ |
| 4905 | --kernel-dir /home/trz/yocto/yocto-image/build/tmp/sysroots/crownbay-noemgd/usr/src/kernel \ |
| 4906 | --native-sysroot /home/trz/yocto/yocto-image/build/tmp/sysroots/x86_64-linux |
| 4907 | |
| 4908 | Creating image(s)... |
| 4909 | |
| 4910 | Info: The new image(s) can be found here: |
| 4911 | /home/trz/testwic/build/test-201309260032-sda.direct |
| 4912 | |
| 4913 | The following build artifacts were used to create the image(s): |
| 4914 | |
| 4915 | ROOTFS_DIR: /home/trz/yocto/yocto-image/build/tmp/work/crownbay_noemgd-poky-linux/core-image-minimal/1.0-r0/rootfs |
| 4916 | BOOTIMG_DIR: /home/trz/yocto/yocto-image/build/tmp/sysroots/crownbay-noemgd/usr/share |
| 4917 | KERNEL_DIR: /home/trz/yocto/yocto-image/build/tmp/sysroots/crownbay-noemgd/usr/src/kernel |
| 4918 | NATIVE_SYSROOT: /home/trz/yocto/yocto-image/build/tmp/sysroots/crownbay-noemgd/usr/src/kernel |
| 4919 | |
| 4920 | The image(s) were created using OE kickstart file: |
| 4921 | /home/trz/test.wks |
| 4922 | </literallayout> |
| 4923 | For this example, |
| 4924 | <ulink url='&YOCTO_DOCS_REF_URL;#var-MACHINE'><filename>MACHINE</filename></ulink> |
| 4925 | did not have to be specified in the |
| 4926 | <filename>local.conf</filename> file since the artifact is |
| 4927 | manually specified. |
| 4928 | </para> |
| 4929 | </section> |
| 4930 | </section> |
| 4931 | |
| 4932 | <section id='openembedded-kickstart-plugins'> |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame^] | 4933 | <title>Plug-ins</title> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 4934 | |
| 4935 | <para> |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame^] | 4936 | Plug-ins allow <filename>wic</filename> functionality to |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 4937 | be extended and specialized by users. |
| 4938 | This section documents the plugin interface, which is |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame^] | 4939 | currently restricted to source plug ins. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 4940 | </para> |
| 4941 | |
| 4942 | <para> |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame^] | 4943 | Source plug ins provide a mechanism to customize |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 4944 | various aspects of the image generation process in |
| 4945 | <filename>wic</filename>, mainly the contents of |
| 4946 | partitions. |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame^] | 4947 | The plug ins provide a mechanism for mapping values |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 4948 | specified in <filename>.wks</filename> files using the |
| 4949 | <filename>--source</filename> keyword to a |
| 4950 | particular plugin implementation that populates a |
| 4951 | corresponding partition. |
| 4952 | </para> |
| 4953 | |
| 4954 | <para> |
| 4955 | A source plugin is created as a subclass of |
| 4956 | <filename>SourcePlugin</filename>. |
| 4957 | The plugin file containing it is added to |
Patrick Williams | f1e5d69 | 2016-03-30 15:21:19 -0500 | [diff] [blame] | 4958 | <filename>scripts/lib/wic/plugins/source/</filename> to |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 4959 | make the plugin implementation available to the |
| 4960 | <filename>wic</filename> implementation. |
| 4961 | For more information, see |
Patrick Williams | f1e5d69 | 2016-03-30 15:21:19 -0500 | [diff] [blame] | 4962 | <filename>scripts/lib/wic/pluginbase.py</filename>. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 4963 | </para> |
| 4964 | |
| 4965 | <para> |
| 4966 | Source plugins can also be implemented and added by |
| 4967 | external layers. |
| 4968 | As such, any plugins found in a |
Patrick Williams | f1e5d69 | 2016-03-30 15:21:19 -0500 | [diff] [blame] | 4969 | <filename>scripts/lib/wic/plugins/source/</filename> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 4970 | directory in an external layer are also made |
| 4971 | available. |
| 4972 | </para> |
| 4973 | |
| 4974 | <para> |
| 4975 | When the <filename>wic</filename> implementation needs |
| 4976 | to invoke a partition-specific implementation, it looks |
| 4977 | for the plugin that has the same name as the |
| 4978 | <filename>--source</filename> parameter given to |
| 4979 | that partition. |
| 4980 | For example, if the partition is set up as follows: |
| 4981 | <literallayout class='monospaced'> |
| 4982 | part /boot --source bootimg-pcbios ... |
| 4983 | </literallayout> |
| 4984 | The methods defined as class members of the plugin |
| 4985 | having the matching <filename>bootimg-pcbios.name</filename> |
| 4986 | class member are used. |
| 4987 | </para> |
| 4988 | |
| 4989 | <para> |
| 4990 | To be more concrete, here is the plugin definition that |
| 4991 | matches a |
| 4992 | <filename>--source bootimg-pcbios</filename> usage, |
| 4993 | along with an example |
| 4994 | method called by the <filename>wic</filename> implementation |
| 4995 | when it needs to invoke an implementation-specific |
| 4996 | partition-preparation function: |
| 4997 | <literallayout class='monospaced'> |
| 4998 | class BootimgPcbiosPlugin(SourcePlugin): |
| 4999 | name = 'bootimg-pcbios' |
| 5000 | |
| 5001 | @classmethod |
| 5002 | def do_prepare_partition(self, part, ...) |
| 5003 | </literallayout> |
| 5004 | If the subclass itself does not implement a function, a |
| 5005 | default version in a superclass is located and |
| 5006 | used, which is why all plugins must be derived from |
| 5007 | <filename>SourcePlugin</filename>. |
| 5008 | </para> |
| 5009 | |
| 5010 | <para> |
| 5011 | The <filename>SourcePlugin</filename> class defines the |
| 5012 | following methods, which is the current set of methods |
| 5013 | that can be implemented or overridden by |
| 5014 | <filename>--source</filename> plugins. |
| 5015 | Any methods not implemented by a |
| 5016 | <filename>SourcePlugin</filename> subclass inherit the |
| 5017 | implementations present in the |
| 5018 | <filename>SourcePlugin</filename> class. |
| 5019 | For more information, see the |
| 5020 | <filename>SourcePlugin</filename> source for details: |
| 5021 | </para> |
| 5022 | |
| 5023 | <para> |
| 5024 | <itemizedlist> |
| 5025 | <listitem><para><emphasis><filename>do_prepare_partition()</filename>:</emphasis> |
| 5026 | Called to do the actual content population for a |
| 5027 | partition. |
| 5028 | In other words, the method prepares the final |
| 5029 | partition image that is incorporated into the |
| 5030 | disk image. |
| 5031 | </para></listitem> |
| 5032 | <listitem><para><emphasis><filename>do_configure_partition()</filename>:</emphasis> |
| 5033 | Called before |
| 5034 | <filename>do_prepare_partition()</filename>. |
| 5035 | This method is typically used to create custom |
| 5036 | configuration files for a partition (e.g. syslinux or |
| 5037 | grub configuration files). |
| 5038 | </para></listitem> |
| 5039 | <listitem><para><emphasis><filename>do_install_disk()</filename>:</emphasis> |
| 5040 | Called after all partitions have been prepared and |
| 5041 | assembled into a disk image. |
| 5042 | This method provides a hook to allow finalization of a |
| 5043 | disk image, (e.g. writing an MBR). |
| 5044 | </para></listitem> |
| 5045 | <listitem><para><emphasis><filename>do_stage_partition()</filename>:</emphasis> |
| 5046 | Special content-staging hook called before |
| 5047 | <filename>do_prepare_partition()</filename>. |
| 5048 | This method is normally empty.</para> |
| 5049 | <para>Typically, a partition just uses the passed-in |
| 5050 | parameters (e.g. the unmodified value of |
| 5051 | <filename>bootimg_dir</filename>). |
| 5052 | However, in some cases things might need to be |
| 5053 | more tailored. |
| 5054 | As an example, certain files might additionally |
| 5055 | need to be taken from |
| 5056 | <filename>bootimg_dir + /boot</filename>. |
| 5057 | This hook allows those files to be staged in a |
| 5058 | customized fashion. |
| 5059 | <note> |
| 5060 | <filename>get_bitbake_var()</filename> |
| 5061 | allows you to access non-standard variables |
| 5062 | that you might want to use for this. |
| 5063 | </note> |
| 5064 | </para></listitem> |
| 5065 | </itemizedlist> |
| 5066 | </para> |
| 5067 | |
| 5068 | <para> |
| 5069 | This scheme is extensible. |
| 5070 | Adding more hooks is a simple matter of adding more |
| 5071 | plugin methods to <filename>SourcePlugin</filename> and |
| 5072 | derived classes. |
| 5073 | The code that then needs to call the plugin methods uses |
| 5074 | <filename>plugin.get_source_plugin_methods()</filename> |
| 5075 | to find the method or methods needed by the call. |
| 5076 | Retrieval of those methods is accomplished |
| 5077 | by filling up a dict with keys |
| 5078 | containing the method names of interest. |
| 5079 | On success, these will be filled in with the actual |
| 5080 | methods. |
| 5081 | Please see the <filename>wic</filename> |
| 5082 | implementation for examples and details. |
| 5083 | </para> |
| 5084 | </section> |
| 5085 | |
| 5086 | <section id='openembedded-kickstart-wks-reference'> |
| 5087 | <title>OpenEmbedded Kickstart (.wks) Reference</title> |
| 5088 | |
| 5089 | <para> |
| 5090 | The current <filename>wic</filename> implementation supports |
| 5091 | only the basic kickstart partitioning commands: |
| 5092 | <filename>partition</filename> (or <filename>part</filename> |
| 5093 | for short) and <filename>bootloader</filename>. |
| 5094 | <note> |
| 5095 | Future updates will implement more commands and options. |
| 5096 | If you use anything that is not specifically |
| 5097 | supported, results can be unpredictable. |
| 5098 | </note> |
| 5099 | </para> |
| 5100 | |
| 5101 | <para> |
| 5102 | The following is a list of the commands, their syntax, |
| 5103 | and meanings. |
| 5104 | The commands are based on the Fedora |
| 5105 | kickstart versions but with modifications to |
| 5106 | reflect <filename>wic</filename> capabilities. |
| 5107 | You can see the original documentation for those commands |
| 5108 | at the following links: |
| 5109 | <itemizedlist> |
| 5110 | <listitem><para> |
| 5111 | <ulink url='http://fedoraproject.org/wiki/Anaconda/Kickstart#part_or_partition'>http://fedoraproject.org/wiki/Anaconda/Kickstart#part_or_partition</ulink> |
| 5112 | </para></listitem> |
| 5113 | <listitem><para> |
| 5114 | <ulink url='http://fedoraproject.org/wiki/Anaconda/Kickstart#bootloader'>http://fedoraproject.org/wiki/Anaconda/Kickstart#bootloader</ulink> |
| 5115 | </para></listitem> |
| 5116 | </itemizedlist> |
| 5117 | </para> |
| 5118 | |
| 5119 | <section id='command-part-or-partition'> |
| 5120 | <title>Command: part or partition</title> |
| 5121 | |
| 5122 | <para> |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 5123 | Either of these commands create a partition on the system |
| 5124 | and uses the following syntax: |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 5125 | <literallayout class='monospaced'> |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 5126 | part [<replaceable>mntpoint</replaceable>] |
| 5127 | partition [<replaceable>mntpoint</replaceable>] |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 5128 | </literallayout> |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 5129 | If you do not provide |
| 5130 | <replaceable>mntpoint</replaceable>, wic creates a partition |
| 5131 | but does not mount it. |
| 5132 | </para> |
| 5133 | |
| 5134 | <para> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 5135 | The <filename><replaceable>mntpoint</replaceable></filename> |
| 5136 | is where the |
| 5137 | partition will be mounted and must be of one of the |
| 5138 | following forms: |
| 5139 | <itemizedlist> |
| 5140 | <listitem><para><filename>/<replaceable>path</replaceable></filename>: |
| 5141 | For example, <filename>/</filename>, |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 5142 | <filename>/usr</filename>, or |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 5143 | <filename>/home</filename></para></listitem> |
| 5144 | <listitem><para><filename>swap</filename>: |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 5145 | The created partition is used as swap space. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 5146 | </para></listitem> |
| 5147 | </itemizedlist> |
| 5148 | </para> |
| 5149 | |
| 5150 | <para> |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 5151 | Specifying a <replaceable>mntpoint</replaceable> causes |
| 5152 | the partition to automatically be mounted. |
| 5153 | Wic achieves this by adding entries to the filesystem |
| 5154 | table (fstab) during image generation. |
| 5155 | In order for wic to generate a valid fstab, you must |
| 5156 | also provide one of the <filename>--ondrive</filename>, |
| 5157 | <filename>--ondisk</filename>, or |
| 5158 | <filename>--use-uuid</filename> partition options as part |
| 5159 | of the command. |
| 5160 | Here is an example using "/" as the mountpoint. |
| 5161 | The command uses "--ondisk" to force the partition onto |
| 5162 | the <filename>sdb</filename> disk: |
| 5163 | <literallayout class='monospaced'> |
| 5164 | part / --source rootfs --ondisk sdb --fstype=ext3 --label platform --align 1024 |
| 5165 | </literallayout> |
| 5166 | </para> |
| 5167 | |
| 5168 | <para> |
| 5169 | Here is a list that describes other supported options you |
| 5170 | can use with the <filename>part</filename> and |
| 5171 | <filename>partition</filename> commands: |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 5172 | <itemizedlist> |
| 5173 | <listitem><para><emphasis><filename>--size</filename>:</emphasis> |
| 5174 | The minimum partition size in MBytes. |
| 5175 | Specify an integer value such as 500. |
| 5176 | Do not append the number with "MB". |
| 5177 | You do not need this option if you use |
| 5178 | <filename>--source</filename>.</para></listitem> |
| 5179 | <listitem><para><emphasis><filename>--source</filename>:</emphasis> |
| 5180 | This option is a |
| 5181 | <filename>wic</filename>-specific option that |
| 5182 | names the source of the data that populates |
| 5183 | the partition. |
| 5184 | The most common value for this option is |
| 5185 | "rootfs", but you can use any value that maps to |
| 5186 | a valid source plugin. |
| 5187 | For information on the source plugins, see the |
| 5188 | "<link linkend='openembedded-kickstart-plugins'>Plugins</link>" |
| 5189 | section.</para> |
| 5190 | <para>If you use |
| 5191 | <filename>--source rootfs</filename>, |
| 5192 | <filename>wic</filename> creates a partition as |
| 5193 | large as needed and to fill it with the contents of |
| 5194 | the root filesystem pointed to by the |
| 5195 | <filename>-r</filename> command-line option |
| 5196 | or the equivalent rootfs derived from the |
| 5197 | <filename>-e</filename> command-line |
| 5198 | option. |
| 5199 | The filesystem type used to create the |
| 5200 | partition is driven by the value of the |
| 5201 | <filename>--fstype</filename> option |
| 5202 | specified for the partition. |
| 5203 | See the entry on |
| 5204 | <filename>--fstype</filename> that |
| 5205 | follows for more information. |
| 5206 | </para> |
| 5207 | <para>If you use |
| 5208 | <filename>--source <replaceable>plugin-name</replaceable></filename>, |
| 5209 | <filename>wic</filename> creates a partition as |
| 5210 | large as needed and fills it with the contents of |
| 5211 | the partition that is generated by the |
| 5212 | specified plugin name using the data pointed |
| 5213 | to by the <filename>-r</filename> command-line |
| 5214 | option or the equivalent rootfs derived from the |
| 5215 | <filename>-e</filename> command-line |
| 5216 | option. |
Patrick Williams | f1e5d69 | 2016-03-30 15:21:19 -0500 | [diff] [blame] | 5217 | Exactly what those contents and filesystem type end |
| 5218 | up being are dependent on the given plugin |
| 5219 | implementation. |
| 5220 | </para> |
| 5221 | <para>If you do not use the |
| 5222 | <filename>--source</filename> option, the |
| 5223 | <filename>wic</filename> command creates an empty |
| 5224 | partition. |
| 5225 | Consequently, you must use the |
| 5226 | <filename>--size</filename> option to specify the |
| 5227 | size of the empty partition. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 5228 | </para></listitem> |
| 5229 | <listitem><para><emphasis><filename>--ondisk</filename> or <filename>--ondrive</filename>:</emphasis> |
| 5230 | Forces the partition to be created on a particular |
| 5231 | disk.</para></listitem> |
| 5232 | <listitem><para><emphasis><filename>--fstype</filename>:</emphasis> |
| 5233 | Sets the file system type for the partition. |
| 5234 | Valid values are: |
| 5235 | <itemizedlist> |
| 5236 | <listitem><para><filename>ext4</filename> |
| 5237 | </para></listitem> |
| 5238 | <listitem><para><filename>ext3</filename> |
| 5239 | </para></listitem> |
| 5240 | <listitem><para><filename>ext2</filename> |
| 5241 | </para></listitem> |
| 5242 | <listitem><para><filename>btrfs</filename> |
| 5243 | </para></listitem> |
| 5244 | <listitem><para><filename>squashfs</filename> |
| 5245 | </para></listitem> |
| 5246 | <listitem><para><filename>swap</filename> |
| 5247 | </para></listitem> |
| 5248 | </itemizedlist></para></listitem> |
| 5249 | <listitem><para><emphasis><filename>--fsoptions</filename>:</emphasis> |
| 5250 | Specifies a free-form string of options to be |
| 5251 | used when mounting the filesystem. |
| 5252 | This string will be copied into the |
| 5253 | <filename>/etc/fstab</filename> file of the |
| 5254 | installed system and should be enclosed in |
| 5255 | quotes. |
| 5256 | If not specified, the default string |
| 5257 | is "defaults". |
| 5258 | </para></listitem> |
| 5259 | <listitem><para><emphasis><filename>--label label</filename>:</emphasis> |
| 5260 | Specifies the label to give to the filesystem to |
| 5261 | be made on the partition. |
| 5262 | If the given label is already in use by another |
| 5263 | filesystem, a new label is created for the |
| 5264 | partition.</para></listitem> |
| 5265 | <listitem><para><emphasis><filename>--active</filename>:</emphasis> |
| 5266 | Marks the partition as active.</para></listitem> |
| 5267 | <listitem><para><emphasis><filename>--align (in KBytes)</filename>:</emphasis> |
| 5268 | This option is a <filename>wic</filename>-specific |
| 5269 | option that says to start a partition on an |
| 5270 | x KBytes boundary.</para></listitem> |
Patrick Williams | f1e5d69 | 2016-03-30 15:21:19 -0500 | [diff] [blame] | 5271 | <listitem><para><emphasis><filename>--no-table</filename>:</emphasis> |
| 5272 | This option is a <filename>wic</filename>-specific |
| 5273 | option. |
| 5274 | Using the option reserves space for the partition |
| 5275 | and causes it to become populated. |
| 5276 | However, the partition is not added to the |
| 5277 | partition table. |
| 5278 | </para></listitem> |
| 5279 | <listitem><para><emphasis><filename>--extra-space</filename>:</emphasis> |
| 5280 | This option is a <filename>wic</filename>-specific |
| 5281 | option that adds extra space after the space |
| 5282 | filled by the content of the partition. |
| 5283 | The final size can go beyond the size specified |
| 5284 | by the <filename>--size</filename> option. |
| 5285 | The default value is 10 Mbytes. |
| 5286 | </para></listitem> |
| 5287 | <listitem><para><emphasis><filename>--overhead-factor</filename>:</emphasis> |
| 5288 | This option is a <filename>wic</filename>-specific |
| 5289 | option that multiplies the size of the partition by |
| 5290 | the option's value. |
| 5291 | You must supply a value greater than or equal to |
| 5292 | "1". |
| 5293 | The default value is "1.3". |
| 5294 | </para></listitem> |
| 5295 | <listitem><para><emphasis><filename>--part-type</filename>:</emphasis> |
| 5296 | This option is a <filename>wic</filename>-specific |
| 5297 | option that specifies the partition type globally |
| 5298 | unique identifier (GUID) for GPT partitions. |
| 5299 | You can find the list of partition type GUIDs |
| 5300 | at |
| 5301 | <ulink url='http://en.wikipedia.org/wiki/GUID_Partition_Table#Partition_type_GUIDs'></ulink>. |
| 5302 | </para></listitem> |
| 5303 | <listitem><para><emphasis><filename>--use-uuid</filename>:</emphasis> |
| 5304 | This option is a <filename>wic</filename>-specific |
| 5305 | option that causes <filename>wic</filename> to |
| 5306 | generate a random GUID for the partition. |
| 5307 | The generated identifier is used in the bootloader |
| 5308 | configuration to specify the root partition. |
| 5309 | </para></listitem> |
| 5310 | <listitem><para><emphasis><filename>--uuid</filename>:</emphasis> |
| 5311 | This option is a <filename>wic</filename>-specific |
| 5312 | option that specifies the partition UUID. |
| 5313 | </para></listitem> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 5314 | </itemizedlist> |
| 5315 | </para> |
| 5316 | </section> |
| 5317 | |
| 5318 | <section id='command-bootloader'> |
| 5319 | <title>Command: bootloader</title> |
| 5320 | |
| 5321 | <para> |
| 5322 | This command specifies how the boot loader should be |
| 5323 | configured and supports the following options: |
| 5324 | <note> |
| 5325 | Bootloader functionality and boot partitions are |
| 5326 | implemented by the various |
| 5327 | <filename>--source</filename> |
| 5328 | plugins that implement bootloader functionality. |
| 5329 | The bootloader command essentially provides a means of |
| 5330 | modifying bootloader configuration. |
| 5331 | </note> |
| 5332 | <itemizedlist> |
| 5333 | <listitem><para><emphasis><filename>--timeout</filename>:</emphasis> |
| 5334 | Specifies the number of seconds before the |
| 5335 | bootloader times out and boots the default option. |
| 5336 | </para></listitem> |
| 5337 | <listitem><para><emphasis><filename>--append</filename>:</emphasis> |
| 5338 | Specifies kernel parameters. |
| 5339 | These parameters will be added to the syslinux |
| 5340 | <filename>APPEND</filename> or |
| 5341 | <filename>grub</filename> kernel command line. |
| 5342 | </para></listitem> |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 5343 | <listitem><para><emphasis><filename>--configfile</filename>:</emphasis> |
| 5344 | Specifies a user-defined configuration file for |
| 5345 | the bootloader. |
| 5346 | You can provide a full pathname for the file or |
| 5347 | a file that exists in the |
| 5348 | <filename>canned-wks</filename> folder. |
| 5349 | This option overrides all other bootloader options. |
| 5350 | </para></listitem> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 5351 | </itemizedlist> |
| 5352 | </para> |
| 5353 | </section> |
| 5354 | </section> |
| 5355 | </section> |
| 5356 | |
| 5357 | <section id='configuring-the-kernel'> |
| 5358 | <title>Configuring the Kernel</title> |
| 5359 | |
| 5360 | <para> |
| 5361 | Configuring the Yocto Project kernel consists of making sure the |
| 5362 | <filename>.config</filename> file has all the right information |
| 5363 | in it for the image you are building. |
| 5364 | You can use the <filename>menuconfig</filename> tool and |
| 5365 | configuration fragments to make sure your |
| 5366 | <filename>.config</filename> file is just how you need it. |
| 5367 | You can also save known configurations in a |
| 5368 | <filename>defconfig</filename> file that the build system can use |
| 5369 | for kernel configuration. |
| 5370 | </para> |
| 5371 | |
| 5372 | <para> |
| 5373 | This section describes how to use <filename>menuconfig</filename>, |
| 5374 | create and use configuration fragments, and how to interactively |
| 5375 | modify your <filename>.config</filename> file to create the |
| 5376 | leanest kernel configuration file possible. |
| 5377 | </para> |
| 5378 | |
| 5379 | <para> |
| 5380 | For more information on kernel configuration, see the |
| 5381 | "<ulink url='&YOCTO_DOCS_KERNEL_DEV_URL;#changing-the-configuration'>Changing the Configuration</ulink>" |
| 5382 | section in the Yocto Project Linux Kernel Development Manual. |
| 5383 | </para> |
| 5384 | |
| 5385 | <section id='using-menuconfig'> |
| 5386 | <title>Using <filename>menuconfig</filename></title> |
| 5387 | |
| 5388 | <para> |
| 5389 | The easiest way to define kernel configurations is to set them through the |
| 5390 | <filename>menuconfig</filename> tool. |
| 5391 | This tool provides an interactive method with which |
| 5392 | to set kernel configurations. |
| 5393 | For general information on <filename>menuconfig</filename>, see |
| 5394 | <ulink url='http://en.wikipedia.org/wiki/Menuconfig'></ulink>. |
| 5395 | </para> |
| 5396 | |
| 5397 | <para> |
| 5398 | To use the <filename>menuconfig</filename> tool in the Yocto Project development |
| 5399 | environment, you must launch it using BitBake. |
| 5400 | Thus, the environment must be set up using the |
| 5401 | <ulink url='&YOCTO_DOCS_REF_URL;#structure-core-script'><filename>&OE_INIT_FILE;</filename></ulink> |
| 5402 | or |
| 5403 | <ulink url='&YOCTO_DOCS_REF_URL;#structure-memres-core-script'><filename>oe-init-build-env-memres</filename></ulink> |
| 5404 | script found in the |
| 5405 | <link linkend='build-directory'>Build Directory</link>. |
| 5406 | You must also be sure of the state of your build in the |
| 5407 | <link linkend='source-directory'>Source Directory</link>. |
| 5408 | The following commands run <filename>menuconfig</filename> |
| 5409 | assuming the Source Directory's top-level folder is |
| 5410 | <filename>~/poky</filename>: |
| 5411 | <literallayout class='monospaced'> |
| 5412 | $ cd poky |
| 5413 | $ source oe-init-build-env |
| 5414 | $ bitbake linux-yocto -c kernel_configme -f |
| 5415 | $ bitbake linux-yocto -c menuconfig |
| 5416 | </literallayout> |
| 5417 | Once <filename>menuconfig</filename> comes up, its standard |
| 5418 | interface allows you to interactively examine and configure |
| 5419 | all the kernel configuration parameters. |
| 5420 | After making your changes, simply exit the tool and save your |
| 5421 | changes to create an updated version of the |
| 5422 | <filename>.config</filename> configuration file. |
| 5423 | </para> |
| 5424 | |
| 5425 | <para> |
| 5426 | Consider an example that configures the <filename>linux-yocto-3.14</filename> |
| 5427 | kernel. |
| 5428 | The OpenEmbedded build system recognizes this kernel as |
| 5429 | <filename>linux-yocto</filename>. |
| 5430 | Thus, the following commands from the shell in which you previously sourced the |
| 5431 | environment initialization script cleans the shared state cache and the |
| 5432 | <ulink url='&YOCTO_DOCS_REF_URL;#var-WORKDIR'><filename>WORKDIR</filename></ulink> |
| 5433 | directory and then runs <filename>menuconfig</filename>: |
| 5434 | <literallayout class='monospaced'> |
| 5435 | $ bitbake linux-yocto -c menuconfig |
| 5436 | </literallayout> |
| 5437 | </para> |
| 5438 | |
| 5439 | <para> |
| 5440 | Once <filename>menuconfig</filename> launches, use the interface |
| 5441 | to navigate through the selections to find the configuration settings in |
| 5442 | which you are interested. |
| 5443 | For example, consider the <filename>CONFIG_SMP</filename> configuration setting. |
| 5444 | You can find it at <filename>Processor Type and Features</filename> under |
| 5445 | the configuration selection <filename>Symmetric Multi-processing Support</filename>. |
| 5446 | After highlighting the selection, use the arrow keys to select or deselect |
| 5447 | the setting. |
| 5448 | When you are finished with all your selections, exit out and save them. |
| 5449 | </para> |
| 5450 | |
| 5451 | <para> |
| 5452 | Saving the selections updates the <filename>.config</filename> configuration file. |
| 5453 | This is the file that the OpenEmbedded build system uses to configure the |
| 5454 | kernel during the build. |
| 5455 | You can find and examine this file in the Build Directory in |
| 5456 | <filename>tmp/work/</filename>. |
| 5457 | The actual <filename>.config</filename> is located in the area where the |
| 5458 | specific kernel is built. |
| 5459 | For example, if you were building a Linux Yocto kernel based on the |
| 5460 | Linux 3.14 kernel and you were building a QEMU image targeted for |
| 5461 | <filename>x86</filename> architecture, the |
| 5462 | <filename>.config</filename> file would be located here: |
| 5463 | <literallayout class='monospaced'> |
| 5464 | poky/build/tmp/work/qemux86-poky-linux/linux-yocto-3.14.11+git1+84f... |
| 5465 | ...656ed30-r1/linux-qemux86-standard-build |
| 5466 | </literallayout> |
| 5467 | <note> |
| 5468 | The previous example directory is artificially split and many of the characters |
| 5469 | in the actual filename are omitted in order to make it more readable. |
| 5470 | Also, depending on the kernel you are using, the exact pathname |
| 5471 | for <filename>linux-yocto-3.14...</filename> might differ. |
| 5472 | </note> |
| 5473 | </para> |
| 5474 | |
| 5475 | <para> |
| 5476 | Within the <filename>.config</filename> file, you can see the kernel settings. |
| 5477 | For example, the following entry shows that symmetric multi-processor support |
| 5478 | is not set: |
| 5479 | <literallayout class='monospaced'> |
| 5480 | # CONFIG_SMP is not set |
| 5481 | </literallayout> |
| 5482 | </para> |
| 5483 | |
| 5484 | <para> |
| 5485 | A good method to isolate changed configurations is to use a combination of the |
| 5486 | <filename>menuconfig</filename> tool and simple shell commands. |
| 5487 | Before changing configurations with <filename>menuconfig</filename>, copy the |
| 5488 | existing <filename>.config</filename> and rename it to something else, |
| 5489 | use <filename>menuconfig</filename> to make |
| 5490 | as many changes as you want and save them, then compare the renamed configuration |
| 5491 | file against the newly created file. |
| 5492 | You can use the resulting differences as your base to create configuration fragments |
| 5493 | to permanently save in your kernel layer. |
| 5494 | <note> |
| 5495 | Be sure to make a copy of the <filename>.config</filename> and don't just |
| 5496 | rename it. |
| 5497 | The build system needs an existing <filename>.config</filename> |
| 5498 | from which to work. |
| 5499 | </note> |
| 5500 | </para> |
| 5501 | </section> |
| 5502 | |
| 5503 | <section id='creating-a-defconfig-file'> |
| 5504 | <title>Creating a <filename>defconfig</filename> File</title> |
| 5505 | |
| 5506 | <para> |
| 5507 | A <filename>defconfig</filename> file is simply a |
| 5508 | <filename>.config</filename> renamed to "defconfig". |
| 5509 | You can use a <filename>defconfig</filename> file |
| 5510 | to retain a known set of kernel configurations from which the |
| 5511 | OpenEmbedded build system can draw to create the final |
| 5512 | <filename>.config</filename> file. |
| 5513 | <note> |
| 5514 | Out-of-the-box, the Yocto Project never ships a |
| 5515 | <filename>defconfig</filename> or |
| 5516 | <filename>.config</filename> file. |
| 5517 | The OpenEmbedded build system creates the final |
| 5518 | <filename>.config</filename> file used to configure the |
| 5519 | kernel. |
| 5520 | </note> |
| 5521 | </para> |
| 5522 | |
| 5523 | <para> |
| 5524 | To create a <filename>defconfig</filename>, start with a |
| 5525 | complete, working Linux kernel <filename>.config</filename> |
| 5526 | file. |
| 5527 | Copy that file to the appropriate |
| 5528 | <filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-PN'><filename>PN</filename></ulink><filename>}</filename> |
| 5529 | directory in your layer's |
| 5530 | <filename>recipes-kernel/linux</filename> directory, and rename |
| 5531 | the copied file to "defconfig". |
| 5532 | Then, add the following lines to the linux-yocto |
| 5533 | <filename>.bbappend</filename> file in your layer: |
| 5534 | <literallayout class='monospaced'> |
| 5535 | FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:" |
| 5536 | SRC_URI += "file://defconfig" |
| 5537 | </literallayout> |
| 5538 | The |
| 5539 | <ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'><filename>SRC_URI</filename></ulink> |
| 5540 | tells the build system how to search for the file, while the |
| 5541 | <ulink url='&YOCTO_DOCS_REF_URL;#var-FILESEXTRAPATHS'><filename>FILESEXTRAPATHS</filename></ulink> |
| 5542 | extends the |
| 5543 | <ulink url='&YOCTO_DOCS_REF_URL;#var-FILESPATH'><filename>FILESPATH</filename></ulink> |
| 5544 | variable (search directories) to include the |
| 5545 | <filename>${PN}</filename> directory you created to hold the |
| 5546 | configuration changes. |
| 5547 | <note> |
| 5548 | The build system applies the configurations from the |
| 5549 | <filename>defconfig</filename> file before applying any |
| 5550 | subsequent configuration fragments. |
| 5551 | The final kernel configuration is a combination of the |
| 5552 | configurations in the <filename>defconfig</filename> |
| 5553 | file and any configuration fragments you provide. |
| 5554 | You need to realize that if you have any configuration |
| 5555 | fragments, the build system applies these on top of and |
| 5556 | after applying the existing defconfig file configurations. |
| 5557 | </note> |
| 5558 | For more information on configuring the kernel, see the |
| 5559 | "<ulink url='&YOCTO_DOCS_KERNEL_DEV_URL;#changing-the-configuration'>Changing the Configuration</ulink>" |
| 5560 | and |
| 5561 | "<ulink url='&YOCTO_DOCS_KERNEL_DEV_URL;#generating-configuration-files'>Generating Configuration Files</ulink>" |
| 5562 | sections, both in the Yocto Project Linux Kernel Development |
| 5563 | Manual. |
| 5564 | </para> |
| 5565 | </section> |
| 5566 | |
| 5567 | <section id='creating-config-fragments'> |
| 5568 | <title>Creating Configuration Fragments</title> |
| 5569 | |
| 5570 | <para> |
| 5571 | Configuration fragments are simply kernel options that appear in a file |
| 5572 | placed where the OpenEmbedded build system can find and apply them. |
| 5573 | Syntactically, the configuration statement is identical to what would appear |
| 5574 | in the <filename>.config</filename> file, which is in the |
| 5575 | <link linkend='build-directory'>Build Directory</link>: |
| 5576 | <literallayout class='monospaced'> |
| 5577 | tmp/work/<replaceable>arch</replaceable>-poky-linux/linux-yocto-<replaceable>release_specific_string</replaceable>/linux-<replaceable>arch</replaceable>-<replaceable>build_type</replaceable> |
| 5578 | </literallayout> |
| 5579 | </para> |
| 5580 | |
| 5581 | <para> |
| 5582 | It is simple to create a configuration fragment. |
| 5583 | For example, issuing the following from the shell creates a configuration fragment |
| 5584 | file named <filename>my_smp.cfg</filename> that enables multi-processor support |
| 5585 | within the kernel: |
| 5586 | <literallayout class='monospaced'> |
| 5587 | $ echo "CONFIG_SMP=y" >> my_smp.cfg |
| 5588 | </literallayout> |
| 5589 | <note> |
| 5590 | All configuration fragment files must use the |
| 5591 | <filename>.cfg</filename> extension in order for the |
| 5592 | OpenEmbedded build system to recognize them as a |
| 5593 | configuration fragment. |
| 5594 | </note> |
| 5595 | </para> |
| 5596 | |
| 5597 | <para> |
| 5598 | Where do you put your configuration fragment files? |
| 5599 | You can place these files in the same area pointed to by |
| 5600 | <ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'><filename>SRC_URI</filename></ulink>. |
| 5601 | The OpenEmbedded build system picks up the configuration and |
| 5602 | adds it to the kernel's configuration. |
| 5603 | For example, suppose you had a set of configuration options |
| 5604 | in a file called <filename>myconfig.cfg</filename>. |
| 5605 | If you put that file inside a directory named |
| 5606 | <filename>linux-yocto</filename> that resides in the same |
| 5607 | directory as the kernel's append file and then add a |
| 5608 | <filename>SRC_URI</filename> statement such as the following |
| 5609 | to the kernel's append file, those configuration options |
| 5610 | will be picked up and applied when the kernel is built. |
| 5611 | <literallayout class='monospaced'> |
| 5612 | SRC_URI += "file://myconfig.cfg" |
| 5613 | </literallayout> |
| 5614 | </para> |
| 5615 | |
| 5616 | <para> |
| 5617 | As mentioned earlier, you can group related configurations into multiple files and |
| 5618 | name them all in the <filename>SRC_URI</filename> statement as well. |
| 5619 | For example, you could group separate configurations specifically for Ethernet and graphics |
| 5620 | into their own files and add those by using a <filename>SRC_URI</filename> statement like the |
| 5621 | following in your append file: |
| 5622 | <literallayout class='monospaced'> |
| 5623 | SRC_URI += "file://myconfig.cfg \ |
| 5624 | file://eth.cfg \ |
| 5625 | file://gfx.cfg" |
| 5626 | </literallayout> |
| 5627 | </para> |
| 5628 | </section> |
| 5629 | |
| 5630 | <section id='fine-tuning-the-kernel-configuration-file'> |
| 5631 | <title>Fine-Tuning the Kernel Configuration File</title> |
| 5632 | |
| 5633 | <para> |
| 5634 | You can make sure the <filename>.config</filename> file is as lean or efficient as |
| 5635 | possible by reading the output of the kernel configuration fragment audit, |
| 5636 | noting any issues, making changes to correct the issues, and then repeating. |
| 5637 | </para> |
| 5638 | |
| 5639 | <para> |
| 5640 | As part of the kernel build process, the |
| 5641 | <filename>do_kernel_configcheck</filename> task runs. |
| 5642 | This task validates the kernel configuration by checking the final |
| 5643 | <filename>.config</filename> file against the input files. |
| 5644 | During the check, the task produces warning messages for the following |
| 5645 | issues: |
| 5646 | <itemizedlist> |
| 5647 | <listitem><para>Requested options that did not make the final |
| 5648 | <filename>.config</filename> file.</para></listitem> |
| 5649 | <listitem><para>Configuration items that appear twice in the same |
| 5650 | configuration fragment.</para></listitem> |
| 5651 | <listitem><para>Configuration items tagged as "required" that were overridden. |
| 5652 | </para></listitem> |
| 5653 | <listitem><para>A board overrides a non-board specific option.</para></listitem> |
| 5654 | <listitem><para>Listed options not valid for the kernel being processed. |
| 5655 | In other words, the option does not appear anywhere.</para></listitem> |
| 5656 | </itemizedlist> |
| 5657 | <note> |
| 5658 | The <filename>do_kernel_configcheck</filename> task can |
| 5659 | also optionally report if an option is overridden during |
| 5660 | processing. |
| 5661 | </note> |
| 5662 | </para> |
| 5663 | |
| 5664 | <para> |
| 5665 | For each output warning, a message points to the file |
| 5666 | that contains a list of the options and a pointer to the |
| 5667 | configuration fragment that defines them. |
| 5668 | Collectively, the files are the key to streamlining the |
| 5669 | configuration. |
| 5670 | </para> |
| 5671 | |
| 5672 | <para> |
| 5673 | To streamline the configuration, do the following: |
| 5674 | <orderedlist> |
| 5675 | <listitem><para>Start with a full configuration that you |
| 5676 | know works - it builds and boots successfully. |
| 5677 | This configuration file will be your baseline. |
| 5678 | </para></listitem> |
| 5679 | <listitem><para>Separately run the |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 5680 | <filename>do_kernel_configme</filename> and |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 5681 | <filename>do_kernel_configcheck</filename> tasks. |
| 5682 | </para></listitem> |
| 5683 | <listitem><para>Take the resulting list of files from the |
| 5684 | <filename>do_kernel_configcheck</filename> task |
| 5685 | warnings and do the following: |
| 5686 | <itemizedlist> |
| 5687 | <listitem><para> |
| 5688 | Drop values that are redefined in the fragment |
| 5689 | but do not change the final |
| 5690 | <filename>.config</filename> file. |
| 5691 | </para></listitem> |
| 5692 | <listitem><para> |
| 5693 | Analyze and potentially drop values from the |
| 5694 | <filename>.config</filename> file that override |
| 5695 | required configurations. |
| 5696 | </para></listitem> |
| 5697 | <listitem><para> |
| 5698 | Analyze and potentially remove non-board |
| 5699 | specific options. |
| 5700 | </para></listitem> |
| 5701 | <listitem><para> |
| 5702 | Remove repeated and invalid options. |
| 5703 | </para></listitem> |
| 5704 | </itemizedlist></para></listitem> |
| 5705 | <listitem><para> |
| 5706 | After you have worked through the output of the kernel |
| 5707 | configuration audit, you can re-run the |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 5708 | <filename>do_kernel_configme</filename> and |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 5709 | <filename>do_kernel_configcheck</filename> tasks to |
| 5710 | see the results of your changes. |
| 5711 | If you have more issues, you can deal with them as |
| 5712 | described in the previous step. |
| 5713 | </para></listitem> |
| 5714 | </orderedlist> |
| 5715 | </para> |
| 5716 | |
| 5717 | <para> |
| 5718 | Iteratively working through steps two through four eventually yields |
| 5719 | a minimal, streamlined configuration file. |
| 5720 | Once you have the best <filename>.config</filename>, you can build the Linux |
| 5721 | Yocto kernel. |
| 5722 | </para> |
| 5723 | </section> |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 5724 | |
| 5725 | <section id='determining-hardware-and-non-hardware-features-for-the-kernel-configuration-audit-phase'> |
| 5726 | <title>Determining Hardware and Non-Hardware Features for the Kernel Configuration Audit Phase</title> |
| 5727 | |
| 5728 | <para> |
| 5729 | This section describes part of the kernel configuration audit |
| 5730 | phase that most developers can ignore. |
| 5731 | During this part of the audit phase, the contents of the final |
| 5732 | <filename>.config</filename> file are compared against the |
| 5733 | fragments specified by the system. |
| 5734 | These fragments can be system fragments, distro fragments, |
| 5735 | or user specified configuration elements. |
| 5736 | Regardless of their origin, the OpenEmbedded build system |
| 5737 | warns the user if a specific option is not included in the |
| 5738 | final kernel configuration. |
| 5739 | </para> |
| 5740 | |
| 5741 | <para> |
| 5742 | In order to not overwhelm the user with configuration warnings, |
| 5743 | by default the system only reports on missing "hardware" |
| 5744 | options because a missing hardware option could mean a boot |
| 5745 | failure or that important hardware is not available. |
| 5746 | </para> |
| 5747 | |
| 5748 | <para> |
| 5749 | To determine whether or not a given option is "hardware" or |
| 5750 | "non-hardware", the kernel Metadata contains files that |
| 5751 | classify individual or groups of options as either hardware |
| 5752 | or non-hardware. |
| 5753 | To better show this, consider a situation where the |
| 5754 | Yocto Project kernel cache contains the following files: |
| 5755 | <literallayout class='monospaced'> |
| 5756 | kernel-cache/features/drm-psb/hardware.cfg |
| 5757 | kernel-cache/features/kgdb/hardware.cfg |
| 5758 | kernel-cache/ktypes/base/hardware.cfg |
| 5759 | kernel-cache/bsp/mti-malta32/hardware.cfg |
| 5760 | kernel-cache/bsp/fsl-mpc8315e-rdb/hardware.cfg |
| 5761 | kernel-cache/bsp/qemu-ppc32/hardware.cfg |
| 5762 | kernel-cache/bsp/qemuarma9/hardware.cfg |
| 5763 | kernel-cache/bsp/mti-malta64/hardware.cfg |
| 5764 | kernel-cache/bsp/arm-versatile-926ejs/hardware.cfg |
| 5765 | kernel-cache/bsp/common-pc/hardware.cfg |
| 5766 | kernel-cache/bsp/common-pc-64/hardware.cfg |
| 5767 | kernel-cache/features/rfkill/non-hardware.cfg |
| 5768 | kernel-cache/ktypes/base/non-hardware.cfg |
| 5769 | kernel-cache/features/aufs/non-hardware.kcf |
| 5770 | kernel-cache/features/ocf/non-hardware.kcf |
| 5771 | kernel-cache/ktypes/base/non-hardware.kcf |
| 5772 | kernel-cache/ktypes/base/hardware.kcf |
| 5773 | kernel-cache/bsp/qemu-ppc32/hardware.kcf |
| 5774 | </literallayout> |
| 5775 | The following list provides explanations for the various |
| 5776 | files: |
| 5777 | <itemizedlist> |
| 5778 | <listitem><para><filename>hardware.kcf</filename>: |
| 5779 | Specifies a list of kernel Kconfig files that contain |
| 5780 | hardware options only. |
| 5781 | </para></listitem> |
| 5782 | <listitem><para><filename>non-hardware.kcf</filename>: |
| 5783 | Specifies a list of kernel Kconfig files that contain |
| 5784 | non-hardware options only. |
| 5785 | </para></listitem> |
| 5786 | <listitem><para><filename>hardware.cfg</filename>: |
| 5787 | Specifies a list of kernel |
| 5788 | <filename>CONFIG_</filename> options that are hardware, |
| 5789 | regardless of whether or not they are within a Kconfig |
| 5790 | file specified by a hardware or non-hardware |
| 5791 | Kconfig file (i.e. <filename>hardware.kcf</filename> or |
| 5792 | <filename>non-hardware.kcf</filename>). |
| 5793 | </para></listitem> |
| 5794 | <listitem><para><filename>non-hardware.cfg</filename>: |
| 5795 | Specifies a list of kernel |
| 5796 | <filename>CONFIG_</filename> options that are |
| 5797 | not hardware, regardless of whether or not they are |
| 5798 | within a Kconfig file specified by a hardware or |
| 5799 | non-hardware Kconfig file (i.e. |
| 5800 | <filename>hardware.kcf</filename> or |
| 5801 | <filename>non-hardware.kcf</filename>). |
| 5802 | </para></listitem> |
| 5803 | </itemizedlist> |
| 5804 | Here is a specific example using the |
| 5805 | <filename>kernel-cache/bsp/mti-malta32/hardware.cfg</filename>: |
| 5806 | <literallayout class='monospaced'> |
| 5807 | CONFIG_SERIAL_8250 |
| 5808 | CONFIG_SERIAL_8250_CONSOLE |
| 5809 | CONFIG_SERIAL_8250_NR_UARTS |
| 5810 | CONFIG_SERIAL_8250_PCI |
| 5811 | CONFIG_SERIAL_CORE |
| 5812 | CONFIG_SERIAL_CORE_CONSOLE |
| 5813 | CONFIG_VGA_ARB |
| 5814 | </literallayout> |
| 5815 | The kernel configuration audit automatically detects these |
| 5816 | files (hence the names must be exactly the ones discussed here), |
| 5817 | and uses them as inputs when generating warnings about the |
| 5818 | final <filename>.config</filename> file. |
| 5819 | </para> |
| 5820 | |
| 5821 | <para> |
| 5822 | A user-specified kernel Metadata repository, or recipe space |
| 5823 | feature, can use these same files to classify options that are |
| 5824 | found within its <filename>.cfg</filename> files as hardware |
| 5825 | or non-hardware, to prevent the OpenEmbedded build system from |
| 5826 | producing an error or warning when an option is not in the |
| 5827 | final <filename>.config</filename> file. |
| 5828 | </para> |
| 5829 | </section> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 5830 | </section> |
| 5831 | |
| 5832 | <section id="patching-the-kernel"> |
| 5833 | <title>Patching the Kernel</title> |
| 5834 | |
| 5835 | <para> |
| 5836 | Patching the kernel involves changing or adding configurations to an existing kernel, |
| 5837 | changing or adding recipes to the kernel that are needed to support specific hardware features, |
| 5838 | or even altering the source code itself. |
| 5839 | <note> |
| 5840 | You can use the <filename>yocto-kernel</filename> script |
| 5841 | found in the <link linkend='source-directory'>Source Directory</link> |
| 5842 | under <filename>scripts</filename> to manage kernel patches and configuration. |
| 5843 | See the "<ulink url='&YOCTO_DOCS_BSP_URL;#managing-kernel-patches-and-config-items-with-yocto-kernel'>Managing kernel Patches and Config Items with yocto-kernel</ulink>" |
| 5844 | section in the Yocto Project Board Support Packages (BSP) Developer's Guide for |
| 5845 | more information.</note> |
| 5846 | </para> |
| 5847 | |
| 5848 | <para> |
| 5849 | This example creates a simple patch by adding some QEMU emulator console |
| 5850 | output at boot time through <filename>printk</filename> statements in the kernel's |
| 5851 | <filename>calibrate.c</filename> source code file. |
| 5852 | Applying the patch and booting the modified image causes the added |
| 5853 | messages to appear on the emulator's console. |
| 5854 | </para> |
| 5855 | |
| 5856 | <para> |
| 5857 | The example assumes a clean build exists for the <filename>qemux86</filename> |
| 5858 | machine in a |
| 5859 | <link linkend='source-directory'>Source Directory</link> |
| 5860 | named <filename>poky</filename>. |
| 5861 | Furthermore, the <link linkend='build-directory'>Build Directory</link> is |
| 5862 | <filename>build</filename> and is located in <filename>poky</filename> and |
| 5863 | the kernel is based on the Linux 3.4 kernel. |
| 5864 | </para> |
| 5865 | |
| 5866 | <para> |
| 5867 | Also, for more information on patching the kernel, see the |
| 5868 | "<ulink url='&YOCTO_DOCS_KERNEL_DEV_URL;#applying-patches'>Applying Patches</ulink>" |
| 5869 | section in the Yocto Project Linux Kernel Development Manual. |
| 5870 | </para> |
| 5871 | |
| 5872 | <section id='create-a-layer-for-your-changes'> |
| 5873 | <title>Create a Layer for your Changes</title> |
| 5874 | |
| 5875 | <para> |
| 5876 | The first step is to create a layer so you can isolate your |
| 5877 | changes. |
| 5878 | Rather than use the <filename>yocto-layer</filename> script |
| 5879 | to create the layer, this example steps through the process |
| 5880 | by hand. |
| 5881 | If you want information on the script that creates a general |
| 5882 | layer, see the |
| 5883 | "<link linkend='creating-a-general-layer-using-the-yocto-layer-script'>Creating a General Layer Using the yocto-layer Script</link>" |
| 5884 | section. |
| 5885 | </para> |
| 5886 | |
| 5887 | <para> |
| 5888 | These two commands create a directory you can use for your |
| 5889 | layer: |
| 5890 | <literallayout class='monospaced'> |
| 5891 | $ cd ~/poky |
| 5892 | $ mkdir meta-mylayer |
| 5893 | </literallayout> |
| 5894 | Creating a directory that follows the Yocto Project layer naming |
| 5895 | conventions sets up the layer for your changes. |
| 5896 | The layer is where you place your configuration files, append |
| 5897 | files, and patch files. |
| 5898 | To learn more about creating a layer and filling it with the |
| 5899 | files you need, see the "<link linkend='understanding-and-creating-layers'>Understanding |
| 5900 | and Creating Layers</link>" section. |
| 5901 | </para> |
| 5902 | </section> |
| 5903 | |
| 5904 | <section id='finding-the-kernel-source-code'> |
| 5905 | <title>Finding the Kernel Source Code</title> |
| 5906 | |
| 5907 | <para> |
| 5908 | Each time you build a kernel image, the kernel source code is fetched |
| 5909 | and unpacked into the following directory: |
| 5910 | <literallayout class='monospaced'> |
| 5911 | ${S}/linux |
| 5912 | </literallayout> |
| 5913 | See the "<link linkend='finding-the-temporary-source-code'>Finding Temporary Source Code</link>" |
| 5914 | section and the |
| 5915 | <ulink url='&YOCTO_DOCS_REF_URL;#var-S'><filename>S</filename></ulink> variable |
| 5916 | for more information about where source is kept during a build. |
| 5917 | </para> |
| 5918 | |
| 5919 | <para> |
| 5920 | For this example, we are going to patch the |
| 5921 | <filename>init/calibrate.c</filename> file |
| 5922 | by adding some simple console <filename>printk</filename> statements that we can |
| 5923 | see when we boot the image using QEMU. |
| 5924 | </para> |
| 5925 | </section> |
| 5926 | |
| 5927 | <section id='creating-the-patch'> |
| 5928 | <title>Creating the Patch</title> |
| 5929 | |
| 5930 | <para> |
| 5931 | Two methods exist by which you can create the patch: |
| 5932 | <link linkend='using-devtool-in-your-workflow'><filename>devtool</filename></link> and |
| 5933 | <link linkend='using-a-quilt-workflow'>Quilt</link>. |
| 5934 | For kernel patches, the Git workflow is more appropriate. |
| 5935 | This section assumes the Git workflow and shows the steps specific to |
| 5936 | this example. |
| 5937 | <orderedlist> |
| 5938 | <listitem><para><emphasis>Change the working directory</emphasis>: |
| 5939 | Change to where the kernel source code is before making |
| 5940 | your edits to the <filename>calibrate.c</filename> file: |
| 5941 | <literallayout class='monospaced'> |
| 5942 | $ cd ~/poky/build/tmp/work/qemux86-poky-linux/linux-yocto-${PV}-${PR}/linux |
| 5943 | </literallayout> |
| 5944 | Because you are working in an established Git repository, |
| 5945 | you must be in this directory in order to commit your changes |
| 5946 | and create the patch file. |
| 5947 | <note>The <ulink url='&YOCTO_DOCS_REF_URL;#var-PV'><filename>PV</filename></ulink> and |
| 5948 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PR'><filename>PR</filename></ulink> variables |
| 5949 | represent the version and revision for the |
| 5950 | <filename>linux-yocto</filename> recipe. |
| 5951 | The <filename>PV</filename> variable includes the Git meta and machine |
| 5952 | hashes, which make the directory name longer than you might |
| 5953 | expect. |
| 5954 | </note></para></listitem> |
| 5955 | <listitem><para><emphasis>Edit the source file</emphasis>: |
| 5956 | Edit the <filename>init/calibrate.c</filename> file to have the |
| 5957 | following changes: |
| 5958 | <literallayout class='monospaced'> |
| 5959 | void calibrate_delay(void) |
| 5960 | { |
| 5961 | unsigned long lpj; |
| 5962 | static bool printed; |
| 5963 | int this_cpu = smp_processor_id(); |
| 5964 | |
| 5965 | printk("*************************************\n"); |
| 5966 | printk("* *\n"); |
| 5967 | printk("* HELLO YOCTO KERNEL *\n"); |
| 5968 | printk("* *\n"); |
| 5969 | printk("*************************************\n"); |
| 5970 | |
| 5971 | if (per_cpu(cpu_loops_per_jiffy, this_cpu)) { |
| 5972 | . |
| 5973 | . |
| 5974 | . |
| 5975 | </literallayout></para></listitem> |
| 5976 | <listitem><para><emphasis>Stage and commit your changes</emphasis>: |
| 5977 | These Git commands display the modified file, stage it, and then |
| 5978 | commit the file: |
| 5979 | <literallayout class='monospaced'> |
| 5980 | $ git status |
| 5981 | $ git add init/calibrate.c |
| 5982 | $ git commit -m "calibrate: Add printk example" |
| 5983 | </literallayout></para></listitem> |
| 5984 | <listitem><para><emphasis>Generate the patch file</emphasis>: |
| 5985 | This Git command creates the a patch file named |
| 5986 | <filename>0001-calibrate-Add-printk-example.patch</filename> |
| 5987 | in the current directory. |
| 5988 | <literallayout class='monospaced'> |
| 5989 | $ git format-patch -1 |
| 5990 | </literallayout> |
| 5991 | </para></listitem> |
| 5992 | </orderedlist> |
| 5993 | </para> |
| 5994 | </section> |
| 5995 | |
| 5996 | <section id='set-up-your-layer-for-the-build'> |
| 5997 | <title>Set Up Your Layer for the Build</title> |
| 5998 | |
| 5999 | <para>These steps get your layer set up for the build: |
| 6000 | <orderedlist> |
| 6001 | <listitem><para><emphasis>Create additional structure</emphasis>: |
| 6002 | Create the additional layer structure: |
| 6003 | <literallayout class='monospaced'> |
| 6004 | $ cd ~/poky/meta-mylayer |
| 6005 | $ mkdir conf |
| 6006 | $ mkdir recipes-kernel |
| 6007 | $ mkdir recipes-kernel/linux |
| 6008 | $ mkdir recipes-kernel/linux/linux-yocto |
| 6009 | </literallayout> |
| 6010 | The <filename>conf</filename> directory holds your configuration files, while the |
| 6011 | <filename>recipes-kernel</filename> directory holds your append file and |
| 6012 | your patch file.</para></listitem> |
| 6013 | <listitem><para><emphasis>Create the layer configuration file</emphasis>: |
| 6014 | Move to the <filename>meta-mylayer/conf</filename> directory and create |
| 6015 | the <filename>layer.conf</filename> file as follows: |
| 6016 | <literallayout class='monospaced'> |
| 6017 | # We have a conf and classes directory, add to BBPATH |
| 6018 | BBPATH .= ":${LAYERDIR}" |
| 6019 | |
| 6020 | # We have recipes-* directories, add to BBFILES |
| 6021 | BBFILES += "${LAYERDIR}/recipes-*/*/*.bb \ |
| 6022 | ${LAYERDIR}/recipes-*/*/*.bbappend" |
| 6023 | |
| 6024 | BBFILE_COLLECTIONS += "mylayer" |
| 6025 | BBFILE_PATTERN_mylayer = "^${LAYERDIR}/" |
| 6026 | BBFILE_PRIORITY_mylayer = "5" |
| 6027 | </literallayout> |
| 6028 | Notice <filename>mylayer</filename> as part of the last three |
| 6029 | statements.</para></listitem> |
| 6030 | <listitem><para><emphasis>Create the kernel recipe append file</emphasis>: |
| 6031 | Move to the <filename>meta-mylayer/recipes-kernel/linux</filename> directory and create |
| 6032 | the <filename>linux-yocto_3.4.bbappend</filename> file as follows: |
| 6033 | <literallayout class='monospaced'> |
| 6034 | FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:" |
| 6035 | |
| 6036 | SRC_URI += "file://0001-calibrate-Add-printk-example.patch" |
| 6037 | </literallayout> |
| 6038 | The <ulink url='&YOCTO_DOCS_REF_URL;#var-FILESEXTRAPATHS'><filename>FILESEXTRAPATHS</filename></ulink> |
| 6039 | and <ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'><filename>SRC_URI</filename></ulink> |
| 6040 | statements enable the OpenEmbedded build system to find the patch file. |
| 6041 | For more information on using append files, see the |
| 6042 | "<link linkend='using-bbappend-files'>Using .bbappend Files</link>" |
| 6043 | section. |
| 6044 | </para></listitem> |
| 6045 | <listitem><para><emphasis>Put the patch file in your layer</emphasis>: |
| 6046 | Move the <filename>0001-calibrate-Add-printk-example.patch</filename> file to |
| 6047 | the <filename>meta-mylayer/recipes-kernel/linux/linux-yocto</filename> |
| 6048 | directory.</para></listitem> |
| 6049 | </orderedlist> |
| 6050 | </para> |
| 6051 | </section> |
| 6052 | |
| 6053 | <section id='set-up-for-the-build'> |
| 6054 | <title>Set Up for the Build</title> |
| 6055 | |
| 6056 | <para> |
| 6057 | Do the following to make sure the build parameters are set up for the example. |
| 6058 | Once you set up these build parameters, they do not have to change unless you |
| 6059 | change the target architecture of the machine you are building: |
| 6060 | <itemizedlist> |
| 6061 | <listitem><para><emphasis>Build for the correct target architecture:</emphasis> Your |
| 6062 | selected <ulink url='&YOCTO_DOCS_REF_URL;#var-MACHINE'><filename>MACHINE</filename></ulink> |
| 6063 | definition within the <filename>local.conf</filename> file in the |
| 6064 | <link linkend='build-directory'>Build Directory</link> |
| 6065 | specifies the target architecture used when building the Linux kernel. |
| 6066 | By default, <filename>MACHINE</filename> is set to |
| 6067 | <filename>qemux86</filename>, which specifies a 32-bit |
| 6068 | <trademark class='registered'>Intel</trademark> Architecture |
| 6069 | target machine suitable for the QEMU emulator.</para></listitem> |
| 6070 | <listitem><para><emphasis>Identify your <filename>meta-mylayer</filename> |
| 6071 | layer:</emphasis> The |
| 6072 | <ulink url='&YOCTO_DOCS_REF_URL;#var-BBLAYERS'><filename>BBLAYERS</filename></ulink> |
| 6073 | variable in the |
| 6074 | <filename>bblayers.conf</filename> file found in the |
| 6075 | <filename>poky/build/conf</filename> directory needs to have the path to your local |
| 6076 | <filename>meta-mylayer</filename> layer. |
| 6077 | By default, the <filename>BBLAYERS</filename> variable contains paths to |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 6078 | <filename>meta</filename>, <filename>meta-poky</filename>, and |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 6079 | <filename>meta-yocto-bsp</filename> in the |
| 6080 | <filename>poky</filename> Git repository. |
| 6081 | Add the path to your <filename>meta-mylayer</filename> location: |
| 6082 | <literallayout class='monospaced'> |
| 6083 | BBLAYERS ?= " \ |
| 6084 | $HOME/poky/meta \ |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 6085 | $HOME/poky/meta-poky \ |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 6086 | $HOME/poky/meta-yocto-bsp \ |
| 6087 | $HOME/poky/meta-mylayer \ |
| 6088 | " |
| 6089 | </literallayout></para></listitem> |
| 6090 | </itemizedlist> |
| 6091 | </para> |
| 6092 | </section> |
| 6093 | |
| 6094 | <section id='build-the-modified-qemu-kernel-image'> |
| 6095 | <title>Build the Modified QEMU Kernel Image</title> |
| 6096 | |
| 6097 | <para> |
| 6098 | The following steps build your modified kernel image: |
| 6099 | <orderedlist> |
| 6100 | <listitem><para><emphasis>Be sure your build environment is initialized</emphasis>: |
| 6101 | Your environment should be set up since you previously sourced |
| 6102 | the |
| 6103 | <ulink url='&YOCTO_DOCS_REF_URL;#structure-core-script'><filename>&OE_INIT_FILE;</filename></ulink> |
| 6104 | script. |
| 6105 | If it is not, source the script again from <filename>poky</filename>. |
| 6106 | <literallayout class='monospaced'> |
| 6107 | $ cd ~/poky |
| 6108 | $ source &OE_INIT_FILE; |
| 6109 | </literallayout> |
| 6110 | </para></listitem> |
| 6111 | <listitem><para><emphasis>Clean up</emphasis>: |
| 6112 | Be sure to clean the shared state out by using BitBake |
| 6113 | to run from within the Build Directory the |
| 6114 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-cleansstate'><filename>do_cleansstate</filename></ulink> |
| 6115 | task as follows: |
| 6116 | <literallayout class='monospaced'> |
| 6117 | $ bitbake -c cleansstate linux-yocto |
| 6118 | </literallayout></para> |
| 6119 | <para> |
| 6120 | <note> |
| 6121 | Never remove any files by hand from the |
| 6122 | <filename>tmp/deploy</filename> |
| 6123 | directory inside the |
| 6124 | <link linkend='build-directory'>Build Directory</link>. |
| 6125 | Always use the various BitBake clean tasks to |
| 6126 | clear out previous build artifacts. |
| 6127 | For information on the clean tasks, see the |
| 6128 | "<ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-clean'><filename>do_clean</filename></ulink>", |
| 6129 | "<ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-cleanall'><filename>do_cleanall</filename></ulink>", |
| 6130 | and |
| 6131 | "<ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-cleansstate'><filename>do_cleansstate</filename></ulink>" |
| 6132 | sections all in the Yocto Project Reference |
| 6133 | Manual. |
| 6134 | </note> |
| 6135 | </para></listitem> |
| 6136 | <listitem><para><emphasis>Build the image</emphasis>: |
| 6137 | Next, build the kernel image using this command: |
| 6138 | <literallayout class='monospaced'> |
| 6139 | $ bitbake -k linux-yocto |
| 6140 | </literallayout></para></listitem> |
| 6141 | </orderedlist> |
| 6142 | </para> |
| 6143 | </section> |
| 6144 | |
| 6145 | <section id='boot-the-image-and-verify-your-changes'> |
| 6146 | <title>Boot the Image and Verify Your Changes</title> |
| 6147 | |
| 6148 | <para> |
| 6149 | These steps boot the image and allow you to see the changes |
| 6150 | <orderedlist> |
| 6151 | <listitem><para><emphasis>Boot the image</emphasis>: |
| 6152 | Boot the modified image in the QEMU emulator |
| 6153 | using this command: |
| 6154 | <literallayout class='monospaced'> |
| 6155 | $ runqemu qemux86 |
| 6156 | </literallayout></para></listitem> |
| 6157 | <listitem><para><emphasis>Verify the changes</emphasis>: |
| 6158 | Log into the machine using <filename>root</filename> with no password and then |
| 6159 | use the following shell command to scroll through the console's boot output. |
| 6160 | <literallayout class='monospaced'> |
| 6161 | # dmesg | less |
| 6162 | </literallayout> |
| 6163 | You should see the results of your <filename>printk</filename> statements |
| 6164 | as part of the output.</para></listitem> |
| 6165 | </orderedlist> |
| 6166 | </para> |
| 6167 | </section> |
| 6168 | </section> |
| 6169 | |
| 6170 | <section id='making-images-more-secure'> |
| 6171 | <title>Making Images More Secure</title> |
| 6172 | |
| 6173 | <para> |
| 6174 | Security is of increasing concern for embedded devices. |
| 6175 | Consider the issues and problems discussed in just this |
| 6176 | sampling of work found across the Internet: |
| 6177 | <itemizedlist> |
| 6178 | <listitem><para><emphasis> |
| 6179 | "<ulink url='https://www.schneier.com/blog/archives/2014/01/security_risks_9.html'>Security Risks of Embedded Systems</ulink>"</emphasis> |
| 6180 | by Bruce Schneier |
| 6181 | </para></listitem> |
| 6182 | <listitem><para><emphasis> |
| 6183 | "<ulink url='http://internetcensus2012.bitbucket.org/paper.html'>Internet Census 2012</ulink>"</emphasis> |
| 6184 | by Carna Botnet</para></listitem> |
| 6185 | <listitem><para><emphasis> |
| 6186 | "<ulink url='http://elinux.org/images/6/6f/Security-issues.pdf'>Security Issues for Embedded Devices</ulink>"</emphasis> |
| 6187 | by Jake Edge |
| 6188 | </para></listitem> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 6189 | </itemizedlist> |
| 6190 | </para> |
| 6191 | |
| 6192 | <para> |
| 6193 | When securing your image is of concern, there are steps, tools, |
| 6194 | and variables that you can consider to help you reach the |
| 6195 | security goals you need for your particular device. |
| 6196 | Not all situations are identical when it comes to making an |
| 6197 | image secure. |
| 6198 | Consequently, this section provides some guidance and suggestions |
| 6199 | for consideration when you want to make your image more secure. |
| 6200 | <note> |
| 6201 | Because the security requirements and risks are |
| 6202 | different for every type of device, this section cannot |
| 6203 | provide a complete reference on securing your custom OS. |
| 6204 | It is strongly recommended that you also consult other sources |
| 6205 | of information on embedded Linux system hardening and on |
| 6206 | security. |
| 6207 | </note> |
| 6208 | </para> |
| 6209 | |
| 6210 | <section id='general-considerations'> |
| 6211 | <title>General Considerations</title> |
| 6212 | |
| 6213 | <para> |
| 6214 | General considerations exist that help you create more |
| 6215 | secure images. |
| 6216 | You should consider the following suggestions to help |
| 6217 | make your device more secure: |
| 6218 | <itemizedlist> |
| 6219 | <listitem><para> |
| 6220 | Scan additional code you are adding to the system |
| 6221 | (e.g. application code) by using static analysis |
| 6222 | tools. |
| 6223 | Look for buffer overflows and other potential |
| 6224 | security problems. |
| 6225 | </para></listitem> |
| 6226 | <listitem><para> |
| 6227 | Pay particular attention to the security for |
| 6228 | any web-based administration interface. |
| 6229 | </para> |
| 6230 | <para>Web interfaces typically need to perform |
| 6231 | administrative functions and tend to need to run with |
| 6232 | elevated privileges. |
| 6233 | Thus, the consequences resulting from the interface's |
| 6234 | security becoming compromised can be serious. |
| 6235 | Look for common web vulnerabilities such as |
| 6236 | cross-site-scripting (XSS), unvalidated inputs, |
| 6237 | and so forth.</para> |
| 6238 | <para>As with system passwords, the default credentials |
| 6239 | for accessing a web-based interface should not be the |
| 6240 | same across all devices. |
| 6241 | This is particularly true if the interface is enabled |
| 6242 | by default as it can be assumed that many end-users |
| 6243 | will not change the credentials. |
| 6244 | </para></listitem> |
| 6245 | <listitem><para> |
| 6246 | Ensure you can update the software on the device to |
| 6247 | mitigate vulnerabilities discovered in the future. |
| 6248 | This consideration especially applies when your |
| 6249 | device is network-enabled. |
| 6250 | </para></listitem> |
| 6251 | <listitem><para> |
| 6252 | Ensure you remove or disable debugging functionality |
| 6253 | before producing the final image. |
| 6254 | For information on how to do this, see the |
| 6255 | "<link linkend='considerations-specific-to-the-openembedded-build-system'>Considerations Specific to the OpenEmbedded Build System</link>" |
| 6256 | section. |
| 6257 | </para></listitem> |
| 6258 | <listitem><para> |
| 6259 | Ensure you have no network services listening that |
| 6260 | are not needed. |
| 6261 | </para></listitem> |
| 6262 | <listitem><para> |
| 6263 | Remove any software from the image that is not needed. |
| 6264 | </para></listitem> |
| 6265 | <listitem><para> |
| 6266 | Enable hardware support for secure boot functionality |
| 6267 | when your device supports this functionality. |
| 6268 | </para></listitem> |
| 6269 | </itemizedlist> |
| 6270 | </para> |
| 6271 | </section> |
| 6272 | |
| 6273 | <section id='security-flags'> |
| 6274 | <title>Security Flags</title> |
| 6275 | |
| 6276 | <para> |
| 6277 | The Yocto Project has security flags that you can enable that |
| 6278 | help make your build output more secure. |
| 6279 | The security flags are in the |
| 6280 | <filename>meta/conf/distro/include/security_flags.inc</filename> |
| 6281 | file in your |
| 6282 | <link linkend='source-directory'>Source Directory</link> |
| 6283 | (e.g. <filename>poky</filename>). |
| 6284 | <note> |
| 6285 | Depending on the recipe, certain security flags are enabled |
| 6286 | and disabled by default. |
| 6287 | </note> |
| 6288 | </para> |
| 6289 | |
| 6290 | <para> |
| 6291 | <!-- |
| 6292 | The GCC/LD flags in <filename>security_flags.inc</filename> |
| 6293 | enable more secure code generation. |
| 6294 | By including the <filename>security_flags.inc</filename> |
| 6295 | file, you enable flags to the compiler and linker that cause |
| 6296 | them to generate more secure code. |
| 6297 | <note> |
| 6298 | The GCC/LD flags are enabled by default in the |
| 6299 | <filename>poky-lsb</filename> distribution. |
| 6300 | </note> |
| 6301 | --> |
| 6302 | Use the following line in your |
| 6303 | <filename>local.conf</filename> file or in your custom |
| 6304 | distribution configuration file to enable the security |
| 6305 | compiler and linker flags for your build: |
| 6306 | <literallayout class='monospaced'> |
| 6307 | require conf/distro/include/security_flags.inc |
| 6308 | </literallayout> |
| 6309 | </para> |
| 6310 | </section> |
| 6311 | |
| 6312 | <section id='considerations-specific-to-the-openembedded-build-system'> |
| 6313 | <title>Considerations Specific to the OpenEmbedded Build System</title> |
| 6314 | |
| 6315 | <para> |
| 6316 | You can take some steps that are specific to the |
| 6317 | OpenEmbedded build system to make your images more secure: |
| 6318 | <itemizedlist> |
| 6319 | <listitem><para> |
| 6320 | Ensure "debug-tweaks" is not one of your selected |
| 6321 | <ulink url='&YOCTO_DOCS_REF_URL;#var-IMAGE_FEATURES'><filename>IMAGE_FEATURES</filename></ulink>. |
| 6322 | When creating a new project, the default is to provide you |
| 6323 | with an initial <filename>local.conf</filename> file that |
| 6324 | enables this feature using the |
| 6325 | <ulink url='&YOCTO_DOCS_REF_URL;#var-EXTRA_IMAGE_FEATURES'><filename>EXTRA_IMAGE_FEATURES</filename></ulink> variable with the line: |
| 6326 | <literallayout class='monospaced'> |
| 6327 | EXTRA_IMAGE_FEATURES = "debug-tweaks" |
| 6328 | </literallayout> |
| 6329 | To disable that feature, simply comment out that line in your |
| 6330 | <filename>local.conf</filename> file, or |
| 6331 | make sure <filename>IMAGE_FEATURES</filename> does not contain |
| 6332 | "debug-tweaks" before producing your final image. |
| 6333 | Among other things, leaving this in place sets the |
| 6334 | root password as blank, which makes logging in for |
| 6335 | debugging or inspection easy during |
| 6336 | development but also means anyone can easily log in |
| 6337 | during production. |
| 6338 | </para></listitem> |
| 6339 | <listitem><para> |
| 6340 | It is possible to set a root password for the image |
| 6341 | and also to set passwords for any extra users you might |
| 6342 | add (e.g. administrative or service type users). |
| 6343 | When you set up passwords for multiple images or |
| 6344 | users, you should not duplicate passwords. |
| 6345 | </para> |
| 6346 | <para> |
| 6347 | To set up passwords, use the |
| 6348 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-extrausers'><filename>extrausers</filename></ulink> |
| 6349 | class, which is the preferred method. |
| 6350 | For an example on how to set up both root and user |
| 6351 | passwords, see the |
| 6352 | "<ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-extrausers'><filename>extrausers.bbclass</filename></ulink>" |
| 6353 | section. |
| 6354 | <note> |
| 6355 | When adding extra user accounts or setting a |
| 6356 | root password, be cautious about setting the |
| 6357 | same password on every device. |
| 6358 | If you do this, and the password you have set |
| 6359 | is exposed, then every device is now potentially |
| 6360 | compromised. |
| 6361 | If you need this access but want to ensure |
| 6362 | security, consider setting a different, |
| 6363 | random password for each device. |
| 6364 | Typically, you do this as a separate step after |
| 6365 | you deploy the image onto the device. |
| 6366 | </note> |
| 6367 | </para></listitem> |
| 6368 | <listitem><para> |
| 6369 | Consider enabling a Mandatory Access Control (MAC) |
| 6370 | framework such as SMACK or SELinux and tuning it |
| 6371 | appropriately for your device's usage. |
| 6372 | You can find more information in the |
| 6373 | <ulink url='http://git.yoctoproject.org/cgit/cgit.cgi/meta-selinux/'><filename>meta-selinux</filename></ulink> |
| 6374 | layer. |
| 6375 | </para></listitem> |
| 6376 | </itemizedlist> |
| 6377 | </para> |
| 6378 | |
| 6379 | <para> |
| 6380 | </para> |
| 6381 | </section> |
| 6382 | |
| 6383 | <section id='tools-for-hardening-your-image'> |
| 6384 | <title>Tools for Hardening Your Image</title> |
| 6385 | |
| 6386 | <para> |
| 6387 | The Yocto Project provides tools for making your image |
| 6388 | more secure. |
| 6389 | You can find these tools in the |
| 6390 | <filename>meta-security</filename> layer of the |
| 6391 | <ulink url='&YOCTO_GIT_URL;/cgit/cgit.cgi'>Yocto Project Source Repositories</ulink>. |
| 6392 | </para> |
| 6393 | </section> |
| 6394 | </section> |
| 6395 | |
| 6396 | <section id='creating-your-own-distribution'> |
| 6397 | <title>Creating Your Own Distribution</title> |
| 6398 | |
| 6399 | <para> |
| 6400 | When you build an image using the Yocto Project and |
| 6401 | do not alter any distribution |
| 6402 | <link linkend='metadata'>Metadata</link>, you are creating a |
| 6403 | Poky distribution. |
| 6404 | If you wish to gain more control over package alternative |
| 6405 | selections, compile-time options, and other low-level |
| 6406 | configurations, you can create your own distribution. |
| 6407 | </para> |
| 6408 | |
| 6409 | <para> |
| 6410 | To create your own distribution, the basic steps consist of |
| 6411 | creating your own distribution layer, creating your own |
| 6412 | distribution configuration file, and then adding any needed |
| 6413 | code and Metadata to the layer. |
| 6414 | The following steps provide some more detail: |
| 6415 | <itemizedlist> |
| 6416 | <listitem><para><emphasis>Create a layer for your new distro:</emphasis> |
| 6417 | Create your distribution layer so that you can keep your |
| 6418 | Metadata and code for the distribution separate. |
| 6419 | It is strongly recommended that you create and use your own |
| 6420 | layer for configuration and code. |
| 6421 | Using your own layer as compared to just placing |
| 6422 | configurations in a <filename>local.conf</filename> |
| 6423 | configuration file makes it easier to reproduce the same |
| 6424 | build configuration when using multiple build machines. |
| 6425 | See the |
| 6426 | "<link linkend='creating-a-general-layer-using-the-yocto-layer-script'>Creating a General Layer Using the yocto-layer Script</link>" |
| 6427 | section for information on how to quickly set up a layer. |
| 6428 | </para></listitem> |
| 6429 | <listitem><para><emphasis>Create the distribution configuration file:</emphasis> |
| 6430 | The distribution configuration file needs to be created in |
| 6431 | the <filename>conf/distro</filename> directory of your |
| 6432 | layer. |
| 6433 | You need to name it using your distribution name |
| 6434 | (e.g. <filename>mydistro.conf</filename>). |
| 6435 | <note> |
| 6436 | The |
| 6437 | <ulink url='&YOCTO_DOCS_REF_URL;#var-DISTRO'><filename>DISTRO</filename></ulink> |
| 6438 | variable in your |
| 6439 | <filename>local.conf</filename> file determines the |
| 6440 | name of your distribution. |
| 6441 | </note></para> |
| 6442 | <para>You can split out parts of your configuration file |
| 6443 | into include files and then "require" them from within |
| 6444 | your distribution configuration file. |
| 6445 | Be sure to place the include files in the |
| 6446 | <filename>conf/distro/include</filename> directory of |
| 6447 | your layer. |
| 6448 | A common example usage of include files would be to |
| 6449 | separate out the selection of desired version and revisions |
| 6450 | for individual recipes. |
| 6451 | </para> |
| 6452 | <para>Your configuration file needs to set the following |
| 6453 | required variables: |
| 6454 | <literallayout class='monospaced'> |
| 6455 | <ulink url='&YOCTO_DOCS_REF_URL;#var-DISTRO_NAME'><filename>DISTRO_NAME</filename></ulink> |
| 6456 | <ulink url='&YOCTO_DOCS_REF_URL;#var-DISTRO_VERSION'><filename>DISTRO_VERSION</filename></ulink> |
| 6457 | </literallayout> |
| 6458 | These following variables are optional and you typically |
| 6459 | set them from the distribution configuration file: |
| 6460 | <literallayout class='monospaced'> |
| 6461 | <ulink url='&YOCTO_DOCS_REF_URL;#var-DISTRO_FEATURES'><filename>DISTRO_FEATURES</filename></ulink> |
| 6462 | <ulink url='&YOCTO_DOCS_REF_URL;#var-DISTRO_EXTRA_RDEPENDS'><filename>DISTRO_EXTRA_RDEPENDS</filename></ulink> |
| 6463 | <ulink url='&YOCTO_DOCS_REF_URL;#var-DISTRO_EXTRA_RRECOMMENDS'><filename>DISTRO_EXTRA_RRECOMMENDS</filename></ulink> |
| 6464 | <ulink url='&YOCTO_DOCS_REF_URL;#var-TCLIBC'><filename>TCLIBC</filename></ulink> |
| 6465 | </literallayout> |
| 6466 | <tip> |
| 6467 | If you want to base your distribution configuration file |
| 6468 | on the very basic configuration from OE-Core, you |
| 6469 | can use |
| 6470 | <filename>conf/distro/defaultsetup.conf</filename> as |
| 6471 | a reference and just include variables that differ |
| 6472 | as compared to <filename>defaultsetup.conf</filename>. |
| 6473 | Alternatively, you can create a distribution |
| 6474 | configuration file from scratch using the |
| 6475 | <filename>defaultsetup.conf</filename> file |
| 6476 | or configuration files from other distributions |
| 6477 | such as Poky or Angstrom as references. |
| 6478 | </tip></para></listitem> |
| 6479 | <listitem><para><emphasis>Provide miscellaneous variables:</emphasis> |
| 6480 | Be sure to define any other variables for which you want to |
| 6481 | create a default or enforce as part of the distribution |
| 6482 | configuration. |
| 6483 | You can include nearly any variable from the |
| 6484 | <filename>local.conf</filename> file. |
| 6485 | The variables you use are not limited to the list in the |
| 6486 | previous bulleted item.</para></listitem> |
| 6487 | <listitem><para><emphasis>Point to Your distribution configuration file:</emphasis> |
| 6488 | In your <filename>local.conf</filename> file in the |
| 6489 | <link linkend='build-directory'>Build Directory</link>, |
| 6490 | set your |
| 6491 | <ulink url='&YOCTO_DOCS_REF_URL;#var-DISTRO'><filename>DISTRO</filename></ulink> |
| 6492 | variable to point to your distribution's configuration file. |
| 6493 | For example, if your distribution's configuration file is |
| 6494 | named <filename>mydistro.conf</filename>, then you point |
| 6495 | to it as follows: |
| 6496 | <literallayout class='monospaced'> |
| 6497 | DISTRO = "mydistro" |
| 6498 | </literallayout></para></listitem> |
| 6499 | <listitem><para><emphasis>Add more to the layer if necessary:</emphasis> |
| 6500 | Use your layer to hold other information needed for the |
| 6501 | distribution: |
| 6502 | <itemizedlist> |
| 6503 | <listitem><para>Add recipes for installing |
| 6504 | distro-specific configuration files that are not |
| 6505 | already installed by another recipe. |
| 6506 | If you have distro-specific configuration files |
| 6507 | that are included by an existing recipe, you should |
| 6508 | add an append file (<filename>.bbappend</filename>) |
| 6509 | for those. |
| 6510 | For general information and recommendations |
| 6511 | on how to add recipes to your layer, see the |
| 6512 | "<link linkend='creating-your-own-layer'>Creating Your Own Layer</link>" |
| 6513 | and |
| 6514 | "<link linkend='best-practices-to-follow-when-creating-layers'>Best Practices to Follow When Creating Layers</link>" |
| 6515 | sections.</para></listitem> |
| 6516 | <listitem><para>Add any image recipes that are specific |
| 6517 | to your distribution.</para></listitem> |
| 6518 | <listitem><para>Add a <filename>psplash</filename> |
| 6519 | append file for a branded splash screen. |
| 6520 | For information on append files, see the |
| 6521 | "<link linkend='using-bbappend-files'>Using .bbappend Files</link>" |
| 6522 | section.</para></listitem> |
| 6523 | <listitem><para>Add any other append files to make |
| 6524 | custom changes that are specific to individual |
| 6525 | recipes.</para></listitem> |
| 6526 | </itemizedlist></para></listitem> |
| 6527 | </itemizedlist> |
| 6528 | </para> |
| 6529 | </section> |
| 6530 | |
| 6531 | <section id='creating-a-custom-template-configuration-directory'> |
| 6532 | <title>Creating a Custom Template Configuration Directory</title> |
| 6533 | |
| 6534 | <para> |
| 6535 | If you are producing your own customized version |
| 6536 | of the build system for use by other users, you might |
| 6537 | want to customize the message shown by the setup script or |
| 6538 | you might want to change the template configuration files (i.e. |
| 6539 | <filename>local.conf</filename> and |
| 6540 | <filename>bblayers.conf</filename>) that are created in |
| 6541 | a new build directory. |
| 6542 | </para> |
| 6543 | |
| 6544 | <para> |
| 6545 | The OpenEmbedded build system uses the environment variable |
| 6546 | <filename>TEMPLATECONF</filename> to locate the directory |
| 6547 | from which it gathers configuration information that ultimately |
| 6548 | ends up in the |
| 6549 | <link linkend='build-directory'>Build Directory's</link> |
| 6550 | <filename>conf</filename> directory. |
| 6551 | By default, <filename>TEMPLATECONF</filename> is set as |
| 6552 | follows in the <filename>poky</filename> repository: |
| 6553 | <literallayout class='monospaced'> |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 6554 | TEMPLATECONF=${TEMPLATECONF:-meta-poky/conf} |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 6555 | </literallayout> |
| 6556 | This is the directory used by the build system to find templates |
| 6557 | from which to build some key configuration files. |
| 6558 | If you look at this directory, you will see the |
| 6559 | <filename>bblayers.conf.sample</filename>, |
| 6560 | <filename>local.conf.sample</filename>, and |
| 6561 | <filename>conf-notes.txt</filename> files. |
| 6562 | The build system uses these files to form the respective |
| 6563 | <filename>bblayers.conf</filename> file, |
| 6564 | <filename>local.conf</filename> file, and display the list of |
| 6565 | BitBake targets when running the setup script. |
| 6566 | </para> |
| 6567 | |
| 6568 | <para> |
| 6569 | To override these default configuration files with |
| 6570 | configurations you want used within every new |
| 6571 | Build Directory, simply set the |
| 6572 | <filename>TEMPLATECONF</filename> variable to your directory. |
| 6573 | The <filename>TEMPLATECONF</filename> variable is set in the |
| 6574 | <filename>.templateconf</filename> file, which is in the |
| 6575 | top-level |
| 6576 | <link linkend='source-directory'>Source Directory</link> |
| 6577 | folder (e.g. <filename>poky</filename>). |
| 6578 | Edit the <filename>.templateconf</filename> so that it can locate |
| 6579 | your directory. |
| 6580 | </para> |
| 6581 | |
| 6582 | <para> |
| 6583 | Best practices dictate that you should keep your |
| 6584 | template configuration directory in your custom distribution layer. |
| 6585 | For example, suppose you have a layer named |
| 6586 | <filename>meta-mylayer</filename> located in your home directory |
| 6587 | and you want your template configuration directory named |
| 6588 | <filename>myconf</filename>. |
| 6589 | Changing the <filename>.templateconf</filename> as follows |
| 6590 | causes the OpenEmbedded build system to look in your directory |
| 6591 | and base its configuration files on the |
| 6592 | <filename>*.sample</filename> configuration files it finds. |
| 6593 | The final configuration files (i.e. |
| 6594 | <filename>local.conf</filename> and |
| 6595 | <filename>bblayers.conf</filename> ultimately still end up in |
| 6596 | your Build Directory, but they are based on your |
| 6597 | <filename>*.sample</filename> files. |
| 6598 | <literallayout class='monospaced'> |
| 6599 | TEMPLATECONF=${TEMPLATECONF:-meta-mylayer/myconf} |
| 6600 | </literallayout> |
| 6601 | </para> |
| 6602 | |
| 6603 | <para> |
| 6604 | Aside from the <filename>*.sample</filename> configuration files, |
| 6605 | the <filename>conf-notes.txt</filename> also resides in the |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 6606 | default <filename>meta-poky/conf</filename> directory. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 6607 | The scripts that set up the build environment |
| 6608 | (i.e. |
| 6609 | <ulink url="&YOCTO_DOCS_REF_URL;#structure-core-script"><filename>&OE_INIT_FILE;</filename></ulink> |
| 6610 | and |
| 6611 | <ulink url="&YOCTO_DOCS_REF_URL;#structure-memres-core-script"><filename>oe-init-build-env-memres</filename></ulink>) |
| 6612 | use this file to display BitBake targets as part of the script |
| 6613 | output. |
| 6614 | Customizing this <filename>conf-notes.txt</filename> file is a |
| 6615 | good way to make sure your list of custom targets appears |
| 6616 | as part of the script's output. |
| 6617 | </para> |
| 6618 | |
| 6619 | <para> |
| 6620 | Here is the default list of targets displayed as a result of |
| 6621 | running either of the setup scripts: |
| 6622 | <literallayout class='monospaced'> |
| 6623 | You can now run 'bitbake <target>' |
| 6624 | |
| 6625 | Common targets are: |
| 6626 | core-image-minimal |
| 6627 | core-image-sato |
| 6628 | meta-toolchain |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 6629 | meta-ide-support |
| 6630 | </literallayout> |
| 6631 | </para> |
| 6632 | |
| 6633 | <para> |
| 6634 | Changing the listed common targets is as easy as editing your |
| 6635 | version of <filename>conf-notes.txt</filename> in your |
| 6636 | custom template configuration directory and making sure you |
| 6637 | have <filename>TEMPLATECONF</filename> set to your directory. |
| 6638 | </para> |
| 6639 | </section> |
| 6640 | |
| 6641 | <section id='building-a-tiny-system'> |
| 6642 | <title>Building a Tiny System</title> |
| 6643 | |
| 6644 | <para> |
| 6645 | Very small distributions have some significant advantages such |
| 6646 | as requiring less on-die or in-package memory (cheaper), better |
| 6647 | performance through efficient cache usage, lower power requirements |
| 6648 | due to less memory, faster boot times, and reduced development |
| 6649 | overhead. |
| 6650 | Some real-world examples where a very small distribution gives |
| 6651 | you distinct advantages are digital cameras, medical devices, |
| 6652 | and small headless systems. |
| 6653 | </para> |
| 6654 | |
| 6655 | <para> |
| 6656 | This section presents information that shows you how you can |
| 6657 | trim your distribution to even smaller sizes than the |
| 6658 | <filename>poky-tiny</filename> distribution, which is around |
| 6659 | 5 Mbytes, that can be built out-of-the-box using the Yocto Project. |
| 6660 | </para> |
| 6661 | |
| 6662 | <section id='tiny-system-overview'> |
| 6663 | <title>Overview</title> |
| 6664 | |
| 6665 | <para> |
| 6666 | The following list presents the overall steps you need to |
| 6667 | consider and perform to create distributions with smaller |
| 6668 | root filesystems, achieve faster boot times, maintain your critical |
| 6669 | functionality, and avoid initial RAM disks: |
| 6670 | <itemizedlist> |
| 6671 | <listitem><para> |
| 6672 | <link linkend='goals-and-guiding-principles'>Determine your goals and guiding principles.</link> |
| 6673 | </para></listitem> |
| 6674 | <listitem><para> |
| 6675 | <link linkend='understand-what-gives-your-image-size'>Understand what contributes to your image size.</link> |
| 6676 | </para></listitem> |
| 6677 | <listitem><para> |
| 6678 | <link linkend='trim-the-root-filesystem'>Reduce the size of the root filesystem.</link> |
| 6679 | </para></listitem> |
| 6680 | <listitem><para> |
| 6681 | <link linkend='trim-the-kernel'>Reduce the size of the kernel.</link> |
| 6682 | </para></listitem> |
| 6683 | <listitem><para> |
| 6684 | <link linkend='remove-package-management-requirements'>Eliminate packaging requirements.</link> |
| 6685 | </para></listitem> |
| 6686 | <listitem><para> |
| 6687 | <link linkend='look-for-other-ways-to-minimize-size'>Look for other ways to minimize size.</link> |
| 6688 | </para></listitem> |
| 6689 | <listitem><para> |
| 6690 | <link linkend='iterate-on-the-process'>Iterate on the process.</link> |
| 6691 | </para></listitem> |
| 6692 | </itemizedlist> |
| 6693 | </para> |
| 6694 | </section> |
| 6695 | |
| 6696 | <section id='goals-and-guiding-principles'> |
| 6697 | <title>Goals and Guiding Principles</title> |
| 6698 | |
| 6699 | <para> |
| 6700 | Before you can reach your destination, you need to know |
| 6701 | where you are going. |
| 6702 | Here is an example list that you can use as a guide when |
| 6703 | creating very small distributions: |
| 6704 | <itemizedlist> |
| 6705 | <listitem><para>Determine how much space you need |
| 6706 | (e.g. a kernel that is 1 Mbyte or less and |
| 6707 | a root filesystem that is 3 Mbytes or less). |
| 6708 | </para></listitem> |
| 6709 | <listitem><para>Find the areas that are currently |
| 6710 | taking 90% of the space and concentrate on reducing |
| 6711 | those areas. |
| 6712 | </para></listitem> |
| 6713 | <listitem><para>Do not create any difficult "hacks" |
| 6714 | to achieve your goals.</para></listitem> |
| 6715 | <listitem><para>Leverage the device-specific |
| 6716 | options.</para></listitem> |
| 6717 | <listitem><para>Work in a separate layer so that you |
| 6718 | keep changes isolated. |
| 6719 | For information on how to create layers, see |
| 6720 | the "<link linkend='understanding-and-creating-layers'>Understanding and Creating Layers</link>" section. |
| 6721 | </para></listitem> |
| 6722 | </itemizedlist> |
| 6723 | </para> |
| 6724 | </section> |
| 6725 | |
| 6726 | <section id='understand-what-gives-your-image-size'> |
| 6727 | <title>Understand What Contributes to Your Image Size</title> |
| 6728 | |
| 6729 | <para> |
| 6730 | It is easiest to have something to start with when creating |
| 6731 | your own distribution. |
| 6732 | You can use the Yocto Project out-of-the-box to create the |
| 6733 | <filename>poky-tiny</filename> distribution. |
| 6734 | Ultimately, you will want to make changes in your own |
| 6735 | distribution that are likely modeled after |
| 6736 | <filename>poky-tiny</filename>. |
| 6737 | <note> |
| 6738 | To use <filename>poky-tiny</filename> in your build, |
| 6739 | set the |
| 6740 | <ulink url='&YOCTO_DOCS_REF_URL;#var-DISTRO'><filename>DISTRO</filename></ulink> |
| 6741 | variable in your |
| 6742 | <filename>local.conf</filename> file to "poky-tiny" |
| 6743 | as described in the |
| 6744 | "<link linkend='creating-your-own-distribution'>Creating Your Own Distribution</link>" |
| 6745 | section. |
| 6746 | </note> |
| 6747 | </para> |
| 6748 | |
| 6749 | <para> |
| 6750 | Understanding some memory concepts will help you reduce the |
| 6751 | system size. |
| 6752 | Memory consists of static, dynamic, and temporary memory. |
| 6753 | Static memory is the TEXT (code), DATA (initialized data |
| 6754 | in the code), and BSS (uninitialized data) sections. |
| 6755 | Dynamic memory represents memory that is allocated at runtime: |
| 6756 | stacks, hash tables, and so forth. |
| 6757 | Temporary memory is recovered after the boot process. |
| 6758 | This memory consists of memory used for decompressing |
| 6759 | the kernel and for the <filename>__init__</filename> |
| 6760 | functions. |
| 6761 | </para> |
| 6762 | |
| 6763 | <para> |
| 6764 | To help you see where you currently are with kernel and root |
| 6765 | filesystem sizes, you can use two tools found in the |
| 6766 | <link linkend='source-directory'>Source Directory</link> in |
| 6767 | the <filename>scripts/tiny/</filename> directory: |
| 6768 | <itemizedlist> |
| 6769 | <listitem><para><filename>ksize.py</filename>: Reports |
| 6770 | component sizes for the kernel build objects. |
| 6771 | </para></listitem> |
| 6772 | <listitem><para><filename>dirsize.py</filename>: Reports |
| 6773 | component sizes for the root filesystem.</para></listitem> |
| 6774 | </itemizedlist> |
| 6775 | This next tool and command help you organize configuration |
| 6776 | fragments and view file dependencies in a human-readable form: |
| 6777 | <itemizedlist> |
| 6778 | <listitem><para><filename>merge_config.sh</filename>: |
| 6779 | Helps you manage configuration files and fragments |
| 6780 | within the kernel. |
| 6781 | With this tool, you can merge individual configuration |
| 6782 | fragments together. |
| 6783 | The tool allows you to make overrides and warns you |
| 6784 | of any missing configuration options. |
| 6785 | The tool is ideal for allowing you to iterate on |
| 6786 | configurations, create minimal configurations, and |
| 6787 | create configuration files for different machines |
| 6788 | without having to duplicate your process.</para> |
| 6789 | <para>The <filename>merge_config.sh</filename> script is |
| 6790 | part of the Linux Yocto kernel Git repositories |
| 6791 | (i.e. <filename>linux-yocto-3.14</filename>, |
| 6792 | <filename>linux-yocto-3.10</filename>, |
| 6793 | <filename>linux-yocto-3.8</filename>, and so forth) |
| 6794 | in the |
| 6795 | <filename>scripts/kconfig</filename> directory.</para> |
| 6796 | <para>For more information on configuration fragments, |
| 6797 | see the |
| 6798 | "<ulink url='&YOCTO_DOCS_KERNEL_DEV_URL;#generating-configuration-files'>Generating Configuration Files</ulink>" |
| 6799 | section of the Yocto Project Linux Kernel Development |
| 6800 | Manual and the "<link linkend='creating-config-fragments'>Creating Configuration Fragments</link>" |
| 6801 | section, which is in this manual.</para></listitem> |
| 6802 | <listitem><para><filename>bitbake -u depexp -g <replaceable>bitbake_target</replaceable></filename>: |
| 6803 | Using the BitBake command with these options brings up |
| 6804 | a Dependency Explorer from which you can view file |
| 6805 | dependencies. |
| 6806 | Understanding these dependencies allows you to make |
| 6807 | informed decisions when cutting out various pieces of the |
| 6808 | kernel and root filesystem.</para></listitem> |
| 6809 | </itemizedlist> |
| 6810 | </para> |
| 6811 | </section> |
| 6812 | |
| 6813 | <section id='trim-the-root-filesystem'> |
| 6814 | <title>Trim the Root Filesystem</title> |
| 6815 | |
| 6816 | <para> |
| 6817 | The root filesystem is made up of packages for booting, |
| 6818 | libraries, and applications. |
| 6819 | To change things, you can configure how the packaging happens, |
| 6820 | which changes the way you build them. |
| 6821 | You can also modify the filesystem itself or select a different |
| 6822 | filesystem. |
| 6823 | </para> |
| 6824 | |
| 6825 | <para> |
| 6826 | First, find out what is hogging your root filesystem by running the |
| 6827 | <filename>dirsize.py</filename> script from your root directory: |
| 6828 | <literallayout class='monospaced'> |
| 6829 | $ cd <replaceable>root-directory-of-image</replaceable> |
| 6830 | $ dirsize.py 100000 > dirsize-100k.log |
| 6831 | $ cat dirsize-100k.log |
| 6832 | </literallayout> |
| 6833 | You can apply a filter to the script to ignore files under |
| 6834 | a certain size. |
| 6835 | The previous example filters out any files below 100 Kbytes. |
| 6836 | The sizes reported by the tool are uncompressed, and thus |
| 6837 | will be smaller by a relatively constant factor in a |
| 6838 | compressed root filesystem. |
| 6839 | When you examine your log file, you can focus on areas of the |
| 6840 | root filesystem that take up large amounts of memory. |
| 6841 | </para> |
| 6842 | |
| 6843 | <para> |
| 6844 | You need to be sure that what you eliminate does not cripple |
| 6845 | the functionality you need. |
| 6846 | One way to see how packages relate to each other is by using |
| 6847 | the Dependency Explorer UI with the BitBake command: |
| 6848 | <literallayout class='monospaced'> |
| 6849 | $ cd <replaceable>image-directory</replaceable> |
| 6850 | $ bitbake -u depexp -g <replaceable>image</replaceable> |
| 6851 | </literallayout> |
| 6852 | Use the interface to select potential packages you wish to |
| 6853 | eliminate and see their dependency relationships. |
| 6854 | </para> |
| 6855 | |
| 6856 | <para> |
| 6857 | When deciding how to reduce the size, get rid of packages that |
| 6858 | result in minimal impact on the feature set. |
| 6859 | For example, you might not need a VGA display. |
| 6860 | Or, you might be able to get by with <filename>devtmpfs</filename> |
| 6861 | and <filename>mdev</filename> instead of |
| 6862 | <filename>udev</filename>. |
| 6863 | </para> |
| 6864 | |
| 6865 | <para> |
| 6866 | Use your <filename>local.conf</filename> file to make changes. |
| 6867 | For example, to eliminate <filename>udev</filename> and |
| 6868 | <filename>glib</filename>, set the following in the |
| 6869 | local configuration file: |
| 6870 | <literallayout class='monospaced'> |
| 6871 | VIRTUAL-RUNTIME_dev_manager = "" |
| 6872 | </literallayout> |
| 6873 | </para> |
| 6874 | |
| 6875 | <para> |
| 6876 | Finally, you should consider exactly the type of root |
| 6877 | filesystem you need to meet your needs while also reducing |
| 6878 | its size. |
| 6879 | For example, consider <filename>cramfs</filename>, |
| 6880 | <filename>squashfs</filename>, <filename>ubifs</filename>, |
| 6881 | <filename>ext2</filename>, or an <filename>initramfs</filename> |
| 6882 | using <filename>initramfs</filename>. |
| 6883 | Be aware that <filename>ext3</filename> requires a 1 Mbyte |
| 6884 | journal. |
| 6885 | If you are okay with running read-only, you do not need this |
| 6886 | journal. |
| 6887 | </para> |
| 6888 | |
| 6889 | <note> |
| 6890 | After each round of elimination, you need to rebuild your |
| 6891 | system and then use the tools to see the effects of your |
| 6892 | reductions. |
| 6893 | </note> |
| 6894 | |
| 6895 | |
| 6896 | </section> |
| 6897 | |
| 6898 | <section id='trim-the-kernel'> |
| 6899 | <title>Trim the Kernel</title> |
| 6900 | |
| 6901 | <para> |
| 6902 | The kernel is built by including policies for hardware-independent |
| 6903 | aspects. |
| 6904 | What subsystems do you enable? |
| 6905 | For what architecture are you building? |
| 6906 | Which drivers do you build by default? |
| 6907 | <note>You can modify the kernel source if you want to help |
| 6908 | with boot time. |
| 6909 | </note> |
| 6910 | </para> |
| 6911 | |
| 6912 | <para> |
| 6913 | Run the <filename>ksize.py</filename> script from the top-level |
| 6914 | Linux build directory to get an idea of what is making up |
| 6915 | the kernel: |
| 6916 | <literallayout class='monospaced'> |
| 6917 | $ cd <replaceable>top-level-linux-build-directory</replaceable> |
| 6918 | $ ksize.py > ksize.log |
| 6919 | $ cat ksize.log |
| 6920 | </literallayout> |
| 6921 | When you examine the log, you will see how much space is |
| 6922 | taken up with the built-in <filename>.o</filename> files for |
| 6923 | drivers, networking, core kernel files, filesystem, sound, |
| 6924 | and so forth. |
| 6925 | The sizes reported by the tool are uncompressed, and thus |
| 6926 | will be smaller by a relatively constant factor in a compressed |
| 6927 | kernel image. |
| 6928 | Look to reduce the areas that are large and taking up around |
| 6929 | the "90% rule." |
| 6930 | </para> |
| 6931 | |
| 6932 | <para> |
| 6933 | To examine, or drill down, into any particular area, use the |
| 6934 | <filename>-d</filename> option with the script: |
| 6935 | <literallayout class='monospaced'> |
| 6936 | $ ksize.py -d > ksize.log |
| 6937 | </literallayout> |
| 6938 | Using this option breaks out the individual file information |
| 6939 | for each area of the kernel (e.g. drivers, networking, and |
| 6940 | so forth). |
| 6941 | </para> |
| 6942 | |
| 6943 | <para> |
| 6944 | Use your log file to see what you can eliminate from the kernel |
| 6945 | based on features you can let go. |
| 6946 | For example, if you are not going to need sound, you do not |
| 6947 | need any drivers that support sound. |
| 6948 | </para> |
| 6949 | |
| 6950 | <para> |
| 6951 | After figuring out what to eliminate, you need to reconfigure |
| 6952 | the kernel to reflect those changes during the next build. |
| 6953 | You could run <filename>menuconfig</filename> and make all your |
| 6954 | changes at once. |
| 6955 | However, that makes it difficult to see the effects of your |
| 6956 | individual eliminations and also makes it difficult to replicate |
| 6957 | the changes for perhaps another target device. |
| 6958 | A better method is to start with no configurations using |
| 6959 | <filename>allnoconfig</filename>, create configuration |
| 6960 | fragments for individual changes, and then manage the |
| 6961 | fragments into a single configuration file using |
| 6962 | <filename>merge_config.sh</filename>. |
| 6963 | The tool makes it easy for you to iterate using the |
| 6964 | configuration change and build cycle. |
| 6965 | </para> |
| 6966 | |
| 6967 | <para> |
| 6968 | Each time you make configuration changes, you need to rebuild |
| 6969 | the kernel and check to see what impact your changes had on |
| 6970 | the overall size. |
| 6971 | </para> |
| 6972 | </section> |
| 6973 | |
| 6974 | <section id='remove-package-management-requirements'> |
| 6975 | <title>Remove Package Management Requirements</title> |
| 6976 | |
| 6977 | <para> |
| 6978 | Packaging requirements add size to the image. |
| 6979 | One way to reduce the size of the image is to remove all the |
| 6980 | packaging requirements from the image. |
| 6981 | This reduction includes both removing the package manager |
| 6982 | and its unique dependencies as well as removing the package |
| 6983 | management data itself. |
| 6984 | </para> |
| 6985 | |
| 6986 | <para> |
| 6987 | To eliminate all the packaging requirements for an image, |
| 6988 | be sure that "package-management" is not part of your |
| 6989 | <ulink url='&YOCTO_DOCS_REF_URL;#var-IMAGE_FEATURES'><filename>IMAGE_FEATURES</filename></ulink> |
| 6990 | statement for the image. |
| 6991 | When you remove this feature, you are removing the package |
| 6992 | manager as well as its dependencies from the root filesystem. |
| 6993 | </para> |
| 6994 | </section> |
| 6995 | |
| 6996 | <section id='look-for-other-ways-to-minimize-size'> |
| 6997 | <title>Look for Other Ways to Minimize Size</title> |
| 6998 | |
| 6999 | <para> |
| 7000 | Depending on your particular circumstances, other areas that you |
| 7001 | can trim likely exist. |
| 7002 | The key to finding these areas is through tools and methods |
| 7003 | described here combined with experimentation and iteration. |
| 7004 | Here are a couple of areas to experiment with: |
| 7005 | <itemizedlist> |
| 7006 | <listitem><para><filename>glibc</filename>: |
| 7007 | In general, follow this process: |
| 7008 | <orderedlist> |
| 7009 | <listitem><para>Remove <filename>glibc</filename> |
| 7010 | features from |
| 7011 | <ulink url='&YOCTO_DOCS_REF_URL;#var-DISTRO_FEATURES'><filename>DISTRO_FEATURES</filename></ulink> |
| 7012 | that you think you do not need.</para></listitem> |
| 7013 | <listitem><para>Build your distribution. |
| 7014 | </para></listitem> |
| 7015 | <listitem><para>If the build fails due to missing |
| 7016 | symbols in a package, determine if you can |
| 7017 | reconfigure the package to not need those |
| 7018 | features. |
| 7019 | For example, change the configuration to not |
| 7020 | support wide character support as is done for |
| 7021 | <filename>ncurses</filename>. |
| 7022 | Or, if support for those characters is needed, |
| 7023 | determine what <filename>glibc</filename> |
| 7024 | features provide the support and restore the |
| 7025 | configuration. |
| 7026 | </para></listitem> |
| 7027 | <listitem><para>Rebuild and repeat the process. |
| 7028 | </para></listitem> |
| 7029 | </orderedlist></para></listitem> |
| 7030 | <listitem><para><filename>busybox</filename>: |
| 7031 | For BusyBox, use a process similar as described for |
| 7032 | <filename>glibc</filename>. |
| 7033 | A difference is you will need to boot the resulting |
| 7034 | system to see if you are able to do everything you |
| 7035 | expect from the running system. |
| 7036 | You need to be sure to integrate configuration fragments |
| 7037 | into Busybox because BusyBox handles its own core |
| 7038 | features and then allows you to add configuration |
| 7039 | fragments on top. |
| 7040 | </para></listitem> |
| 7041 | </itemizedlist> |
| 7042 | </para> |
| 7043 | </section> |
| 7044 | |
| 7045 | <section id='iterate-on-the-process'> |
| 7046 | <title>Iterate on the Process</title> |
| 7047 | |
| 7048 | <para> |
| 7049 | If you have not reached your goals on system size, you need |
| 7050 | to iterate on the process. |
| 7051 | The process is the same. |
| 7052 | Use the tools and see just what is taking up 90% of the root |
| 7053 | filesystem and the kernel. |
| 7054 | Decide what you can eliminate without limiting your device |
| 7055 | beyond what you need. |
| 7056 | </para> |
| 7057 | |
| 7058 | <para> |
| 7059 | Depending on your system, a good place to look might be |
| 7060 | Busybox, which provides a stripped down |
| 7061 | version of Unix tools in a single, executable file. |
| 7062 | You might be able to drop virtual terminal services or perhaps |
| 7063 | ipv6. |
| 7064 | </para> |
| 7065 | </section> |
| 7066 | </section> |
| 7067 | |
| 7068 | <section id='building-images-for-more-than-one-machine'> |
| 7069 | <title>Building Images for More than One Machine</title> |
| 7070 | |
| 7071 | <para> |
| 7072 | A common scenario developers face is creating images for several |
| 7073 | different machines that use the same software environment. |
| 7074 | In this situation, it is tempting to set the |
| 7075 | tunings and optimization flags for each build specifically for |
| 7076 | the targeted hardware (i.e. "maxing out" the tunings). |
| 7077 | Doing so can considerably add to build times and package feed |
| 7078 | maintenance collectively for the machines. |
| 7079 | For example, selecting tunes that are extremely specific to a |
| 7080 | CPU core used in a system might enable some micro optimizations |
| 7081 | in GCC for that particular system but would otherwise not gain |
| 7082 | you much of a performance difference across the other systems |
| 7083 | as compared to using a more general tuning across all the builds |
| 7084 | (e.g. setting |
| 7085 | <ulink url='var-DEFAULTTUNE'><filename>DEFAULTTUNE</filename></ulink> |
| 7086 | specifically for each machine's build). |
| 7087 | Rather than "max out" each build's tunings, you can take steps that |
| 7088 | cause the OpenEmbedded build system to reuse software across the |
| 7089 | various machines where it makes sense. |
| 7090 | </para> |
| 7091 | <para> |
| 7092 | If build speed and package feed maintenance are considerations, |
| 7093 | you should consider the points in this section that can help you |
| 7094 | optimize your tunings to best consider build times and package |
| 7095 | feed maintenance. |
| 7096 | <itemizedlist> |
| 7097 | <listitem><para><emphasis>Share the Build Directory:</emphasis> |
| 7098 | If at all possible, share the |
| 7099 | <ulink url='&YOCTO_DOCS_REF_URL;#var-TMPDIR'><filename>TMPDIR</filename></ulink> |
| 7100 | across builds. |
| 7101 | The Yocto Project supports switching between different |
| 7102 | <ulink url='&YOCTO_DOCS_REF_URL;#var-MACHINE'><filename>MACHINE</filename></ulink> |
| 7103 | values in the same <filename>TMPDIR</filename>. |
| 7104 | This practice is well supported and regularly used by |
| 7105 | developers when building for multiple machines. |
| 7106 | When you use the same <filename>TMPDIR</filename> for |
| 7107 | multiple machine builds, the OpenEmbedded build system can |
| 7108 | reuse the existing native and often cross-recipes for |
| 7109 | multiple machines. |
| 7110 | Thus, build time decreases. |
| 7111 | <note> |
| 7112 | If |
| 7113 | <ulink url='&YOCTO_DOCS_REF_URL;#var-DISTRO'><filename>DISTRO</filename></ulink> |
| 7114 | settings change or fundamental configuration settings |
| 7115 | such as the filesystem layout, you need to work with |
| 7116 | a clean <filename>TMPDIR</filename>. |
| 7117 | Sharing <filename>TMPDIR</filename> under these |
| 7118 | circumstances might work but since it is not |
| 7119 | guaranteed, you should use a clean |
| 7120 | <filename>TMPDIR</filename>. |
| 7121 | </note> |
| 7122 | </para></listitem> |
| 7123 | <listitem><para><emphasis>Enable the Appropriate Package Architecture:</emphasis> |
| 7124 | By default, the OpenEmbedded build system enables three |
| 7125 | levels of package architectures: "all", "tune" or "package", |
| 7126 | and "machine". |
| 7127 | Any given recipe usually selects one of these package |
| 7128 | architectures (types) for its output. |
| 7129 | Depending for what a given recipe creates packages, making |
| 7130 | sure you enable the appropriate package architecture can |
| 7131 | directly impact the build time.</para> |
| 7132 | <para>A recipe that just generates scripts can enable |
| 7133 | "all" architecture because there are no binaries to build. |
| 7134 | To specifically enable "all" architecture, be sure your |
| 7135 | recipe inherits the |
| 7136 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-allarch'><filename>allarch</filename></ulink> |
| 7137 | class. |
| 7138 | This class is useful for "all" architectures because it |
| 7139 | configures many variables so packages can be used across |
| 7140 | multiple architectures.</para> |
| 7141 | <para>If your recipe needs to generate packages that are |
| 7142 | machine-specific or when one of the build or runtime |
| 7143 | dependencies is already machine-architecture dependent, |
| 7144 | which makes your recipe also machine-architecture dependent, |
| 7145 | make sure your recipe enables the "machine" package |
| 7146 | architecture through the |
| 7147 | <ulink url='&YOCTO_DOCS_REF_URL;#var-MACHINE_ARCH'><filename>MACHINE_ARCH</filename></ulink> |
| 7148 | variable: |
| 7149 | <literallayout class='monospaced'> |
| 7150 | PACKAGE_ARCH = "${MACHINE_ARCH}" |
| 7151 | </literallayout> |
| 7152 | When you do not specifically enable a package |
| 7153 | architecture through the |
| 7154 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_ARCH'><filename>PACKAGE_ARCH</filename></ulink>, |
| 7155 | The OpenEmbedded build system defaults to the |
| 7156 | <ulink url='&YOCTO_DOCS_REF_URL;#var-TUNE_PKGARCH'><filename>TUNE_PKGARCH</filename></ulink> |
| 7157 | setting: |
| 7158 | <literallayout class='monospaced'> |
| 7159 | PACKAGE_ARCH = "${TUNE_PKGARCH}" |
| 7160 | </literallayout> |
| 7161 | </para></listitem> |
| 7162 | <listitem><para><emphasis>Choose a Generic Tuning File if Possible:</emphasis> |
| 7163 | Some tunes are more generic and can run on multiple targets |
| 7164 | (e.g. an <filename>armv5</filename> set of packages could |
| 7165 | run on <filename>armv6</filename> and |
| 7166 | <filename>armv7</filename> processors in most cases). |
| 7167 | Similarly, <filename>i486</filename> binaries could work |
| 7168 | on <filename>i586</filename> and higher processors. |
| 7169 | You should realize, however, that advances on newer |
| 7170 | processor versions would not be used.</para> |
| 7171 | <para>If you select the same tune for several different |
| 7172 | machines, the OpenEmbedded build system reuses software |
| 7173 | previously built, thus speeding up the overall build time. |
| 7174 | Realize that even though a new sysroot for each machine is |
| 7175 | generated, the software is not recompiled and only one |
| 7176 | package feed exists. |
| 7177 | </para></listitem> |
| 7178 | <listitem><para><emphasis>Manage Granular Level Packaging:</emphasis> |
| 7179 | Sometimes cases exist where injecting another level |
| 7180 | of package architecture beyond the three higher levels |
| 7181 | noted earlier can be useful. |
| 7182 | For example, consider the <filename>emgd</filename> |
| 7183 | graphics stack in the |
| 7184 | <filename>meta-intel</filename> layer. |
| 7185 | In this layer, a subset of software exists that is |
| 7186 | compiled against something different from the rest of the |
| 7187 | generic packages. |
| 7188 | You can examine the key code in the |
| 7189 | <ulink url='http://git.yoctoproject.org/cgit/cgit.cgi'>Source Repositories</ulink> |
| 7190 | "daisy" branch in |
| 7191 | <filename>classes/emgd-gl.bbclass</filename>. |
| 7192 | For a specific set of packages, the code redefines |
| 7193 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_ARCH'><filename>PACKAGE_ARCH</filename></ulink>. |
| 7194 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_EXTRA_ARCHS'><filename>PACKAGE_EXTRA_ARCHS</filename></ulink> |
| 7195 | is then appended with this extra tune name in |
| 7196 | <filename>meta-intel-emgd.inc</filename>. |
| 7197 | The result is that when searching for packages, the |
| 7198 | build system uses a four-level search and the packages |
| 7199 | in this new level are preferred as compared to the standard |
| 7200 | tune. |
| 7201 | The overall result is that the build system reuses most |
| 7202 | software from the common tune except for specific cases |
| 7203 | as needed. |
| 7204 | </para></listitem> |
| 7205 | <listitem><para><emphasis>Use Tools to Debug Issues:</emphasis> |
| 7206 | Sometimes you can run into situations where software is |
| 7207 | being rebuilt when you think it should not be. |
| 7208 | For example, the OpenEmbedded build system might not be |
| 7209 | using shared state between machines when you think it |
| 7210 | should be. |
| 7211 | These types of situations are usually due to references |
| 7212 | to machine-specific variables such as |
| 7213 | <ulink url='&YOCTO_DOCS_REF_URL;#var-MACHINE'><filename>MACHINE</filename></ulink>, |
| 7214 | <ulink url='&YOCTO_DOCS_REF_URL;#var-SERIAL_CONSOLE'><filename>SERIAL_CONSOLE</filename></ulink>, |
| 7215 | <ulink url='&YOCTO_DOCS_REF_URL;#var-XSERVER'><filename>XSERVER</filename></ulink>, |
| 7216 | <ulink url='&YOCTO_DOCS_REF_URL;#var-MACHINE_FEATURES'><filename>MACHINE_FEATURES</filename></ulink>, |
| 7217 | and so forth in code that is supposed to only be |
| 7218 | tune-specific or when the recipe depends |
| 7219 | (<ulink url='&YOCTO_DOCS_REF_URL;#var-DEPENDS'><filename>DEPENDS</filename></ulink>, |
| 7220 | <ulink url='&YOCTO_DOCS_REF_URL;#var-RDEPENDS'><filename>RDEPENDS</filename></ulink>, |
| 7221 | <ulink url='&YOCTO_DOCS_REF_URL;#var-RRECOMMENDS'><filename>RRECOMMENDS</filename></ulink>, |
| 7222 | <ulink url='&YOCTO_DOCS_REF_URL;#var-RSUGGESTS'><filename>RSUGGESTS</filename></ulink>, |
| 7223 | and so forth) on some other recipe that already has |
| 7224 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_ARCH'><filename>PACKAGE_ARCH</filename></ulink> |
| 7225 | defined as "${MACHINE_ARCH}". |
| 7226 | <note> |
| 7227 | Patches to fix any issues identified are most welcome |
| 7228 | as these issues occasionally do occur. |
| 7229 | </note></para> |
| 7230 | <para>For such cases, you can use some tools to help you |
| 7231 | sort out the situation: |
| 7232 | <itemizedlist> |
| 7233 | <listitem><para><emphasis><filename>sstate-diff-machines.sh</filename>:</emphasis> |
| 7234 | You can find this tool in the |
| 7235 | <filename>scripts</filename> directory of the |
| 7236 | Source Repositories. |
| 7237 | See the comments in the script for information on |
| 7238 | how to use the tool. |
| 7239 | </para></listitem> |
| 7240 | <listitem><para><emphasis>BitBake's "-S printdiff" Option:</emphasis> |
| 7241 | Using this option causes BitBake to try to |
| 7242 | establish the closest signature match it can |
| 7243 | (e.g. in the shared state cache) and then run |
| 7244 | <filename>bitbake-diffsigs</filename> over the |
| 7245 | matches to determine the stamps and delta where |
| 7246 | these two stamp trees diverge. |
| 7247 | </para></listitem> |
| 7248 | </itemizedlist> |
| 7249 | </para></listitem> |
| 7250 | </itemizedlist> |
| 7251 | </para> |
| 7252 | </section> |
| 7253 | |
| 7254 | <section id='working-with-packages'> |
| 7255 | <title>Working with Packages</title> |
| 7256 | |
| 7257 | <para> |
| 7258 | This section describes a few tasks that involve packages: |
| 7259 | <itemizedlist> |
| 7260 | <listitem><para> |
| 7261 | <link linkend='excluding-packages-from-an-image'>Excluding packages from an image</link> |
| 7262 | </para></listitem> |
| 7263 | <listitem><para> |
| 7264 | <link linkend='incrementing-a-package-revision-number'>Incrementing a package revision number</link> |
| 7265 | </para></listitem> |
| 7266 | <listitem><para> |
| 7267 | <link linkend='handling-optional-module-packaging'>Handling optional module packaging</link> |
| 7268 | </para></listitem> |
| 7269 | <listitem><para> |
| 7270 | <link linkend='using-runtime-package-management'>Using Runtime Package Management</link> |
| 7271 | </para></listitem> |
| 7272 | <listitem><para> |
| 7273 | <link linkend='testing-packages-with-ptest'>Setting up and running package test (ptest)</link> |
| 7274 | </para></listitem> |
| 7275 | </itemizedlist> |
| 7276 | </para> |
| 7277 | |
| 7278 | <section id='excluding-packages-from-an-image'> |
| 7279 | <title>Excluding Packages from an Image</title> |
| 7280 | |
| 7281 | <para> |
| 7282 | You might find it necessary to prevent specific packages |
| 7283 | from being installed into an image. |
| 7284 | If so, you can use several variables to direct the build |
| 7285 | system to essentially ignore installing recommended packages |
| 7286 | or to not install a package at all. |
| 7287 | </para> |
| 7288 | |
| 7289 | <para> |
| 7290 | The following list introduces variables you can use to |
| 7291 | prevent packages from being installed into your image. |
| 7292 | Each of these variables only works with IPK and RPM |
| 7293 | package types. |
| 7294 | Support for Debian packages does not exist. |
| 7295 | Also, you can use these variables from your |
| 7296 | <filename>local.conf</filename> file or attach them to a |
| 7297 | specific image recipe by using a recipe name override. |
| 7298 | For more detail on the variables, see the descriptions in the |
| 7299 | Yocto Project Reference Manual's glossary chapter. |
| 7300 | <itemizedlist> |
| 7301 | <listitem><para><ulink url='&YOCTO_DOCS_REF_URL;#var-BAD_RECOMMENDATIONS'><filename>BAD_RECOMMENDATIONS</filename></ulink>: |
| 7302 | Use this variable to specify "recommended-only" |
| 7303 | packages that you do not want installed. |
| 7304 | </para></listitem> |
| 7305 | <listitem><para><ulink url='&YOCTO_DOCS_REF_URL;#var-NO_RECOMMENDATIONS'><filename>NO_RECOMMENDATIONS</filename></ulink>: |
| 7306 | Use this variable to prevent all "recommended-only" |
| 7307 | packages from being installed. |
| 7308 | </para></listitem> |
| 7309 | <listitem><para><ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_EXCLUDE'><filename>PACKAGE_EXCLUDE</filename></ulink>: |
| 7310 | Use this variable to prevent specific packages from |
| 7311 | being installed regardless of whether they are |
| 7312 | "recommended-only" or not. |
| 7313 | You need to realize that the build process could |
| 7314 | fail with an error when you |
| 7315 | prevent the installation of a package whose presence |
| 7316 | is required by an installed package. |
| 7317 | </para></listitem> |
| 7318 | </itemizedlist> |
| 7319 | </para> |
| 7320 | </section> |
| 7321 | |
| 7322 | <section id='incrementing-a-package-revision-number'> |
| 7323 | <title>Incrementing a Package Revision Number</title> |
| 7324 | |
| 7325 | <para> |
| 7326 | If a committed change results in changing the package output, |
| 7327 | then the value of the |
| 7328 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PR'><filename>PR</filename></ulink> |
| 7329 | variable needs to be increased (or "bumped"). |
| 7330 | Increasing <filename>PR</filename> occurs one of two ways: |
| 7331 | <itemizedlist> |
| 7332 | <listitem><para>Automatically using a Package Revision |
| 7333 | Service (PR Service).</para></listitem> |
| 7334 | <listitem><para>Manually incrementing the |
| 7335 | <filename>PR</filename> variable.</para></listitem> |
| 7336 | </itemizedlist> |
| 7337 | </para> |
| 7338 | |
| 7339 | <para> |
| 7340 | Given that one of the challenges any build system and its |
| 7341 | users face is how to maintain a package feed that is compatible |
| 7342 | with existing package manager applications such as |
| 7343 | RPM, APT, and OPKG, using an automated system is much |
| 7344 | preferred over a manual system. |
| 7345 | In either system, the main requirement is that version |
| 7346 | numbering increases in a linear fashion and that a number of |
| 7347 | version components exist that support that linear progression. |
| 7348 | </para> |
| 7349 | |
| 7350 | <para> |
| 7351 | The following two sections provide information on the PR Service |
| 7352 | and on manual <filename>PR</filename> bumping. |
| 7353 | </para> |
| 7354 | |
| 7355 | <section id='working-with-a-pr-service'> |
| 7356 | <title>Working With a PR Service</title> |
| 7357 | |
| 7358 | <para> |
| 7359 | As mentioned, attempting to maintain revision numbers in the |
| 7360 | <ulink url='&YOCTO_DOCS_DEV_URL;#metadata'>Metadata</ulink> |
| 7361 | is error prone, inaccurate, and causes problems for people |
| 7362 | submitting recipes. |
| 7363 | Conversely, the PR Service automatically generates |
| 7364 | increasing numbers, particularly the revision field, |
| 7365 | which removes the human element. |
| 7366 | <note> |
| 7367 | For additional information on using a PR Service, you |
| 7368 | can see the |
| 7369 | <ulink url='&YOCTO_WIKI_URL;/wiki/PR_Service'>PR Service</ulink> |
| 7370 | wiki page. |
| 7371 | </note> |
| 7372 | </para> |
| 7373 | |
| 7374 | <para> |
| 7375 | The Yocto Project uses variables in order of |
| 7376 | decreasing priority to facilitate revision numbering (i.e. |
| 7377 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PE'><filename>PE</filename></ulink>, |
| 7378 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PV'><filename>PV</filename></ulink>, and |
| 7379 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PR'><filename>PR</filename></ulink> |
| 7380 | for epoch, version, and revision, respectively). |
| 7381 | The values are highly dependent on the policies and |
| 7382 | procedures of a given distribution and package feed. |
| 7383 | </para> |
| 7384 | |
| 7385 | <para> |
| 7386 | Because the OpenEmbedded build system uses |
| 7387 | "<ulink url='&YOCTO_DOCS_REF_URL;#checksums'>signatures</ulink>", |
| 7388 | which are unique to a given build, the build system |
| 7389 | knows when to rebuild packages. |
| 7390 | All the inputs into a given task are represented by a |
| 7391 | signature, which can trigger a rebuild when different. |
| 7392 | Thus, the build system itself does not rely on the |
| 7393 | <filename>PR</filename> numbers to trigger a rebuild. |
| 7394 | The signatures, however, can be used to generate |
| 7395 | <filename>PR</filename> values. |
| 7396 | </para> |
| 7397 | |
| 7398 | <para> |
| 7399 | The PR Service works with both |
| 7400 | <filename>OEBasic</filename> and |
| 7401 | <filename>OEBasicHash</filename> generators. |
| 7402 | The value of <filename>PR</filename> bumps when the |
| 7403 | checksum changes and the different generator mechanisms |
| 7404 | change signatures under different circumstances. |
| 7405 | </para> |
| 7406 | |
| 7407 | <para> |
| 7408 | As implemented, the build system includes values from |
| 7409 | the PR Service into the <filename>PR</filename> field as |
| 7410 | an addition using the form "<filename>.x</filename>" so |
| 7411 | <filename>r0</filename> becomes <filename>r0.1</filename>, |
| 7412 | <filename>r0.2</filename> and so forth. |
| 7413 | This scheme allows existing <filename>PR</filename> values |
| 7414 | to be used for whatever reasons, which include manual |
| 7415 | <filename>PR</filename> bumps, should it be necessary. |
| 7416 | </para> |
| 7417 | |
| 7418 | <para> |
| 7419 | By default, the PR Service is not enabled or running. |
| 7420 | Thus, the packages generated are just "self consistent". |
| 7421 | The build system adds and removes packages and |
| 7422 | there are no guarantees about upgrade paths but images |
| 7423 | will be consistent and correct with the latest changes. |
| 7424 | </para> |
| 7425 | |
| 7426 | <para> |
| 7427 | The simplest form for a PR Service is for it to exist |
| 7428 | for a single host development system that builds the |
| 7429 | package feed (building system). |
| 7430 | For this scenario, you can enable a local PR Service by |
| 7431 | setting |
| 7432 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PRSERV_HOST'><filename>PRSERV_HOST</filename></ulink> |
| 7433 | in your <filename>local.conf</filename> file in the |
| 7434 | <ulink url='&YOCTO_DOCS_DEV_URL;#build-directory'>Build Directory</ulink>: |
| 7435 | <literallayout class='monospaced'> |
| 7436 | PRSERV_HOST = "localhost:0" |
| 7437 | </literallayout> |
| 7438 | Once the service is started, packages will automatically |
| 7439 | get increasing <filename>PR</filename> values and |
| 7440 | BitBake will take care of starting and stopping the server. |
| 7441 | </para> |
| 7442 | |
| 7443 | <para> |
| 7444 | If you have a more complex setup where multiple host |
| 7445 | development systems work against a common, shared package |
| 7446 | feed, you have a single PR Service running and it is |
| 7447 | connected to each building system. |
| 7448 | For this scenario, you need to start the PR Service using |
| 7449 | the <filename>bitbake-prserv</filename> command: |
| 7450 | <literallayout class='monospaced'> |
| 7451 | bitbake-prserv --host <replaceable>ip</replaceable> --port <replaceable>port</replaceable> --start |
| 7452 | </literallayout> |
| 7453 | In addition to hand-starting the service, you need to |
| 7454 | update the <filename>local.conf</filename> file of each |
| 7455 | building system as described earlier so each system |
| 7456 | points to the server and port. |
| 7457 | </para> |
| 7458 | |
| 7459 | <para> |
| 7460 | It is also recommended you use build history, which adds |
| 7461 | some sanity checks to package versions, in conjunction with |
| 7462 | the server that is running the PR Service. |
| 7463 | To enable build history, add the following to each building |
| 7464 | system's <filename>local.conf</filename> file: |
| 7465 | <literallayout class='monospaced'> |
| 7466 | # It is recommended to activate "buildhistory" for testing the PR service |
| 7467 | INHERIT += "buildhistory" |
| 7468 | BUILDHISTORY_COMMIT = "1" |
| 7469 | </literallayout> |
| 7470 | For information on build history, see the |
| 7471 | "<ulink url='&YOCTO_DOCS_REF_URL;#maintaining-build-output-quality'>Maintaining Build Output Quality</ulink>" |
| 7472 | section in the Yocto Project Reference Manual. |
| 7473 | </para> |
| 7474 | |
| 7475 | <note> |
| 7476 | <para>The OpenEmbedded build system does not maintain |
| 7477 | <filename>PR</filename> information as part of the |
| 7478 | shared state (sstate) packages. |
| 7479 | If you maintain an sstate feed, its expected that either |
| 7480 | all your building systems that contribute to the sstate |
| 7481 | feed use a shared PR Service, or you do not run a PR |
| 7482 | Service on any of your building systems. |
| 7483 | Having some systems use a PR Service while others do |
| 7484 | not leads to obvious problems.</para> |
| 7485 | <para>For more information on shared state, see the |
| 7486 | "<ulink url='&YOCTO_DOCS_REF_URL;#shared-state-cache'>Shared State Cache</ulink>" |
| 7487 | section in the Yocto Project Reference Manual.</para> |
| 7488 | </note> |
| 7489 | </section> |
| 7490 | |
| 7491 | <section id='manually-bumping-pr'> |
| 7492 | <title>Manually Bumping PR</title> |
| 7493 | |
| 7494 | <para> |
| 7495 | The alternative to setting up a PR Service is to manually |
| 7496 | bump the |
| 7497 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PR'><filename>PR</filename></ulink> |
| 7498 | variable. |
| 7499 | </para> |
| 7500 | |
| 7501 | <para> |
| 7502 | If a committed change results in changing the package output, |
| 7503 | then the value of the PR variable needs to be increased |
| 7504 | (or "bumped") as part of that commit. |
| 7505 | For new recipes you should add the <filename>PR</filename> |
| 7506 | variable and set its initial value equal to "r0", which is the default. |
| 7507 | Even though the default value is "r0", the practice of adding it to a new recipe makes |
| 7508 | it harder to forget to bump the variable when you make changes |
| 7509 | to the recipe in future. |
| 7510 | </para> |
| 7511 | |
| 7512 | <para> |
| 7513 | If you are sharing a common <filename>.inc</filename> file with multiple recipes, |
| 7514 | you can also use the |
| 7515 | <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-INC_PR'>INC_PR</ulink></filename> |
| 7516 | variable to ensure that |
| 7517 | the recipes sharing the <filename>.inc</filename> file are rebuilt when the |
| 7518 | <filename>.inc</filename> file itself is changed. |
| 7519 | The <filename>.inc</filename> file must set <filename>INC_PR</filename> |
| 7520 | (initially to "r0"), and all recipes referring to it should set <filename>PR</filename> |
| 7521 | to "$(INC_PR).0" initially, incrementing the last number when the recipe is changed. |
| 7522 | If the <filename>.inc</filename> file is changed then its |
| 7523 | <filename>INC_PR</filename> should be incremented. |
| 7524 | </para> |
| 7525 | |
| 7526 | <para> |
| 7527 | When upgrading the version of a package, assuming the |
| 7528 | <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-PV'>PV</ulink></filename> |
| 7529 | changes, the <filename>PR</filename> variable should be |
| 7530 | reset to "r0" (or "$(INC_PR).0" if you are using |
| 7531 | <filename>INC_PR</filename>). |
| 7532 | </para> |
| 7533 | |
| 7534 | <para> |
| 7535 | Usually, version increases occur only to packages. |
| 7536 | However, if for some reason <filename>PV</filename> changes but does not |
| 7537 | increase, you can increase the |
| 7538 | <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-PE'>PE</ulink></filename> |
| 7539 | variable (Package Epoch). |
| 7540 | The <filename>PE</filename> variable defaults to "0". |
| 7541 | </para> |
| 7542 | |
| 7543 | <para> |
| 7544 | Version numbering strives to follow the |
| 7545 | <ulink url='http://www.debian.org/doc/debian-policy/ch-controlfields.html'> |
| 7546 | Debian Version Field Policy Guidelines</ulink>. |
| 7547 | These guidelines define how versions are compared and what "increasing" a version means. |
| 7548 | </para> |
| 7549 | </section> |
| 7550 | </section> |
| 7551 | |
| 7552 | <section id='handling-optional-module-packaging'> |
| 7553 | <title>Handling Optional Module Packaging</title> |
| 7554 | |
| 7555 | <para> |
| 7556 | Many pieces of software split functionality into optional |
| 7557 | modules (or plug-ins) and the plug-ins that are built |
| 7558 | might depend on configuration options. |
| 7559 | To avoid having to duplicate the logic that determines what |
| 7560 | modules are available in your recipe or to avoid having |
| 7561 | to package each module by hand, the OpenEmbedded build system |
| 7562 | provides functionality to handle module packaging dynamically. |
| 7563 | </para> |
| 7564 | |
| 7565 | <para> |
| 7566 | To handle optional module packaging, you need to do two things: |
| 7567 | <itemizedlist> |
| 7568 | <listitem><para>Ensure the module packaging is actually |
| 7569 | done.</para></listitem> |
| 7570 | <listitem><para>Ensure that any dependencies on optional |
| 7571 | modules from other recipes are satisfied by your recipe. |
| 7572 | </para></listitem> |
| 7573 | </itemizedlist> |
| 7574 | </para> |
| 7575 | |
| 7576 | <section id='making-sure-the-packaging-is-done'> |
| 7577 | <title>Making Sure the Packaging is Done</title> |
| 7578 | |
| 7579 | <para> |
| 7580 | To ensure the module packaging actually gets done, you use |
| 7581 | the <filename>do_split_packages</filename> function within |
| 7582 | the <filename>populate_packages</filename> Python function |
| 7583 | in your recipe. |
| 7584 | The <filename>do_split_packages</filename> function |
| 7585 | searches for a pattern of files or directories under a |
| 7586 | specified path and creates a package for each one it finds |
| 7587 | by appending to the |
| 7588 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGES'><filename>PACKAGES</filename></ulink> |
| 7589 | variable and setting the appropriate values for |
| 7590 | <filename>FILES_packagename</filename>, |
| 7591 | <filename>RDEPENDS_packagename</filename>, |
| 7592 | <filename>DESCRIPTION_packagename</filename>, and so forth. |
| 7593 | Here is an example from the <filename>lighttpd</filename> |
| 7594 | recipe: |
| 7595 | <literallayout class='monospaced'> |
| 7596 | python populate_packages_prepend () { |
| 7597 | lighttpd_libdir = d.expand('${libdir}') |
| 7598 | do_split_packages(d, lighttpd_libdir, '^mod_(.*)\.so$', |
| 7599 | 'lighttpd-module-%s', 'Lighttpd module for %s', |
| 7600 | extra_depends='') |
| 7601 | } |
| 7602 | </literallayout> |
| 7603 | The previous example specifies a number of things in the |
| 7604 | call to <filename>do_split_packages</filename>. |
| 7605 | <itemizedlist> |
| 7606 | <listitem><para>A directory within the files installed |
| 7607 | by your recipe through <filename>do_install</filename> |
| 7608 | in which to search.</para></listitem> |
| 7609 | <listitem><para>A regular expression used to match module |
| 7610 | files in that directory. |
| 7611 | In the example, note the parentheses () that mark |
| 7612 | the part of the expression from which the module |
| 7613 | name should be derived.</para></listitem> |
| 7614 | <listitem><para>A pattern to use for the package names. |
| 7615 | </para></listitem> |
| 7616 | <listitem><para>A description for each package. |
| 7617 | </para></listitem> |
| 7618 | <listitem><para>An empty string for |
| 7619 | <filename>extra_depends</filename>, which disables |
| 7620 | the default dependency on the main |
| 7621 | <filename>lighttpd</filename> package. |
| 7622 | Thus, if a file in <filename>${libdir}</filename> |
| 7623 | called <filename>mod_alias.so</filename> is found, |
| 7624 | a package called <filename>lighttpd-module-alias</filename> |
| 7625 | is created for it and the |
| 7626 | <ulink url='&YOCTO_DOCS_REF_URL;#var-DESCRIPTION'><filename>DESCRIPTION</filename></ulink> |
| 7627 | is set to "Lighttpd module for alias".</para></listitem> |
| 7628 | </itemizedlist> |
| 7629 | </para> |
| 7630 | |
| 7631 | <para> |
| 7632 | Often, packaging modules is as simple as the previous |
| 7633 | example. |
| 7634 | However, more advanced options exist that you can use |
| 7635 | within <filename>do_split_packages</filename> to modify its |
| 7636 | behavior. |
| 7637 | And, if you need to, you can add more logic by specifying |
| 7638 | a hook function that is called for each package. |
| 7639 | It is also perfectly acceptable to call |
| 7640 | <filename>do_split_packages</filename> multiple times if |
| 7641 | you have more than one set of modules to package. |
| 7642 | </para> |
| 7643 | |
| 7644 | <para> |
| 7645 | For more examples that show how to use |
| 7646 | <filename>do_split_packages</filename>, see the |
| 7647 | <filename>connman.inc</filename> file in the |
| 7648 | <filename>meta/recipes-connectivity/connman/</filename> |
| 7649 | directory of the <filename>poky</filename> |
| 7650 | <link linkend='yocto-project-repositories'>source repository</link>. |
| 7651 | You can also find examples in |
| 7652 | <filename>meta/classes/kernel.bbclass</filename>. |
| 7653 | </para> |
| 7654 | |
| 7655 | <para> |
| 7656 | Following is a reference that shows |
| 7657 | <filename>do_split_packages</filename> mandatory and |
| 7658 | optional arguments: |
| 7659 | <literallayout class='monospaced'> |
| 7660 | Mandatory arguments |
| 7661 | |
| 7662 | root |
| 7663 | The path in which to search |
| 7664 | file_regex |
| 7665 | Regular expression to match searched files. |
| 7666 | Use parentheses () to mark the part of this |
| 7667 | expression that should be used to derive the |
| 7668 | module name (to be substituted where %s is |
| 7669 | used in other function arguments as noted below) |
| 7670 | output_pattern |
| 7671 | Pattern to use for the package names. Must |
| 7672 | include %s. |
| 7673 | description |
| 7674 | Description to set for each package. Must |
| 7675 | include %s. |
| 7676 | |
| 7677 | Optional arguments |
| 7678 | |
| 7679 | postinst |
| 7680 | Postinstall script to use for all packages |
| 7681 | (as a string) |
| 7682 | recursive |
| 7683 | True to perform a recursive search - default |
| 7684 | False |
| 7685 | hook |
| 7686 | A hook function to be called for every match. |
| 7687 | The function will be called with the following |
| 7688 | arguments (in the order listed): |
| 7689 | |
| 7690 | f |
| 7691 | Full path to the file/directory match |
| 7692 | pkg |
| 7693 | The package name |
| 7694 | file_regex |
| 7695 | As above |
| 7696 | output_pattern |
| 7697 | As above |
| 7698 | modulename |
| 7699 | The module name derived using file_regex |
| 7700 | |
| 7701 | extra_depends |
| 7702 | Extra runtime dependencies (RDEPENDS) to be |
| 7703 | set for all packages. The default value of None |
| 7704 | causes a dependency on the main package |
| 7705 | (${PN}) - if you do not want this, pass empty |
| 7706 | string '' for this parameter. |
| 7707 | aux_files_pattern |
| 7708 | Extra item(s) to be added to FILES for each |
| 7709 | package. Can be a single string item or a list |
| 7710 | of strings for multiple items. Must include %s. |
| 7711 | postrm |
| 7712 | postrm script to use for all packages (as a |
| 7713 | string) |
| 7714 | allow_dirs |
| 7715 | True to allow directories to be matched - |
| 7716 | default False |
| 7717 | prepend |
| 7718 | If True, prepend created packages to PACKAGES |
| 7719 | instead of the default False which appends them |
| 7720 | match_path |
| 7721 | match file_regex on the whole relative path to |
| 7722 | the root rather than just the file name |
| 7723 | aux_files_pattern_verbatim |
| 7724 | Extra item(s) to be added to FILES for each |
| 7725 | package, using the actual derived module name |
| 7726 | rather than converting it to something legal |
| 7727 | for a package name. Can be a single string item |
| 7728 | or a list of strings for multiple items. Must |
| 7729 | include %s. |
| 7730 | allow_links |
| 7731 | True to allow symlinks to be matched - default |
| 7732 | False |
| 7733 | summary |
| 7734 | Summary to set for each package. Must include %s; |
| 7735 | defaults to description if not set. |
| 7736 | </literallayout> |
| 7737 | </para> |
| 7738 | </section> |
| 7739 | |
| 7740 | <section id='satisfying-dependencies'> |
| 7741 | <title>Satisfying Dependencies</title> |
| 7742 | |
| 7743 | <para> |
| 7744 | The second part for handling optional module packaging |
| 7745 | is to ensure that any dependencies on optional modules |
| 7746 | from other recipes are satisfied by your recipe. |
| 7747 | You can be sure these dependencies are satisfied by |
| 7748 | using the |
| 7749 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGES_DYNAMIC'><filename>PACKAGES_DYNAMIC</filename></ulink> variable. |
| 7750 | Here is an example that continues with the |
| 7751 | <filename>lighttpd</filename> recipe shown earlier: |
| 7752 | <literallayout class='monospaced'> |
| 7753 | PACKAGES_DYNAMIC = "lighttpd-module-.*" |
| 7754 | </literallayout> |
| 7755 | The name specified in the regular expression can of |
| 7756 | course be anything. |
| 7757 | In this example, it is <filename>lighttpd-module-</filename> |
| 7758 | and is specified as the prefix to ensure that any |
| 7759 | <ulink url='&YOCTO_DOCS_REF_URL;#var-RDEPENDS'><filename>RDEPENDS</filename></ulink> |
| 7760 | and <ulink url='&YOCTO_DOCS_REF_URL;#var-RRECOMMENDS'><filename>RRECOMMENDS</filename></ulink> |
| 7761 | on a package name starting with the prefix are satisfied |
| 7762 | during build time. |
| 7763 | If you are using <filename>do_split_packages</filename> |
| 7764 | as described in the previous section, the value you put in |
| 7765 | <filename>PACKAGES_DYNAMIC</filename> should correspond to |
| 7766 | the name pattern specified in the call to |
| 7767 | <filename>do_split_packages</filename>. |
| 7768 | </para> |
| 7769 | </section> |
| 7770 | </section> |
| 7771 | |
| 7772 | <section id='using-runtime-package-management'> |
| 7773 | <title>Using Runtime Package Management</title> |
| 7774 | |
| 7775 | <para> |
| 7776 | During a build, BitBake always transforms a recipe into one or |
| 7777 | more packages. |
| 7778 | For example, BitBake takes the <filename>bash</filename> recipe |
| 7779 | and currently produces the <filename>bash-dbg</filename>, |
| 7780 | <filename>bash-staticdev</filename>, |
| 7781 | <filename>bash-dev</filename>, <filename>bash-doc</filename>, |
| 7782 | <filename>bash-locale</filename>, and |
| 7783 | <filename>bash</filename> packages. |
| 7784 | Not all generated packages are included in an image. |
| 7785 | </para> |
| 7786 | |
| 7787 | <para> |
| 7788 | In several situations, you might need to update, add, remove, |
| 7789 | or query the packages on a target device at runtime |
| 7790 | (i.e. without having to generate a new image). |
| 7791 | Examples of such situations include: |
| 7792 | <itemizedlist> |
| 7793 | <listitem><para> |
| 7794 | You want to provide in-the-field updates to deployed |
| 7795 | devices (e.g. security updates). |
| 7796 | </para></listitem> |
| 7797 | <listitem><para> |
| 7798 | You want to have a fast turn-around development cycle |
| 7799 | for one or more applications that run on your device. |
| 7800 | </para></listitem> |
| 7801 | <listitem><para> |
| 7802 | You want to temporarily install the "debug" packages |
| 7803 | of various applications on your device so that |
| 7804 | debugging can be greatly improved by allowing |
| 7805 | access to symbols and source debugging. |
| 7806 | </para></listitem> |
| 7807 | <listitem><para> |
| 7808 | You want to deploy a more minimal package selection of |
| 7809 | your device but allow in-the-field updates to add a |
| 7810 | larger selection for customization. |
| 7811 | </para></listitem> |
| 7812 | </itemizedlist> |
| 7813 | </para> |
| 7814 | |
| 7815 | <para> |
| 7816 | In all these situations, you have something similar to a more |
| 7817 | traditional Linux distribution in that in-field devices |
| 7818 | are able to receive pre-compiled packages from a server for |
| 7819 | installation or update. |
| 7820 | Being able to install these packages on a running, |
| 7821 | in-field device is what is termed "runtime package |
| 7822 | management". |
| 7823 | </para> |
| 7824 | |
| 7825 | <para> |
| 7826 | In order to use runtime package management, you |
| 7827 | need a host/server machine that serves up the pre-compiled |
| 7828 | packages plus the required metadata. |
| 7829 | You also need package manipulation tools on the target. |
| 7830 | The build machine is a likely candidate to act as the server. |
| 7831 | However, that machine does not necessarily have to be the |
| 7832 | package server. |
| 7833 | The build machine could push its artifacts to another machine |
| 7834 | that acts as the server (e.g. Internet-facing). |
| 7835 | </para> |
| 7836 | |
| 7837 | <para> |
| 7838 | A simple build that targets just one device produces |
| 7839 | more than one package database. |
| 7840 | In other words, the packages produced by a build are separated |
| 7841 | out into a couple of different package groupings based on |
| 7842 | criteria such as the target's CPU architecture, the target |
| 7843 | board, or the C library used on the target. |
| 7844 | For example, a build targeting the <filename>qemuarm</filename> |
| 7845 | device produces the following three package databases: |
| 7846 | <filename>all</filename>, <filename>armv5te</filename>, and |
| 7847 | <filename>qemuarm</filename>. |
| 7848 | If you wanted your <filename>qemuarm</filename> device to be |
| 7849 | aware of all the packages that were available to it, |
| 7850 | you would need to point it to each of these databases |
| 7851 | individually. |
| 7852 | In a similar way, a traditional Linux distribution usually is |
| 7853 | configured to be aware of a number of software repositories |
| 7854 | from which it retrieves packages. |
| 7855 | </para> |
| 7856 | |
| 7857 | <para> |
| 7858 | Using runtime package management is completely optional and |
| 7859 | not required for a successful build or deployment in any |
| 7860 | way. |
| 7861 | But if you want to make use of runtime package management, |
| 7862 | you need to do a couple things above and beyond the basics. |
| 7863 | The remainder of this section describes what you need to do. |
| 7864 | </para> |
| 7865 | |
| 7866 | <section id='runtime-package-management-build'> |
| 7867 | <title>Build Considerations</title> |
| 7868 | |
| 7869 | <para> |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame^] | 7870 | This section describes build considerations of which you |
| 7871 | need to be aware in order to provide support for runtime |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 7872 | package management. |
| 7873 | </para> |
| 7874 | |
| 7875 | <para> |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame^] | 7876 | When BitBake generates packages, it needs to know |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 7877 | what format or formats to use. |
| 7878 | In your configuration, you use the |
| 7879 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_CLASSES'><filename>PACKAGE_CLASSES</filename></ulink> |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame^] | 7880 | variable to specify the format: |
| 7881 | <orderedlist> |
| 7882 | <listitem><para> |
| 7883 | Open the <filename>local.conf</filename> file |
| 7884 | inside your |
| 7885 | <link linkend='build-directory'>Build Directory</link> |
| 7886 | (e.g. <filename>~/poky/build/conf/local.conf</filename>). |
| 7887 | </para></listitem> |
| 7888 | <listitem><para> |
| 7889 | Select the desired package format as follows: |
| 7890 | <literallayout class='monospaced'> |
| 7891 | PACKAGE_CLASSES ?= “package_<replaceable>packageformat</replaceable>” |
| 7892 | </literallayout> |
| 7893 | where <replaceable>packageformat</replaceable> |
| 7894 | can be "ipk", "rpm", and "deb", which are the |
| 7895 | supported package formats. |
| 7896 | <note> |
| 7897 | Because the Yocto Project supports three |
| 7898 | different package formats, you can set the |
| 7899 | variable with more than one argument. |
| 7900 | However, the OpenEmbedded build system only |
| 7901 | uses the first argument when creating an image |
| 7902 | or Software Development Kit (SDK). |
| 7903 | </note> |
| 7904 | </para></listitem> |
| 7905 | </orderedlist> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 7906 | </para> |
| 7907 | |
| 7908 | <para> |
| 7909 | If you would like your image to start off with a basic |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame^] | 7910 | package database containing the packages in your current |
| 7911 | build as well as to have the relevant tools available on the |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 7912 | target for runtime package management, you can include |
| 7913 | "package-management" in the |
| 7914 | <ulink url='&YOCTO_DOCS_REF_URL;#var-IMAGE_FEATURES'><filename>IMAGE_FEATURES</filename></ulink> |
| 7915 | variable. |
| 7916 | Including "package-management" in this |
| 7917 | configuration variable ensures that when the image |
| 7918 | is assembled for your target, the image includes |
| 7919 | the currently-known package databases as well as |
| 7920 | the target-specific tools required for runtime |
| 7921 | package management to be performed on the target. |
| 7922 | However, this is not strictly necessary. |
| 7923 | You could start your image off without any databases |
| 7924 | but only include the required on-target package |
| 7925 | tool(s). |
| 7926 | As an example, you could include "opkg" in your |
| 7927 | <ulink url='&YOCTO_DOCS_REF_URL;#var-IMAGE_INSTALL'><filename>IMAGE_INSTALL</filename></ulink> |
| 7928 | variable if you are using the IPK package format. |
| 7929 | You can then initialize your target's package database(s) |
| 7930 | later once your image is up and running. |
| 7931 | </para> |
| 7932 | |
| 7933 | <para> |
| 7934 | Whenever you perform any sort of build step that can |
| 7935 | potentially generate a package or modify an existing |
| 7936 | package, it is always a good idea to re-generate the |
| 7937 | package index with: |
| 7938 | <literallayout class='monospaced'> |
| 7939 | $ bitbake package-index |
| 7940 | </literallayout> |
| 7941 | Realize that it is not sufficient to simply do the |
| 7942 | following: |
| 7943 | <literallayout class='monospaced'> |
| 7944 | $ bitbake <replaceable>some-package</replaceable> package-index |
| 7945 | </literallayout> |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame^] | 7946 | The reason for this restriction is because BitBake does not |
| 7947 | properly schedule the <filename>package-index</filename> |
| 7948 | target fully after any other target has completed. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 7949 | Thus, be sure to run the package update step separately. |
| 7950 | </para> |
| 7951 | |
| 7952 | <para> |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame^] | 7953 | You can use the |
| 7954 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_FEED_ARCHS'><filename>PACKAGE_FEED_ARCHS</filename></ulink>, |
| 7955 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_FEED_BASE_PATHS'><filename>PACKAGE_FEED_BASE_PATHS</filename></ulink>, |
| 7956 | and |
| 7957 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_FEED_URIS'><filename>PACKAGE_FEED_URIS</filename></ulink> |
| 7958 | variables to pre-configure target images to use a package |
| 7959 | feed. |
| 7960 | If you do not define these variables, then manual steps |
| 7961 | as described in the subsequent sections are necessary to |
| 7962 | configure the target. |
| 7963 | You should set these variables before building the image |
| 7964 | in order to produce a correctly configured image. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 7965 | </para> |
| 7966 | |
| 7967 | <para> |
| 7968 | When your build is complete, your packages reside in the |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame^] | 7969 | <filename>${TMPDIR}/deploy/<replaceable>packageformat</replaceable></filename> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 7970 | directory. |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame^] | 7971 | For example, if |
| 7972 | <filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-TMPDIR'><filename>TMPDIR</filename></ulink><filename>}</filename> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 7973 | is <filename>tmp</filename> and your selected package type |
| 7974 | is IPK, then your IPK packages are available in |
| 7975 | <filename>tmp/deploy/ipk</filename>. |
| 7976 | </para> |
| 7977 | </section> |
| 7978 | |
| 7979 | <section id='runtime-package-management-server'> |
| 7980 | <title>Host or Server Machine Setup</title> |
| 7981 | |
| 7982 | <para> |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame^] | 7983 | Although other protocols are possible, a server using HTTP |
| 7984 | typically serves packages. |
| 7985 | If you want to use HTTP, then set up and configure a |
| 7986 | web server such as Apache 2, lighttpd, or |
| 7987 | SimpleHTTPServer on the machine serving the packages. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 7988 | </para> |
| 7989 | |
| 7990 | <para> |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame^] | 7991 | To keep things simple, this section describes how to set |
| 7992 | up a SimpleHTTPServer web server to share package feeds |
| 7993 | from the developer's machine. |
| 7994 | Although this server might not be the best for a production |
| 7995 | environment, the setup is simple and straight forward. |
| 7996 | Should you want to use a different server more suited for |
| 7997 | production (e.g. Apache 2, Lighttpd, or Nginx), take the |
| 7998 | appropriate steps to do so. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 7999 | </para> |
| 8000 | |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame^] | 8001 | <para> |
| 8002 | From within the build directory where you have built an |
| 8003 | image based on your packaging choice (i.e. the |
| 8004 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_CLASSES'><filename>PACKAGE_CLASSES</filename></ulink> |
| 8005 | setting), simply start the server. |
| 8006 | The following example assumes a build directory of |
| 8007 | <filename>~/poky/build/tmp/deploy/rpm</filename> and a |
| 8008 | <filename>PACKAGE_CLASSES</filename> setting of |
| 8009 | "package_rpm": |
| 8010 | <literallayout class='monospaced'> |
| 8011 | $ cd ~/poky/build/tmp/deploy/rpm |
| 8012 | $ python -m SimpleHTTPServer |
| 8013 | </literallayout> |
| 8014 | </para> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 8015 | </section> |
| 8016 | |
| 8017 | <section id='runtime-package-management-target'> |
| 8018 | <title>Target Setup</title> |
| 8019 | |
| 8020 | <para> |
| 8021 | Setting up the target differs depending on the |
| 8022 | package management system. |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame^] | 8023 | This section provides information for RPM, IPK, and DEB. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 8024 | </para> |
| 8025 | |
| 8026 | <section id='runtime-package-management-target-rpm'> |
| 8027 | <title>Using RPM</title> |
| 8028 | |
| 8029 | <para> |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame^] | 8030 | The <filename>smart</filename> application performs |
| 8031 | runtime package management of RPM packages. |
| 8032 | You must perform an initial setup for |
| 8033 | <filename>smart</filename> on the target machine |
| 8034 | if the |
| 8035 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_FEED_ARCHS'><filename>PACKAGE_FEED_ARCHS</filename></ulink>, |
| 8036 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_FEED_BASE_PATHS'><filename>PACKAGE_FEED_BASE_PATHS</filename></ulink>, and |
| 8037 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_FEED_URIS'><filename>PACKAGE_FEED_URIS</filename></ulink> |
| 8038 | variables have not been set or the target image was |
| 8039 | built before the variables were set. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 8040 | </para> |
| 8041 | |
| 8042 | <para> |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame^] | 8043 | As an example, assume the target is able to use the |
| 8044 | following package databases: |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 8045 | <filename>all</filename>, <filename>i586</filename>, |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame^] | 8046 | and <filename>qemux86</filename> from a server named |
| 8047 | <filename>my.server</filename>. |
| 8048 | You must inform <filename>smart</filename> of the |
| 8049 | availability of these databases by issuing the |
| 8050 | following commands on the target: |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 8051 | <literallayout class='monospaced'> |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame^] | 8052 | # smart channel --add i585 type=rpm-md baseurl=http://my.server/rpm/i586 |
| 8053 | # smart channel --add qemux86 type=rpm-md baseurl=http://my.server/rpm/qemux86 |
| 8054 | # smart channel --add all type=rpm-md baseurl=http://my.server/rpm/all |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 8055 | </literallayout> |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame^] | 8056 | From the target machine, fetch the repository: |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 8057 | <literallayout class='monospaced'> |
| 8058 | # smart update |
| 8059 | </literallayout> |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame^] | 8060 | After everything is set up, <filename>smart</filename> |
| 8061 | is able to find, install, and upgrade packages from |
| 8062 | the specified repository. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 8063 | </para> |
| 8064 | </section> |
| 8065 | |
| 8066 | <section id='runtime-package-management-target-ipk'> |
| 8067 | <title>Using IPK</title> |
| 8068 | |
| 8069 | <para> |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame^] | 8070 | The <filename>opkg</filename> application performs |
| 8071 | runtime package management of IPK packages. |
| 8072 | You must perform an initial setup for |
| 8073 | <filename>opkg</filename> on the target machine |
| 8074 | if the |
| 8075 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_FEED_ARCHS'><filename>PACKAGE_FEED_ARCHS</filename></ulink>, |
| 8076 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_FEED_BASE_PATHS'><filename>PACKAGE_FEED_BASE_PATHS</filename></ulink>, and |
| 8077 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_FEED_URIS'><filename>PACKAGE_FEED_URIS</filename></ulink> |
| 8078 | variables have not been set or the target image was |
| 8079 | built before the variables were set. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 8080 | </para> |
| 8081 | |
| 8082 | <para> |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame^] | 8083 | The <filename>opkg</filename> application uses |
| 8084 | configuration files to find available package |
| 8085 | databases. |
| 8086 | Thus, you need to create a configuration file inside |
| 8087 | the <filename>/etc/opkg/</filename> direction, which |
| 8088 | informs <filename>opkg</filename> of any repository |
| 8089 | you want to use. |
| 8090 | </para> |
| 8091 | |
| 8092 | <para> |
| 8093 | As an example, suppose you are serving packages from a |
| 8094 | <filename>ipk/</filename> directory containing the |
| 8095 | <filename>i586</filename>, |
| 8096 | <filename>all</filename>, and |
| 8097 | <filename>qemux86</filename> databases through an |
| 8098 | HTTP server named <filename>my.server</filename>. |
| 8099 | On the target, create a configuration file |
| 8100 | (e.g. <filename>my_repo.conf</filename>) inside the |
| 8101 | <filename>/etc/opkg/</filename> directory containing |
| 8102 | the following: |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 8103 | <literallayout class='monospaced'> |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame^] | 8104 | src/gz all http://my.server/ipk/all |
| 8105 | src/gz i586 http://my.server/ipk/i586 |
| 8106 | src/gz qemux86 http://my.server/ipk/qemux86 |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 8107 | </literallayout> |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame^] | 8108 | Next, instruct <filename>opkg</filename> to fetch |
| 8109 | the repository information: |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 8110 | <literallayout class='monospaced'> |
| 8111 | # opkg update |
| 8112 | </literallayout> |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame^] | 8113 | The <filename>opkg</filename> application is now able |
| 8114 | to find, install, and upgrade packages from the |
| 8115 | specified repository. |
| 8116 | </para> |
| 8117 | </section> |
| 8118 | |
| 8119 | <section id='runtime-package-management-target-deb'> |
| 8120 | <title>Using DEB</title> |
| 8121 | |
| 8122 | <para> |
| 8123 | The <filename>apt</filename> application performs |
| 8124 | runtime package management of DEB packages. |
| 8125 | This application uses a source list file to find |
| 8126 | available package databases. |
| 8127 | You must perform an initial setup for |
| 8128 | <filename>apt</filename> on the target machine |
| 8129 | if the |
| 8130 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_FEED_ARCHS'><filename>PACKAGE_FEED_ARCHS</filename></ulink>, |
| 8131 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_FEED_BASE_PATHS'><filename>PACKAGE_FEED_BASE_PATHS</filename></ulink>, and |
| 8132 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_FEED_URIS'><filename>PACKAGE_FEED_URIS</filename></ulink> |
| 8133 | variables have not been set or the target image was |
| 8134 | built before the variables were set. |
| 8135 | </para> |
| 8136 | |
| 8137 | <para> |
| 8138 | To inform <filename>apt</filename> of the repository |
| 8139 | you want to use, you might create a list file (e.g. |
| 8140 | <filename>my_repo.list</filename>) inside the |
| 8141 | <filename>/etc/apt/sources.list.d/</filename> |
| 8142 | directory. |
| 8143 | As an example, suppose you are serving packages from a |
| 8144 | <filename>deb/</filename> directory containing the |
| 8145 | <filename>i586</filename>, |
| 8146 | <filename>all</filename>, and |
| 8147 | <filename>qemux86</filename> databases through an |
| 8148 | HTTP server named <filename>my.server</filename>. |
| 8149 | The list file should contain: |
| 8150 | <literallayout class='monospaced'> |
| 8151 | deb http://my.server/deb/all ./ |
| 8152 | deb http://my.server/deb/i586 ./ |
| 8153 | deb http://my.server/deb/qemux86 ./ |
| 8154 | </literallayout> |
| 8155 | Next, instruct the <filename>apt</filename> |
| 8156 | application to fetch the repository information: |
| 8157 | <literallayout class='monospaced'> |
| 8158 | # apt-get update |
| 8159 | </literallayout> |
| 8160 | After this step, <filename>apt</filename> is able |
| 8161 | to find, install, and upgrade packages from the |
| 8162 | specified repository. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 8163 | </para> |
| 8164 | </section> |
| 8165 | </section> |
| 8166 | </section> |
| 8167 | |
| 8168 | <section id='testing-packages-with-ptest'> |
| 8169 | <title>Testing Packages With ptest</title> |
| 8170 | |
| 8171 | <para> |
| 8172 | A Package Test (ptest) runs tests against packages built |
| 8173 | by the OpenEmbedded build system on the target machine. |
| 8174 | A ptest contains at least two items: the actual test, and |
| 8175 | a shell script (<filename>run-ptest</filename>) that starts |
| 8176 | the test. |
| 8177 | The shell script that starts the test must not contain |
| 8178 | the actual test - the script only starts the test. |
| 8179 | On the other hand, the test can be anything from a simple |
| 8180 | shell script that runs a binary and checks the output to |
| 8181 | an elaborate system of test binaries and data files. |
| 8182 | </para> |
| 8183 | |
| 8184 | <para> |
| 8185 | The test generates output in the format used by |
| 8186 | Automake: |
| 8187 | <literallayout class='monospaced'> |
| 8188 | <replaceable>result</replaceable>: <replaceable>testname</replaceable> |
| 8189 | </literallayout> |
| 8190 | where the result can be <filename>PASS</filename>, |
| 8191 | <filename>FAIL</filename>, or <filename>SKIP</filename>, |
| 8192 | and the testname can be any identifying string. |
| 8193 | </para> |
| 8194 | |
| 8195 | <para> |
| 8196 | For a list of Yocto Project recipes that are already |
| 8197 | enabled with ptest, see the |
| 8198 | <ulink url='https://wiki.yoctoproject.org/wiki/Ptest'>Ptest</ulink> |
| 8199 | wiki page. |
| 8200 | <note> |
| 8201 | A recipe is "ptest-enabled" if it inherits the |
| 8202 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-ptest'><filename>ptest</filename></ulink> |
| 8203 | class. |
| 8204 | </note> |
| 8205 | </para> |
| 8206 | |
| 8207 | <section id='adding-ptest-to-your-build'> |
| 8208 | <title>Adding ptest to Your Build</title> |
| 8209 | |
| 8210 | <para> |
| 8211 | To add package testing to your build, add the |
| 8212 | <ulink url='&YOCTO_DOCS_REF_URL;#var-DISTRO_FEATURES'><filename>DISTRO_FEATURES</filename></ulink> |
| 8213 | and <ulink url='&YOCTO_DOCS_REF_URL;#var-EXTRA_IMAGE_FEATURES'><filename>EXTRA_IMAGE_FEATURES</filename></ulink> |
| 8214 | variables to your <filename>local.conf</filename> file, |
| 8215 | which is found in the |
| 8216 | <link linkend='build-directory'>Build Directory</link>: |
| 8217 | <literallayout class='monospaced'> |
| 8218 | DISTRO_FEATURES_append = " ptest" |
| 8219 | EXTRA_IMAGE_FEATURES += "ptest-pkgs" |
| 8220 | </literallayout> |
| 8221 | Once your build is complete, the ptest files are installed |
| 8222 | into the |
| 8223 | <filename>/usr/lib/<replaceable>package</replaceable>/ptest</filename> |
| 8224 | directory within the image, where |
| 8225 | <filename><replaceable>package</replaceable></filename> |
| 8226 | is the name of the package. |
| 8227 | </para> |
| 8228 | </section> |
| 8229 | |
| 8230 | <section id='running-ptest'> |
| 8231 | <title>Running ptest</title> |
| 8232 | |
| 8233 | <para> |
| 8234 | The <filename>ptest-runner</filename> package installs a |
| 8235 | shell script that loops through all installed ptest test |
| 8236 | suites and runs them in sequence. |
| 8237 | Consequently, you might want to add this package to |
| 8238 | your image. |
| 8239 | </para> |
| 8240 | </section> |
| 8241 | |
| 8242 | <section id='getting-your-package-ready'> |
| 8243 | <title>Getting Your Package Ready</title> |
| 8244 | |
| 8245 | <para> |
| 8246 | In order to enable a recipe to run installed ptests |
| 8247 | on target hardware, |
| 8248 | you need to prepare the recipes that build the packages |
| 8249 | you want to test. |
| 8250 | Here is what you have to do for each recipe: |
| 8251 | <itemizedlist> |
| 8252 | <listitem><para><emphasis>Be sure the recipe |
| 8253 | inherits the |
| 8254 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-ptest'><filename>ptest</filename></ulink> |
| 8255 | class:</emphasis> |
| 8256 | Include the following line in each recipe: |
| 8257 | <literallayout class='monospaced'> |
| 8258 | inherit ptest |
| 8259 | </literallayout> |
| 8260 | </para></listitem> |
| 8261 | <listitem><para><emphasis>Create <filename>run-ptest</filename>:</emphasis> |
| 8262 | This script starts your test. |
| 8263 | Locate the script where you will refer to it |
| 8264 | using |
| 8265 | <ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'><filename>SRC_URI</filename></ulink>. |
| 8266 | Here is an example that starts a test for |
| 8267 | <filename>dbus</filename>: |
| 8268 | <literallayout class='monospaced'> |
| 8269 | #!/bin/sh |
| 8270 | cd test |
| 8271 | make -k runtest-TESTS |
| 8272 | </literallayout> |
| 8273 | </para></listitem> |
| 8274 | <listitem><para><emphasis>Ensure dependencies are |
| 8275 | met:</emphasis> |
| 8276 | If the test adds build or runtime dependencies |
| 8277 | that normally do not exist for the package |
| 8278 | (such as requiring "make" to run the test suite), |
| 8279 | use the |
| 8280 | <ulink url='&YOCTO_DOCS_REF_URL;#var-DEPENDS'><filename>DEPENDS</filename></ulink> |
| 8281 | and |
| 8282 | <ulink url='&YOCTO_DOCS_REF_URL;#var-RDEPENDS'><filename>RDEPENDS</filename></ulink> |
| 8283 | variables in your recipe in order for the package |
| 8284 | to meet the dependencies. |
| 8285 | Here is an example where the package has a runtime |
| 8286 | dependency on "make": |
| 8287 | <literallayout class='monospaced'> |
| 8288 | RDEPENDS_${PN}-ptest += "make" |
| 8289 | </literallayout> |
| 8290 | </para></listitem> |
| 8291 | <listitem><para><emphasis>Add a function to build the |
| 8292 | test suite:</emphasis> |
| 8293 | Not many packages support cross-compilation of |
| 8294 | their test suites. |
| 8295 | Consequently, you usually need to add a |
| 8296 | cross-compilation function to the package. |
| 8297 | </para> |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 8298 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 8299 | <para>Many packages based on Automake compile and |
| 8300 | run the test suite by using a single command |
| 8301 | such as <filename>make check</filename>. |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 8302 | However, the host <filename>make check</filename> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 8303 | builds and runs on the same computer, while |
| 8304 | cross-compiling requires that the package is built |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 8305 | on the host but executed for the target |
| 8306 | architecture (though often, as in the case for |
| 8307 | ptest, the execution occurs on the host). |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 8308 | The built version of Automake that ships with the |
| 8309 | Yocto Project includes a patch that separates |
| 8310 | building and execution. |
| 8311 | Consequently, packages that use the unaltered, |
| 8312 | patched version of <filename>make check</filename> |
| 8313 | automatically cross-compiles.</para> |
| 8314 | <para>Regardless, you still must add a |
| 8315 | <filename>do_compile_ptest</filename> function to |
| 8316 | build the test suite. |
| 8317 | Add a function similar to the following to your |
| 8318 | recipe: |
| 8319 | <literallayout class='monospaced'> |
| 8320 | do_compile_ptest() { |
| 8321 | oe_runmake buildtest-TESTS |
| 8322 | } |
| 8323 | </literallayout> |
| 8324 | </para></listitem> |
| 8325 | <listitem><para><emphasis>Ensure special configurations |
| 8326 | are set:</emphasis> |
| 8327 | If the package requires special configurations |
| 8328 | prior to compiling the test code, you must |
| 8329 | insert a <filename>do_configure_ptest</filename> |
| 8330 | function into the recipe. |
| 8331 | </para></listitem> |
| 8332 | <listitem><para><emphasis>Install the test |
| 8333 | suite:</emphasis> |
| 8334 | The <filename>ptest</filename> class |
| 8335 | automatically copies the file |
| 8336 | <filename>run-ptest</filename> to the target and |
| 8337 | then runs make <filename>install-ptest</filename> |
| 8338 | to run the tests. |
| 8339 | If this is not enough, you need to create a |
| 8340 | <filename>do_install_ptest</filename> function and |
| 8341 | make sure it gets called after the |
| 8342 | "make install-ptest" completes. |
| 8343 | </para></listitem> |
| 8344 | </itemizedlist> |
| 8345 | </para> |
| 8346 | </section> |
| 8347 | </section> |
| 8348 | </section> |
| 8349 | |
| 8350 | <section id='working-with-source-files'> |
| 8351 | <title>Working with Source Files</title> |
| 8352 | |
| 8353 | <para> |
| 8354 | The OpenEmbedded build system works with source files located |
| 8355 | through the |
| 8356 | <ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'><filename>SRC_URI</filename></ulink> |
| 8357 | variable. |
| 8358 | When you build something using BitBake, a big part of the operation |
| 8359 | is locating and downloading all the source tarballs. |
| 8360 | For images, downloading all the source for various packages can |
| 8361 | take a significant amount of time. |
| 8362 | </para> |
| 8363 | |
| 8364 | <para> |
| 8365 | This section presents information for working with source |
| 8366 | files that can lead to more efficient use of resources and |
| 8367 | time. |
| 8368 | </para> |
| 8369 | |
| 8370 | <section id='setting-up-effective-mirrors'> |
| 8371 | <title>Setting up Effective Mirrors</title> |
| 8372 | |
| 8373 | <para> |
| 8374 | As mentioned, a good deal that goes into a Yocto Project |
| 8375 | build is simply downloading all of the source tarballs. |
| 8376 | Maybe you have been working with another build system |
| 8377 | (OpenEmbedded or Angstrom) for which you have built up a |
| 8378 | sizable directory of source tarballs. |
| 8379 | Or, perhaps someone else has such a directory for which you |
| 8380 | have read access. |
| 8381 | If so, you can save time by adding statements to your |
| 8382 | configuration file so that the build process checks local |
| 8383 | directories first for existing tarballs before checking the |
| 8384 | Internet. |
| 8385 | </para> |
| 8386 | |
| 8387 | <para> |
| 8388 | Here is an efficient way to set it up in your |
| 8389 | <filename>local.conf</filename> file: |
| 8390 | <literallayout class='monospaced'> |
| 8391 | SOURCE_MIRROR_URL ?= "file:///home/you/your-download-dir/" |
| 8392 | INHERIT += "own-mirrors" |
| 8393 | BB_GENERATE_MIRROR_TARBALLS = "1" |
| 8394 | # BB_NO_NETWORK = "1" |
| 8395 | </literallayout> |
| 8396 | </para> |
| 8397 | |
| 8398 | <para> |
| 8399 | In the previous example, the |
| 8400 | <ulink url='&YOCTO_DOCS_REF_URL;#var-BB_GENERATE_MIRROR_TARBALLS'><filename>BB_GENERATE_MIRROR_TARBALLS</filename></ulink> |
| 8401 | variable causes the OpenEmbedded build system to generate |
| 8402 | tarballs of the Git repositories and store them in the |
| 8403 | <ulink url='&YOCTO_DOCS_REF_URL;#var-DL_DIR'><filename>DL_DIR</filename></ulink> |
| 8404 | directory. |
| 8405 | Due to performance reasons, generating and storing these |
| 8406 | tarballs is not the build system's default behavior. |
| 8407 | </para> |
| 8408 | |
| 8409 | <para> |
| 8410 | You can also use the |
| 8411 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PREMIRRORS'><filename>PREMIRRORS</filename></ulink> |
| 8412 | variable. |
| 8413 | For an example, see the variable's glossary entry in the |
| 8414 | Yocto Project Reference Manual. |
| 8415 | </para> |
| 8416 | </section> |
| 8417 | |
| 8418 | <section id='getting-source-files-and-suppressing-the-build'> |
| 8419 | <title>Getting Source Files and Suppressing the Build</title> |
| 8420 | |
| 8421 | <para> |
| 8422 | Another technique you can use to ready yourself for a |
| 8423 | successive string of build operations, is to pre-fetch |
| 8424 | all the source files without actually starting a build. |
| 8425 | This technique lets you work through any download issues |
| 8426 | and ultimately gathers all the source files into your |
| 8427 | download directory |
| 8428 | <ulink url='&YOCTO_DOCS_REF_URL;#structure-build-downloads'><filename>build/downloads</filename></ulink>, |
| 8429 | which is located with |
| 8430 | <ulink url='&YOCTO_DOCS_REF_URL;#var-DL_DIR'><filename>DL_DIR</filename></ulink>. |
| 8431 | </para> |
| 8432 | |
| 8433 | <para> |
| 8434 | Use the following BitBake command form to fetch all the |
| 8435 | necessary sources without starting the build: |
| 8436 | <literallayout class='monospaced'> |
| 8437 | $ bitbake -c fetchall <replaceable>target</replaceable> |
| 8438 | </literallayout> |
| 8439 | This variation of the BitBake command guarantees that you |
| 8440 | have all the sources for that BitBake target should you |
| 8441 | disconnect from the Internet and want to do the build |
| 8442 | later offline. |
| 8443 | </para> |
| 8444 | </section> |
| 8445 | </section> |
| 8446 | |
| 8447 | <section id="building-software-from-an-external-source"> |
| 8448 | <title>Building Software from an External Source</title> |
| 8449 | |
| 8450 | <para> |
| 8451 | By default, the OpenEmbedded build system uses the |
| 8452 | <link linkend='build-directory'>Build Directory</link> when |
| 8453 | building source code. |
| 8454 | The build process involves fetching the source files, unpacking |
| 8455 | them, and then patching them if necessary before the build takes |
| 8456 | place. |
| 8457 | </para> |
| 8458 | |
| 8459 | <para> |
| 8460 | Situations exist where you might want to build software from source |
| 8461 | files that are external to and thus outside of the |
| 8462 | OpenEmbedded build system. |
| 8463 | For example, suppose you have a project that includes a new BSP with |
| 8464 | a heavily customized kernel. |
| 8465 | And, you want to minimize exposing the build system to the |
| 8466 | development team so that they can focus on their project and |
| 8467 | maintain everyone's workflow as much as possible. |
| 8468 | In this case, you want a kernel source directory on the development |
| 8469 | machine where the development occurs. |
| 8470 | You want the recipe's |
| 8471 | <ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'><filename>SRC_URI</filename></ulink> |
| 8472 | variable to point to the external directory and use it as is, not |
| 8473 | copy it. |
| 8474 | </para> |
| 8475 | |
| 8476 | <para> |
| 8477 | To build from software that comes from an external source, all you |
| 8478 | need to do is inherit the |
| 8479 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-externalsrc'><filename>externalsrc</filename></ulink> |
| 8480 | class and then set the |
| 8481 | <ulink url='&YOCTO_DOCS_REF_URL;#var-EXTERNALSRC'><filename>EXTERNALSRC</filename></ulink> |
| 8482 | variable to point to your external source code. |
| 8483 | Here are the statements to put in your |
| 8484 | <filename>local.conf</filename> file: |
| 8485 | <literallayout class='monospaced'> |
| 8486 | INHERIT += "externalsrc" |
| 8487 | EXTERNALSRC_pn-<replaceable>myrecipe</replaceable> = "<replaceable>path-to-your-source-tree</replaceable>" |
| 8488 | </literallayout> |
| 8489 | </para> |
| 8490 | |
| 8491 | <para> |
| 8492 | This next example shows how to accomplish the same thing by setting |
| 8493 | <filename>EXTERNALSRC</filename> in the recipe itself or in the |
| 8494 | recipe's append file: |
| 8495 | <literallayout class='monospaced'> |
| 8496 | EXTERNALSRC = "<replaceable>path</replaceable>" |
| 8497 | EXTERNALSRC_BUILD = "<replaceable>path</replaceable>" |
| 8498 | </literallayout> |
| 8499 | <note> |
| 8500 | In order for these settings to take effect, you must globally |
| 8501 | or locally inherit the |
| 8502 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-externalsrc'><filename>externalsrc</filename></ulink> |
| 8503 | class. |
| 8504 | </note> |
| 8505 | </para> |
| 8506 | |
| 8507 | <para> |
| 8508 | By default, <filename>externalsrc.bbclass</filename> builds |
| 8509 | the source code in a directory separate from the external source |
| 8510 | directory as specified by |
| 8511 | <ulink url='&YOCTO_DOCS_REF_URL;#var-EXTERNALSRC'><filename>EXTERNALSRC</filename></ulink>. |
| 8512 | If you need to have the source built in the same directory in |
| 8513 | which it resides, or some other nominated directory, you can set |
| 8514 | <ulink url='&YOCTO_DOCS_REF_URL;#var-EXTERNALSRC_BUILD'><filename>EXTERNALSRC_BUILD</filename></ulink> |
| 8515 | to point to that directory: |
| 8516 | <literallayout class='monospaced'> |
| 8517 | EXTERNALSRC_BUILD_pn-<replaceable>myrecipe</replaceable> = "<replaceable>path-to-your-source-tree</replaceable>" |
| 8518 | </literallayout> |
| 8519 | </para> |
| 8520 | </section> |
| 8521 | |
| 8522 | <section id="selecting-an-initialization-manager"> |
| 8523 | <title>Selecting an Initialization Manager</title> |
| 8524 | |
| 8525 | <para> |
| 8526 | By default, the Yocto Project uses SysVinit as the initialization |
| 8527 | manager. |
| 8528 | However, support also exists for systemd, |
| 8529 | which is a full replacement for init with |
| 8530 | parallel starting of services, reduced shell overhead and other |
| 8531 | features that are used by many distributions. |
| 8532 | </para> |
| 8533 | |
| 8534 | <para> |
| 8535 | If you want to use SysVinit, you do |
| 8536 | not have to do anything. |
| 8537 | But, if you want to use systemd, you must |
| 8538 | take some steps as described in the following sections. |
| 8539 | </para> |
| 8540 | |
| 8541 | <section id='using-systemd-exclusively'> |
| 8542 | <title>Using systemd Exclusively</title> |
| 8543 | |
| 8544 | <para> |
| 8545 | Set the these variables in your distribution configuration |
| 8546 | file as follows: |
| 8547 | <literallayout class='monospaced'> |
| 8548 | DISTRO_FEATURES_append = " systemd" |
| 8549 | VIRTUAL-RUNTIME_init_manager = "systemd" |
| 8550 | </literallayout> |
| 8551 | You can also prevent the SysVinit |
| 8552 | distribution feature from |
| 8553 | being automatically enabled as follows: |
| 8554 | <literallayout class='monospaced'> |
| 8555 | DISTRO_FEATURES_BACKFILL_CONSIDERED = "sysvinit" |
| 8556 | </literallayout> |
| 8557 | Doing so removes any redundant SysVinit scripts. |
| 8558 | </para> |
| 8559 | |
| 8560 | <para> |
| 8561 | To remove initscripts from your image altogether, |
| 8562 | set this variable also: |
| 8563 | <literallayout class='monospaced'> |
| 8564 | VIRTUAL-RUNTIME_initscripts = "" |
| 8565 | </literallayout> |
| 8566 | </para> |
| 8567 | |
| 8568 | <para> |
| 8569 | For information on the backfill variable, see |
| 8570 | <ulink url='&YOCTO_DOCS_REF_URL;#var-DISTRO_FEATURES_BACKFILL_CONSIDERED'><filename>DISTRO_FEATURES_BACKFILL_CONSIDERED</filename></ulink>. |
| 8571 | </para> |
| 8572 | </section> |
| 8573 | |
| 8574 | <section id='using-systemd-for-the-main-image-and-using-sysvinit-for-the-rescue-image'> |
| 8575 | <title>Using systemd for the Main Image and Using SysVinit for the Rescue Image</title> |
| 8576 | |
| 8577 | <para> |
| 8578 | Set these variables in your distribution configuration |
| 8579 | file as follows: |
| 8580 | <literallayout class='monospaced'> |
| 8581 | DISTRO_FEATURES_append = " systemd" |
| 8582 | VIRTUAL-RUNTIME_init_manager = "systemd" |
| 8583 | </literallayout> |
| 8584 | Doing so causes your main image to use the |
| 8585 | <filename>packagegroup-core-boot.bb</filename> recipe and |
| 8586 | systemd. |
| 8587 | The rescue/minimal image cannot use this package group. |
| 8588 | However, it can install SysVinit |
| 8589 | and the appropriate packages will have support for both |
| 8590 | systemd and SysVinit. |
| 8591 | </para> |
| 8592 | </section> |
| 8593 | </section> |
| 8594 | |
| 8595 | <section id="selecting-dev-manager"> |
| 8596 | <title>Selecting a Device Manager</title> |
| 8597 | |
| 8598 | <para> |
| 8599 | The Yocto Project provides multiple ways to manage the device |
| 8600 | manager (<filename>/dev</filename>): |
| 8601 | <itemizedlist> |
| 8602 | <listitem><para><emphasis>Persistent and Pre-Populated<filename>/dev</filename>:</emphasis> |
| 8603 | For this case, the <filename>/dev</filename> directory |
| 8604 | is persistent and the required device nodes are created |
| 8605 | during the build. |
| 8606 | </para></listitem> |
| 8607 | <listitem><para><emphasis>Use <filename>devtmpfs</filename> with a Device Manager:</emphasis> |
| 8608 | For this case, the <filename>/dev</filename> directory |
| 8609 | is provided by the kernel as an in-memory file system and |
| 8610 | is automatically populated by the kernel at runtime. |
| 8611 | Additional configuration of device nodes is done in user |
| 8612 | space by a device manager like |
| 8613 | <filename>udev</filename> or |
| 8614 | <filename>busybox-mdev</filename>. |
| 8615 | </para></listitem> |
| 8616 | </itemizedlist> |
| 8617 | </para> |
| 8618 | |
| 8619 | <section id="static-dev-management"> |
| 8620 | <title>Using Persistent and Pre-Populated<filename>/dev</filename></title> |
| 8621 | |
| 8622 | <para> |
| 8623 | To use the static method for device population, you need to |
| 8624 | set the |
| 8625 | <ulink url='&YOCTO_DOCS_REF_URL;#var-USE_DEVFS'><filename>USE_DEVFS</filename></ulink> |
| 8626 | variable to "0" as follows: |
| 8627 | <literallayout class='monospaced'> |
| 8628 | USE_DEVFS = "0" |
| 8629 | </literallayout> |
| 8630 | </para> |
| 8631 | |
| 8632 | <para> |
| 8633 | The content of the resulting <filename>/dev</filename> |
| 8634 | directory is defined in a Device Table file. |
| 8635 | The |
| 8636 | <ulink url='&YOCTO_DOCS_REF_URL;#var-IMAGE_DEVICE_TABLES'><filename>IMAGE_DEVICE_TABLES</filename></ulink> |
| 8637 | variable defines the Device Table to use and should be set |
| 8638 | in the machine or distro configuration file. |
| 8639 | Alternatively, you can set this variable in your |
| 8640 | <filename>local.conf</filename> configuration file. |
| 8641 | </para> |
| 8642 | |
| 8643 | <para> |
| 8644 | If you do not define the |
| 8645 | <filename>IMAGE_DEVICE_TABLES</filename> variable, the default |
| 8646 | <filename>device_table-minimal.txt</filename> is used: |
| 8647 | <literallayout class='monospaced'> |
| 8648 | IMAGE_DEVICE_TABLES = "device_table-mymachine.txt" |
| 8649 | </literallayout> |
| 8650 | </para> |
| 8651 | |
| 8652 | <para> |
| 8653 | The population is handled by the <filename>makedevs</filename> |
| 8654 | utility during image creation: |
| 8655 | </para> |
| 8656 | </section> |
| 8657 | |
| 8658 | <section id="devtmpfs-dev-management"> |
| 8659 | <title>Using <filename>devtmpfs</filename> and a Device Manager</title> |
| 8660 | |
| 8661 | <para> |
| 8662 | To use the dynamic method for device population, you need to |
| 8663 | use (or be sure to set) the |
| 8664 | <ulink url='&YOCTO_DOCS_REF_URL;#var-USE_DEVFS'><filename>USE_DEVFS</filename></ulink> |
| 8665 | variable to "1", which is the default: |
| 8666 | <literallayout class='monospaced'> |
| 8667 | USE_DEVFS = "1" |
| 8668 | </literallayout> |
| 8669 | With this setting, the resulting <filename>/dev</filename> |
| 8670 | directory is populated by the kernel using |
| 8671 | <filename>devtmpfs</filename>. |
| 8672 | Make sure the corresponding kernel configuration variable |
| 8673 | <filename>CONFIG_DEVTMPFS</filename> is set when building |
| 8674 | you build a Linux kernel. |
| 8675 | </para> |
| 8676 | |
| 8677 | <para> |
| 8678 | All devices created by <filename>devtmpfs</filename> will be |
| 8679 | owned by <filename>root</filename> and have permissions |
| 8680 | <filename>0600</filename>. |
| 8681 | </para> |
| 8682 | |
| 8683 | <para> |
| 8684 | To have more control over the device nodes, you can use a |
| 8685 | device manager like <filename>udev</filename> or |
| 8686 | <filename>busybox-mdev</filename>. |
| 8687 | You choose the device manager by defining the |
| 8688 | <filename>VIRTUAL-RUNTIME_dev_manager</filename> variable |
| 8689 | in your machine or distro configuration file. |
| 8690 | Alternatively, you can set this variable in your |
| 8691 | <filename>local.conf</filename> configuration file: |
| 8692 | <literallayout class='monospaced'> |
| 8693 | VIRTUAL-RUNTIME_dev_manager = "udev" |
| 8694 | |
| 8695 | # Some alternative values |
| 8696 | # VIRTUAL-RUNTIME_dev_manager = "busybox-mdev" |
| 8697 | # VIRTUAL-RUNTIME_dev_manager = "systemd" |
| 8698 | </literallayout> |
| 8699 | </para> |
| 8700 | </section> |
| 8701 | </section> |
| 8702 | |
| 8703 | <section id="platdev-appdev-srcrev"> |
| 8704 | <title>Using an External SCM</title> |
| 8705 | |
| 8706 | <para> |
| 8707 | If you're working on a recipe that pulls from an external Source |
| 8708 | Code Manager (SCM), it is possible to have the OpenEmbedded build |
| 8709 | system notice new recipe changes added to the SCM and then build |
| 8710 | the resulting packages that depend on the new recipes by using |
| 8711 | the latest versions. |
| 8712 | This only works for SCMs from which it is possible to get a |
| 8713 | sensible revision number for changes. |
| 8714 | Currently, you can do this with Apache Subversion (SVN), Git, and |
| 8715 | Bazaar (BZR) repositories. |
| 8716 | </para> |
| 8717 | |
| 8718 | <para> |
| 8719 | To enable this behavior, the |
| 8720 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PV'><filename>PV</filename></ulink> |
| 8721 | of the recipe needs to reference |
| 8722 | <ulink url='&YOCTO_DOCS_REF_URL;#var-SRCPV'><filename>SRCPV</filename></ulink>. |
| 8723 | Here is an example: |
| 8724 | <literallayout class='monospaced'> |
| 8725 | PV = "1.2.3+git${SRCPV}" |
| 8726 | </literallayout> |
| 8727 | Then, you can add the following to your |
| 8728 | <filename>local.conf</filename>: |
| 8729 | <literallayout class='monospaced'> |
| 8730 | SRCREV_pn-<replaceable>PN</replaceable> = "${AUTOREV}" |
| 8731 | </literallayout> |
| 8732 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PN'><filename>PN</filename></ulink> |
| 8733 | is the name of the recipe for which you want to enable automatic source |
| 8734 | revision updating. |
| 8735 | </para> |
| 8736 | |
| 8737 | <para> |
| 8738 | If you do not want to update your local configuration file, you can |
| 8739 | add the following directly to the recipe to finish enabling |
| 8740 | the feature: |
| 8741 | <literallayout class='monospaced'> |
| 8742 | SRCREV = "${AUTOREV}" |
| 8743 | </literallayout> |
| 8744 | </para> |
| 8745 | |
| 8746 | <para> |
| 8747 | The Yocto Project provides a distribution named |
| 8748 | <filename>poky-bleeding</filename>, whose configuration |
| 8749 | file contains the line: |
| 8750 | <literallayout class='monospaced'> |
| 8751 | require conf/distro/include/poky-floating-revisions.inc |
| 8752 | </literallayout> |
| 8753 | This line pulls in the listed include file that contains |
| 8754 | numerous lines of exactly that form: |
| 8755 | <literallayout class='monospaced'> |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 8756 | #SRCREV_pn-opkg-native ?= "${AUTOREV}" |
| 8757 | #SRCREV_pn-opkg-sdk ?= "${AUTOREV}" |
| 8758 | #SRCREV_pn-opkg ?= "${AUTOREV}" |
| 8759 | #SRCREV_pn-opkg-utils-native ?= "${AUTOREV}" |
| 8760 | #SRCREV_pn-opkg-utils ?= "${AUTOREV}" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 8761 | SRCREV_pn-gconf-dbus ?= "${AUTOREV}" |
| 8762 | SRCREV_pn-matchbox-common ?= "${AUTOREV}" |
| 8763 | SRCREV_pn-matchbox-config-gtk ?= "${AUTOREV}" |
| 8764 | SRCREV_pn-matchbox-desktop ?= "${AUTOREV}" |
| 8765 | SRCREV_pn-matchbox-keyboard ?= "${AUTOREV}" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 8766 | SRCREV_pn-matchbox-panel-2 ?= "${AUTOREV}" |
| 8767 | SRCREV_pn-matchbox-themes-extra ?= "${AUTOREV}" |
| 8768 | SRCREV_pn-matchbox-terminal ?= "${AUTOREV}" |
| 8769 | SRCREV_pn-matchbox-wm ?= "${AUTOREV}" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 8770 | SRCREV_pn-settings-daemon ?= "${AUTOREV}" |
| 8771 | SRCREV_pn-screenshot ?= "${AUTOREV}" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 8772 | . |
| 8773 | . |
| 8774 | . |
| 8775 | </literallayout> |
| 8776 | These lines allow you to experiment with building a |
| 8777 | distribution that tracks the latest development source |
| 8778 | for numerous packages. |
| 8779 | <note><title>Caution</title> |
| 8780 | The <filename>poky-bleeding</filename> distribution |
| 8781 | is not tested on a regular basis. |
| 8782 | Keep this in mind if you use it. |
| 8783 | </note> |
| 8784 | </para> |
| 8785 | </section> |
| 8786 | |
| 8787 | <section id='creating-a-read-only-root-filesystem'> |
| 8788 | <title>Creating a Read-Only Root Filesystem</title> |
| 8789 | |
| 8790 | <para> |
| 8791 | Suppose, for security reasons, you need to disable |
| 8792 | your target device's root filesystem's write permissions |
| 8793 | (i.e. you need a read-only root filesystem). |
| 8794 | Or, perhaps you are running the device's operating system |
| 8795 | from a read-only storage device. |
| 8796 | For either case, you can customize your image for |
| 8797 | that behavior. |
| 8798 | </para> |
| 8799 | |
| 8800 | <note> |
| 8801 | Supporting a read-only root filesystem requires that the system and |
| 8802 | applications do not try to write to the root filesystem. |
| 8803 | You must configure all parts of the target system to write |
| 8804 | elsewhere, or to gracefully fail in the event of attempting to |
| 8805 | write to the root filesystem. |
| 8806 | </note> |
| 8807 | |
| 8808 | <section id='creating-the-root-filesystem'> |
| 8809 | <title>Creating the Root Filesystem</title> |
| 8810 | |
| 8811 | <para> |
| 8812 | To create the read-only root filesystem, simply add the |
| 8813 | "read-only-rootfs" feature to your image. |
| 8814 | Using either of the following statements in your |
| 8815 | image recipe or from within the |
| 8816 | <filename>local.conf</filename> file found in the |
| 8817 | <link linkend='build-directory'>Build Directory</link> |
| 8818 | causes the build system to create a read-only root filesystem: |
| 8819 | <literallayout class='monospaced'> |
| 8820 | IMAGE_FEATURES = "read-only-rootfs" |
| 8821 | </literallayout> |
| 8822 | or |
| 8823 | <literallayout class='monospaced'> |
| 8824 | EXTRA_IMAGE_FEATURES += "read-only-rootfs" |
| 8825 | </literallayout> |
| 8826 | </para> |
| 8827 | |
| 8828 | <para> |
| 8829 | For more information on how to use these variables, see the |
| 8830 | "<link linkend='usingpoky-extend-customimage-imagefeatures'>Customizing Images Using Custom <filename>IMAGE_FEATURES</filename> and <filename>EXTRA_IMAGE_FEATURES</filename></link>" |
| 8831 | section. |
| 8832 | For information on the variables, see |
| 8833 | <ulink url='&YOCTO_DOCS_REF_URL;#var-IMAGE_FEATURES'><filename>IMAGE_FEATURES</filename></ulink> |
| 8834 | and <ulink url='&YOCTO_DOCS_REF_URL;#var-EXTRA_IMAGE_FEATURES'><filename>EXTRA_IMAGE_FEATURES</filename></ulink>. |
| 8835 | </para> |
| 8836 | </section> |
| 8837 | |
| 8838 | <section id='post-installation-scripts'> |
| 8839 | <title>Post-Installation Scripts</title> |
| 8840 | |
| 8841 | <para> |
| 8842 | It is very important that you make sure all |
| 8843 | post-Installation (<filename>pkg_postinst</filename>) scripts |
| 8844 | for packages that are installed into the image can be run |
| 8845 | at the time when the root filesystem is created during the |
| 8846 | build on the host system. |
| 8847 | These scripts cannot attempt to run during first-boot on the |
| 8848 | target device. |
| 8849 | With the "read-only-rootfs" feature enabled, |
| 8850 | the build system checks during root filesystem creation to make |
| 8851 | sure all post-installation scripts succeed. |
| 8852 | If any of these scripts still need to be run after the root |
| 8853 | filesystem is created, the build immediately fails. |
| 8854 | These build-time checks ensure that the build fails |
| 8855 | rather than the target device fails later during its |
| 8856 | initial boot operation. |
| 8857 | </para> |
| 8858 | |
| 8859 | <para> |
| 8860 | Most of the common post-installation scripts generated by the |
| 8861 | build system for the out-of-the-box Yocto Project are engineered |
| 8862 | so that they can run during root filesystem creation |
| 8863 | (e.g. post-installation scripts for caching fonts). |
| 8864 | However, if you create and add custom scripts, you need |
| 8865 | to be sure they can be run during this file system creation. |
| 8866 | </para> |
| 8867 | |
| 8868 | <para> |
| 8869 | Here are some common problems that prevent |
| 8870 | post-installation scripts from running during root filesystem |
| 8871 | creation: |
| 8872 | <itemizedlist> |
| 8873 | <listitem><para> |
| 8874 | <emphasis>Not using $D in front of absolute |
| 8875 | paths:</emphasis> |
| 8876 | The build system defines |
| 8877 | <filename>$</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-D'><filename>D</filename></ulink> |
| 8878 | when the root filesystem is created. |
| 8879 | Furthermore, <filename>$D</filename> is blank when the |
| 8880 | script is run on the target device. |
| 8881 | This implies two purposes for <filename>$D</filename>: |
| 8882 | ensuring paths are valid in both the host and target |
| 8883 | environments, and checking to determine which |
| 8884 | environment is being used as a method for taking |
| 8885 | appropriate actions. |
| 8886 | </para></listitem> |
| 8887 | <listitem><para> |
| 8888 | <emphasis>Attempting to run processes that are |
| 8889 | specific to or dependent on the target |
| 8890 | architecture:</emphasis> |
| 8891 | You can work around these attempts by using native |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 8892 | tools, which run on the host system, |
| 8893 | to accomplish the same tasks, or |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 8894 | by alternatively running the processes under QEMU, |
| 8895 | which has the <filename>qemu_run_binary</filename> |
| 8896 | function. |
| 8897 | For more information, see the |
| 8898 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-qemu'><filename>qemu</filename></ulink> |
| 8899 | class.</para></listitem> |
| 8900 | </itemizedlist> |
| 8901 | </para> |
| 8902 | </section> |
| 8903 | |
| 8904 | <section id='areas-with-write-access'> |
| 8905 | <title>Areas With Write Access</title> |
| 8906 | |
| 8907 | <para> |
| 8908 | With the "read-only-rootfs" feature enabled, |
| 8909 | any attempt by the target to write to the root filesystem at |
| 8910 | runtime fails. |
| 8911 | Consequently, you must make sure that you configure processes |
| 8912 | and applications that attempt these types of writes do so |
| 8913 | to directories with write access (e.g. |
| 8914 | <filename>/tmp</filename> or <filename>/var/run</filename>). |
| 8915 | </para> |
| 8916 | </section> |
| 8917 | </section> |
| 8918 | |
| 8919 | <section id="performing-automated-runtime-testing"> |
| 8920 | <title>Performing Automated Runtime Testing</title> |
| 8921 | |
| 8922 | <para> |
| 8923 | The OpenEmbedded build system makes available a series of automated |
| 8924 | tests for images to verify runtime functionality. |
| 8925 | You can run these tests on either QEMU or actual target hardware. |
| 8926 | Tests are written in Python making use of the |
| 8927 | <filename>unittest</filename> module, and the majority of them |
| 8928 | run commands on the target system over SSH. |
| 8929 | This section describes how you set up the environment to use these |
| 8930 | tests, run available tests, and write and add your own tests. |
| 8931 | </para> |
| 8932 | |
| 8933 | <section id='enabling-tests'> |
| 8934 | <title>Enabling Tests</title> |
| 8935 | |
| 8936 | <para> |
| 8937 | Depending on whether you are planning to run tests using |
| 8938 | QEMU or on the hardware, you have to take |
| 8939 | different steps to enable the tests. |
| 8940 | See the following subsections for information on how to |
| 8941 | enable both types of tests. |
| 8942 | </para> |
| 8943 | |
| 8944 | <section id='qemu-image-enabling-tests'> |
| 8945 | <title>Enabling Runtime Tests on QEMU</title> |
| 8946 | |
| 8947 | <para> |
| 8948 | In order to run tests, you need to do the following: |
| 8949 | <itemizedlist> |
| 8950 | <listitem><para><emphasis>Set up to avoid interaction |
| 8951 | with <filename>sudo</filename> for networking:</emphasis> |
| 8952 | To accomplish this, you must do one of the |
| 8953 | following: |
| 8954 | <itemizedlist> |
| 8955 | <listitem><para>Add |
| 8956 | <filename>NOPASSWD</filename> for your user |
| 8957 | in <filename>/etc/sudoers</filename> either for |
| 8958 | all commands or just for |
| 8959 | <filename>runqemu-ifup</filename>. |
| 8960 | You must provide the full path as that can |
| 8961 | change if you are using multiple clones of the |
| 8962 | source repository. |
| 8963 | <note> |
| 8964 | On some distributions, you also need to |
| 8965 | comment out "Defaults requiretty" in |
| 8966 | <filename>/etc/sudoers</filename>. |
| 8967 | </note></para></listitem> |
| 8968 | <listitem><para>Manually configure a tap interface |
| 8969 | for your system.</para></listitem> |
| 8970 | <listitem><para>Run as root the script in |
| 8971 | <filename>scripts/runqemu-gen-tapdevs</filename>, |
| 8972 | which should generate a list of tap devices. |
| 8973 | This is the option typically chosen for |
| 8974 | Autobuilder-type environments. |
| 8975 | </para></listitem> |
| 8976 | </itemizedlist></para></listitem> |
| 8977 | <listitem><para><emphasis>Set the |
| 8978 | <filename>DISPLAY</filename> variable:</emphasis> |
| 8979 | You need to set this variable so that you have an X |
| 8980 | server available (e.g. start |
| 8981 | <filename>vncserver</filename> for a headless machine). |
| 8982 | </para></listitem> |
| 8983 | <listitem><para><emphasis>Be sure your host's firewall |
| 8984 | accepts incoming connections from |
| 8985 | 192.168.7.0/24:</emphasis> |
| 8986 | Some of the tests (in particular smart tests) start an |
| 8987 | HTTP server on a random high number port, which is |
| 8988 | used to serve files to the target. |
| 8989 | The smart module serves |
| 8990 | <filename>${DEPLOY_DIR}/rpm</filename> so it can run |
| 8991 | smart channel commands. That means your host's firewall |
| 8992 | must accept incoming connections from 192.168.7.0/24, |
| 8993 | which is the default IP range used for tap devices |
| 8994 | by <filename>runqemu</filename>.</para></listitem> |
Patrick Williams | f1e5d69 | 2016-03-30 15:21:19 -0500 | [diff] [blame] | 8995 | <listitem><para><emphasis>Be sure your host has the |
| 8996 | correct packages installed:</emphasis> |
| 8997 | Depending your host's distribution, you need |
| 8998 | to have the following packages installed: |
| 8999 | <itemizedlist> |
| 9000 | <listitem><para>Ubuntu and Debian: |
| 9001 | <filename>sysstat</filename> and |
| 9002 | <filename>iproute2</filename> |
| 9003 | </para></listitem> |
| 9004 | <listitem><para>OpenSUSE: |
| 9005 | <filename>sysstat</filename> and |
| 9006 | <filename>iproute2</filename> |
| 9007 | </para></listitem> |
| 9008 | <listitem><para>Fedora: |
| 9009 | <filename>sysstat</filename> and |
| 9010 | <filename>iproute</filename> |
| 9011 | </para></listitem> |
| 9012 | <listitem><para>CentOS: |
| 9013 | <filename>sysstat</filename> and |
| 9014 | <filename>iproute</filename> |
| 9015 | </para></listitem> |
| 9016 | </itemizedlist> |
| 9017 | </para></listitem> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 9018 | </itemizedlist> |
| 9019 | </para> |
| 9020 | |
| 9021 | <para> |
| 9022 | Once you start running the tests, the following happens: |
| 9023 | <orderedlist> |
| 9024 | <listitem><para>A copy of the root filesystem is written |
| 9025 | to <filename>${WORKDIR}/testimage</filename>. |
| 9026 | </para></listitem> |
| 9027 | <listitem><para>The image is booted under QEMU using the |
| 9028 | standard <filename>runqemu</filename> script. |
| 9029 | </para></listitem> |
| 9030 | <listitem><para>A default timeout of 500 seconds occurs |
| 9031 | to allow for the boot process to reach the login prompt. |
| 9032 | You can change the timeout period by setting |
| 9033 | <ulink url='&YOCTO_DOCS_REF_URL;#var-TEST_QEMUBOOT_TIMEOUT'><filename>TEST_QEMUBOOT_TIMEOUT</filename></ulink> |
| 9034 | in the <filename>local.conf</filename> file. |
| 9035 | </para></listitem> |
| 9036 | <listitem><para>Once the boot process is reached and the |
| 9037 | login prompt appears, the tests run. |
| 9038 | The full boot log is written to |
| 9039 | <filename>${WORKDIR}/testimage/qemu_boot_log</filename>. |
| 9040 | </para></listitem> |
| 9041 | <listitem><para>Each test module loads in the order found |
| 9042 | in <filename>TEST_SUITES</filename>. |
| 9043 | You can find the full output of the commands run over |
| 9044 | SSH in |
| 9045 | <filename>${WORKDIR}/testimgage/ssh_target_log</filename>. |
| 9046 | </para></listitem> |
| 9047 | <listitem><para>If no failures occur, the task running the |
| 9048 | tests ends successfully. |
| 9049 | You can find the output from the |
| 9050 | <filename>unittest</filename> in the task log at |
| 9051 | <filename>${WORKDIR}/temp/log.do_testimage</filename>. |
| 9052 | </para></listitem> |
| 9053 | </orderedlist> |
| 9054 | </para> |
| 9055 | </section> |
| 9056 | |
| 9057 | <section id='hardware-image-enabling-tests'> |
| 9058 | <title>Enabling Runtime Tests on Hardware</title> |
| 9059 | |
| 9060 | <para> |
| 9061 | The OpenEmbedded build system can run tests on real |
| 9062 | hardware, and for certain devices it can also deploy |
| 9063 | the image to be tested onto the device beforehand. |
| 9064 | </para> |
| 9065 | |
| 9066 | <para> |
| 9067 | For automated deployment, a "master image" is installed |
| 9068 | onto the hardware once as part of setup. |
| 9069 | Then, each time tests are to be run, the following |
| 9070 | occurs: |
| 9071 | <orderedlist> |
| 9072 | <listitem><para>The master image is booted into and |
| 9073 | used to write the image to be tested to |
| 9074 | a second partition. |
| 9075 | </para></listitem> |
| 9076 | <listitem><para>The device is then rebooted using an |
| 9077 | external script that you need to provide. |
| 9078 | </para></listitem> |
| 9079 | <listitem><para>The device boots into the image to be |
| 9080 | tested. |
| 9081 | </para></listitem> |
| 9082 | </orderedlist> |
| 9083 | </para> |
| 9084 | |
| 9085 | <para> |
| 9086 | When running tests (independent of whether the image |
| 9087 | has been deployed automatically or not), the device is |
| 9088 | expected to be connected to a network on a |
| 9089 | pre-determined IP address. |
| 9090 | You can either use static IP addresses written into |
| 9091 | the image, or set the image to use DHCP and have your |
| 9092 | DHCP server on the test network assign a known IP address |
| 9093 | based on the MAC address of the device. |
| 9094 | </para> |
| 9095 | |
| 9096 | <para> |
| 9097 | In order to run tests on hardware, you need to set |
| 9098 | <filename>TEST_TARGET</filename> to an appropriate value. |
| 9099 | For QEMU, you do not have to change anything, the default |
| 9100 | value is "QemuTarget". |
| 9101 | For running tests on hardware, the following options exist: |
| 9102 | <itemizedlist> |
| 9103 | <listitem><para><emphasis>"SimpleRemoteTarget":</emphasis> |
| 9104 | Choose "SimpleRemoteTarget" if you are going to |
| 9105 | run tests on a target system that is already |
| 9106 | running the image to be tested and is available |
| 9107 | on the network. |
| 9108 | You can use "SimpleRemoteTarget" in conjunction |
| 9109 | with either real hardware or an image running |
| 9110 | within a separately started QEMU or any |
| 9111 | other virtual machine manager. |
| 9112 | </para></listitem> |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame^] | 9113 | <listitem><para><emphasis>"Systemd-bootTarget":</emphasis> |
| 9114 | Choose "Systemd-bootTarget" if your hardware is |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 9115 | an EFI-based machine with |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame^] | 9116 | <filename>systemd-boot</filename> as bootloader and |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 9117 | <filename>core-image-testmaster</filename> |
| 9118 | (or something similar) is installed. |
| 9119 | Also, your hardware under test must be in a |
| 9120 | DHCP-enabled network that gives it the same IP |
| 9121 | address for each reboot.</para> |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame^] | 9122 | <para>If you choose "Systemd-bootTarget", there are |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 9123 | additional requirements and considerations. |
| 9124 | See the |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame^] | 9125 | "<link linkend='selecting-systemd-boottarget'>Selecting Systemd-bootTarget</link>" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 9126 | section, which follows, for more information. |
| 9127 | </para></listitem> |
| 9128 | <listitem><para><emphasis>"BeagleBoneTarget":</emphasis> |
| 9129 | Choose "BeagleBoneTarget" if you are deploying |
| 9130 | images and running tests on the BeagleBone |
| 9131 | "Black" or original "White" hardware. |
| 9132 | For information on how to use these tests, see the |
| 9133 | comments at the top of the BeagleBoneTarget |
| 9134 | <filename>meta-yocto-bsp/lib/oeqa/controllers/beaglebonetarget.py</filename> |
| 9135 | file. |
| 9136 | </para></listitem> |
| 9137 | <listitem><para><emphasis>"EdgeRouterTarget":</emphasis> |
| 9138 | Choose "EdgeRouterTarget" is you are deploying |
| 9139 | images and running tests on the Ubiquiti Networks |
| 9140 | EdgeRouter Lite. |
| 9141 | For information on how to use these tests, see the |
| 9142 | comments at the top of the EdgeRouterTarget |
| 9143 | <filename>meta-yocto-bsp/lib/oeqa/controllers/edgeroutertarget.py</filename> |
| 9144 | file. |
| 9145 | </para></listitem> |
| 9146 | <listitem><para><emphasis>"GrubTarget":</emphasis> |
| 9147 | Choose the "supports deploying images and running |
| 9148 | tests on any generic PC that boots using GRUB. |
| 9149 | For information on how to use these tests, see the |
| 9150 | comments at the top of the GrubTarget |
| 9151 | <filename>meta-yocto-bsp/lib/oeqa/controllers/grubtarget.py</filename> |
| 9152 | file. |
| 9153 | </para></listitem> |
| 9154 | <listitem><para><emphasis>"<replaceable>your-target</replaceable>":</emphasis> |
| 9155 | Create your own custom target if you want to run |
| 9156 | tests when you are deploying images and running |
| 9157 | tests on a custom machine within your BSP layer. |
| 9158 | To do this, you need to add a Python unit that |
| 9159 | defines the target class under |
| 9160 | <filename>lib/oeqa/controllers/</filename> within |
| 9161 | your layer. |
| 9162 | You must also provide an empty |
| 9163 | <filename>__init__.py</filename>. |
| 9164 | For examples, see files in |
| 9165 | <filename>meta-yocto-bsp/lib/oeqa/controllers/</filename>. |
| 9166 | </para></listitem> |
| 9167 | </itemizedlist> |
| 9168 | </para> |
| 9169 | </section> |
| 9170 | |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame^] | 9171 | <section id='selecting-systemd-boottarget'> |
| 9172 | <title>Selecting Systemd-bootTarget</title> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 9173 | |
| 9174 | <para> |
| 9175 | If you did not set <filename>TEST_TARGET</filename> to |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame^] | 9176 | "Systemd-bootTarget", then you do not need any information |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 9177 | in this section. |
| 9178 | You can skip down to the |
| 9179 | "<link linkend='qemu-image-running-tests'>Running Tests</link>" |
| 9180 | section. |
| 9181 | </para> |
| 9182 | |
| 9183 | <para> |
| 9184 | If you did set <filename>TEST_TARGET</filename> to |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame^] | 9185 | "Systemd-bootTarget", you also need to perform a one-time |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 9186 | setup of your master image by doing the following: |
| 9187 | <orderedlist> |
| 9188 | <listitem><para><emphasis>Set <filename>EFI_PROVIDER</filename>:</emphasis> |
| 9189 | Be sure that <filename>EFI_PROVIDER</filename> |
| 9190 | is as follows: |
| 9191 | <literallayout class='monospaced'> |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame^] | 9192 | EFI_PROVIDER = "systemd-boot" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 9193 | </literallayout> |
| 9194 | </para></listitem> |
| 9195 | <listitem><para><emphasis>Build the master image:</emphasis> |
| 9196 | Build the <filename>core-image-testmaster</filename> |
| 9197 | image. |
| 9198 | The <filename>core-image-testmaster</filename> |
| 9199 | recipe is provided as an example for a |
| 9200 | "master" image and you can customize the image |
| 9201 | recipe as you would any other recipe. |
| 9202 | </para> |
| 9203 | <para>Here are the image recipe requirements: |
| 9204 | <itemizedlist> |
| 9205 | <listitem><para>Inherits |
| 9206 | <filename>core-image</filename> |
| 9207 | so that kernel modules are installed. |
| 9208 | </para></listitem> |
| 9209 | <listitem><para>Installs normal linux utilities |
| 9210 | not busybox ones (e.g. |
| 9211 | <filename>bash</filename>, |
| 9212 | <filename>coreutils</filename>, |
| 9213 | <filename>tar</filename>, |
| 9214 | <filename>gzip</filename>, and |
| 9215 | <filename>kmod</filename>). |
| 9216 | </para></listitem> |
| 9217 | <listitem><para>Uses a custom |
| 9218 | Initial RAM Disk (initramfs) image with a |
| 9219 | custom installer. |
| 9220 | A normal image that you can install usually |
| 9221 | creates a single rootfs partition. |
| 9222 | This image uses another installer that |
| 9223 | creates a specific partition layout. |
| 9224 | Not all Board Support Packages (BSPs) |
| 9225 | can use an installer. |
| 9226 | For such cases, you need to manually create |
| 9227 | the following partition layout on the |
| 9228 | target: |
| 9229 | <itemizedlist> |
| 9230 | <listitem><para>First partition mounted |
| 9231 | under <filename>/boot</filename>, |
| 9232 | labeled "boot". |
| 9233 | </para></listitem> |
| 9234 | <listitem><para>The main rootfs |
| 9235 | partition where this image gets |
| 9236 | installed, which is mounted under |
| 9237 | <filename>/</filename>. |
| 9238 | </para></listitem> |
| 9239 | <listitem><para>Another partition |
| 9240 | labeled "testrootfs" where test |
| 9241 | images get deployed. |
| 9242 | </para></listitem> |
| 9243 | </itemizedlist> |
| 9244 | </para></listitem> |
| 9245 | </itemizedlist> |
| 9246 | </para></listitem> |
| 9247 | <listitem><para><emphasis>Install image:</emphasis> |
| 9248 | Install the image that you just built on the target |
| 9249 | system. |
| 9250 | </para></listitem> |
| 9251 | </orderedlist> |
| 9252 | </para> |
| 9253 | |
| 9254 | <para> |
| 9255 | The final thing you need to do when setting |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame^] | 9256 | <filename>TEST_TARGET</filename> to "Systemd-bootTarget" is |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 9257 | to set up the test image: |
| 9258 | <orderedlist> |
| 9259 | <listitem><para><emphasis>Set up your <filename>local.conf</filename> file:</emphasis> |
| 9260 | Make sure you have the following statements in |
| 9261 | your <filename>local.conf</filename> file: |
| 9262 | <literallayout class='monospaced'> |
| 9263 | IMAGE_FSTYPES += "tar.gz" |
| 9264 | INHERIT += "testimage" |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame^] | 9265 | TEST_TARGET = "Systemd-bootTarget" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 9266 | TEST_TARGET_IP = "192.168.2.3" |
| 9267 | </literallayout> |
| 9268 | </para></listitem> |
| 9269 | <listitem><para><emphasis>Build your test image:</emphasis> |
| 9270 | Use BitBake to build the image: |
| 9271 | <literallayout class='monospaced'> |
| 9272 | $ bitbake core-image-sato |
| 9273 | </literallayout> |
| 9274 | </para></listitem> |
| 9275 | </orderedlist> |
| 9276 | </para> |
| 9277 | </section> |
| 9278 | |
| 9279 | <section id='power-control'> |
| 9280 | <title>Power Control</title> |
| 9281 | |
| 9282 | <para> |
| 9283 | For most hardware targets other than SimpleRemoteTarget, |
| 9284 | you can control power: |
| 9285 | <itemizedlist> |
| 9286 | <listitem><para> |
| 9287 | You can use |
| 9288 | <filename>TEST_POWERCONTROL_CMD</filename> |
| 9289 | together with |
| 9290 | <filename>TEST_POWERCONTROL_EXTRA_ARGS</filename> |
| 9291 | as a command that runs on the host and does power |
| 9292 | cycling. |
| 9293 | The test code passes one argument to that command: |
| 9294 | off, on or cycle (off then on). |
| 9295 | Here is an example that could appear in your |
| 9296 | <filename>local.conf</filename> file: |
| 9297 | <literallayout class='monospaced'> |
| 9298 | TEST_POWERCONTROL_CMD = "powercontrol.exp test 10.11.12.1 nuc1" |
| 9299 | </literallayout> |
| 9300 | In this example, the expect script does the |
| 9301 | following: |
| 9302 | <literallayout class='monospaced'> |
| 9303 | ssh test@10.11.12.1 "pyctl nuc1 <replaceable>arg</replaceable>" |
| 9304 | </literallayout> |
| 9305 | It then runs a Python script that controls power |
| 9306 | for a label called <filename>nuc1</filename>. |
| 9307 | <note> |
| 9308 | You need to customize |
| 9309 | <filename>TEST_POWERCONTROL_CMD</filename> |
| 9310 | and |
| 9311 | <filename>TEST_POWERCONTROL_EXTRA_ARGS</filename> |
| 9312 | for your own setup. |
| 9313 | The one requirement is that it accepts |
| 9314 | "on", "off", and "cycle" as the last argument. |
| 9315 | </note> |
| 9316 | </para></listitem> |
| 9317 | <listitem><para> |
| 9318 | When no command is defined, it connects to the |
| 9319 | device over SSH and uses the classic reboot command |
| 9320 | to reboot the device. |
| 9321 | Classic reboot is fine as long as the machine |
| 9322 | actually reboots (i.e. the SSH test has not |
| 9323 | failed). |
| 9324 | It is useful for scenarios where you have a simple |
| 9325 | setup, typically with a single board, and where |
| 9326 | some manual interaction is okay from time to time. |
| 9327 | </para></listitem> |
| 9328 | </itemizedlist> |
| 9329 | If you have no hardware to automatically perform power |
| 9330 | control but still wish to experiment with automated |
| 9331 | hardware testing, you can use the dialog-power-control |
| 9332 | script that shows a dialog prompting you to perform the |
| 9333 | required power action. |
| 9334 | This script requires either KDialog or Zenity to be |
| 9335 | installed. |
| 9336 | To use this script, set the |
| 9337 | <ulink url='&YOCTO_DOCS_REF_URL;#var-TEST_POWERCONTROL_CMD'><filename>TEST_POWERCONTROL_CMD</filename></ulink> |
| 9338 | variable as follows: |
| 9339 | <literallayout class='monospaced'> |
| 9340 | TEST_POWERCONTROL_CMD = "${COREBASE}/scripts/contrib/dialog-power-control" |
| 9341 | </literallayout> |
| 9342 | </para> |
| 9343 | </section> |
| 9344 | |
| 9345 | <section id='serial-console-connection'> |
| 9346 | <title>Serial Console Connection</title> |
| 9347 | |
| 9348 | <para> |
| 9349 | For test target classes requiring a serial console |
| 9350 | to interact with the bootloader (e.g. BeagleBoneTarget, |
| 9351 | EdgeRouterTarget, and GrubTarget), you need to |
| 9352 | specify a command to use to connect to the serial console |
| 9353 | of the target machine by using the |
| 9354 | <ulink url='&YOCTO_DOCS_REF_URL;#var-TEST_SERIALCONTROL_CMD'><filename>TEST_SERIALCONTROL_CMD</filename></ulink> |
| 9355 | variable and optionally the |
| 9356 | <ulink url='&YOCTO_DOCS_REF_URL;#var-TEST_SERIALCONTROL_EXTRA_ARGS'><filename>TEST_SERIALCONTROL_EXTRA_ARGS</filename></ulink> |
| 9357 | variable. |
| 9358 | </para> |
| 9359 | |
| 9360 | <para> |
| 9361 | These cases could be a serial terminal program if the |
| 9362 | machine is connected to a local serial port, or a |
| 9363 | <filename>telnet</filename> or |
| 9364 | <filename>ssh</filename> command connecting to a remote |
| 9365 | console server. |
| 9366 | Regardless of the case, the command simply needs to |
| 9367 | connect to the serial console and forward that connection |
| 9368 | to standard input and output as any normal terminal |
| 9369 | program does. |
| 9370 | For example, to use the picocom terminal program on |
| 9371 | serial device <filename>/dev/ttyUSB0</filename> |
| 9372 | at 115200bps, you would set the variable as follows: |
| 9373 | <literallayout class='monospaced'> |
| 9374 | TEST_SERIALCONTROL_CMD = "picocom /dev/ttyUSB0 -b 115200" |
| 9375 | </literallayout> |
| 9376 | For local devices where the serial port device disappears |
| 9377 | when the device reboots, an additional "serdevtry" wrapper |
| 9378 | script is provided. |
| 9379 | To use this wrapper, simply prefix the terminal command |
| 9380 | with |
| 9381 | <filename>${COREBASE}/scripts/contrib/serdevtry</filename>: |
| 9382 | <literallayout class='monospaced'> |
| 9383 | TEST_SERIALCONTROL_CMD = "${COREBASE}/scripts/contrib/serdevtry picocom -b |
| 9384 | 115200 /dev/ttyUSB0" |
| 9385 | </literallayout> |
| 9386 | </para> |
| 9387 | </section> |
| 9388 | </section> |
| 9389 | |
| 9390 | <section id="qemu-image-running-tests"> |
| 9391 | <title>Running Tests</title> |
| 9392 | |
| 9393 | <para> |
| 9394 | You can start the tests automatically or manually: |
| 9395 | <itemizedlist> |
| 9396 | <listitem><para><emphasis>Automatically running tests:</emphasis> |
| 9397 | To run the tests automatically after the |
| 9398 | OpenEmbedded build system successfully creates an image, |
| 9399 | first set the |
| 9400 | <ulink url='&YOCTO_DOCS_REF_URL;#var-TEST_IMAGE'><filename>TEST_IMAGE</filename></ulink> |
| 9401 | variable to "1" in your <filename>local.conf</filename> |
| 9402 | file in the |
| 9403 | <ulink url='&YOCTO_DOCS_DEV_URL;#build-directory'>Build Directory</ulink>: |
| 9404 | <literallayout class='monospaced'> |
| 9405 | TEST_IMAGE = "1" |
| 9406 | </literallayout> |
| 9407 | Next, build your image. |
| 9408 | If the image successfully builds, the tests will be |
| 9409 | run: |
| 9410 | <literallayout class='monospaced'> |
| 9411 | bitbake core-image-sato |
| 9412 | </literallayout></para></listitem> |
| 9413 | <listitem><para><emphasis>Manually running tests:</emphasis> |
| 9414 | To manually run the tests, first globally inherit the |
Patrick Williams | f1e5d69 | 2016-03-30 15:21:19 -0500 | [diff] [blame] | 9415 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-testimage*'><filename>testimage</filename></ulink> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 9416 | class by editing your <filename>local.conf</filename> |
| 9417 | file: |
| 9418 | <literallayout class='monospaced'> |
| 9419 | INHERIT += "testimage" |
| 9420 | </literallayout> |
| 9421 | Next, use BitBake to run the tests: |
| 9422 | <literallayout class='monospaced'> |
| 9423 | bitbake -c testimage <replaceable>image</replaceable> |
| 9424 | </literallayout></para></listitem> |
| 9425 | </itemizedlist> |
| 9426 | </para> |
| 9427 | |
| 9428 | <para> |
| 9429 | All test files reside in |
| 9430 | <filename>meta/lib/oeqa/runtime</filename> in the |
| 9431 | <link linkend='source-directory'>Source Directory</link>. |
| 9432 | A test name maps directly to a Python module. |
| 9433 | Each test module may contain a number of individual tests. |
| 9434 | Tests are usually grouped together by the area |
| 9435 | tested (e.g tests for systemd reside in |
| 9436 | <filename>meta/lib/oeqa/runtime/systemd.py</filename>). |
| 9437 | </para> |
| 9438 | |
| 9439 | <para> |
| 9440 | You can add tests to any layer provided you place them in the |
| 9441 | proper area and you extend |
| 9442 | <ulink url='&YOCTO_DOCS_REF_URL;#var-BBPATH'><filename>BBPATH</filename></ulink> |
| 9443 | in the <filename>local.conf</filename> file as normal. |
| 9444 | Be sure that tests reside in |
| 9445 | <filename><replaceable>layer</replaceable>/lib/oeqa/runtime</filename>. |
| 9446 | <note> |
| 9447 | Be sure that module names do not collide with module names |
| 9448 | used in the default set of test modules in |
| 9449 | <filename>meta/lib/oeqa/runtime</filename>. |
| 9450 | </note> |
| 9451 | </para> |
| 9452 | |
| 9453 | <para> |
| 9454 | You can change the set of tests run by appending or overriding |
| 9455 | <ulink url='&YOCTO_DOCS_REF_URL;#var-TEST_SUITES'><filename>TEST_SUITES</filename></ulink> |
| 9456 | variable in <filename>local.conf</filename>. |
| 9457 | Each name in <filename>TEST_SUITES</filename> represents a |
| 9458 | required test for the image. |
| 9459 | Test modules named within <filename>TEST_SUITES</filename> |
| 9460 | cannot be skipped even if a test is not suitable for an image |
| 9461 | (e.g. running the RPM tests on an image without |
| 9462 | <filename>rpm</filename>). |
| 9463 | Appending "auto" to <filename>TEST_SUITES</filename> causes the |
| 9464 | build system to try to run all tests that are suitable for the |
| 9465 | image (i.e. each test module may elect to skip itself). |
| 9466 | </para> |
| 9467 | |
| 9468 | <para> |
| 9469 | The order you list tests in <filename>TEST_SUITES</filename> |
| 9470 | is important and influences test dependencies. |
| 9471 | Consequently, tests that depend on other tests should be added |
| 9472 | after the test on which they depend. |
| 9473 | For example, since the <filename>ssh</filename> test |
| 9474 | depends on the |
| 9475 | <filename>ping</filename> test, "ssh" needs to come after |
| 9476 | "ping" in the list. |
| 9477 | The test class provides no re-ordering or dependency handling. |
| 9478 | <note> |
| 9479 | Each module can have multiple classes with multiple test |
| 9480 | methods. |
| 9481 | And, Python <filename>unittest</filename> rules apply. |
| 9482 | </note> |
| 9483 | </para> |
| 9484 | |
| 9485 | <para> |
| 9486 | Here are some things to keep in mind when running tests: |
| 9487 | <itemizedlist> |
| 9488 | <listitem><para>The default tests for the image are defined |
| 9489 | as: |
| 9490 | <literallayout class='monospaced'> |
| 9491 | DEFAULT_TEST_SUITES_pn-<replaceable>image</replaceable> = "ping ssh df connman syslog xorg scp vnc date rpm smart dmesg" |
| 9492 | </literallayout></para></listitem> |
| 9493 | <listitem><para>Add your own test to the list of the |
| 9494 | by using the following: |
| 9495 | <literallayout class='monospaced'> |
| 9496 | TEST_SUITES_append = " mytest" |
| 9497 | </literallayout></para></listitem> |
| 9498 | <listitem><para>Run a specific list of tests as follows: |
| 9499 | <literallayout class='monospaced'> |
| 9500 | TEST_SUITES = "test1 test2 test3" |
| 9501 | </literallayout> |
| 9502 | Remember, order is important. |
| 9503 | Be sure to place a test that is dependent on another test |
| 9504 | later in the order.</para></listitem> |
| 9505 | </itemizedlist> |
| 9506 | </para> |
| 9507 | </section> |
| 9508 | |
| 9509 | <section id="exporting-tests"> |
| 9510 | <title>Exporting Tests</title> |
| 9511 | |
| 9512 | <para> |
| 9513 | You can export tests so that they can run independently of |
| 9514 | the build system. |
| 9515 | Exporting tests is required if you want to be able to hand |
| 9516 | the test execution off to a scheduler. |
| 9517 | You can only export tests that are defined in |
| 9518 | <ulink url='&YOCTO_DOCS_REF_URL;#var-TEST_SUITES'><filename>TEST_SUITES</filename></ulink>. |
| 9519 | </para> |
| 9520 | |
| 9521 | <para> |
| 9522 | If your image is already built, make sure the following are set |
| 9523 | in your <filename>local.conf</filename> file. |
| 9524 | Be sure to provide the IP address you need: |
| 9525 | <literallayout class='monospaced'> |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame^] | 9526 | INHERIT +="testexport" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 9527 | TEST_TARGET_IP = "192.168.7.2" |
| 9528 | TEST_SERVER_IP = "192.168.7.1" |
| 9529 | </literallayout> |
| 9530 | You can then export the tests with the following: |
| 9531 | <literallayout class='monospaced'> |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame^] | 9532 | $ bitbake core-image-sato -c testexport |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 9533 | </literallayout> |
| 9534 | Exporting the tests places them in the |
| 9535 | <link linkend='build-directory'>Build Directory</link> in |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame^] | 9536 | <filename>tmp/testexport/core-image-sato</filename>, which |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 9537 | is controlled by the |
| 9538 | <filename>TEST_EXPORT_DIR</filename> variable. |
| 9539 | </para> |
| 9540 | |
| 9541 | <para> |
| 9542 | You can now run the tests outside of the build environment: |
| 9543 | <literallayout class='monospaced'> |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame^] | 9544 | $ cd tmp/testexport/core-image-sato |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 9545 | $ ./runexported.py testdata.json |
| 9546 | </literallayout> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 9547 | </para> |
| 9548 | </section> |
| 9549 | |
| 9550 | <section id="qemu-image-writing-new-tests"> |
| 9551 | <title>Writing New Tests</title> |
| 9552 | |
| 9553 | <para> |
| 9554 | As mentioned previously, all new test files need to be in the |
| 9555 | proper place for the build system to find them. |
| 9556 | New tests for additional functionality outside of the core |
| 9557 | should be added to the layer that adds the functionality, in |
| 9558 | <filename><replaceable>layer</replaceable>/lib/oeqa/runtime</filename> |
| 9559 | (as long as |
| 9560 | <ulink url='&YOCTO_DOCS_REF_URL;#var-BBPATH'><filename>BBPATH</filename></ulink> |
| 9561 | is extended in the layer's |
| 9562 | <filename>layer.conf</filename> file as normal). |
| 9563 | Just remember the following: |
| 9564 | <itemizedlist> |
| 9565 | <listitem><para>Filenames need to map directly to test |
| 9566 | (module) names. |
| 9567 | </para></listitem> |
| 9568 | <listitem><para>Do not use module names that |
| 9569 | collide with existing core tests. |
| 9570 | </para></listitem> |
| 9571 | <listitem><para>Minimally, an empty |
| 9572 | <filename>__init__.py</filename> file must exist |
| 9573 | in the runtime directory. |
| 9574 | </para></listitem> |
| 9575 | </itemizedlist> |
| 9576 | </para> |
| 9577 | |
| 9578 | <para> |
| 9579 | To create a new test, start by copying an existing module |
| 9580 | (e.g. <filename>syslog.py</filename> or |
| 9581 | <filename>gcc.py</filename> are good ones to use). |
| 9582 | Test modules can use code from |
| 9583 | <filename>meta/lib/oeqa/utils</filename>, which are helper |
| 9584 | classes. |
| 9585 | </para> |
| 9586 | |
| 9587 | <note> |
| 9588 | Structure shell commands such that you rely on them and they |
| 9589 | return a single code for success. |
| 9590 | Be aware that sometimes you will need to parse the output. |
| 9591 | See the <filename>df.py</filename> and |
| 9592 | <filename>date.py</filename> modules for examples. |
| 9593 | </note> |
| 9594 | |
| 9595 | <para> |
| 9596 | You will notice that all test classes inherit |
| 9597 | <filename>oeRuntimeTest</filename>, which is found in |
| 9598 | <filename>meta/lib/oetest.py</filename>. |
| 9599 | This base class offers some helper attributes, which are |
| 9600 | described in the following sections: |
| 9601 | </para> |
| 9602 | |
| 9603 | <section id='qemu-image-writing-tests-class-methods'> |
| 9604 | <title>Class Methods</title> |
| 9605 | |
| 9606 | <para> |
| 9607 | Class methods are as follows: |
| 9608 | <itemizedlist> |
| 9609 | <listitem><para><emphasis><filename>hasPackage(pkg)</filename>:</emphasis> |
| 9610 | Returns "True" if <filename>pkg</filename> is in the |
| 9611 | installed package list of the image, which is based |
| 9612 | on the manifest file that is generated during the |
| 9613 | <filename>do_rootfs</filename> task. |
| 9614 | </para></listitem> |
| 9615 | <listitem><para><emphasis><filename>hasFeature(feature)</filename>:</emphasis> |
| 9616 | Returns "True" if the feature is in |
| 9617 | <ulink url='&YOCTO_DOCS_REF_URL;#var-IMAGE_FEATURES'><filename>IMAGE_FEATURES</filename></ulink> |
| 9618 | or |
| 9619 | <ulink url='&YOCTO_DOCS_REF_URL;#var-DISTRO_FEATURES'><filename>DISTRO_FEATURES</filename></ulink>. |
| 9620 | </para></listitem> |
| 9621 | </itemizedlist> |
| 9622 | </para> |
| 9623 | </section> |
| 9624 | |
| 9625 | <section id='qemu-image-writing-tests-class-attributes'> |
| 9626 | <title>Class Attributes</title> |
| 9627 | |
| 9628 | <para> |
| 9629 | Class attributes are as follows: |
| 9630 | <itemizedlist> |
| 9631 | <listitem><para><emphasis><filename>pscmd</filename>:</emphasis> |
| 9632 | Equals "ps -ef" if <filename>procps</filename> is |
| 9633 | installed in the image. |
| 9634 | Otherwise, <filename>pscmd</filename> equals |
| 9635 | "ps" (busybox). |
| 9636 | </para></listitem> |
| 9637 | <listitem><para><emphasis><filename>tc</filename>:</emphasis> |
| 9638 | The called test context, which gives access to the |
| 9639 | following attributes: |
| 9640 | <itemizedlist> |
| 9641 | <listitem><para><emphasis><filename>d</filename>:</emphasis> |
| 9642 | The BitBake datastore, which allows you to |
| 9643 | use stuff such as |
| 9644 | <filename>oeRuntimeTest.tc.d.getVar("VIRTUAL-RUNTIME_init_manager")</filename>. |
| 9645 | </para></listitem> |
| 9646 | <listitem><para><emphasis><filename>testslist</filename> and <filename>testsrequired</filename>:</emphasis> |
| 9647 | Used internally. |
| 9648 | The tests do not need these. |
| 9649 | </para></listitem> |
| 9650 | <listitem><para><emphasis><filename>filesdir</filename>:</emphasis> |
| 9651 | The absolute path to |
| 9652 | <filename>meta/lib/oeqa/runtime/files</filename>, |
| 9653 | which contains helper files for tests meant |
| 9654 | for copying on the target such as small |
| 9655 | files written in C for compilation. |
| 9656 | </para></listitem> |
| 9657 | <listitem><para><emphasis><filename>target</filename>:</emphasis> |
| 9658 | The target controller object used to deploy |
| 9659 | and start an image on a particular target |
| 9660 | (e.g. QemuTarget, SimpleRemote, and |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame^] | 9661 | Systemd-bootTarget). |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 9662 | Tests usually use the following: |
| 9663 | <itemizedlist> |
| 9664 | <listitem><para><emphasis><filename>ip</filename>:</emphasis> |
| 9665 | The target's IP address. |
| 9666 | </para></listitem> |
| 9667 | <listitem><para><emphasis><filename>server_ip</filename>:</emphasis> |
| 9668 | The host's IP address, which is |
| 9669 | usually used by the "smart" test |
| 9670 | suite. |
| 9671 | </para></listitem> |
| 9672 | <listitem><para><emphasis><filename>run(cmd, timeout=None)</filename>:</emphasis> |
| 9673 | The single, most used method. |
| 9674 | This command is a wrapper for: |
| 9675 | <filename>ssh root@host "cmd"</filename>. |
| 9676 | The command returns a tuple: |
| 9677 | (status, output), which are what |
| 9678 | their names imply - the return code |
| 9679 | of "cmd" and whatever output |
| 9680 | it produces. |
| 9681 | The optional timeout argument |
| 9682 | represents the number of seconds the |
| 9683 | test should wait for "cmd" to |
| 9684 | return. |
| 9685 | If the argument is "None", the |
| 9686 | test uses the default instance's |
| 9687 | timeout period, which is 300 |
| 9688 | seconds. |
| 9689 | If the argument is "0", the test |
| 9690 | runs until the command returns. |
| 9691 | </para></listitem> |
| 9692 | <listitem><para><emphasis><filename>copy_to(localpath, remotepath)</filename>:</emphasis> |
| 9693 | <filename>scp localpath root@ip:remotepath</filename>. |
| 9694 | </para></listitem> |
| 9695 | <listitem><para><emphasis><filename>copy_from(remotepath, localpath)</filename>:</emphasis> |
| 9696 | <filename>scp root@host:remotepath localpath</filename>. |
| 9697 | </para></listitem> |
| 9698 | </itemizedlist></para></listitem> |
| 9699 | </itemizedlist></para></listitem> |
| 9700 | </itemizedlist> |
| 9701 | </para> |
| 9702 | </section> |
| 9703 | |
| 9704 | <section id='qemu-image-writing-tests-instance-attributes'> |
| 9705 | <title>Instance Attributes</title> |
| 9706 | |
| 9707 | <para> |
| 9708 | A single instance attribute exists, which is |
| 9709 | <filename>target</filename>. |
| 9710 | The <filename>target</filename> instance attribute is |
| 9711 | identical to the class attribute of the same name, which |
| 9712 | is described in the previous section. |
| 9713 | This attribute exists as both an instance and class |
| 9714 | attribute so tests can use |
| 9715 | <filename>self.target.run(cmd)</filename> in instance |
| 9716 | methods instead of |
| 9717 | <filename>oeRuntimeTest.tc.target.run(cmd)</filename>. |
| 9718 | </para> |
| 9719 | </section> |
| 9720 | </section> |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame^] | 9721 | |
| 9722 | <section id='installing-packages-in-the-dut-without-the-package-manager'> |
| 9723 | <title>Installing Packages in the DUT Without the Package Manager</title> |
| 9724 | |
| 9725 | <para> |
| 9726 | When a test requires a package built by BitBake, it is possible |
| 9727 | to install that package. |
| 9728 | Installing the package does not require a package manager be |
| 9729 | installed in the device under test (DUT). |
| 9730 | It does, however, require an SSH connection and the target must |
| 9731 | be using the <filename>sshcontrol</filename> class. |
| 9732 | <note> |
| 9733 | This method uses <filename>scp</filename> to copy files |
| 9734 | from the host to the target, which causes permissions and |
| 9735 | special attributes to be lost. |
| 9736 | </note> |
| 9737 | </para> |
| 9738 | |
| 9739 | <para> |
| 9740 | A JSON file is used to define the packages needed by a test. |
| 9741 | This file must be in the same path as the file used to define |
| 9742 | the tests. |
| 9743 | Furthermore, the filename must map directly to the test |
| 9744 | module name with a <filename>.json</filename> extension. |
| 9745 | </para> |
| 9746 | |
| 9747 | <para> |
| 9748 | The JSON file must include an object with the test name as |
| 9749 | keys of an object or an array. |
| 9750 | This object (or array of objects) uses the following data: |
| 9751 | <itemizedlist> |
| 9752 | <listitem><para>"pkg" - A mandatory string that is the |
| 9753 | name of the package to be installed. |
| 9754 | </para></listitem> |
| 9755 | <listitem><para>"rm" - An optional boolean, which defaults |
| 9756 | to "false", that specifies to remove the package after |
| 9757 | the test. |
| 9758 | </para></listitem> |
| 9759 | <listitem><para>"extract" - An optional boolean, which |
| 9760 | defaults to "false", that specifies if the package must |
| 9761 | be extracted from the package format. |
| 9762 | When set to "true", the package is not automatically |
| 9763 | installed into the DUT. |
| 9764 | </para></listitem> |
| 9765 | </itemizedlist> |
| 9766 | </para> |
| 9767 | |
| 9768 | <para> |
| 9769 | Following is an example JSON file that handles test "foo" |
| 9770 | installing package "bar" and test "foobar" installing |
| 9771 | packages "foo" and "bar". |
| 9772 | Once the test is complete, the packages are removed from the |
| 9773 | DUT. |
| 9774 | <literallayout class='monospaced'> |
| 9775 | { |
| 9776 | "foo": { |
| 9777 | "pkg": "bar" |
| 9778 | }, |
| 9779 | "foobar": [ |
| 9780 | { |
| 9781 | "pkg": "foo", |
| 9782 | "rm": true |
| 9783 | }, |
| 9784 | { |
| 9785 | "pkg": "bar", |
| 9786 | "rm": true |
| 9787 | } |
| 9788 | ] |
| 9789 | } |
| 9790 | </literallayout> |
| 9791 | </para> |
| 9792 | </section> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 9793 | </section> |
| 9794 | |
| 9795 | <section id="platdev-gdb-remotedebug"> |
| 9796 | <title>Debugging With the GNU Project Debugger (GDB) Remotely</title> |
| 9797 | |
| 9798 | <para> |
| 9799 | GDB allows you to examine running programs, which in turn helps you to understand and fix problems. |
| 9800 | It also allows you to perform post-mortem style analysis of program crashes. |
| 9801 | GDB is available as a package within the Yocto Project and is |
| 9802 | installed in SDK images by default. |
| 9803 | See the "<ulink url='&YOCTO_DOCS_REF_URL;#ref-images'>Images</ulink>" chapter |
| 9804 | in the Yocto Project Reference Manual for a description of these images. |
| 9805 | You can find information on GDB at <ulink url="http://sourceware.org/gdb/"/>. |
| 9806 | </para> |
| 9807 | |
| 9808 | <tip> |
| 9809 | For best results, install debug (<filename>-dbg</filename>) packages |
| 9810 | for the applications you are going to debug. |
| 9811 | Doing so makes extra debug symbols available that give you more |
| 9812 | meaningful output. |
| 9813 | </tip> |
| 9814 | |
| 9815 | <para> |
| 9816 | Sometimes, due to memory or disk space constraints, it is not possible |
| 9817 | to use GDB directly on the remote target to debug applications. |
| 9818 | These constraints arise because GDB needs to load the debugging information and the |
| 9819 | binaries of the process being debugged. |
| 9820 | Additionally, GDB needs to perform many computations to locate information such as function |
| 9821 | names, variable names and values, stack traces and so forth - even before starting the |
| 9822 | debugging process. |
| 9823 | These extra computations place more load on the target system and can alter the |
| 9824 | characteristics of the program being debugged. |
| 9825 | </para> |
| 9826 | |
| 9827 | <para> |
| 9828 | To help get past the previously mentioned constraints, you can use Gdbserver. |
| 9829 | Gdbserver runs on the remote target and does not load any debugging information |
| 9830 | from the debugged process. |
| 9831 | Instead, a GDB instance processes the debugging information that is run on a |
| 9832 | remote computer - the host GDB. |
| 9833 | The host GDB then sends control commands to Gdbserver to make it stop or start the debugged |
| 9834 | program, as well as read or write memory regions of that debugged program. |
| 9835 | All the debugging information loaded and processed as well |
| 9836 | as all the heavy debugging is done by the host GDB. |
| 9837 | Offloading these processes gives the Gdbserver running on the target a chance to remain |
| 9838 | small and fast. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 9839 | </para> |
| 9840 | |
| 9841 | <para> |
| 9842 | Because the host GDB is responsible for loading the debugging information and |
| 9843 | for doing the necessary processing to make actual debugging happen, |
| 9844 | you have to make sure the host can access the unstripped binaries complete |
| 9845 | with their debugging information and also be sure the target is compiled with no optimizations. |
| 9846 | The host GDB must also have local access to all the libraries used by the |
| 9847 | debugged program. |
| 9848 | Because Gdbserver does not need any local debugging information, the binaries on |
| 9849 | the remote target can remain stripped. |
| 9850 | However, the binaries must also be compiled without optimization |
| 9851 | so they match the host's binaries. |
| 9852 | </para> |
| 9853 | |
| 9854 | <para> |
| 9855 | To remain consistent with GDB documentation and terminology, the binary being debugged |
| 9856 | on the remote target machine is referred to as the "inferior" binary. |
| 9857 | For documentation on GDB see the |
| 9858 | <ulink url="http://sourceware.org/gdb/documentation/">GDB site</ulink>. |
| 9859 | </para> |
| 9860 | |
| 9861 | <para> |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame^] | 9862 | The following steps show you how to debug using the GNU project |
| 9863 | debugger. |
| 9864 | <orderedlist> |
| 9865 | <listitem><para> |
| 9866 | <emphasis>Configure your build system to construct the |
| 9867 | companion debug filesystem:</emphasis></para> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 9868 | |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame^] | 9869 | <para>In your <filename>local.conf</filename> file, set |
| 9870 | the following: |
| 9871 | <literallayout class='monospaced'> |
| 9872 | IMAGE_GEN_DEBUGFS = "1" |
| 9873 | IMAGE_FSTYPES_DEBUGFS = "tar.bz2" |
| 9874 | </literallayout> |
| 9875 | These options cause the OpenEmbedded build system |
| 9876 | to generate a special companion filesystem fragment, |
| 9877 | which contains the matching source and debug symbols to |
| 9878 | your deployable filesystem. |
| 9879 | The build system does this by looking at what is in the |
| 9880 | deployed filesystem, and pulling the corresponding |
| 9881 | <filename>-dbg</filename> packages.</para> |
| 9882 | |
| 9883 | <para>The companion debug filesystem is not a complete |
| 9884 | filesystem, but only contains the debug fragments. |
| 9885 | This filesystem must be combined with the full filesystem |
| 9886 | for debugging. |
| 9887 | Subsequent steps in this procedure show how to combine |
| 9888 | the partial filesystem with the full filesystem. |
| 9889 | </para></listitem> |
| 9890 | <listitem><para> |
| 9891 | <emphasis>Configure the system to include Gdbserver in |
| 9892 | the target filesystem:</emphasis></para> |
| 9893 | |
| 9894 | <para>Make the following addition in either your |
| 9895 | <filename>local.conf</filename> file or in an image |
| 9896 | recipe: |
| 9897 | <literallayout class='monospaced'> |
| 9898 | IMAGE_INSTALL_append = “ gdbserver" |
| 9899 | </literallayout> |
| 9900 | The change makes sure the <filename>gdbserver</filename> |
| 9901 | package is included. |
| 9902 | </para></listitem> |
| 9903 | <listitem><para> |
| 9904 | <emphasis>Build the environment:</emphasis></para> |
| 9905 | |
| 9906 | <para>Use the following command to construct the image and |
| 9907 | the companion Debug Filesystem: |
| 9908 | <literallayout class='monospaced'> |
| 9909 | $ bitbake <replaceable>image</replaceable> |
| 9910 | </literallayout> |
| 9911 | Build the cross GDB component and make it available |
| 9912 | for debugging. |
| 9913 | Build the SDK that matches the image. |
| 9914 | Building the SDK is best for a production build |
| 9915 | that can be used later for debugging, especially |
| 9916 | during long term maintenance: |
| 9917 | <literallayout class='monospaced'> |
| 9918 | $ bitbake -c populate_sdk <replaceable>image</replaceable> |
| 9919 | </literallayout></para> |
| 9920 | |
| 9921 | <para>Alternatively, you can build the minimal |
| 9922 | toolchain components that match the target. |
| 9923 | Doing so creates a smaller than typical SDK and only |
| 9924 | contains a minimal set of components with which to |
| 9925 | build simple test applications, as well as run the |
| 9926 | debugger: |
| 9927 | <literallayout class='monospaced'> |
| 9928 | $ bitbake meta-toolchain |
| 9929 | </literallayout></para> |
| 9930 | |
| 9931 | <para>A final method is to build Gdb itself within |
| 9932 | the build system: |
| 9933 | <literallayout class='monospaced'> |
| 9934 | $ bitbake gdb-cross-<replaceable>architecture</replaceable> |
| 9935 | </literallayout> |
| 9936 | Doing so produces a temporary copy of |
| 9937 | <filename>cross-gdb</filename> you can use for |
| 9938 | debugging during development. |
| 9939 | While this is the quickest approach, the two previous |
| 9940 | methods in this step are better when considering |
| 9941 | long-term maintenance strategies. |
| 9942 | <note> |
| 9943 | If you run |
| 9944 | <filename>bitbake gdb-cross</filename>, the |
| 9945 | OpenEmbedded build system suggests the actual |
| 9946 | image (e.g. <filename>gdb-cross-i586</filename>). |
| 9947 | The suggestion is usually the actual name you want |
| 9948 | to use. |
| 9949 | </note> |
| 9950 | </para></listitem> |
| 9951 | <listitem><para> |
| 9952 | <emphasis>Set up the</emphasis> <filename>debugfs</filename></para> |
| 9953 | |
| 9954 | <para>Run the following commands to set up the |
| 9955 | <filename>debugfs</filename>: |
| 9956 | <literallayout class='monospaced'> |
| 9957 | $ mkdir debugfs |
| 9958 | $ cd debugfs |
| 9959 | $ tar xvfj <replaceable>build-dir</replaceable>/tmp-glibc/deploy/images/<replaceable>machine</replaceable>/<replaceable>image</replaceable>.rootfs.tar.bz2 |
| 9960 | $ tar xvfj <replaceable>build-dir</replaceable>/tmp-glibc/deploy/images/<replaceable>machine</replaceable>/<replaceable>image</replaceable>-dbg.rootfs.tar.bz2 |
| 9961 | </literallayout> |
| 9962 | </para></listitem> |
| 9963 | <listitem><para> |
| 9964 | <emphasis>Set up GDB</emphasis></para> |
| 9965 | |
| 9966 | <para>Install the SDK (if you built one) and then |
| 9967 | source the correct environment file. |
| 9968 | Sourcing the environment file puts the SDK in your |
| 9969 | <filename>PATH</filename> environment variable.</para> |
| 9970 | |
| 9971 | <para>If you are using the build system, Gdb is |
| 9972 | located in |
| 9973 | <replaceable>build-dir</replaceable>/tmp/sysroots/<replaceable>host</replaceable>/usr/bin/<replaceable>architecture</replaceable>/<replaceable>architecture</replaceable>-gdb |
| 9974 | </para></listitem> |
| 9975 | <listitem><para> |
| 9976 | <emphasis>Boot the target:</emphasis></para> |
| 9977 | |
| 9978 | <para>For information on how to run QEMU, see the |
| 9979 | <ulink url='http://wiki.qemu.org/Documentation/GettingStartedDevelopers'>QEMU Documentation</ulink>. |
| 9980 | <note> |
| 9981 | Be sure to verify that your host can access the |
| 9982 | target via TCP. |
| 9983 | </note> |
| 9984 | </para></listitem> |
| 9985 | <listitem><para> |
| 9986 | <emphasis>Debug a program:</emphasis></para> |
| 9987 | |
| 9988 | <para>Debugging a program involves running Gdbserver |
| 9989 | on the target and then running Gdb on the host. |
| 9990 | The example in this step debugs |
| 9991 | <filename>gzip</filename>: |
| 9992 | <literallayout class='monospaced'> |
| 9993 | root@qemux86:~# gdbserver localhost:1234 /bin/gzip —help |
| 9994 | </literallayout> |
| 9995 | For additional Gdbserver options, see the |
| 9996 | <ulink url='https://www.gnu.org/software/gdb/documentation/'>Gdb Server Documentation</ulink>. |
| 9997 | </para> |
| 9998 | |
| 9999 | <para>After running Gdbserver on the target, you need |
| 10000 | to run Gdb on the host and configure it and connect to |
| 10001 | the target. |
| 10002 | Use these commands: |
| 10003 | <literallayout class='monospaced'> |
| 10004 | $ cd <replaceable>directory-holding-the-debugfs-directory</replaceable> |
| 10005 | $ <replaceable>arch</replaceable>-gdb |
| 10006 | |
| 10007 | (gdb) set sysroot debugfs |
| 10008 | (gdb) set substitute-path /usr/src/debug debugfs/usr/src/debug |
| 10009 | (gdb) target remote <replaceable>IP-of-target</replaceable>:1234 |
| 10010 | </literallayout> |
| 10011 | At this point, everything should automatically load |
| 10012 | (i.e. matching binaries, symbols and headers). |
| 10013 | <note> |
| 10014 | The Gdb <filename>set</filename> commands in the |
| 10015 | previous example can be placed into the users |
| 10016 | <filename>~/.gdbinit</filename> file. |
| 10017 | Upon starting, Gdb automatically runs whatever |
| 10018 | commands are in that file. |
| 10019 | </note> |
| 10020 | </para></listitem> |
| 10021 | <listitem><para> |
| 10022 | <emphasis>Deploying without a full image |
| 10023 | rebuild:</emphasis></para> |
| 10024 | |
| 10025 | <para>In many cases, during development you want a |
| 10026 | quick method to deploy a new binary to the target and |
| 10027 | debug it, without waiting for a full image build. |
| 10028 | </para> |
| 10029 | |
| 10030 | <para>One approach to solving this situation is to |
| 10031 | just build the component you want to debug. |
| 10032 | Once you have built the component, copy the |
| 10033 | executable directly to both the target and the |
| 10034 | host <filename>debugfs</filename>.</para> |
| 10035 | |
| 10036 | <para>If the binary is processed through the debug |
| 10037 | splitting in OpenEmbedded, you should also |
| 10038 | copy the debug items (i.e. <filename>.debug</filename> |
| 10039 | contents and corresponding |
| 10040 | <filename>/usr/src/debug</filename> files) |
| 10041 | from the work directory. |
| 10042 | Here is an example: |
| 10043 | <literallayout class='monospaced'> |
| 10044 | $ bitbake bash |
| 10045 | $ bitbake -c devshell bash |
| 10046 | $ cd .. |
| 10047 | $ scp packages-split/bash/bin/bash <replaceable>target</replaceable>:/bin/bash |
| 10048 | $ cp -a packages-split/bash-dbg/* <replaceable>path</replaceable>/debugfs |
| 10049 | </literallayout> |
| 10050 | </para></listitem> |
| 10051 | </orderedlist> |
| 10052 | </para> |
| 10053 | </section> |
| 10054 | |
| 10055 | <!-- |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 10056 | <section id='platdev-gdb-remotedebug-setup'> |
| 10057 | <title>Set Up the Cross-Development Debugging Environment</title> |
| 10058 | |
| 10059 | <para> |
| 10060 | Before you can initiate a remote debugging session, you need |
| 10061 | to be sure you have set up the cross-development environment, |
| 10062 | toolchain, and sysroot. |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 10063 | The <ulink url='&YOCTO_DOCS_SDK_URL;#sdk-intro'>Yocto Project Software Development Kit (SDK) Developer's Guide</ulink> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 10064 | describes this process. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 10065 | </para> |
| 10066 | </section> |
| 10067 | |
| 10068 | <section id="platdev-gdb-remotedebug-launch-gdbserver"> |
| 10069 | <title>Launch Gdbserver on the Target</title> |
| 10070 | |
| 10071 | <para> |
| 10072 | Make sure Gdbserver is installed on the target. |
| 10073 | If it is not, install the package |
| 10074 | <filename>gdbserver</filename>, which needs the |
| 10075 | <filename>libthread-db1</filename> package. |
| 10076 | </para> |
| 10077 | |
| 10078 | <para> |
| 10079 | Here is an example, that when entered from the host, |
| 10080 | connects to the target and launches Gdbserver in order to |
| 10081 | "debug" a binary named <filename>helloworld</filename>: |
| 10082 | <literallayout class='monospaced'> |
| 10083 | $ gdbserver localhost:2345 /usr/bin/helloworld |
| 10084 | </literallayout> |
| 10085 | Gdbserver should now be listening on port 2345 for debugging |
| 10086 | commands coming from a remote GDB process that is running on |
| 10087 | the host computer. |
| 10088 | Communication between Gdbserver and the host GDB are done |
| 10089 | using TCP. |
| 10090 | To use other communication protocols, please refer to the |
| 10091 | <ulink url='http://www.gnu.org/software/gdb/'>Gdbserver documentation</ulink>. |
| 10092 | </para> |
| 10093 | </section> |
| 10094 | |
| 10095 | <section id="platdev-gdb-remotedebug-launch-gdb"> |
| 10096 | <title>Launch GDB on the Host Computer</title> |
| 10097 | |
| 10098 | <para> |
| 10099 | Running GDB on the host computer takes a number of stages, which |
| 10100 | this section describes. |
| 10101 | </para> |
| 10102 | |
| 10103 | <section id="platdev-gdb-remotedebug-launch-gdb-buildcross"> |
| 10104 | <title>Build the Cross-GDB Package</title> |
| 10105 | <para> |
| 10106 | A suitable GDB cross-binary is required that runs on your |
| 10107 | host computer but also knows about the the ABI of the |
| 10108 | remote target. |
| 10109 | You can get this binary from the |
| 10110 | <link linkend='cross-development-toolchain'>Cross-Development Toolchain</link>. |
| 10111 | Here is an example where the toolchain has been installed |
| 10112 | in the default directory |
| 10113 | <filename>/opt/poky/&DISTRO;</filename>: |
| 10114 | <literallayout class='monospaced'> |
| 10115 | /opt/poky/&DISTRO;/sysroots/i686-pokysdk-linux/usr/bin/armv7a-vfp-neon-poky-linux-gnueabi/arm-poky-linux-gnueabi-gdb |
| 10116 | </literallayout> |
| 10117 | where <filename>arm</filename> is the target architecture |
| 10118 | and <filename>linux-gnueabi</filename> is the target ABI. |
| 10119 | </para> |
| 10120 | |
| 10121 | <para> |
| 10122 | Alternatively, you can use BitBake to build the |
| 10123 | <filename>gdb-cross</filename> binary. |
| 10124 | Here is an example: |
| 10125 | <literallayout class='monospaced'> |
| 10126 | $ bitbake gdb-cross |
| 10127 | </literallayout> |
| 10128 | Once the binary is built, you can find it here: |
| 10129 | <literallayout class='monospaced'> |
| 10130 | tmp/sysroots/<replaceable>host-arch</replaceable>/usr/bin/<replaceable>target-platform</replaceable>/<replaceable>target-abi</replaceable>-gdb |
| 10131 | </literallayout> |
| 10132 | </para> |
| 10133 | </section> |
| 10134 | |
| 10135 | <section id='create-the-gdb-initialization-file'> |
| 10136 | <title>Create the GDB Initialization File and Point to Your Root Filesystem</title> |
| 10137 | |
| 10138 | <para> |
| 10139 | Aside from the GDB cross-binary, you also need a GDB |
| 10140 | initialization file in the same top directory in which |
| 10141 | your binary resides. |
| 10142 | When you start GDB on your host development system, GDB |
| 10143 | finds this initialization file and executes all the |
| 10144 | commands within. |
| 10145 | For information on the <filename>.gdbinit</filename>, see |
| 10146 | "<ulink url='http://sourceware.org/gdb/onlinedocs/gdb/'>Debugging with GDB</ulink>", |
| 10147 | which is maintained by |
| 10148 | <ulink url='http://www.sourceware.org'>sourceware.org</ulink>. |
| 10149 | </para> |
| 10150 | |
| 10151 | <para> |
| 10152 | You need to add a statement in the |
| 10153 | <filename>~/.gdbinit</filename> file that points to your |
| 10154 | root filesystem. |
| 10155 | Here is an example that points to the root filesystem for |
| 10156 | an ARM-based target device: |
| 10157 | <literallayout class='monospaced'> |
| 10158 | set sysroot ~/sysroot_arm |
| 10159 | </literallayout> |
| 10160 | </para> |
| 10161 | </section> |
| 10162 | |
| 10163 | <section id="platdev-gdb-remotedebug-launch-gdb-launchhost"> |
| 10164 | <title>Launch the Host GDB</title> |
| 10165 | |
| 10166 | <para> |
| 10167 | Before launching the host GDB, you need to be sure |
| 10168 | you have sourced the cross-debugging environment script, |
| 10169 | which if you installed the root filesystem in the default |
| 10170 | location is at <filename>/opt/poky/&DISTRO;</filename> |
| 10171 | and begins with the string "environment-setup". |
| 10172 | For more information, see the |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 10173 | <ulink url='&YOCTO_DOCS_SDK_URL;#sdk-manual'>Yocto Project Software Development Kit (SDK) Developer's |
| 10174 | Guide</ulink>. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 10175 | </para> |
| 10176 | |
| 10177 | <para> |
| 10178 | Finally, switch to the directory where the binary resides |
| 10179 | and run the <filename>cross-gdb</filename> binary. |
| 10180 | Provide the binary file you are going to debug. |
| 10181 | For example, the following command continues with the |
| 10182 | example used in the previous section by loading |
| 10183 | the <filename>helloworld</filename> binary as well as the |
| 10184 | debugging information: |
| 10185 | <literallayout class='monospaced'> |
| 10186 | $ arm-poky-linux-gnuabi-gdb helloworld |
| 10187 | </literallayout> |
| 10188 | The commands in your <filename>.gdbinit</filename> execute |
| 10189 | and the GDB prompt appears. |
| 10190 | </para> |
| 10191 | </section> |
| 10192 | </section> |
| 10193 | |
| 10194 | <section id='platdev-gdb-connect-to-the-remote-gdb-server'> |
| 10195 | <title>Connect to the Remote GDB Server</title> |
| 10196 | |
| 10197 | <para> |
| 10198 | From the target, you need to connect to the remote GDB |
| 10199 | server that is running on the host. |
| 10200 | You need to specify the remote host and port. |
| 10201 | Here is the command continuing with the example: |
| 10202 | <literallayout class='monospaced'> |
| 10203 | target remote 192.168.7.2:2345 |
| 10204 | </literallayout> |
| 10205 | </para> |
| 10206 | </section> |
| 10207 | |
| 10208 | <section id="platdev-gdb-remotedebug-launch-gdb-using"> |
| 10209 | <title>Use the Debugger</title> |
| 10210 | |
| 10211 | <para> |
| 10212 | You can now proceed with debugging as normal - as if you were debugging |
| 10213 | on the local machine. |
| 10214 | For example, to instruct GDB to break in the "main" function and then |
| 10215 | continue with execution of the inferior binary use the following commands |
| 10216 | from within GDB: |
| 10217 | <literallayout class='monospaced'> |
| 10218 | (gdb) break main |
| 10219 | (gdb) continue |
| 10220 | </literallayout> |
| 10221 | </para> |
| 10222 | |
| 10223 | <para> |
| 10224 | For more information about using GDB, see the project's online documentation at |
| 10225 | <ulink url="http://sourceware.org/gdb/download/onlinedocs/"/>. |
| 10226 | </para> |
| 10227 | </section> |
| 10228 | </section> |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame^] | 10229 | --> |
| 10230 | |
| 10231 | <section id='debugging-with-the-gnu-project-debugger-gdb-on-the-target'> |
| 10232 | <title>Debugging with the GNU Project Debugger (GDB) on the Target</title> |
| 10233 | |
| 10234 | <para> |
| 10235 | The previous section addressed using GDB remotely for debugging |
| 10236 | purposes, which is the most usual case due to the inherent |
| 10237 | hardware limitations on many embedded devices. |
| 10238 | However, debugging in the target hardware itself is also possible |
| 10239 | with more powerful devices. |
| 10240 | This section describes what you need to do in order to support |
| 10241 | using GDB to debug on the target hardware. |
| 10242 | </para> |
| 10243 | |
| 10244 | <para> |
| 10245 | To support this kind of debugging, you need do the following: |
| 10246 | <itemizedlist> |
| 10247 | <listitem><para> |
| 10248 | Ensure that GDB is on the target. |
| 10249 | You can do this by adding "gdb" to |
| 10250 | <ulink url='&YOCTO_DOCS_REF_URL;#var-IMAGE_INSTALL'><filename>IMAGE_INSTALL</filename></ulink>: |
| 10251 | <literallayout class='monospaced'> |
| 10252 | IMAGE_INSTALL_append = " gdb" |
| 10253 | </literallayout> |
| 10254 | Alternatively, you can add "tools-debug" to |
| 10255 | <ulink url='&YOCTO_DOCS_REF_URL;#var-IMAGE_FEATURES'><filename>IMAGE_FEATURES</filename></ulink>: |
| 10256 | <literallayout class='monospaced'> |
| 10257 | IMAGE_FEATURES_append = " tools-debug" |
| 10258 | </literallayout> |
| 10259 | </para></listitem> |
| 10260 | <listitem><para> |
| 10261 | Ensure that debug symbols are present. |
| 10262 | You can make sure these symbols are present by installing |
| 10263 | <filename>-dbg</filename>: |
| 10264 | <literallayout class='monospaced'> |
| 10265 | IMAGE_INSTALL_append = " <replaceable>packagename</replaceable>-dbg" |
| 10266 | </literallayout> |
| 10267 | Alternatively, you can do the following to include all the |
| 10268 | debug symbols: |
| 10269 | <literallayout class='monospaced'> |
| 10270 | IMAGE_FEATURES_append = " dbg-pkgs" |
| 10271 | </literallayout> |
| 10272 | </para></listitem> |
| 10273 | </itemizedlist> |
| 10274 | <note> |
| 10275 | To improve the debug information accuracy, you can reduce the |
| 10276 | level of optimization used by the compiler. |
| 10277 | For example, when adding the following line to your |
| 10278 | <filename>local.conf</filename> file, you will reduce |
| 10279 | optimization from |
| 10280 | <ulink url='&YOCTO_DOCS_REF_URL;#var-FULL_OPTIMIZATION'><filename>FULL_OPTIMIZATION</filename></ulink> |
| 10281 | of "-O2" to |
| 10282 | <ulink url='&YOCTO_DOCS_REF_URL;#var-DEBUG_OPTIMIZATION'><filename>DEBUG_OPTIMIZATION</filename></ulink> |
| 10283 | of "-O -fno-omit-frame-pointer": |
| 10284 | <literallayout class='monospaced'> |
| 10285 | DEBUG_BUILD = "1" |
| 10286 | </literallayout> |
| 10287 | Consider that this will reduce the application's performance |
| 10288 | and is recommended only for debugging purposes. |
| 10289 | </note> |
| 10290 | </para> |
| 10291 | </section> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 10292 | |
| 10293 | <section id='debugging-parallel-make-races'> |
| 10294 | <title>Debugging Parallel Make Races</title> |
| 10295 | |
| 10296 | <para> |
| 10297 | A parallel <filename>make</filename> race occurs when the build |
| 10298 | consists of several parts that are run simultaneously and |
| 10299 | a situation occurs when the output or result of one |
| 10300 | part is not ready for use with a different part of the build that |
| 10301 | depends on that output. |
| 10302 | Parallel make races are annoying and can sometimes be difficult |
| 10303 | to reproduce and fix. |
| 10304 | However, some simple tips and tricks exist that can help |
| 10305 | you debug and fix them. |
| 10306 | This section presents a real-world example of an error encountered |
| 10307 | on the Yocto Project autobuilder and the process used to fix it. |
| 10308 | <note> |
| 10309 | If you cannot properly fix a <filename>make</filename> race |
| 10310 | condition, you can work around it by clearing either the |
| 10311 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PARALLEL_MAKE'><filename>PARALLEL_MAKE</filename></ulink> |
| 10312 | or |
| 10313 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PARALLEL_MAKEINST'><filename>PARALLEL_MAKEINST</filename></ulink> |
| 10314 | variables. |
| 10315 | </note> |
| 10316 | </para> |
| 10317 | |
| 10318 | <section id='the-failure'> |
| 10319 | <title>The Failure</title> |
| 10320 | |
| 10321 | <para> |
| 10322 | For this example, assume that you are building an image that |
| 10323 | depends on the "neard" package. |
| 10324 | And, during the build, BitBake runs into problems and |
| 10325 | creates the following output. |
| 10326 | <note> |
| 10327 | This example log file has longer lines artificially |
| 10328 | broken to make the listing easier to read. |
| 10329 | </note> |
| 10330 | If you examine the output or the log file, you see the |
| 10331 | failure during <filename>make</filename>: |
| 10332 | <literallayout class='monospaced'> |
| 10333 | | DEBUG: SITE files ['endian-little', 'bit-32', 'ix86-common', 'common-linux', 'common-glibc', 'i586-linux', 'common'] |
| 10334 | | DEBUG: Executing shell function do_compile |
| 10335 | | NOTE: make -j 16 |
| 10336 | | make --no-print-directory all-am |
| 10337 | | /bin/mkdir -p include/near |
| 10338 | | /bin/mkdir -p include/near |
| 10339 | | /bin/mkdir -p include/near |
| 10340 | | ln -s /home/pokybuild/yocto-autobuilder/yocto-slave/nightly-x86/build/build/tmp/work/i586-poky-linux/neard/ |
| 10341 | 0.14-r0/neard-0.14/include/types.h include/near/types.h |
| 10342 | | ln -s /home/pokybuild/yocto-autobuilder/yocto-slave/nightly-x86/build/build/tmp/work/i586-poky-linux/neard/ |
| 10343 | 0.14-r0/neard-0.14/include/log.h include/near/log.h |
| 10344 | | ln -s /home/pokybuild/yocto-autobuilder/yocto-slave/nightly-x86/build/build/tmp/work/i586-poky-linux/neard/ |
| 10345 | 0.14-r0/neard-0.14/include/plugin.h include/near/plugin.h |
| 10346 | | /bin/mkdir -p include/near |
| 10347 | | /bin/mkdir -p include/near |
| 10348 | | /bin/mkdir -p include/near |
| 10349 | | ln -s /home/pokybuild/yocto-autobuilder/yocto-slave/nightly-x86/build/build/tmp/work/i586-poky-linux/neard/ |
| 10350 | 0.14-r0/neard-0.14/include/tag.h include/near/tag.h |
| 10351 | | /bin/mkdir -p include/near |
| 10352 | | ln -s /home/pokybuild/yocto-autobuilder/yocto-slave/nightly-x86/build/build/tmp/work/i586-poky-linux/neard/ |
| 10353 | 0.14-r0/neard-0.14/include/adapter.h include/near/adapter.h |
| 10354 | | /bin/mkdir -p include/near |
| 10355 | | ln -s /home/pokybuild/yocto-autobuilder/yocto-slave/nightly-x86/build/build/tmp/work/i586-poky-linux/neard/ |
| 10356 | 0.14-r0/neard-0.14/include/ndef.h include/near/ndef.h |
| 10357 | | ln -s /home/pokybuild/yocto-autobuilder/yocto-slave/nightly-x86/build/build/tmp/work/i586-poky-linux/neard/ |
| 10358 | 0.14-r0/neard-0.14/include/tlv.h include/near/tlv.h |
| 10359 | | /bin/mkdir -p include/near |
| 10360 | | /bin/mkdir -p include/near |
| 10361 | | ln -s /home/pokybuild/yocto-autobuilder/yocto-slave/nightly-x86/build/build/tmp/work/i586-poky-linux/neard/ |
| 10362 | 0.14-r0/neard-0.14/include/setting.h include/near/setting.h |
| 10363 | | /bin/mkdir -p include/near |
| 10364 | | /bin/mkdir -p include/near |
| 10365 | | /bin/mkdir -p include/near |
| 10366 | | ln -s /home/pokybuild/yocto-autobuilder/yocto-slave/nightly-x86/build/build/tmp/work/i586-poky-linux/neard/ |
| 10367 | 0.14-r0/neard-0.14/include/device.h include/near/device.h |
| 10368 | | ln -s /home/pokybuild/yocto-autobuilder/yocto-slave/nightly-x86/build/build/tmp/work/i586-poky-linux/neard/ |
| 10369 | 0.14-r0/neard-0.14/include/nfc_copy.h include/near/nfc_copy.h |
| 10370 | | ln -s /home/pokybuild/yocto-autobuilder/yocto-slave/nightly-x86/build/build/tmp/work/i586-poky-linux/neard/ |
| 10371 | 0.14-r0/neard-0.14/include/snep.h include/near/snep.h |
| 10372 | | ln -s /home/pokybuild/yocto-autobuilder/yocto-slave/nightly-x86/build/build/tmp/work/i586-poky-linux/neard/ |
| 10373 | 0.14-r0/neard-0.14/include/version.h include/near/version.h |
| 10374 | | ln -s /home/pokybuild/yocto-autobuilder/yocto-slave/nightly-x86/build/build/tmp/work/i586-poky-linux/neard/ |
| 10375 | 0.14-r0/neard-0.14/include/dbus.h include/near/dbus.h |
| 10376 | | ./src/genbuiltin nfctype1 nfctype2 nfctype3 nfctype4 p2p > src/builtin.h |
| 10377 | | i586-poky-linux-gcc -m32 -march=i586 --sysroot=/home/pokybuild/yocto-autobuilder/yocto-slave/nightly-x86/ |
| 10378 | build/build/tmp/sysroots/qemux86 -DHAVE_CONFIG_H -I. -I./include -I./src -I./gdbus -I/home/pokybuild/ |
| 10379 | yocto-autobuilder/yocto-slave/nightly-x86/build/build/tmp/sysroots/qemux86/usr/include/glib-2.0 |
| 10380 | -I/home/pokybuild/yocto-autobuilder/yocto-slave/nightly-x86/build/build/tmp/sysroots/qemux86/usr/ |
| 10381 | lib/glib-2.0/include -I/home/pokybuild/yocto-autobuilder/yocto-slave/nightly-x86/build/build/ |
| 10382 | tmp/sysroots/qemux86/usr/include/dbus-1.0 -I/home/pokybuild/yocto-autobuilder/yocto-slave/ |
| 10383 | nightly-x86/build/build/tmp/sysroots/qemux86/usr/lib/dbus-1.0/include -I/home/pokybuild/yocto-autobuilder/ |
| 10384 | yocto-slave/nightly-x86/build/build/tmp/sysroots/qemux86/usr/include/libnl3 |
| 10385 | -DNEAR_PLUGIN_BUILTIN -DPLUGINDIR=\""/usr/lib/near/plugins"\" |
| 10386 | -DCONFIGDIR=\""/etc/neard\"" -O2 -pipe -g -feliminate-unused-debug-types -c |
| 10387 | -o tools/snep-send.o tools/snep-send.c |
| 10388 | | In file included from tools/snep-send.c:16:0: |
| 10389 | | tools/../src/near.h:41:23: fatal error: near/dbus.h: No such file or directory |
| 10390 | | #include <near/dbus.h> |
| 10391 | | ^ |
| 10392 | | compilation terminated. |
| 10393 | | make[1]: *** [tools/snep-send.o] Error 1 |
| 10394 | | make[1]: *** Waiting for unfinished jobs.... |
| 10395 | | make: *** [all] Error 2 |
| 10396 | | ERROR: oe_runmake failed |
| 10397 | </literallayout> |
| 10398 | </para> |
| 10399 | </section> |
| 10400 | |
| 10401 | <section id='reproducing-the-error'> |
| 10402 | <title>Reproducing the Error</title> |
| 10403 | |
| 10404 | <para> |
| 10405 | Because race conditions are intermittent, they do not |
| 10406 | manifest themselves every time you do the build. |
| 10407 | In fact, most times the build will complete without problems |
| 10408 | even though the potential race condition exists. |
| 10409 | Thus, once the error surfaces, you need a way to reproduce it. |
| 10410 | </para> |
| 10411 | |
| 10412 | <para> |
| 10413 | In this example, compiling the "neard" package is causing the |
| 10414 | problem. |
| 10415 | So the first thing to do is build "neard" locally. |
| 10416 | Before you start the build, set the |
| 10417 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PARALLEL_MAKE'><filename>PARALLEL_MAKE</filename></ulink> |
| 10418 | variable in your <filename>local.conf</filename> file to |
| 10419 | a high number (e.g. "-j 20"). |
| 10420 | Using a high value for <filename>PARALLEL_MAKE</filename> |
| 10421 | increases the chances of the race condition showing up: |
| 10422 | <literallayout class='monospaced'> |
| 10423 | $ bitbake neard |
| 10424 | </literallayout> |
| 10425 | </para> |
| 10426 | |
| 10427 | <para> |
| 10428 | Once the local build for "neard" completes, start a |
| 10429 | <filename>devshell</filename> build: |
| 10430 | <literallayout class='monospaced'> |
| 10431 | $ bitbake neard -c devshell |
| 10432 | </literallayout> |
| 10433 | For information on how to use a |
| 10434 | <filename>devshell</filename>, see the |
| 10435 | "<link linkend='platdev-appdev-devshell'>Using a Development Shell</link>" |
| 10436 | section. |
| 10437 | </para> |
| 10438 | |
| 10439 | <para> |
| 10440 | In the <filename>devshell</filename>, do the following: |
| 10441 | <literallayout class='monospaced'> |
| 10442 | $ make clean |
| 10443 | $ make tools/snep-send.o |
| 10444 | </literallayout> |
| 10445 | The <filename>devshell</filename> commands cause the failure |
| 10446 | to clearly be visible. |
| 10447 | In this case, a missing dependency exists for the "neard" |
| 10448 | Makefile target. |
| 10449 | Here is some abbreviated, sample output with the |
| 10450 | missing dependency clearly visible at the end: |
| 10451 | <literallayout class='monospaced'> |
| 10452 | i586-poky-linux-gcc -m32 -march=i586 --sysroot=/home/scott-lenovo/...... |
| 10453 | . |
| 10454 | . |
| 10455 | . |
| 10456 | tools/snep-send.c |
| 10457 | In file included from tools/snep-send.c:16:0: |
| 10458 | tools/../src/near.h:41:23: fatal error: near/dbus.h: No such file or directory |
| 10459 | #include <near/dbus.h> |
| 10460 | ^ |
| 10461 | compilation terminated. |
| 10462 | make: *** [tools/snep-send.o] Error 1 |
| 10463 | $ |
| 10464 | </literallayout> |
| 10465 | </para> |
| 10466 | </section> |
| 10467 | |
| 10468 | <section id='creating-a-patch-for-the-fix'> |
| 10469 | <title>Creating a Patch for the Fix</title> |
| 10470 | |
| 10471 | <para> |
| 10472 | Because there is a missing dependency for the Makefile |
| 10473 | target, you need to patch the |
| 10474 | <filename>Makefile.am</filename> file, which is generated |
| 10475 | from <filename>Makefile.in</filename>. |
| 10476 | You can use Quilt to create the patch: |
| 10477 | <literallayout class='monospaced'> |
| 10478 | $ quilt new parallelmake.patch |
| 10479 | Patch patches/parallelmake.patch is now on top |
| 10480 | $ quilt add Makefile.am |
| 10481 | File Makefile.am added to patch patches/parallelmake.patch |
| 10482 | </literallayout> |
| 10483 | For more information on using Quilt, see the |
| 10484 | "<link linkend='using-a-quilt-workflow'>Using Quilt in Your Workflow</link>" |
| 10485 | section. |
| 10486 | </para> |
| 10487 | |
| 10488 | <para> |
| 10489 | At this point you need to make the edits to |
| 10490 | <filename>Makefile.am</filename> to add the missing |
| 10491 | dependency. |
| 10492 | For our example, you have to add the following line |
| 10493 | to the file: |
| 10494 | <literallayout class='monospaced'> |
| 10495 | tools/snep-send.$(OBJEXT): include/near/dbus.h |
| 10496 | </literallayout> |
| 10497 | </para> |
| 10498 | |
| 10499 | <para> |
| 10500 | Once you have edited the file, use the |
| 10501 | <filename>refresh</filename> command to create the patch: |
| 10502 | <literallayout class='monospaced'> |
| 10503 | $ quilt refresh |
| 10504 | Refreshed patch patches/parallelmake.patch |
| 10505 | </literallayout> |
| 10506 | Once the patch file exists, you need to add it back to the |
| 10507 | originating recipe folder. |
| 10508 | Here is an example assuming a top-level |
| 10509 | <link linkend='source-directory'>Source Directory</link> |
| 10510 | named <filename>poky</filename>: |
| 10511 | <literallayout class='monospaced'> |
| 10512 | $ cp patches/parallelmake.patch poky/meta/recipes-connectivity/neard/neard |
| 10513 | </literallayout> |
| 10514 | The final thing you need to do to implement the fix in the |
| 10515 | build is to update the "neard" recipe (i.e. |
| 10516 | <filename>neard-0.14.bb</filename>) so that the |
| 10517 | <ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'><filename>SRC_URI</filename></ulink> |
| 10518 | statement includes the patch file. |
| 10519 | The recipe file is in the folder above the patch. |
| 10520 | Here is what the edited <filename>SRC_URI</filename> |
| 10521 | statement would look like: |
| 10522 | <literallayout class='monospaced'> |
| 10523 | SRC_URI = "${KERNELORG_MIRROR}/linux/network/nfc/${BPN}-${PV}.tar.xz \ |
| 10524 | file://neard.in \ |
| 10525 | file://neard.service.in \ |
| 10526 | file://parallelmake.patch \ |
| 10527 | " |
| 10528 | </literallayout> |
| 10529 | </para> |
| 10530 | |
| 10531 | <para> |
| 10532 | With the patch complete and moved to the correct folder and |
| 10533 | the <filename>SRC_URI</filename> statement updated, you can |
| 10534 | exit the <filename>devshell</filename>: |
| 10535 | <literallayout class='monospaced'> |
| 10536 | $ exit |
| 10537 | </literallayout> |
| 10538 | </para> |
| 10539 | </section> |
| 10540 | |
| 10541 | <section id='testing-the-build'> |
| 10542 | <title>Testing the Build</title> |
| 10543 | |
| 10544 | <para> |
| 10545 | With everything in place, you can get back to trying the |
| 10546 | build again locally: |
| 10547 | <literallayout class='monospaced'> |
| 10548 | $ bitbake neard |
| 10549 | </literallayout> |
| 10550 | This build should succeed. |
| 10551 | </para> |
| 10552 | |
| 10553 | <para> |
| 10554 | Now you can open up a <filename>devshell</filename> again |
| 10555 | and repeat the clean and make operations as follows: |
| 10556 | <literallayout class='monospaced'> |
| 10557 | $ bitbake neard -c devshell |
| 10558 | $ make clean |
| 10559 | $ make tools/snep-send.o |
| 10560 | </literallayout> |
| 10561 | The build should work without issue. |
| 10562 | </para> |
| 10563 | |
| 10564 | <para> |
| 10565 | As with all solved problems, if they originated upstream, you |
| 10566 | need to submit the fix for the recipe in OE-Core and upstream |
| 10567 | so that the problem is taken care of at its source. |
| 10568 | See the |
| 10569 | "<link linkend='how-to-submit-a-change'>How to Submit a Change</link>" |
| 10570 | section for more information. |
| 10571 | </para> |
| 10572 | </section> |
| 10573 | </section> |
| 10574 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 10575 | <section id='maintaining-open-source-license-compliance-during-your-products-lifecycle'> |
| 10576 | <title>Maintaining Open Source License Compliance During Your Product's Lifecycle</title> |
| 10577 | |
| 10578 | <para> |
| 10579 | One of the concerns for a development organization using open source |
| 10580 | software is how to maintain compliance with various open source |
| 10581 | licensing during the lifecycle of the product. |
| 10582 | While this section does not provide legal advice or |
| 10583 | comprehensively cover all scenarios, it does |
| 10584 | present methods that you can use to |
| 10585 | assist you in meeting the compliance requirements during a software |
| 10586 | release. |
| 10587 | </para> |
| 10588 | |
| 10589 | <para> |
| 10590 | With hundreds of different open source licenses that the Yocto |
| 10591 | Project tracks, it is difficult to know the requirements of each |
| 10592 | and every license. |
| 10593 | However, the requirements of the major FLOSS licenses can begin |
| 10594 | to be covered by |
| 10595 | assuming that three main areas of concern exist: |
| 10596 | <itemizedlist> |
| 10597 | <listitem><para>Source code must be provided.</para></listitem> |
| 10598 | <listitem><para>License text for the software must be |
| 10599 | provided.</para></listitem> |
| 10600 | <listitem><para>Compilation scripts and modifications to the |
| 10601 | source code must be provided. |
| 10602 | </para></listitem> |
| 10603 | </itemizedlist> |
| 10604 | There are other requirements beyond the scope of these |
| 10605 | three and the methods described in this section |
| 10606 | (e.g. the mechanism through which source code is distributed). |
| 10607 | </para> |
| 10608 | |
| 10609 | <para> |
| 10610 | As different organizations have different methods of complying with |
| 10611 | open source licensing, this section is not meant to imply that |
| 10612 | there is only one single way to meet your compliance obligations, |
| 10613 | but rather to describe one method of achieving compliance. |
| 10614 | The remainder of this section describes methods supported to meet the |
| 10615 | previously mentioned three requirements. |
| 10616 | Once you take steps to meet these requirements, |
| 10617 | and prior to releasing images, sources, and the build system, |
| 10618 | you should audit all artifacts to ensure completeness. |
| 10619 | <note> |
| 10620 | The Yocto Project generates a license manifest during |
| 10621 | image creation that is located |
| 10622 | in <filename>${DEPLOY_DIR}/licenses/<replaceable>image_name-datestamp</replaceable></filename> |
| 10623 | to assist with any audits. |
| 10624 | </note> |
| 10625 | </para> |
| 10626 | |
| 10627 | <section id='providing-the-source-code'> |
| 10628 | <title>Providing the Source Code</title> |
| 10629 | |
| 10630 | <para> |
| 10631 | Compliance activities should begin before you generate the |
| 10632 | final image. |
| 10633 | The first thing you should look at is the requirement that |
| 10634 | tops the list for most compliance groups - providing |
| 10635 | the source. |
| 10636 | The Yocto Project has a few ways of meeting this |
| 10637 | requirement. |
| 10638 | </para> |
| 10639 | |
| 10640 | <para> |
| 10641 | One of the easiest ways to meet this requirement is |
| 10642 | to provide the entire |
| 10643 | <ulink url='&YOCTO_DOCS_REF_URL;#var-DL_DIR'><filename>DL_DIR</filename></ulink> |
| 10644 | used by the build. |
| 10645 | This method, however, has a few issues. |
| 10646 | The most obvious is the size of the directory since it includes |
| 10647 | all sources used in the build and not just the source used in |
| 10648 | the released image. |
| 10649 | It will include toolchain source, and other artifacts, which |
| 10650 | you would not generally release. |
| 10651 | However, the more serious issue for most companies is accidental |
| 10652 | release of proprietary software. |
| 10653 | The Yocto Project provides an |
| 10654 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-archiver'><filename>archiver</filename></ulink> |
| 10655 | class to help avoid some of these concerns. |
| 10656 | </para> |
| 10657 | |
| 10658 | <para> |
| 10659 | Before you employ <filename>DL_DIR</filename> or the |
| 10660 | archiver class, you need to decide how you choose to |
| 10661 | provide source. |
| 10662 | The source archiver class can generate tarballs and SRPMs |
| 10663 | and can create them with various levels of compliance in mind. |
| 10664 | </para> |
| 10665 | |
| 10666 | <para> |
| 10667 | One way of doing this (but certainly not the only way) is to |
| 10668 | release just the source as a tarball. |
| 10669 | You can do this by adding the following to the |
| 10670 | <filename>local.conf</filename> file found in the |
| 10671 | <link linkend='build-directory'>Build Directory</link>: |
| 10672 | <literallayout class='monospaced'> |
| 10673 | INHERIT += "archiver" |
| 10674 | ARCHIVER_MODE[src] = "original" |
| 10675 | </literallayout> |
| 10676 | During the creation of your image, the source from all |
| 10677 | recipes that deploy packages to the image is placed within |
| 10678 | subdirectories of |
| 10679 | <filename>DEPLOY_DIR/sources</filename> based on the |
| 10680 | <ulink url='&YOCTO_DOCS_REF_URL;#var-LICENSE'><filename>LICENSE</filename></ulink> |
| 10681 | for each recipe. |
| 10682 | Releasing the entire directory enables you to comply with |
| 10683 | requirements concerning providing the unmodified source. |
| 10684 | It is important to note that the size of the directory can |
| 10685 | get large. |
| 10686 | </para> |
| 10687 | |
| 10688 | <para> |
| 10689 | A way to help mitigate the size issue is to only release |
| 10690 | tarballs for licenses that require the release of |
| 10691 | source. |
| 10692 | Let us assume you are only concerned with GPL code as |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame^] | 10693 | identified by running the following script: |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 10694 | <literallayout class='monospaced'> |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame^] | 10695 | # Script to archive a subset of packages matching specific license(s) |
| 10696 | # Source and license files are copied into sub folders of package folder |
| 10697 | # Must be run from build folder |
| 10698 | #!/bin/bash |
| 10699 | src_release_dir="source-release" |
| 10700 | mkdir -p $src_release_dir |
| 10701 | for a in tmp/deploy/sources/*; do |
| 10702 | for d in $a/*; do |
| 10703 | # Get package name from path |
| 10704 | p=`basename $d` |
| 10705 | p=${p%-*} |
| 10706 | p=${p%-*} |
| 10707 | # Only archive GPL packages (update *GPL* regex for your license check) |
| 10708 | numfiles=`ls tmp/deploy/licenses/$p/*GPL* 2> /dev/null | wc -l` |
| 10709 | if [ $numfiles -gt 1 ]; then |
| 10710 | echo Archiving $p |
| 10711 | mkdir -p $src_release_dir/$p/source |
| 10712 | cp $d/* $src_release_dir/$p/source 2> /dev/null |
| 10713 | mkdir -p $src_release_dir/$p/license |
| 10714 | cp tmp/deploy/licenses/$p/* $src_release_dir/$p/license 2> /dev/null |
| 10715 | fi |
| 10716 | done |
| 10717 | done </literallayout> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 10718 | At this point, you could create a tarball from the |
| 10719 | <filename>gpl_source_release</filename> directory and |
| 10720 | provide that to the end user. |
| 10721 | This method would be a step toward achieving compliance |
| 10722 | with section 3a of GPLv2 and with section 6 of GPLv3. |
| 10723 | </para> |
| 10724 | </section> |
| 10725 | |
| 10726 | <section id='providing-license-text'> |
| 10727 | <title>Providing License Text</title> |
| 10728 | |
| 10729 | <para> |
| 10730 | One requirement that is often overlooked is inclusion |
| 10731 | of license text. |
| 10732 | This requirement also needs to be dealt with prior to |
| 10733 | generating the final image. |
| 10734 | Some licenses require the license text to accompany |
| 10735 | the binary. |
| 10736 | You can achieve this by adding the following to your |
| 10737 | <filename>local.conf</filename> file: |
| 10738 | <literallayout class='monospaced'> |
| 10739 | COPY_LIC_MANIFEST = "1" |
| 10740 | COPY_LIC_DIRS = "1" |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 10741 | LICENSE_CREATE_PACKAGE = "1" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 10742 | </literallayout> |
| 10743 | Adding these statements to the configuration file ensures |
| 10744 | that the licenses collected during package generation |
| 10745 | are included on your image. |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 10746 | <note> |
| 10747 | <para>Setting all three variables to "1" results in the |
| 10748 | image having two copies of the same license file. |
| 10749 | One copy resides in |
| 10750 | <filename>/usr/share/common-licenses</filename> and |
| 10751 | the other resides in |
| 10752 | <filename>/usr/share/license</filename>.</para> |
| 10753 | |
| 10754 | <para>The reason for this behavior is because |
| 10755 | <ulink url='&YOCTO_DOCS_REF_URL;#var-COPY_LIC_DIRS'><filename>COPY_LIC_DIRS</filename></ulink> |
| 10756 | and |
| 10757 | <ulink url='&YOCTO_DOCS_REF_URL;#var-COPY_LIC_MANIFEST'><filename>COPY_LIC_MANIFEST</filename></ulink> |
| 10758 | add a copy of the license when the image is built but do not |
| 10759 | offer a path for adding licenses for newly installed packages |
| 10760 | to an image. |
| 10761 | <ulink url='&YOCTO_DOCS_REF_URL;#var-LICENSE_CREATE_PACKAGE'><filename>LICENSE_CREATE_PACKAGE</filename></ulink> |
| 10762 | adds a separate package and an upgrade path for adding |
| 10763 | licenses to an image.</para> |
| 10764 | </note> |
| 10765 | </para> |
| 10766 | |
| 10767 | <para> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 10768 | As the source archiver has already archived the original |
| 10769 | unmodified source that contains the license files, |
| 10770 | you would have already met the requirements for inclusion |
| 10771 | of the license information with source as defined by the GPL |
| 10772 | and other open source licenses. |
| 10773 | </para> |
| 10774 | </section> |
| 10775 | |
| 10776 | <section id='providing-compilation-scripts-and-source-code-modifications'> |
| 10777 | <title>Providing Compilation Scripts and Source Code Modifications</title> |
| 10778 | |
| 10779 | <para> |
| 10780 | At this point, we have addressed all we need to address |
| 10781 | prior to generating the image. |
| 10782 | The next two requirements are addressed during the final |
| 10783 | packaging of the release. |
| 10784 | </para> |
| 10785 | |
| 10786 | <para> |
| 10787 | By releasing the version of the OpenEmbedded build system |
| 10788 | and the layers used during the build, you will be providing both |
| 10789 | compilation scripts and the source code modifications in one |
| 10790 | step. |
| 10791 | </para> |
| 10792 | |
| 10793 | <para> |
| 10794 | If the deployment team has a |
| 10795 | <ulink url='&YOCTO_DOCS_BSP_URL;#bsp-layers'>BSP layer</ulink> |
| 10796 | and a distro layer, and those those layers are used to patch, |
| 10797 | compile, package, or modify (in any way) any open source |
| 10798 | software included in your released images, you |
| 10799 | might be required to to release those layers under section 3 of |
| 10800 | GPLv2 or section 1 of GPLv3. |
| 10801 | One way of doing that is with a clean |
| 10802 | checkout of the version of the Yocto Project and layers used |
| 10803 | during your build. |
| 10804 | Here is an example: |
| 10805 | <literallayout class='monospaced'> |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 10806 | # We built using the &DISTRO_NAME_NO_CAP; branch of the poky repo |
| 10807 | $ git clone -b &DISTRO_NAME_NO_CAP; git://git.yoctoproject.org/poky |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 10808 | $ cd poky |
| 10809 | # We built using the release_branch for our layers |
| 10810 | $ git clone -b release_branch git://git.mycompany.com/meta-my-bsp-layer |
| 10811 | $ git clone -b release_branch git://git.mycompany.com/meta-my-software-layer |
| 10812 | # clean up the .git repos |
| 10813 | $ find . -name ".git" -type d -exec rm -rf {} \; |
| 10814 | </literallayout> |
| 10815 | One thing a development organization might want to consider |
| 10816 | for end-user convenience is to modify |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 10817 | <filename>meta-poky/conf/bblayers.conf.sample</filename> to |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 10818 | ensure that when the end user utilizes the released build |
| 10819 | system to build an image, the development organization's |
| 10820 | layers are included in the <filename>bblayers.conf</filename> |
| 10821 | file automatically: |
| 10822 | <literallayout class='monospaced'> |
| 10823 | # LAYER_CONF_VERSION is increased each time build/conf/bblayers.conf |
| 10824 | # changes incompatibly |
| 10825 | LCONF_VERSION = "6" |
| 10826 | |
| 10827 | BBPATH = "${TOPDIR}" |
| 10828 | BBFILES ?= "" |
| 10829 | |
| 10830 | BBLAYERS ?= " \ |
| 10831 | ##OEROOT##/meta \ |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 10832 | ##OEROOT##/meta-poky \ |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 10833 | ##OEROOT##/meta-yocto-bsp \ |
| 10834 | ##OEROOT##/meta-mylayer \ |
| 10835 | " |
| 10836 | </literallayout> |
| 10837 | Creating and providing an archive of the |
| 10838 | <link linkend='metadata'>Metadata</link> layers |
| 10839 | (recipes, configuration files, and so forth) |
| 10840 | enables you to meet your |
| 10841 | requirements to include the scripts to control compilation |
| 10842 | as well as any modifications to the original source. |
| 10843 | </para> |
| 10844 | </section> |
| 10845 | </section> |
| 10846 | |
| 10847 | <section id='using-the-error-reporting-tool'> |
| 10848 | <title>Using the Error Reporting Tool</title> |
| 10849 | |
| 10850 | <para> |
| 10851 | The error reporting tool allows you to |
| 10852 | submit errors encountered during builds to a central database. |
| 10853 | Outside of the build environment, you can use a web interface to |
| 10854 | browse errors, view statistics, and query for errors. |
| 10855 | The tool works using a client-server system where the client |
| 10856 | portion is integrated with the installed Yocto Project |
| 10857 | <link linkend='source-directory'>Source Directory</link> |
| 10858 | (e.g. <filename>poky</filename>). |
| 10859 | The server receives the information collected and saves it in a |
| 10860 | database. |
| 10861 | </para> |
| 10862 | |
| 10863 | <para> |
| 10864 | A live instance of the error reporting server exists at |
| 10865 | <ulink url='http://errors.yoctoproject.org'></ulink>. |
| 10866 | This server exists so that when you want to get help with |
| 10867 | build failures, you can submit all of the information on the |
| 10868 | failure easily and then point to the URL in your bug report |
| 10869 | or send an email to the mailing list. |
| 10870 | <note> |
| 10871 | If you send error reports to this server, the reports become |
| 10872 | publicly visible. |
| 10873 | </note> |
| 10874 | </para> |
| 10875 | |
| 10876 | <section id='enabling-and-using-the-tool'> |
| 10877 | <title>Enabling and Using the Tool</title> |
| 10878 | |
| 10879 | <para> |
| 10880 | By default, the error reporting tool is disabled. |
| 10881 | You can enable it by inheriting the |
| 10882 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-report-error'><filename>report-error</filename></ulink> |
| 10883 | class by adding the following statement to the end of |
| 10884 | your <filename>local.conf</filename> file in your |
| 10885 | <link linkend='build-directory'>Build Directory</link>. |
| 10886 | <literallayout class='monospaced'> |
| 10887 | INHERIT += "report-error" |
| 10888 | </literallayout> |
| 10889 | </para> |
| 10890 | |
| 10891 | <para> |
| 10892 | By default, the error reporting feature stores information in |
| 10893 | <filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-LOG_DIR'><filename>LOG_DIR</filename></ulink><filename>}/error-report</filename>. |
| 10894 | However, you can specify a directory to use by adding the following |
| 10895 | to your <filename>local.conf</filename> file: |
| 10896 | <literallayout class='monospaced'> |
| 10897 | ERR_REPORT_DIR = "path" |
| 10898 | </literallayout> |
| 10899 | Enabling error reporting causes the build process to collect |
| 10900 | the errors and store them in a file as previously described. |
| 10901 | When the build system encounters an error, it includes a |
| 10902 | command as part of the console output. |
| 10903 | You can run the command to send the error file to the server. |
| 10904 | For example, the following command sends the errors to an |
| 10905 | upstream server: |
| 10906 | <literallayout class='monospaced'> |
| 10907 | $ send-error-report /home/brandusa/project/poky/build/tmp/log/error-report/error_report_201403141617.txt |
| 10908 | </literallayout> |
| 10909 | In the previous example, the errors are sent to a public |
| 10910 | database available at |
| 10911 | <ulink url='http://errors.yoctoproject.org'></ulink>, which is |
| 10912 | used by the entire community. |
| 10913 | If you specify a particular server, you can send the errors |
| 10914 | to a different database. |
| 10915 | Use the following command for more information on available |
| 10916 | options: |
| 10917 | <literallayout class='monospaced'> |
| 10918 | $ send-error-report --help |
| 10919 | </literallayout> |
| 10920 | </para> |
| 10921 | |
| 10922 | <para> |
| 10923 | When sending the error file, you are prompted to review the |
| 10924 | data being sent as well as to provide a name and optional |
| 10925 | email address. |
| 10926 | Once you satisfy these prompts, the command returns a link |
| 10927 | from the server that corresponds to your entry in the database. |
| 10928 | For example, here is a typical link: |
| 10929 | <literallayout class='monospaced'> |
| 10930 | http://errors.yoctoproject.org/Errors/Details/9522/ |
| 10931 | </literallayout> |
| 10932 | Following the link takes you to a web interface where you can |
| 10933 | browse, query the errors, and view statistics. |
| 10934 | </para> |
| 10935 | </section> |
| 10936 | |
| 10937 | <section id='disabling-the-tool'> |
| 10938 | <title>Disabling the Tool</title> |
| 10939 | |
| 10940 | <para> |
| 10941 | To disable the error reporting feature, simply remove or comment |
| 10942 | out the following statement from the end of your |
| 10943 | <filename>local.conf</filename> file in your |
| 10944 | <link linkend='build-directory'>Build Directory</link>. |
| 10945 | <literallayout class='monospaced'> |
| 10946 | INHERIT += "report-error" |
| 10947 | </literallayout> |
| 10948 | </para> |
| 10949 | </section> |
| 10950 | |
| 10951 | <section id='setting-up-your-own-error-reporting-server'> |
| 10952 | <title>Setting Up Your Own Error Reporting Server</title> |
| 10953 | |
| 10954 | <para> |
| 10955 | If you want to set up your own error reporting server, you |
| 10956 | can obtain the code from the Git repository at |
| 10957 | <ulink url='http://git.yoctoproject.org/cgit/cgit.cgi/error-report-web/'></ulink>. |
| 10958 | Instructions on how to set it up are in the README document. |
| 10959 | </para> |
| 10960 | </section> |
| 10961 | </section> |
| 10962 | </chapter> |
| 10963 | |
| 10964 | <!-- |
| 10965 | vim: expandtab tw=80 ts=4 |
| 10966 | --> |