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 |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 21 | <ulink url='&YOCTO_DOCS_REF_URL;#metadata'>Metadata</ulink> into |
| 22 | multiple layers. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 23 | Layers allow you to isolate different types of customizations from |
| 24 | each other. |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 25 | For introductory information on the Yocto Project Layer Model, |
| 26 | see the |
| 27 | "<ulink url='&YOCTO_DOCS_OM_URL;#the-yocto-project-layer-model'>The Yocto Project Layer Model</ulink>" |
| 28 | section in the Yocto Project Overview and Concepts Manual. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 29 | </para> |
| 30 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 31 | <section id='creating-your-own-layer'> |
| 32 | <title>Creating Your Own Layer</title> |
| 33 | |
| 34 | <para> |
| 35 | It is very easy to create your own layers to use with the |
| 36 | OpenEmbedded build system. |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 37 | The Yocto Project ships with tools that speed up creating |
| 38 | layers. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 39 | This section describes the steps you perform by hand to create |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 40 | layers so that you can better understand them. |
| 41 | For information about the layer-creation tools, see the |
| 42 | "<ulink url='&YOCTO_DOCS_BSP_URL;#creating-a-new-bsp-layer-using-the-bitbake-layers-script'>Creating a New BSP Layer Using the <filename>bitbake-layers</filename> Script</ulink>" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 43 | section in the Yocto Project Board Support Package (BSP) |
| 44 | Developer's Guide and the |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 45 | "<link linkend='creating-a-general-layer-using-the-bitbake-layers-script'>Creating a General Layer Using the <filename>bitbake-layers</filename> Script</link>" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 46 | section further down in this manual. |
| 47 | </para> |
| 48 | |
| 49 | <para> |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 50 | Follow these general steps to create your layer without using |
| 51 | tools: |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 52 | <orderedlist> |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 53 | <listitem><para> |
| 54 | <emphasis>Check Existing Layers:</emphasis> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 55 | Before creating a new layer, you should be sure someone |
| 56 | has not already created a layer containing the Metadata |
| 57 | you need. |
| 58 | You can see the |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 59 | <ulink url='http://layers.openembedded.org/layerindex/layers/'>OpenEmbedded Metadata Index</ulink> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 60 | for a list of layers from the OpenEmbedded community |
| 61 | that can be used in the Yocto Project. |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 62 | You could find a layer that is identical or close to |
| 63 | what you need. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 64 | </para></listitem> |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 65 | <listitem><para> |
| 66 | <emphasis>Create a Directory:</emphasis> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 67 | Create the directory for your layer. |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 68 | When you create the layer, be sure to create the |
| 69 | directory in an area not associated with the |
| 70 | Yocto Project |
| 71 | <ulink url='&YOCTO_DOCS_REF_URL;#source-directory'>Source Directory</ulink> |
| 72 | (e.g. the cloned <filename>poky</filename> repository). |
| 73 | </para> |
| 74 | |
| 75 | <para>While not strictly required, prepend the name of |
| 76 | the directory with the string "meta-". |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 77 | For example: |
| 78 | <literallayout class='monospaced'> |
| 79 | meta-mylayer |
| 80 | meta-GUI_xyz |
| 81 | meta-mymachine |
| 82 | </literallayout> |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 83 | With rare exceptions, a layer's name follows this |
| 84 | form: |
| 85 | <literallayout class='monospaced'> |
| 86 | meta-<replaceable>root_name</replaceable> |
| 87 | </literallayout> |
| 88 | Following this layer naming convention can |
| 89 | save you trouble later when tools, components, or |
| 90 | variables "assume" your layer name begins with "meta-". |
| 91 | A notable example is in configuration files as |
| 92 | shown in the following step where layer names without |
| 93 | the "meta-" string are appended |
| 94 | to several variables used in the configuration. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 95 | </para></listitem> |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 96 | <listitem><para id='dev-layer-config-file-description'> |
| 97 | <emphasis>Create a Layer Configuration File:</emphasis> |
| 98 | Inside your new layer folder, you need to create a |
| 99 | <filename>conf/layer.conf</filename> file. |
| 100 | It is easiest to take an existing layer configuration |
| 101 | file and copy that to your layer's |
| 102 | <filename>conf</filename> directory and then modify the |
| 103 | file as needed.</para> |
| 104 | |
| 105 | <para>The |
| 106 | <filename>meta-yocto-bsp/conf/layer.conf</filename> file |
| 107 | in the Yocto Project |
| 108 | <ulink url='&YOCTO_GIT_URL;/cgit/cgit.cgi/poky/tree/meta-yocto-bsp/conf'>Source Repositories</ulink> |
| 109 | demonstrates the required syntax. |
| 110 | For your layer, you need to replace "yoctobsp" with |
| 111 | a unique identifier for your layer (e.g. "machinexyz" |
| 112 | for a layer named "meta-machinexyz"): |
| 113 | <literallayout class='monospaced'> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 114 | # We have a conf and classes directory, add to BBPATH |
| 115 | BBPATH .= ":${LAYERDIR}" |
| 116 | |
| 117 | # We have recipes-* directories, add to BBFILES |
| 118 | BBFILES += "${LAYERDIR}/recipes-*/*/*.bb \ |
| 119 | ${LAYERDIR}/recipes-*/*/*.bbappend" |
| 120 | |
| 121 | BBFILE_COLLECTIONS += "yoctobsp" |
| 122 | BBFILE_PATTERN_yoctobsp = "^${LAYERDIR}/" |
| 123 | BBFILE_PRIORITY_yoctobsp = "5" |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 124 | LAYERVERSION_yoctobsp = "4" |
| 125 | LAYERSERIES_COMPAT_yoctobsp = "&DISTRO_NAME_NO_CAP;" |
| 126 | </literallayout> |
| 127 | Following is an explanation of the layer configuration |
| 128 | file: |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 129 | <itemizedlist> |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 130 | <listitem><para> |
| 131 | <ulink url='&YOCTO_DOCS_REF_URL;#var-BBPATH'><filename>BBPATH</filename></ulink>: |
| 132 | Adds the layer's root directory to BitBake's |
| 133 | search path. |
| 134 | Through the use of the |
| 135 | <filename>BBPATH</filename> variable, BitBake |
| 136 | locates class files |
| 137 | (<filename>.bbclass</filename>), |
| 138 | configuration files, and files that are |
| 139 | included with <filename>include</filename> and |
| 140 | <filename>require</filename> statements. |
| 141 | For these cases, BitBake uses the first file |
| 142 | that matches the name found in |
| 143 | <filename>BBPATH</filename>. |
| 144 | This is similar to the way the |
| 145 | <filename>PATH</filename> variable is used for |
| 146 | binaries. |
| 147 | It is recommended, therefore, that you use |
| 148 | unique class and configuration filenames in |
| 149 | your custom layer. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 150 | </para></listitem> |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 151 | <listitem><para> |
| 152 | <ulink url='&YOCTO_DOCS_REF_URL;#var-BBFILES'><filename>BBFILES</filename></ulink>: |
| 153 | Defines the location for all recipes in the |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 154 | layer. |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 155 | </para></listitem> |
| 156 | <listitem><para> |
| 157 | <ulink url='&YOCTO_DOCS_REF_URL;#var-BBFILE_COLLECTIONS'><filename>BBFILE_COLLECTIONS</filename></ulink>: |
| 158 | Establishes the current layer through a |
| 159 | unique identifier that is used throughout the |
| 160 | OpenEmbedded build system to refer to the layer. |
| 161 | In this example, the identifier "yoctobsp" is |
| 162 | the representation for the container layer |
| 163 | named "meta-yocto-bsp". |
| 164 | </para></listitem> |
| 165 | <listitem><para> |
| 166 | <ulink url='&YOCTO_DOCS_REF_URL;#var-BBFILE_PATTERN'><filename>BBFILE_PATTERN</filename></ulink>: |
| 167 | Expands immediately during parsing to |
| 168 | provide the directory of the layer. |
| 169 | </para></listitem> |
| 170 | <listitem><para> |
| 171 | <ulink url='&YOCTO_DOCS_REF_URL;#var-BBFILE_PRIORITY'><filename>BBFILE_PRIORITY</filename></ulink>: |
| 172 | Establishes a priority to use for |
| 173 | recipes in the layer when the OpenEmbedded build |
| 174 | finds recipes of the same name in different |
| 175 | layers. |
| 176 | </para></listitem> |
| 177 | <listitem><para> |
| 178 | <ulink url='&YOCTO_DOCS_REF_URL;#var-LAYERVERSION'><filename>LAYERVERSION</filename></ulink>: |
| 179 | Establishes a version number for the layer. |
| 180 | You can use this version number to specify this |
| 181 | exact version of the layer as a dependency when |
| 182 | using the |
| 183 | <ulink url='&YOCTO_DOCS_REF_URL;#var-LAYERDEPENDS'><filename>LAYERDEPENDS</filename></ulink> |
| 184 | variable. |
| 185 | </para></listitem> |
| 186 | <listitem><para> |
| 187 | <ulink url='&YOCTO_DOCS_REF_URL;#var-LAYERSERIES_COMPAT'><filename>LAYERSERIES_COMPAT</filename></ulink>: |
| 188 | Lists the |
| 189 | <ulink url='&YOCTO_WIKI_URL;/wiki/Releases'>Yocto Project</ulink> |
| 190 | releases for which the current version is |
| 191 | compatible. |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 192 | This variable is a good way to indicate if |
| 193 | your particular layer is current. |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 194 | </para></listitem> |
| 195 | </itemizedlist> |
| 196 | </para></listitem> |
| 197 | <listitem><para> |
| 198 | <emphasis>Add Content:</emphasis> |
| 199 | Depending on the type of layer, add the content. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 200 | If the layer adds support for a machine, add the machine |
| 201 | configuration in a <filename>conf/machine/</filename> |
| 202 | file within the layer. |
| 203 | If the layer adds distro policy, add the distro |
| 204 | configuration in a <filename>conf/distro/</filename> |
| 205 | file within the layer. |
| 206 | If the layer introduces new recipes, put the recipes |
| 207 | you need in <filename>recipes-*</filename> |
| 208 | subdirectories within the layer. |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 209 | <note> |
| 210 | For an explanation of layer hierarchy that |
| 211 | is compliant with the Yocto Project, see |
| 212 | the |
| 213 | "<ulink url='&YOCTO_DOCS_BSP_URL;#bsp-filelayout'>Example Filesystem Layout</ulink>" |
| 214 | section in the Yocto Project Board |
| 215 | Support Package (BSP) Developer's Guide. |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 216 | </note> |
| 217 | </para></listitem> |
| 218 | <listitem><para> |
| 219 | <emphasis>Optionally Test for Compatibility:</emphasis> |
| 220 | If you want permission to use the Yocto Project |
| 221 | Compatibility logo with your layer or application that |
| 222 | uses your layer, perform the steps to apply for |
| 223 | compatibility. |
| 224 | See the |
| 225 | "<link linkend='making-sure-your-layer-is-compatible-with-yocto-project'>Making Sure Your Layer is Compatible With Yocto Project</link>" |
| 226 | section for more information. |
| 227 | </para></listitem> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 228 | </orderedlist> |
| 229 | </para> |
| 230 | </section> |
| 231 | |
| 232 | <section id='best-practices-to-follow-when-creating-layers'> |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 233 | <title>Following Best Practices When Creating Layers</title> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 234 | |
| 235 | <para> |
| 236 | To create layers that are easier to maintain and that will |
| 237 | not impact builds for other machines, you should consider the |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 238 | information in the following list: |
| 239 | <itemizedlist> |
| 240 | <listitem><para> |
| 241 | <emphasis>Avoid "Overlaying" Entire Recipes from Other Layers in Your Configuration:</emphasis> |
| 242 | In other words, do not copy an entire recipe into your |
| 243 | layer and then modify it. |
| 244 | Rather, use an append file |
| 245 | (<filename>.bbappend</filename>) to override only those |
| 246 | parts of the original recipe you need to modify. |
| 247 | </para></listitem> |
| 248 | <listitem><para> |
| 249 | <emphasis>Avoid Duplicating Include Files:</emphasis> |
| 250 | Use append files (<filename>.bbappend</filename>) |
| 251 | for each recipe that uses an include file. |
| 252 | Or, if you are introducing a new recipe that requires |
| 253 | the included file, use the path relative to the |
| 254 | original layer directory to refer to the file. |
| 255 | For example, use |
| 256 | <filename>require recipes-core/</filename><replaceable>package</replaceable><filename>/</filename><replaceable>file</replaceable><filename>.inc</filename> |
| 257 | instead of |
| 258 | <filename>require </filename><replaceable>file</replaceable><filename>.inc</filename>. |
| 259 | If you're finding you have to overlay the include file, |
| 260 | it could indicate a deficiency in the include file in |
| 261 | the layer to which it originally belongs. |
| 262 | If this is the case, you should try to address that |
| 263 | deficiency instead of overlaying the include file. |
| 264 | For example, you could address this by getting the |
| 265 | maintainer of the include file to add a variable or |
| 266 | variables to make it easy to override the parts needing |
| 267 | to be overridden. |
| 268 | </para></listitem> |
| 269 | <listitem><para> |
| 270 | <emphasis>Structure Your Layers:</emphasis> |
| 271 | Proper use of overrides within append files and |
| 272 | placement of machine-specific files within your layer |
| 273 | can ensure that a build is not using the wrong Metadata |
| 274 | and negatively impacting a build for a different |
| 275 | machine. |
| 276 | Following are some examples: |
| 277 | <itemizedlist> |
| 278 | <listitem><para> |
| 279 | <emphasis>Modify Variables to Support a |
| 280 | Different Machine:</emphasis> |
| 281 | Suppose you have a layer named |
| 282 | <filename>meta-one</filename> that adds support |
| 283 | for building machine "one". |
| 284 | To do so, you use an append file named |
| 285 | <filename>base-files.bbappend</filename> and |
| 286 | create a dependency on "foo" by altering the |
| 287 | <ulink url='&YOCTO_DOCS_REF_URL;#var-DEPENDS'><filename>DEPENDS</filename></ulink> |
| 288 | variable: |
| 289 | <literallayout class='monospaced'> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 290 | DEPENDS = "foo" |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 291 | </literallayout> |
| 292 | The dependency is created during any build that |
| 293 | includes the layer |
| 294 | <filename>meta-one</filename>. |
| 295 | However, you might not want this dependency |
| 296 | for all machines. |
| 297 | For example, suppose you are building for |
| 298 | machine "two" but your |
| 299 | <filename>bblayers.conf</filename> file has the |
| 300 | <filename>meta-one</filename> layer included. |
| 301 | During the build, the |
| 302 | <filename>base-files</filename> for machine |
| 303 | "two" will also have the dependency on |
| 304 | <filename>foo</filename>.</para> |
| 305 | <para>To make sure your changes apply only when |
| 306 | building machine "one", use a machine override |
| 307 | with the <filename>DEPENDS</filename> statement: |
| 308 | <literallayout class='monospaced'> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 309 | DEPENDS_one = "foo" |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 310 | </literallayout> |
| 311 | You should follow the same strategy when using |
| 312 | <filename>_append</filename> and |
| 313 | <filename>_prepend</filename> operations: |
| 314 | <literallayout class='monospaced'> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 315 | DEPENDS_append_one = " foo" |
| 316 | DEPENDS_prepend_one = "foo " |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 317 | </literallayout> |
| 318 | As an actual example, here's a line from the recipe |
| 319 | for gnutls, which adds dependencies on |
| 320 | "argp-standalone" when building with the musl C |
| 321 | library: |
| 322 | <literallayout class='monospaced'> |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 323 | DEPENDS_append_libc-musl = " argp-standalone" |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 324 | </literallayout> |
| 325 | <note> |
| 326 | Avoiding "+=" and "=+" and using |
| 327 | machine-specific |
| 328 | <filename>_append</filename> |
| 329 | and <filename>_prepend</filename> operations |
| 330 | is recommended as well. |
| 331 | </note> |
| 332 | </para></listitem> |
| 333 | <listitem><para> |
| 334 | <emphasis>Place Machine-Specific Files in |
| 335 | Machine-Specific Locations:</emphasis> |
| 336 | When you have a base recipe, such as |
| 337 | <filename>base-files.bb</filename>, that |
| 338 | contains a |
| 339 | <ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'><filename>SRC_URI</filename></ulink> |
| 340 | statement to a file, you can use an append file |
| 341 | to cause the build to use your own version of |
| 342 | the file. |
| 343 | For example, an append file in your layer at |
| 344 | <filename>meta-one/recipes-core/base-files/base-files.bbappend</filename> |
| 345 | could extend |
| 346 | <ulink url='&YOCTO_DOCS_REF_URL;#var-FILESPATH'><filename>FILESPATH</filename></ulink> |
| 347 | using |
| 348 | <ulink url='&YOCTO_DOCS_REF_URL;#var-FILESEXTRAPATHS'><filename>FILESEXTRAPATHS</filename></ulink> |
| 349 | as follows: |
| 350 | <literallayout class='monospaced'> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 351 | FILESEXTRAPATHS_prepend := "${THISDIR}/${BPN}:" |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 352 | </literallayout> |
| 353 | The build for machine "one" will pick up your |
| 354 | machine-specific file as long as you have the |
| 355 | file in |
| 356 | <filename>meta-one/recipes-core/base-files/base-files/</filename>. |
| 357 | However, if you are building for a different |
| 358 | machine and the |
| 359 | <filename>bblayers.conf</filename> file includes |
| 360 | the <filename>meta-one</filename> layer and |
| 361 | the location of your machine-specific file is |
| 362 | the first location where that file is found |
| 363 | according to <filename>FILESPATH</filename>, |
| 364 | builds for all machines will also use that |
| 365 | machine-specific file.</para> |
| 366 | <para>You can make sure that a machine-specific |
| 367 | file is used for a particular machine by putting |
| 368 | the file in a subdirectory specific to the |
| 369 | machine. |
| 370 | For example, rather than placing the file in |
| 371 | <filename>meta-one/recipes-core/base-files/base-files/</filename> |
| 372 | as shown above, put it in |
| 373 | <filename>meta-one/recipes-core/base-files/base-files/one/</filename>. |
| 374 | Not only does this make sure the file is used |
| 375 | only when building for machine "one", but the |
| 376 | build process locates the file more quickly.</para> |
| 377 | <para>In summary, you need to place all files |
| 378 | referenced from <filename>SRC_URI</filename> |
| 379 | in a machine-specific subdirectory within the |
| 380 | layer in order to restrict those files to |
| 381 | machine-specific builds. |
| 382 | </para></listitem> |
| 383 | </itemizedlist> |
| 384 | </para></listitem> |
| 385 | <listitem><para> |
| 386 | <emphasis>Perform Steps to Apply for Yocto Project Compatibility:</emphasis> |
| 387 | If you want permission to use the |
| 388 | Yocto Project Compatibility logo with your layer |
| 389 | or application that uses your layer, perform the |
| 390 | steps to apply for compatibility. |
| 391 | See the |
| 392 | "<link linkend='making-sure-your-layer-is-compatible-with-yocto-project'>Making Sure Your Layer is Compatible With Yocto Project</link>" |
| 393 | section for more information. |
| 394 | </para></listitem> |
| 395 | <listitem><para> |
| 396 | <emphasis>Follow the Layer Naming Convention:</emphasis> |
| 397 | Store custom layers in a Git repository that use the |
| 398 | <filename>meta-<replaceable>layer_name</replaceable></filename> |
| 399 | format. |
| 400 | </para></listitem> |
| 401 | <listitem><para> |
| 402 | <emphasis>Group Your Layers Locally:</emphasis> |
| 403 | Clone your repository alongside other cloned |
| 404 | <filename>meta</filename> directories from the |
| 405 | <ulink url='&YOCTO_DOCS_REF_URL;#source-directory'>Source Directory</ulink>. |
| 406 | </para></listitem> |
| 407 | </itemizedlist> |
| 408 | </para> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 409 | </section> |
| 410 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 411 | <section id='making-sure-your-layer-is-compatible-with-yocto-project'> |
| 412 | <title>Making Sure Your Layer is Compatible With Yocto Project</title> |
| 413 | |
| 414 | <para> |
| 415 | When you create a layer used with the Yocto Project, it is |
| 416 | advantageous to make sure that the layer interacts well with |
| 417 | existing Yocto Project layers (i.e. the layer is compatible |
| 418 | with the Yocto Project). |
| 419 | Ensuring compatibility makes the layer easy to be consumed |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 420 | by others in the Yocto Project community and could allow you |
| 421 | permission to use the Yocto Project Compatible Logo. |
| 422 | <note> |
| 423 | Only Yocto Project member organizations are permitted to |
| 424 | use the Yocto Project Compatible Logo. |
| 425 | The logo is not available for general use. |
| 426 | For information on how to become a Yocto Project member |
| 427 | organization, see the |
| 428 | <ulink url='&YOCTO_HOME_URL;'>Yocto Project Website</ulink>. |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 429 | </note> |
| 430 | </para> |
| 431 | |
| 432 | <para> |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 433 | The Yocto Project Compatibility Program consists of a layer |
| 434 | application process that requests permission to use the Yocto |
| 435 | Project Compatibility Logo for your layer and application. |
| 436 | The process consists of two parts: |
| 437 | <orderedlist> |
| 438 | <listitem><para> |
| 439 | Successfully passing a script |
| 440 | (<filename>yocto-check-layer</filename>) that |
| 441 | when run against your layer, tests it against |
| 442 | constraints based on experiences of how layers have |
| 443 | worked in the real world and where pitfalls have been |
| 444 | found. |
| 445 | Getting a "PASS" result from the script is required for |
| 446 | successful compatibility registration. |
| 447 | </para></listitem> |
| 448 | <listitem><para> |
| 449 | Completion of an application acceptance form, which |
| 450 | you can find at |
| 451 | <ulink url='https://www.yoctoproject.org/webform/yocto-project-compatible-registration'></ulink>. |
| 452 | </para></listitem> |
| 453 | </orderedlist> |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 454 | </para> |
| 455 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 456 | <para> |
| 457 | To be granted permission to use the logo, you need to satisfy |
| 458 | the following: |
| 459 | <itemizedlist> |
| 460 | <listitem><para> |
| 461 | Be able to check the box indicating that you |
| 462 | got a "PASS" when running the script against your |
| 463 | layer. |
| 464 | </para></listitem> |
| 465 | <listitem><para> |
| 466 | Answer "Yes" to the questions on the form or have an |
| 467 | acceptable explanation for any questions answered "No". |
| 468 | </para></listitem> |
| 469 | <listitem><para> |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 470 | Be a Yocto Project Member Organization. |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 471 | </para></listitem> |
| 472 | </itemizedlist> |
| 473 | </para> |
| 474 | |
| 475 | <para> |
| 476 | The remainder of this section presents information on the |
| 477 | registration form and on the |
| 478 | <filename>yocto-check-layer</filename> script. |
| 479 | </para> |
| 480 | |
| 481 | <section id='yocto-project-compatible-program-application'> |
| 482 | <title>Yocto Project Compatible Program Application</title> |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 483 | |
| 484 | <para> |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 485 | Use the form to apply for your layer's approval. |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 486 | Upon successful application, you can use the Yocto |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 487 | Project Compatibility Logo with your layer and the |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 488 | application that uses your layer. |
| 489 | </para> |
| 490 | |
| 491 | <para> |
| 492 | To access the form, use this link: |
| 493 | <ulink url='https://www.yoctoproject.org/webform/yocto-project-compatible-registration'></ulink>. |
| 494 | Follow the instructions on the form to complete your |
| 495 | application. |
| 496 | </para> |
| 497 | |
| 498 | <para> |
| 499 | The application consists of the following sections: |
| 500 | <itemizedlist> |
| 501 | <listitem><para> |
| 502 | <emphasis>Contact Information:</emphasis> |
| 503 | Provide your contact information as the fields |
| 504 | require. |
| 505 | Along with your information, provide the |
| 506 | released versions of the Yocto Project for which |
| 507 | your layer is compatible. |
| 508 | </para></listitem> |
| 509 | <listitem><para> |
| 510 | <emphasis>Acceptance Criteria:</emphasis> |
| 511 | Provide "Yes" or "No" answers for each of the |
| 512 | items in the checklist. |
| 513 | Space exists at the bottom of the form for any |
| 514 | explanations for items for which you answered "No". |
| 515 | </para></listitem> |
| 516 | <listitem><para> |
| 517 | <emphasis>Recommendations:</emphasis> |
| 518 | Provide answers for the questions regarding Linux |
| 519 | kernel use and build success. |
| 520 | </para></listitem> |
| 521 | </itemizedlist> |
| 522 | </para> |
| 523 | </section> |
| 524 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 525 | <section id='yocto-check-layer-script'> |
| 526 | <title><filename>yocto-check-layer</filename> Script</title> |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 527 | |
| 528 | <para> |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 529 | The <filename>yocto-check-layer</filename> script |
| 530 | provides you a way to assess how compatible your layer is |
| 531 | with the Yocto Project. |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 532 | You should run this script prior to using the form to |
| 533 | apply for compatibility as described in the previous |
| 534 | section. |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 535 | You need to achieve a "PASS" result in order to have |
| 536 | your application form successfully processed. |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 537 | </para> |
| 538 | |
| 539 | <para> |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 540 | The script divides tests into three areas: COMMON, BSP, |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 541 | and DISTRO. |
| 542 | For example, given a distribution layer (DISTRO), the |
| 543 | layer must pass both the COMMON and DISTRO related tests. |
| 544 | Furthermore, if your layer is a BSP layer, the layer must |
| 545 | pass the COMMON and BSP set of tests. |
| 546 | </para> |
| 547 | |
| 548 | <para> |
| 549 | To execute the script, enter the following commands from |
| 550 | your build directory: |
| 551 | <literallayout class='monospaced'> |
| 552 | $ source oe-init-build-env |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 553 | $ yocto-check-layer <replaceable>your_layer_directory</replaceable> |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 554 | </literallayout> |
| 555 | Be sure to provide the actual directory for your layer |
| 556 | as part of the command. |
| 557 | </para> |
| 558 | |
| 559 | <para> |
| 560 | Entering the command causes the script to determine the |
| 561 | type of layer and then to execute a set of specific |
| 562 | tests against the layer. |
| 563 | The following list overviews the test: |
| 564 | <itemizedlist> |
| 565 | <listitem><para> |
| 566 | <filename>common.test_readme</filename>: |
| 567 | Tests if a <filename>README</filename> file |
| 568 | exists in the layer and the file is not empty. |
| 569 | </para></listitem> |
| 570 | <listitem><para> |
| 571 | <filename>common.test_parse</filename>: |
| 572 | Tests to make sure that BitBake can parse the |
| 573 | files without error (i.e. |
| 574 | <filename>bitbake -p</filename>). |
| 575 | </para></listitem> |
| 576 | <listitem><para> |
| 577 | <filename>common.test_show_environment</filename>: |
| 578 | Tests that the global or per-recipe environment |
| 579 | is in order without errors (i.e. |
| 580 | <filename>bitbake -e</filename>). |
| 581 | </para></listitem> |
| 582 | <listitem><para> |
| 583 | <filename>common.test_signatures</filename>: |
| 584 | Tests to be sure that BSP and DISTRO layers do not |
| 585 | come with recipes that change signatures. |
| 586 | </para></listitem> |
| 587 | <listitem><para> |
| 588 | <filename>bsp.test_bsp_defines_machines</filename>: |
| 589 | Tests if a BSP layer has machine configurations. |
| 590 | </para></listitem> |
| 591 | <listitem><para> |
| 592 | <filename>bsp.test_bsp_no_set_machine</filename>: |
| 593 | Tests to ensure a BSP layer does not set the |
| 594 | machine when the layer is added. |
| 595 | </para></listitem> |
| 596 | <listitem><para> |
| 597 | <filename>distro.test_distro_defines_distros</filename>: |
| 598 | Tests if a DISTRO layer has distro configurations. |
| 599 | </para></listitem> |
| 600 | <listitem><para> |
| 601 | <filename>distro.test_distro_no_set_distro</filename>: |
| 602 | Tests to ensure a DISTRO layer does not set the |
| 603 | distribution when the layer is added. |
| 604 | </para></listitem> |
| 605 | </itemizedlist> |
| 606 | </para> |
| 607 | </section> |
| 608 | </section> |
| 609 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 610 | <section id='enabling-your-layer'> |
| 611 | <title>Enabling Your Layer</title> |
| 612 | |
| 613 | <para> |
| 614 | Before the OpenEmbedded build system can use your new layer, |
| 615 | you need to enable it. |
| 616 | To enable your layer, simply add your layer's path to the |
| 617 | <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-BBLAYERS'>BBLAYERS</ulink></filename> |
| 618 | variable in your <filename>conf/bblayers.conf</filename> file, |
| 619 | which is found in the |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 620 | <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink>. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 621 | The following example shows how to enable a layer named |
| 622 | <filename>meta-mylayer</filename>: |
| 623 | <literallayout class='monospaced'> |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 624 | # POKY_BBLAYERS_CONF_VERSION is increased each time build/conf/bblayers.conf |
| 625 | # changes incompatibly |
| 626 | POKY_BBLAYERS_CONF_VERSION = "2" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 627 | |
| 628 | BBPATH = "${TOPDIR}" |
| 629 | BBFILES ?= "" |
| 630 | |
| 631 | BBLAYERS ?= " \ |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 632 | /home/<replaceable>user</replaceable>/poky/meta \ |
| 633 | /home/<replaceable>user</replaceable>/poky/meta-poky \ |
| 634 | /home/<replaceable>user</replaceable>/poky/meta-yocto-bsp \ |
| 635 | /home/<replaceable>user</replaceable>/poky/meta-mylayer \ |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 636 | " |
| 637 | </literallayout> |
| 638 | </para> |
| 639 | |
| 640 | <para> |
| 641 | BitBake parses each <filename>conf/layer.conf</filename> file |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 642 | from the top down as specified in the |
| 643 | <filename>BBLAYERS</filename> variable |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 644 | within the <filename>conf/bblayers.conf</filename> file. |
| 645 | During the processing of each |
| 646 | <filename>conf/layer.conf</filename> file, BitBake adds the |
| 647 | recipes, classes and configurations contained within the |
| 648 | particular layer to the source directory. |
| 649 | </para> |
| 650 | </section> |
| 651 | |
| 652 | <section id='using-bbappend-files'> |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 653 | <title>Using .bbappend Files in Your Layer</title> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 654 | |
| 655 | <para> |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 656 | A recipe that appends Metadata to another recipe is called a |
| 657 | BitBake append file. |
| 658 | A BitBake append file uses the <filename>.bbappend</filename> |
| 659 | file type suffix, while the corresponding recipe to which |
| 660 | Metadata is being appended uses the <filename>.bb</filename> |
| 661 | file type suffix. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 662 | </para> |
| 663 | |
| 664 | <para> |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 665 | You can use a <filename>.bbappend</filename> file in your |
| 666 | layer to make additions or changes to the content of another |
| 667 | layer's recipe without having to copy the other layer's |
| 668 | recipe into your layer. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 669 | Your <filename>.bbappend</filename> file resides in your layer, |
| 670 | while the main <filename>.bb</filename> recipe file to |
| 671 | which you are appending Metadata resides in a different layer. |
| 672 | </para> |
| 673 | |
| 674 | <para> |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 675 | Being able to append information to an existing recipe not only |
| 676 | avoids duplication, but also automatically applies recipe |
| 677 | changes from a different layer into your layer. |
| 678 | If you were copying recipes, you would have to manually merge |
| 679 | changes as they occur. |
| 680 | </para> |
| 681 | |
| 682 | <para> |
| 683 | When you create an append file, you must use the same root |
| 684 | name as the corresponding recipe file. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 685 | For example, the append file |
| 686 | <filename>someapp_&DISTRO;.bbappend</filename> must apply to |
| 687 | <filename>someapp_&DISTRO;.bb</filename>. |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 688 | This means the original recipe and append file names are |
| 689 | version number-specific. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 690 | If the corresponding recipe is renamed to update to a newer |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 691 | version, you must also rename and possibly update |
| 692 | the corresponding <filename>.bbappend</filename> as well. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 693 | During the build process, BitBake displays an error on starting |
| 694 | if it detects a <filename>.bbappend</filename> file that does |
| 695 | not have a corresponding recipe with a matching name. |
| 696 | See the |
| 697 | <ulink url='&YOCTO_DOCS_REF_URL;#var-BB_DANGLINGAPPENDS_WARNONLY'><filename>BB_DANGLINGAPPENDS_WARNONLY</filename></ulink> |
| 698 | variable for information on how to handle this error. |
| 699 | </para> |
| 700 | |
| 701 | <para> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 702 | As an example, consider the main formfactor recipe and a |
| 703 | corresponding formfactor append file both from the |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 704 | <ulink url='&YOCTO_DOCS_REF_URL;#source-directory'>Source Directory</ulink>. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 705 | Here is the main formfactor recipe, which is named |
| 706 | <filename>formfactor_0.0.bb</filename> and located in the |
| 707 | "meta" layer at |
| 708 | <filename>meta/recipes-bsp/formfactor</filename>: |
| 709 | <literallayout class='monospaced'> |
| 710 | SUMMARY = "Device formfactor information" |
| 711 | SECTION = "base" |
| 712 | LICENSE = "MIT" |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 713 | LIC_FILES_CHKSUM = "file://${COREBASE}/meta/COPYING.MIT;md5=3da9cfbcb788c80a0384361b4de20420" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 714 | PR = "r45" |
| 715 | |
| 716 | SRC_URI = "file://config file://machconfig" |
| 717 | S = "${WORKDIR}" |
| 718 | |
| 719 | PACKAGE_ARCH = "${MACHINE_ARCH}" |
| 720 | INHIBIT_DEFAULT_DEPS = "1" |
| 721 | |
| 722 | do_install() { |
| 723 | # Install file only if it has contents |
| 724 | install -d ${D}${sysconfdir}/formfactor/ |
| 725 | install -m 0644 ${S}/config ${D}${sysconfdir}/formfactor/ |
| 726 | if [ -s "${S}/machconfig" ]; then |
| 727 | install -m 0644 ${S}/machconfig ${D}${sysconfdir}/formfactor/ |
| 728 | fi |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 729 | } </literallayout> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 730 | In the main recipe, note the |
| 731 | <ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'><filename>SRC_URI</filename></ulink> |
| 732 | variable, which tells the OpenEmbedded build system where to |
| 733 | find files during the build. |
| 734 | </para> |
| 735 | |
| 736 | <para> |
| 737 | Following is the append file, which is named |
| 738 | <filename>formfactor_0.0.bbappend</filename> and is from the |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 739 | Raspberry Pi BSP Layer named |
| 740 | <filename>meta-raspberrypi</filename>. |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 741 | The file is in the layer at |
| 742 | <filename>recipes-bsp/formfactor</filename>: |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 743 | <literallayout class='monospaced'> |
| 744 | FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:" |
| 745 | </literallayout> |
| 746 | </para> |
| 747 | |
| 748 | <para> |
| 749 | By default, the build system uses the |
| 750 | <ulink url='&YOCTO_DOCS_REF_URL;#var-FILESPATH'><filename>FILESPATH</filename></ulink> |
| 751 | variable to locate files. |
| 752 | This append file extends the locations by setting the |
| 753 | <ulink url='&YOCTO_DOCS_REF_URL;#var-FILESEXTRAPATHS'><filename>FILESEXTRAPATHS</filename></ulink> |
| 754 | variable. |
| 755 | Setting this variable in the <filename>.bbappend</filename> |
| 756 | file is the most reliable and recommended method for adding |
| 757 | directories to the search path used by the build system |
| 758 | to find files. |
| 759 | </para> |
| 760 | |
| 761 | <para> |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 762 | The statement in this example extends the directories to |
| 763 | include |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 764 | <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>, |
| 765 | which resolves to a directory named |
| 766 | <filename>formfactor</filename> in the same directory |
| 767 | in which the append file resides (i.e. |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 768 | <filename>meta-raspberrypi/recipes-bsp/formfactor</filename>. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 769 | This implies that you must have the supporting directory |
| 770 | structure set up that will contain any files or patches you |
| 771 | will be including from the layer. |
| 772 | </para> |
| 773 | |
| 774 | <para> |
| 775 | Using the immediate expansion assignment operator |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 776 | <filename>:=</filename> is important because of the reference |
| 777 | to <filename>THISDIR</filename>. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 778 | The trailing colon character is important as it ensures that |
| 779 | items in the list remain colon-separated. |
| 780 | <note> |
| 781 | <para> |
| 782 | BitBake automatically defines the |
| 783 | <filename>THISDIR</filename> variable. |
| 784 | You should never set this variable yourself. |
| 785 | Using "_prepend" as part of the |
| 786 | <filename>FILESEXTRAPATHS</filename> ensures your path |
| 787 | will be searched prior to other paths in the final |
| 788 | list. |
| 789 | </para> |
| 790 | |
| 791 | <para> |
| 792 | Also, not all append files add extra files. |
| 793 | Many append files simply exist to add build options |
| 794 | (e.g. <filename>systemd</filename>). |
| 795 | For these cases, your append file would not even |
| 796 | use the <filename>FILESEXTRAPATHS</filename> statement. |
| 797 | </para> |
| 798 | </note> |
| 799 | </para> |
| 800 | </section> |
| 801 | |
| 802 | <section id='prioritizing-your-layer'> |
| 803 | <title>Prioritizing Your Layer</title> |
| 804 | |
| 805 | <para> |
| 806 | Each layer is assigned a priority value. |
| 807 | Priority values control which layer takes precedence if there |
| 808 | are recipe files with the same name in multiple layers. |
| 809 | For these cases, the recipe file from the layer with a higher |
| 810 | priority number takes precedence. |
| 811 | Priority values also affect the order in which multiple |
| 812 | <filename>.bbappend</filename> files for the same recipe are |
| 813 | applied. |
| 814 | You can either specify the priority manually, or allow the |
| 815 | build system to calculate it based on the layer's dependencies. |
| 816 | </para> |
| 817 | |
| 818 | <para> |
| 819 | To specify the layer's priority manually, use the |
| 820 | <ulink url='&YOCTO_DOCS_REF_URL;#var-BBFILE_PRIORITY'><filename>BBFILE_PRIORITY</filename></ulink> |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 821 | variable and append the layer's root name: |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 822 | <literallayout class='monospaced'> |
| 823 | BBFILE_PRIORITY_mylayer = "1" |
| 824 | </literallayout> |
| 825 | </para> |
| 826 | |
| 827 | <note> |
| 828 | <para>It is possible for a recipe with a lower version number |
| 829 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PV'><filename>PV</filename></ulink> |
| 830 | in a layer that has a higher priority to take precedence.</para> |
| 831 | <para>Also, the layer priority does not currently affect the |
| 832 | precedence order of <filename>.conf</filename> |
| 833 | or <filename>.bbclass</filename> files. |
| 834 | Future versions of BitBake might address this.</para> |
| 835 | </note> |
| 836 | </section> |
| 837 | |
| 838 | <section id='managing-layers'> |
| 839 | <title>Managing Layers</title> |
| 840 | |
| 841 | <para> |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 842 | You can use the BitBake layer management tool |
| 843 | <filename>bitbake-layers</filename> to provide a view |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 844 | into the structure of recipes across a multi-layer project. |
| 845 | Being able to generate output that reports on configured layers |
| 846 | with their paths and priorities and on |
| 847 | <filename>.bbappend</filename> files and their applicable |
| 848 | recipes can help to reveal potential problems. |
| 849 | </para> |
| 850 | |
| 851 | <para> |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 852 | For help on the BitBake layer management tool, use the |
| 853 | following command: |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 854 | <literallayout class='monospaced'> |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 855 | $ bitbake-layers --help |
| 856 | NOTE: Starting bitbake server... |
| 857 | usage: bitbake-layers [-d] [-q] [-F] [--color COLOR] [-h] <subcommand> ... |
| 858 | |
| 859 | BitBake layers utility |
| 860 | |
| 861 | optional arguments: |
| 862 | -d, --debug Enable debug output |
| 863 | -q, --quiet Print only errors |
| 864 | -F, --force Force add without recipe parse verification |
| 865 | --color COLOR Colorize output (where COLOR is auto, always, never) |
| 866 | -h, --help show this help message and exit |
| 867 | |
| 868 | subcommands: |
| 869 | <subcommand> |
| 870 | show-layers show current configured layers. |
| 871 | show-overlayed list overlayed recipes (where the same recipe exists |
| 872 | in another layer) |
| 873 | show-recipes list available recipes, showing the layer they are |
| 874 | provided by |
| 875 | show-appends list bbappend files and recipe files they apply to |
| 876 | show-cross-depends Show dependencies between recipes that cross layer |
| 877 | boundaries. |
| 878 | add-layer Add one or more layers to bblayers.conf. |
| 879 | remove-layer Remove one or more layers from bblayers.conf. |
| 880 | flatten flatten layer configuration into a separate output |
| 881 | directory. |
| 882 | layerindex-fetch Fetches a layer from a layer index along with its |
| 883 | dependent layers, and adds them to conf/bblayers.conf. |
| 884 | layerindex-show-depends |
| 885 | Find layer dependencies from layer index. |
| 886 | create-layer Create a basic layer |
| 887 | |
| 888 | Use bitbake-layers <subcommand> --help to get help on a specific command |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 889 | </literallayout> |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 890 | </para> |
| 891 | |
| 892 | <para> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 893 | The following list describes the available commands: |
| 894 | <itemizedlist> |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 895 | <listitem><para> |
| 896 | <emphasis><filename>help:</filename></emphasis> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 897 | Displays general help or help on a specified command. |
| 898 | </para></listitem> |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 899 | <listitem><para> |
| 900 | <emphasis><filename>show-layers:</filename></emphasis> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 901 | Shows the current configured layers. |
| 902 | </para></listitem> |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 903 | <listitem><para> |
| 904 | <emphasis><filename>show-overlayed:</filename></emphasis> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 905 | Lists overlayed recipes. |
| 906 | A recipe is overlayed when a recipe with the same name |
| 907 | exists in another layer that has a higher layer |
| 908 | priority. |
| 909 | </para></listitem> |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 910 | <listitem><para> |
| 911 | <emphasis><filename>show-recipes:</filename></emphasis> |
| 912 | Lists available recipes and the layers that provide them. |
| 913 | </para></listitem> |
| 914 | <listitem><para> |
| 915 | <emphasis><filename>show-appends:</filename></emphasis> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 916 | Lists <filename>.bbappend</filename> files and the |
| 917 | recipe files to which they apply. |
| 918 | </para></listitem> |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 919 | <listitem><para> |
| 920 | <emphasis><filename>show-cross-depends:</filename></emphasis> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 921 | Lists dependency relationships between recipes that |
| 922 | cross layer boundaries. |
| 923 | </para></listitem> |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 924 | <listitem><para> |
| 925 | <emphasis><filename>add-layer:</filename></emphasis> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 926 | Adds a layer to <filename>bblayers.conf</filename>. |
| 927 | </para></listitem> |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 928 | <listitem><para> |
| 929 | <emphasis><filename>remove-layer:</filename></emphasis> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 930 | Removes a layer from <filename>bblayers.conf</filename> |
| 931 | </para></listitem> |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 932 | <listitem><para> |
| 933 | <emphasis><filename>flatten:</filename></emphasis> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 934 | Flattens the layer configuration into a separate output |
| 935 | directory. |
| 936 | Flattening your layer configuration builds a "flattened" |
| 937 | directory that contains the contents of all layers, |
| 938 | with any overlayed recipes removed and any |
| 939 | <filename>.bbappend</filename> files appended to the |
| 940 | corresponding recipes. |
| 941 | You might have to perform some manual cleanup of the |
| 942 | flattened layer as follows: |
| 943 | <itemizedlist> |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 944 | <listitem><para> |
| 945 | Non-recipe files (such as patches) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 946 | are overwritten. |
| 947 | The flatten command shows a warning for these |
| 948 | files. |
| 949 | </para></listitem> |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 950 | <listitem><para> |
| 951 | Anything beyond the normal layer |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 952 | setup has been added to the |
| 953 | <filename>layer.conf</filename> file. |
| 954 | Only the lowest priority layer's |
| 955 | <filename>layer.conf</filename> is used. |
| 956 | </para></listitem> |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 957 | <listitem><para> |
| 958 | Overridden and appended items from |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 959 | <filename>.bbappend</filename> files need to be |
| 960 | cleaned up. |
| 961 | The contents of each |
| 962 | <filename>.bbappend</filename> end up in the |
| 963 | flattened recipe. |
| 964 | However, if there are appended or changed |
| 965 | variable values, you need to tidy these up |
| 966 | yourself. |
| 967 | Consider the following example. |
| 968 | Here, the <filename>bitbake-layers</filename> |
| 969 | command adds the line |
| 970 | <filename>#### bbappended ...</filename> so that |
| 971 | you know where the following lines originate: |
| 972 | <literallayout class='monospaced'> |
| 973 | ... |
| 974 | DESCRIPTION = "A useful utility" |
| 975 | ... |
| 976 | EXTRA_OECONF = "--enable-something" |
| 977 | ... |
| 978 | |
| 979 | #### bbappended from meta-anotherlayer #### |
| 980 | |
| 981 | DESCRIPTION = "Customized utility" |
| 982 | EXTRA_OECONF += "--enable-somethingelse" |
| 983 | </literallayout> |
| 984 | Ideally, you would tidy up these utilities as |
| 985 | follows: |
| 986 | <literallayout class='monospaced'> |
| 987 | ... |
| 988 | DESCRIPTION = "Customized utility" |
| 989 | ... |
| 990 | EXTRA_OECONF = "--enable-something --enable-somethingelse" |
| 991 | ... |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 992 | </literallayout> |
| 993 | </para></listitem> |
| 994 | </itemizedlist> |
| 995 | </para></listitem> |
| 996 | <listitem><para> |
| 997 | <emphasis><filename>layerindex-fetch</filename>:</emphasis> |
| 998 | Fetches a layer from a layer index, along with its |
| 999 | dependent layers, and adds the layers to the |
| 1000 | <filename>conf/bblayers.conf</filename> file. |
| 1001 | </para></listitem> |
| 1002 | <listitem><para> |
| 1003 | <emphasis><filename>layerindex-show-depends</filename>:</emphasis> |
| 1004 | Finds layer dependencies from the layer index. |
| 1005 | </para></listitem> |
| 1006 | <listitem><para> |
| 1007 | <emphasis><filename>create-layer</filename>:</emphasis> |
| 1008 | Creates a basic layer. |
| 1009 | </para></listitem> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1010 | </itemizedlist> |
| 1011 | </para> |
| 1012 | </section> |
| 1013 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 1014 | <section id='creating-a-general-layer-using-the-bitbake-layers-script'> |
| 1015 | <title>Creating a General Layer Using the <filename>bitbake-layers</filename> Script</title> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1016 | |
| 1017 | <para> |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 1018 | The <filename>bitbake-layers</filename> script with the |
| 1019 | <filename>create-layer</filename> subcommand simplifies |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1020 | creating a new general layer. |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 1021 | <note><title>Notes</title> |
| 1022 | <itemizedlist> |
| 1023 | <listitem><para> |
| 1024 | For information on BSP layers, see the |
| 1025 | "<ulink url='&YOCTO_DOCS_BSP_URL;#bsp-layers'>BSP Layers</ulink>" |
| 1026 | section in the Yocto Project Board Specific (BSP) |
| 1027 | Developer's Guide. |
| 1028 | </para></listitem> |
| 1029 | <listitem><para> |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 1030 | In order to use a layer with the OpenEmbedded |
| 1031 | build system, you need to add the layer to your |
| 1032 | <filename>bblayers.conf</filename> configuration |
| 1033 | file. |
| 1034 | See the |
| 1035 | "<link linkend='adding-a-layer-using-the-bitbake-layers-script'>Adding a Layer Using the <filename>bitbake-layers</filename> Script</link>" |
| 1036 | section for more information. |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 1037 | </para></listitem> |
| 1038 | </itemizedlist> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1039 | </note> |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 1040 | The default mode of the script's operation with this |
| 1041 | subcommand is to create a layer with the following: |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1042 | <itemizedlist> |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 1043 | <listitem><para>A layer priority of 6. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1044 | </para></listitem> |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 1045 | <listitem><para>A <filename>conf</filename> |
| 1046 | subdirectory that contains a |
| 1047 | <filename>layer.conf</filename> file. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1048 | </para></listitem> |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 1049 | <listitem><para> |
| 1050 | A <filename>recipes-example</filename> subdirectory |
| 1051 | that contains a further subdirectory named |
| 1052 | <filename>example</filename>, which contains |
| 1053 | an <filename>example.bb</filename> recipe file. |
| 1054 | </para></listitem> |
| 1055 | <listitem><para>A <filename >COPYING.MIT</filename>, |
| 1056 | which is the license statement for the layer. |
| 1057 | The script assumes you want to use the MIT license, |
| 1058 | which is typical for most layers, for the contents of |
| 1059 | the layer itself. |
| 1060 | </para></listitem> |
| 1061 | <listitem><para> |
| 1062 | A <filename>README</filename> file, which is a file |
| 1063 | describing the contents of your new layer. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1064 | </para></listitem> |
| 1065 | </itemizedlist> |
| 1066 | </para> |
| 1067 | |
| 1068 | <para> |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 1069 | In its simplest form, you can use the following command form |
| 1070 | to create a layer. |
| 1071 | The command creates a layer whose name corresponds to |
| 1072 | <replaceable>your_layer_name</replaceable> in the current |
| 1073 | directory: |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1074 | <literallayout class='monospaced'> |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 1075 | $ bitbake-layers create-layer <replaceable>your_layer_name</replaceable> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1076 | </literallayout> |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 1077 | As an example, the following command creates a layer named |
| 1078 | <filename>meta-scottrif</filename> in your home directory: |
| 1079 | <literallayout class='monospaced'> |
| 1080 | $ cd /usr/home |
| 1081 | $ bitbake-layers create-layer meta-scottrif |
| 1082 | NOTE: Starting bitbake server... |
| 1083 | Add your new layer with 'bitbake-layers add-layer meta-scottrif' |
| 1084 | </literallayout> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1085 | </para> |
| 1086 | |
| 1087 | <para> |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 1088 | If you want to set the priority of the layer to other than the |
| 1089 | default value of "6", you can either use the |
| 1090 | <filename>‐‐priority</filename> option or you can |
| 1091 | edit the |
| 1092 | <ulink url='&YOCTO_DOCS_REF_URL;#var-BBFILE_PRIORITY'><filename>BBFILE_PRIORITY</filename></ulink> |
| 1093 | value in the <filename>conf/layer.conf</filename> after the |
| 1094 | script creates it. |
| 1095 | Furthermore, if you want to give the example recipe file |
| 1096 | some name other than the default, you can |
| 1097 | use the |
| 1098 | <filename>‐‐example-recipe-name</filename> option. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1099 | </para> |
| 1100 | |
| 1101 | <para> |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 1102 | The easiest way to see how the |
| 1103 | <filename>bitbake-layers create-layer</filename> command |
| 1104 | works is to experiment with the script. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1105 | You can also read the usage information by entering the |
| 1106 | following: |
| 1107 | <literallayout class='monospaced'> |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 1108 | $ bitbake-layers create-layer --help |
| 1109 | NOTE: Starting bitbake server... |
| 1110 | usage: bitbake-layers create-layer [-h] [--priority PRIORITY] |
| 1111 | [--example-recipe-name EXAMPLERECIPE] |
| 1112 | layerdir |
| 1113 | |
| 1114 | Create a basic layer |
| 1115 | |
| 1116 | positional arguments: |
| 1117 | layerdir Layer directory to create |
| 1118 | |
| 1119 | optional arguments: |
| 1120 | -h, --help show this help message and exit |
| 1121 | --priority PRIORITY, -p PRIORITY |
| 1122 | Layer directory to create |
| 1123 | --example-recipe-name EXAMPLERECIPE, -e EXAMPLERECIPE |
| 1124 | Filename of the example recipe |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1125 | </literallayout> |
| 1126 | </para> |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 1127 | </section> |
| 1128 | |
| 1129 | <section id='adding-a-layer-using-the-bitbake-layers-script'> |
| 1130 | <title>Adding a Layer Using the <filename>bitbake-layers</filename> Script</title> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1131 | |
| 1132 | <para> |
| 1133 | Once you create your general layer, you must add it to your |
| 1134 | <filename>bblayers.conf</filename> file. |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 1135 | Adding the layer to this configuration file makes the |
| 1136 | OpenEmbedded build system aware of your layer so that it can |
| 1137 | search it for metadata. |
| 1138 | </para> |
| 1139 | |
| 1140 | <para> |
| 1141 | Add your layer by using the |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 1142 | <filename>bitbake-layers add-layer</filename> command: |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1143 | <literallayout class='monospaced'> |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 1144 | $ bitbake-layers add-layer <replaceable>your_layer_name</replaceable> |
| 1145 | </literallayout> |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 1146 | Here is an example that adds a layer named |
| 1147 | <filename>meta-scottrif</filename> to the configuration file. |
| 1148 | Following the command that adds the layer is another |
| 1149 | <filename>bitbake-layers</filename> command that shows the |
| 1150 | layers that are in your <filename>bblayers.conf</filename> |
| 1151 | file: |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 1152 | <literallayout class='monospaced'> |
| 1153 | $ bitbake-layers add-layer meta-scottrif |
| 1154 | NOTE: Starting bitbake server... |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 1155 | Parsing recipes: 100% |##########################################################| Time: 0:00:49 |
| 1156 | Parsing of 1441 .bb files complete (0 cached, 1441 parsed). 2055 targets, 56 skipped, 0 masked, 0 errors. |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 1157 | $ bitbake-layers show-layers |
| 1158 | NOTE: Starting bitbake server... |
| 1159 | layer path priority |
| 1160 | ========================================================================== |
| 1161 | meta /home/scottrif/poky/meta 5 |
| 1162 | meta-poky /home/scottrif/poky/meta-poky 5 |
| 1163 | meta-yocto-bsp /home/scottrif/poky/meta-yocto-bsp 5 |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 1164 | workspace /home/scottrif/poky/build/workspace 99 |
| 1165 | meta-scottrif /home/scottrif/poky/build/meta-scottrif 6 |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1166 | </literallayout> |
| 1167 | Adding the layer to this file enables the build system to |
| 1168 | locate the layer during the build. |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 1169 | <note> |
| 1170 | During a build, the OpenEmbedded build system looks in |
| 1171 | the layers from the top of the list down to the bottom |
| 1172 | in that order. |
| 1173 | </note> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1174 | </para> |
| 1175 | </section> |
| 1176 | </section> |
| 1177 | |
| 1178 | <section id='usingpoky-extend-customimage'> |
| 1179 | <title>Customizing Images</title> |
| 1180 | |
| 1181 | <para> |
| 1182 | You can customize images to satisfy particular requirements. |
| 1183 | This section describes several methods and provides guidelines for each. |
| 1184 | </para> |
| 1185 | |
| 1186 | <section id='usingpoky-extend-customimage-localconf'> |
| 1187 | <title>Customizing Images Using <filename>local.conf</filename></title> |
| 1188 | |
| 1189 | <para> |
| 1190 | Probably the easiest way to customize an image is to add a |
| 1191 | package by way of the <filename>local.conf</filename> |
| 1192 | configuration file. |
| 1193 | Because it is limited to local use, this method generally only |
| 1194 | allows you to add packages and is not as flexible as creating |
| 1195 | your own customized image. |
| 1196 | When you add packages using local variables this way, you need |
| 1197 | to realize that these variable changes are in effect for every |
| 1198 | build and consequently affect all images, which might not |
| 1199 | be what you require. |
| 1200 | </para> |
| 1201 | |
| 1202 | <para> |
| 1203 | To add a package to your image using the local configuration |
| 1204 | file, use the |
| 1205 | <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-IMAGE_INSTALL'>IMAGE_INSTALL</ulink></filename> |
| 1206 | variable with the <filename>_append</filename> operator: |
| 1207 | <literallayout class='monospaced'> |
| 1208 | IMAGE_INSTALL_append = " strace" |
| 1209 | </literallayout> |
| 1210 | Use of the syntax is important - specifically, the space between |
| 1211 | the quote and the package name, which is |
| 1212 | <filename>strace</filename> in this example. |
| 1213 | This space is required since the <filename>_append</filename> |
| 1214 | operator does not add the space. |
| 1215 | </para> |
| 1216 | |
| 1217 | <para> |
| 1218 | Furthermore, you must use <filename>_append</filename> instead |
| 1219 | of the <filename>+=</filename> operator if you want to avoid |
| 1220 | ordering issues. |
| 1221 | The reason for this is because doing so unconditionally appends |
| 1222 | to the variable and avoids ordering problems due to the |
| 1223 | variable being set in image recipes and |
| 1224 | <filename>.bbclass</filename> files with operators like |
| 1225 | <filename>?=</filename>. |
| 1226 | Using <filename>_append</filename> ensures the operation takes |
| 1227 | affect. |
| 1228 | </para> |
| 1229 | |
| 1230 | <para> |
| 1231 | As shown in its simplest use, |
| 1232 | <filename>IMAGE_INSTALL_append</filename> affects all images. |
| 1233 | It is possible to extend the syntax so that the variable |
| 1234 | applies to a specific image only. |
| 1235 | Here is an example: |
| 1236 | <literallayout class='monospaced'> |
| 1237 | IMAGE_INSTALL_append_pn-core-image-minimal = " strace" |
| 1238 | </literallayout> |
| 1239 | This example adds <filename>strace</filename> to the |
| 1240 | <filename>core-image-minimal</filename> image only. |
| 1241 | </para> |
| 1242 | |
| 1243 | <para> |
| 1244 | You can add packages using a similar approach through the |
| 1245 | <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-CORE_IMAGE_EXTRA_INSTALL'>CORE_IMAGE_EXTRA_INSTALL</ulink></filename> |
| 1246 | variable. |
| 1247 | If you use this variable, only |
| 1248 | <filename>core-image-*</filename> images are affected. |
| 1249 | </para> |
| 1250 | </section> |
| 1251 | |
| 1252 | <section id='usingpoky-extend-customimage-imagefeatures'> |
| 1253 | <title>Customizing Images Using Custom <filename>IMAGE_FEATURES</filename> and |
| 1254 | <filename>EXTRA_IMAGE_FEATURES</filename></title> |
| 1255 | |
| 1256 | <para> |
| 1257 | Another method for customizing your image is to enable or |
| 1258 | disable high-level image features by using the |
| 1259 | <ulink url='&YOCTO_DOCS_REF_URL;#var-IMAGE_FEATURES'><filename>IMAGE_FEATURES</filename></ulink> |
| 1260 | and <ulink url='&YOCTO_DOCS_REF_URL;#var-EXTRA_IMAGE_FEATURES'><filename>EXTRA_IMAGE_FEATURES</filename></ulink> |
| 1261 | variables. |
| 1262 | Although the functions for both variables are nearly equivalent, |
| 1263 | best practices dictate using <filename>IMAGE_FEATURES</filename> |
| 1264 | from within a recipe and using |
| 1265 | <filename>EXTRA_IMAGE_FEATURES</filename> from within |
| 1266 | your <filename>local.conf</filename> file, which is found in the |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 1267 | <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink>. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1268 | </para> |
| 1269 | |
| 1270 | <para> |
| 1271 | To understand how these features work, the best reference is |
| 1272 | <filename>meta/classes/core-image.bbclass</filename>. |
| 1273 | This class lists out the available |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 1274 | <filename>IMAGE_FEATURES</filename> of which most map to |
| 1275 | package groups while some, such as |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1276 | <filename>debug-tweaks</filename> and |
| 1277 | <filename>read-only-rootfs</filename>, resolve as general |
| 1278 | configuration settings. |
| 1279 | </para> |
| 1280 | |
| 1281 | <para> |
| 1282 | In summary, the file looks at the contents of the |
| 1283 | <filename>IMAGE_FEATURES</filename> variable and then maps |
| 1284 | or configures the feature accordingly. |
| 1285 | Based on this information, the build system automatically |
| 1286 | adds the appropriate packages or configurations to the |
| 1287 | <ulink url='&YOCTO_DOCS_REF_URL;#var-IMAGE_INSTALL'><filename>IMAGE_INSTALL</filename></ulink> |
| 1288 | variable. |
| 1289 | Effectively, you are enabling extra features by extending the |
| 1290 | class or creating a custom class for use with specialized image |
| 1291 | <filename>.bb</filename> files. |
| 1292 | </para> |
| 1293 | |
| 1294 | <para> |
| 1295 | Use the <filename>EXTRA_IMAGE_FEATURES</filename> variable |
| 1296 | from within your local configuration file. |
| 1297 | Using a separate area from which to enable features with |
| 1298 | this variable helps you avoid overwriting the features in the |
| 1299 | image recipe that are enabled with |
| 1300 | <filename>IMAGE_FEATURES</filename>. |
| 1301 | The value of <filename>EXTRA_IMAGE_FEATURES</filename> is added |
| 1302 | to <filename>IMAGE_FEATURES</filename> within |
| 1303 | <filename>meta/conf/bitbake.conf</filename>. |
| 1304 | </para> |
| 1305 | |
| 1306 | <para> |
| 1307 | To illustrate how you can use these variables to modify your |
| 1308 | image, consider an example that selects the SSH server. |
| 1309 | The Yocto Project ships with two SSH servers you can use |
| 1310 | with your images: Dropbear and OpenSSH. |
| 1311 | Dropbear is a minimal SSH server appropriate for |
| 1312 | resource-constrained environments, while OpenSSH is a |
| 1313 | well-known standard SSH server implementation. |
| 1314 | By default, the <filename>core-image-sato</filename> image |
| 1315 | is configured to use Dropbear. |
| 1316 | The <filename>core-image-full-cmdline</filename> and |
| 1317 | <filename>core-image-lsb</filename> images both |
| 1318 | include OpenSSH. |
| 1319 | The <filename>core-image-minimal</filename> image does not |
| 1320 | contain an SSH server. |
| 1321 | </para> |
| 1322 | |
| 1323 | <para> |
| 1324 | You can customize your image and change these defaults. |
| 1325 | Edit the <filename>IMAGE_FEATURES</filename> variable |
| 1326 | in your recipe or use the |
| 1327 | <filename>EXTRA_IMAGE_FEATURES</filename> in your |
| 1328 | <filename>local.conf</filename> file so that it configures the |
| 1329 | image you are working with to include |
| 1330 | <filename>ssh-server-dropbear</filename> or |
| 1331 | <filename>ssh-server-openssh</filename>. |
| 1332 | </para> |
| 1333 | |
| 1334 | <note> |
| 1335 | See the |
| 1336 | "<ulink url='&YOCTO_DOCS_REF_URL;#ref-images'>Images</ulink>" |
| 1337 | section in the Yocto Project Reference Manual for a complete |
| 1338 | list of image features that ship with the Yocto Project. |
| 1339 | </note> |
| 1340 | </section> |
| 1341 | |
| 1342 | <section id='usingpoky-extend-customimage-custombb'> |
| 1343 | <title>Customizing Images Using Custom .bb Files</title> |
| 1344 | |
| 1345 | <para> |
| 1346 | You can also customize an image by creating a custom recipe |
| 1347 | that defines additional software as part of the image. |
| 1348 | The following example shows the form for the two lines you need: |
| 1349 | <literallayout class='monospaced'> |
| 1350 | IMAGE_INSTALL = "packagegroup-core-x11-base package1 package2" |
| 1351 | |
| 1352 | inherit core-image |
| 1353 | </literallayout> |
| 1354 | </para> |
| 1355 | |
| 1356 | <para> |
| 1357 | Defining the software using a custom recipe gives you total |
| 1358 | control over the contents of the image. |
| 1359 | It is important to use the correct names of packages in the |
| 1360 | <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-IMAGE_INSTALL'>IMAGE_INSTALL</ulink></filename> |
| 1361 | variable. |
| 1362 | You must use the OpenEmbedded notation and not the Debian notation for the names |
| 1363 | (e.g. <filename>glibc-dev</filename> instead of <filename>libc6-dev</filename>). |
| 1364 | </para> |
| 1365 | |
| 1366 | <para> |
| 1367 | The other method for creating a custom image is to base it on an existing image. |
| 1368 | For example, if you want to create an image based on <filename>core-image-sato</filename> |
| 1369 | but add the additional package <filename>strace</filename> to the image, |
| 1370 | copy the <filename>meta/recipes-sato/images/core-image-sato.bb</filename> to a |
| 1371 | new <filename>.bb</filename> and add the following line to the end of the copy: |
| 1372 | <literallayout class='monospaced'> |
| 1373 | IMAGE_INSTALL += "strace" |
| 1374 | </literallayout> |
| 1375 | </para> |
| 1376 | </section> |
| 1377 | |
| 1378 | <section id='usingpoky-extend-customimage-customtasks'> |
| 1379 | <title>Customizing Images Using Custom Package Groups</title> |
| 1380 | |
| 1381 | <para> |
| 1382 | For complex custom images, the best approach for customizing |
| 1383 | an image is to create a custom package group recipe that is |
| 1384 | used to build the image or images. |
| 1385 | A good example of a package group recipe is |
| 1386 | <filename>meta/recipes-core/packagegroups/packagegroup-base.bb</filename>. |
| 1387 | </para> |
| 1388 | |
| 1389 | <para> |
| 1390 | If you examine that recipe, you see that the |
| 1391 | <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGES'>PACKAGES</ulink></filename> |
| 1392 | variable lists the package group packages to produce. |
| 1393 | The <filename>inherit packagegroup</filename> statement |
| 1394 | sets appropriate default values and automatically adds |
| 1395 | <filename>-dev</filename>, <filename>-dbg</filename>, and |
| 1396 | <filename>-ptest</filename> complementary packages for each |
| 1397 | package specified in the <filename>PACKAGES</filename> |
| 1398 | statement. |
| 1399 | <note> |
| 1400 | The <filename>inherit packages</filename> should be |
| 1401 | located near the top of the recipe, certainly before |
| 1402 | the <filename>PACKAGES</filename> statement. |
| 1403 | </note> |
| 1404 | </para> |
| 1405 | |
| 1406 | <para> |
| 1407 | For each package you specify in <filename>PACKAGES</filename>, |
| 1408 | you can use |
| 1409 | <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-RDEPENDS'>RDEPENDS</ulink></filename> |
| 1410 | and |
| 1411 | <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-RRECOMMENDS'>RRECOMMENDS</ulink></filename> |
| 1412 | entries to provide a list of packages the parent task package |
| 1413 | should contain. |
| 1414 | You can see examples of these further down in the |
| 1415 | <filename>packagegroup-base.bb</filename> recipe. |
| 1416 | </para> |
| 1417 | |
| 1418 | <para> |
| 1419 | Here is a short, fabricated example showing the same basic |
| 1420 | pieces: |
| 1421 | <literallayout class='monospaced'> |
| 1422 | DESCRIPTION = "My Custom Package Groups" |
| 1423 | |
| 1424 | inherit packagegroup |
| 1425 | |
| 1426 | PACKAGES = "\ |
| 1427 | packagegroup-custom-apps \ |
| 1428 | packagegroup-custom-tools \ |
| 1429 | " |
| 1430 | |
| 1431 | RDEPENDS_packagegroup-custom-apps = "\ |
| 1432 | dropbear \ |
| 1433 | portmap \ |
| 1434 | psplash" |
| 1435 | |
| 1436 | RDEPENDS_packagegroup-custom-tools = "\ |
| 1437 | oprofile \ |
| 1438 | oprofileui-server \ |
| 1439 | lttng-tools" |
| 1440 | |
| 1441 | RRECOMMENDS_packagegroup-custom-tools = "\ |
| 1442 | kernel-module-oprofile" |
| 1443 | </literallayout> |
| 1444 | </para> |
| 1445 | |
| 1446 | <para> |
| 1447 | In the previous example, two package group packages are created with their dependencies and their |
| 1448 | recommended package dependencies listed: <filename>packagegroup-custom-apps</filename>, and |
| 1449 | <filename>packagegroup-custom-tools</filename>. |
| 1450 | To build an image using these package group packages, you need to add |
| 1451 | <filename>packagegroup-custom-apps</filename> and/or |
| 1452 | <filename>packagegroup-custom-tools</filename> to |
| 1453 | <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-IMAGE_INSTALL'>IMAGE_INSTALL</ulink></filename>. |
| 1454 | For other forms of image dependencies see the other areas of this section. |
| 1455 | </para> |
| 1456 | </section> |
| 1457 | |
| 1458 | <section id='usingpoky-extend-customimage-image-name'> |
| 1459 | <title>Customizing an Image Hostname</title> |
| 1460 | |
| 1461 | <para> |
| 1462 | By default, the configured hostname (i.e. |
| 1463 | <filename>/etc/hostname</filename>) in an image is the |
| 1464 | same as the machine name. |
| 1465 | For example, if |
| 1466 | <ulink url='&YOCTO_DOCS_REF_URL;#var-MACHINE'><filename>MACHINE</filename></ulink> |
| 1467 | equals "qemux86", the configured hostname written to |
| 1468 | <filename>/etc/hostname</filename> is "qemux86". |
| 1469 | </para> |
| 1470 | |
| 1471 | <para> |
| 1472 | You can customize this name by altering the value of the |
| 1473 | "hostname" variable in the |
| 1474 | <filename>base-files</filename> recipe using either |
| 1475 | an append file or a configuration file. |
| 1476 | Use the following in an append file: |
| 1477 | <literallayout class='monospaced'> |
| 1478 | hostname="myhostname" |
| 1479 | </literallayout> |
| 1480 | Use the following in a configuration file: |
| 1481 | <literallayout class='monospaced'> |
| 1482 | hostname_pn-base-files = "myhostname" |
| 1483 | </literallayout> |
| 1484 | </para> |
| 1485 | |
| 1486 | <para> |
| 1487 | Changing the default value of the variable "hostname" can be |
| 1488 | useful in certain situations. |
| 1489 | For example, suppose you need to do extensive testing on an |
| 1490 | image and you would like to easily identify the image |
| 1491 | under test from existing images with typical default |
| 1492 | hostnames. |
| 1493 | In this situation, you could change the default hostname to |
| 1494 | "testme", which results in all the images using the name |
| 1495 | "testme". |
| 1496 | Once testing is complete and you do not need to rebuild the |
| 1497 | image for test any longer, you can easily reset the default |
| 1498 | hostname. |
| 1499 | </para> |
| 1500 | |
| 1501 | <para> |
| 1502 | Another point of interest is that if you unset the variable, |
| 1503 | the image will have no default hostname in the filesystem. |
| 1504 | Here is an example that unsets the variable in a |
| 1505 | configuration file: |
| 1506 | <literallayout class='monospaced'> |
| 1507 | hostname_pn-base-files = "" |
| 1508 | </literallayout> |
| 1509 | Having no default hostname in the filesystem is suitable for |
| 1510 | environments that use dynamic hostnames such as virtual |
| 1511 | machines. |
| 1512 | </para> |
| 1513 | </section> |
| 1514 | </section> |
| 1515 | |
| 1516 | <section id='new-recipe-writing-a-new-recipe'> |
| 1517 | <title>Writing a New Recipe</title> |
| 1518 | |
| 1519 | <para> |
| 1520 | Recipes (<filename>.bb</filename> files) are fundamental components |
| 1521 | in the Yocto Project environment. |
| 1522 | Each software component built by the OpenEmbedded build system |
| 1523 | requires a recipe to define the component. |
| 1524 | This section describes how to create, write, and test a new |
| 1525 | recipe. |
| 1526 | <note> |
| 1527 | For information on variables that are useful for recipes and |
| 1528 | for information about recipe naming issues, see the |
| 1529 | "<ulink url='&YOCTO_DOCS_REF_URL;#ref-varlocality-recipe-required'>Required</ulink>" |
| 1530 | section of the Yocto Project Reference Manual. |
| 1531 | </note> |
| 1532 | </para> |
| 1533 | |
| 1534 | <section id='new-recipe-overview'> |
| 1535 | <title>Overview</title> |
| 1536 | |
| 1537 | <para> |
| 1538 | The following figure shows the basic process for creating a |
| 1539 | new recipe. |
| 1540 | The remainder of the section provides details for the steps. |
| 1541 | <imagedata fileref="figures/recipe-workflow.png" width="6in" depth="7in" align="center" scalefit="1" /> |
| 1542 | </para> |
| 1543 | </section> |
| 1544 | |
| 1545 | <section id='new-recipe-locate-or-automatically-create-a-base-recipe'> |
| 1546 | <title>Locate or Automatically Create a Base Recipe</title> |
| 1547 | |
| 1548 | <para> |
| 1549 | You can always write a recipe from scratch. |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 1550 | However, three choices exist that can help you quickly get a |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1551 | start on a new recipe: |
| 1552 | <itemizedlist> |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 1553 | <listitem><para> |
| 1554 | <emphasis><filename>devtool add</filename>:</emphasis> |
| 1555 | A command that assists in creating a recipe and |
| 1556 | an environment conducive to development. |
| 1557 | </para></listitem> |
| 1558 | <listitem><para> |
| 1559 | <emphasis><filename>recipetool create</filename>:</emphasis> |
| 1560 | A command provided by the Yocto Project that automates |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1561 | creation of a base recipe based on the source |
| 1562 | files. |
| 1563 | </para></listitem> |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 1564 | <listitem><para> |
| 1565 | <emphasis>Existing Recipes:</emphasis> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1566 | Location and modification of an existing recipe that is |
| 1567 | similar in function to the recipe you need. |
| 1568 | </para></listitem> |
| 1569 | </itemizedlist> |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 1570 | <note> |
| 1571 | For information on recipe syntax, see the |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 1572 | "<link linkend='recipe-syntax'>Recipe Syntax</link>" |
| 1573 | section. |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 1574 | </note> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1575 | </para> |
| 1576 | |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 1577 | <section id='new-recipe-creating-the-base-recipe-using-devtool'> |
| 1578 | <title>Creating the Base Recipe Using <filename>devtool add</filename></title> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1579 | |
| 1580 | <para> |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 1581 | The <filename>devtool add</filename> command uses the same |
| 1582 | logic for auto-creating the recipe as |
| 1583 | <filename>recipetool create</filename>, which is listed |
| 1584 | below. |
| 1585 | Additionally, however, <filename>devtool add</filename> |
| 1586 | sets up an environment that makes it easy for you to |
| 1587 | patch the source and to make changes to the recipe as |
| 1588 | is often necessary when adding a recipe to build a new |
| 1589 | piece of software to be included in a build. |
| 1590 | </para> |
| 1591 | |
| 1592 | <para> |
| 1593 | You can find a complete description of the |
| 1594 | <filename>devtool add</filename> command in the |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 1595 | "<ulink url='&YOCTO_DOCS_SDK_URL;#sdk-a-closer-look-at-devtool-add'>A Closer Look at <filename>devtool</filename> add</ulink>" |
| 1596 | section in the Yocto Project Application Development |
| 1597 | and the Extensible Software Development Kit (eSDK) manual. |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 1598 | </para> |
| 1599 | </section> |
| 1600 | |
| 1601 | <section id='new-recipe-creating-the-base-recipe-using-recipetool'> |
| 1602 | <title>Creating the Base Recipe Using <filename>recipetool create</filename></title> |
| 1603 | |
| 1604 | <para> |
| 1605 | <filename>recipetool create</filename> automates creation |
| 1606 | of a base recipe given a set of source code files. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1607 | As long as you can extract or point to the source files, |
| 1608 | the tool will construct a recipe and automatically |
| 1609 | configure all pre-build information into the recipe. |
| 1610 | For example, suppose you have an application that builds |
| 1611 | using Autotools. |
| 1612 | Creating the base recipe using |
| 1613 | <filename>recipetool</filename> results in a recipe |
| 1614 | that has the pre-build dependencies, license requirements, |
| 1615 | and checksums configured. |
| 1616 | </para> |
| 1617 | |
| 1618 | <para> |
| 1619 | To run the tool, you just need to be in your |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 1620 | <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1621 | and have sourced the build environment setup script |
| 1622 | (i.e. |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 1623 | <ulink url='&YOCTO_DOCS_REF_URL;#structure-core-script'><filename>oe-init-build-env</filename></ulink>). |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 1624 | To get help on the tool, use the following command: |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1625 | <literallayout class='monospaced'> |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 1626 | $ recipetool -h |
| 1627 | NOTE: Starting bitbake server... |
| 1628 | usage: recipetool [-d] [-q] [--color COLOR] [-h] <subcommand> ... |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1629 | |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 1630 | OpenEmbedded recipe tool |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1631 | |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 1632 | options: |
| 1633 | -d, --debug Enable debug output |
| 1634 | -q, --quiet Print only errors |
| 1635 | --color COLOR Colorize output (where COLOR is auto, always, never) |
| 1636 | -h, --help show this help message and exit |
| 1637 | |
| 1638 | subcommands: |
| 1639 | create Create a new recipe |
| 1640 | newappend Create a bbappend for the specified target in the specified |
| 1641 | layer |
| 1642 | setvar Set a variable within a recipe |
| 1643 | appendfile Create/update a bbappend to replace a target file |
| 1644 | appendsrcfiles Create/update a bbappend to add or replace source files |
| 1645 | appendsrcfile Create/update a bbappend to add or replace a source file |
| 1646 | Use recipetool <subcommand> --help to get help on a specific command |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1647 | </literallayout> |
| 1648 | </para> |
| 1649 | |
| 1650 | <para> |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 1651 | Running |
| 1652 | <filename>recipetool create -o</filename> <replaceable>OUTFILE</replaceable> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1653 | creates the base recipe and locates it properly in the |
| 1654 | layer that contains your source files. |
| 1655 | Following are some syntax examples: |
| 1656 | </para> |
| 1657 | |
| 1658 | <para> |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 1659 | Use this syntax to generate a recipe based on |
| 1660 | <replaceable>source</replaceable>. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1661 | Once generated, the recipe resides in the existing source |
| 1662 | code layer: |
| 1663 | <literallayout class='monospaced'> |
| 1664 | recipetool create -o <replaceable>OUTFILE</replaceable> <replaceable>source</replaceable> |
| 1665 | </literallayout> |
| 1666 | Use this syntax to generate a recipe using code that you |
| 1667 | extract from <replaceable>source</replaceable>. |
| 1668 | The extracted code is placed in its own layer defined |
| 1669 | by <replaceable>EXTERNALSRC</replaceable>. |
| 1670 | <literallayout class='monospaced'> |
| 1671 | recipetool create -o <replaceable>OUTFILE</replaceable> -x <replaceable>EXTERNALSRC</replaceable> <replaceable>source</replaceable> |
| 1672 | </literallayout> |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 1673 | Use this syntax to generate a recipe based on |
| 1674 | <replaceable>source</replaceable>. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1675 | The options direct <filename>recipetool</filename> to |
Brad Bishop | 37a0e4d | 2017-12-04 01:01:44 -0500 | [diff] [blame] | 1676 | generate debugging information. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1677 | Once generated, the recipe resides in the existing source |
| 1678 | code layer: |
| 1679 | <literallayout class='monospaced'> |
Brad Bishop | 37a0e4d | 2017-12-04 01:01:44 -0500 | [diff] [blame] | 1680 | recipetool create -d -o <replaceable>OUTFILE</replaceable> <replaceable>source</replaceable> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1681 | </literallayout> |
| 1682 | </para> |
| 1683 | </section> |
| 1684 | |
| 1685 | <section id='new-recipe-locating-and-using-a-similar-recipe'> |
| 1686 | <title>Locating and Using a Similar Recipe</title> |
| 1687 | |
| 1688 | <para> |
| 1689 | Before writing a recipe from scratch, it is often useful to |
| 1690 | discover whether someone else has already written one that |
| 1691 | meets (or comes close to meeting) your needs. |
| 1692 | The Yocto Project and OpenEmbedded communities maintain many |
| 1693 | recipes that might be candidates for what you are doing. |
| 1694 | You can find a good central index of these recipes in the |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 1695 | <ulink url='http://layers.openembedded.org'>OpenEmbedded Layer Index</ulink>. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1696 | </para> |
| 1697 | |
| 1698 | <para> |
| 1699 | Working from an existing recipe or a skeleton recipe is the |
| 1700 | best way to get started. |
| 1701 | Here are some points on both methods: |
| 1702 | <itemizedlist> |
| 1703 | <listitem><para><emphasis>Locate and modify a recipe that |
| 1704 | is close to what you want to do:</emphasis> |
| 1705 | This method works when you are familiar with the |
| 1706 | current recipe space. |
| 1707 | The method does not work so well for those new to |
| 1708 | the Yocto Project or writing recipes.</para> |
| 1709 | <para>Some risks associated with this method are |
| 1710 | using a recipe that has areas totally unrelated to |
| 1711 | what you are trying to accomplish with your recipe, |
| 1712 | not recognizing areas of the recipe that you might |
| 1713 | have to add from scratch, and so forth. |
| 1714 | All these risks stem from unfamiliarity with the |
| 1715 | existing recipe space.</para></listitem> |
| 1716 | <listitem><para><emphasis>Use and modify the following |
| 1717 | skeleton recipe:</emphasis> |
| 1718 | If for some reason you do not want to use |
| 1719 | <filename>recipetool</filename> and you cannot |
| 1720 | find an existing recipe that is close to meeting |
| 1721 | your needs, you can use the following structure to |
| 1722 | provide the fundamental areas of a new recipe. |
| 1723 | <literallayout class='monospaced'> |
| 1724 | DESCRIPTION = "" |
| 1725 | HOMEPAGE = "" |
| 1726 | LICENSE = "" |
| 1727 | SECTION = "" |
| 1728 | DEPENDS = "" |
| 1729 | LIC_FILES_CHKSUM = "" |
| 1730 | |
| 1731 | SRC_URI = "" |
| 1732 | </literallayout> |
| 1733 | </para></listitem> |
| 1734 | </itemizedlist> |
| 1735 | </para> |
| 1736 | </section> |
| 1737 | </section> |
| 1738 | |
| 1739 | <section id='new-recipe-storing-and-naming-the-recipe'> |
| 1740 | <title>Storing and Naming the Recipe</title> |
| 1741 | |
| 1742 | <para> |
| 1743 | Once you have your base recipe, you should put it in your |
| 1744 | own layer and name it appropriately. |
| 1745 | Locating it correctly ensures that the OpenEmbedded build |
| 1746 | system can find it when you use BitBake to process the |
| 1747 | recipe. |
| 1748 | </para> |
| 1749 | |
| 1750 | <itemizedlist> |
| 1751 | <listitem><para><emphasis>Storing Your Recipe:</emphasis> |
| 1752 | The OpenEmbedded build system locates your recipe |
| 1753 | through the layer's <filename>conf/layer.conf</filename> |
| 1754 | file and the |
| 1755 | <ulink url='&YOCTO_DOCS_REF_URL;#var-BBFILES'><filename>BBFILES</filename></ulink> |
| 1756 | variable. |
| 1757 | This variable sets up a path from which the build system can |
| 1758 | locate recipes. |
| 1759 | Here is the typical use: |
| 1760 | <literallayout class='monospaced'> |
| 1761 | BBFILES += "${LAYERDIR}/recipes-*/*/*.bb \ |
| 1762 | ${LAYERDIR}/recipes-*/*/*.bbappend" |
| 1763 | </literallayout> |
| 1764 | Consequently, you need to be sure you locate your new recipe |
| 1765 | inside your layer such that it can be found.</para> |
| 1766 | <para>You can find more information on how layers are |
| 1767 | structured in the |
| 1768 | "<link linkend='understanding-and-creating-layers'>Understanding and Creating Layers</link>" |
| 1769 | section.</para></listitem> |
| 1770 | <listitem><para><emphasis>Naming Your Recipe:</emphasis> |
| 1771 | When you name your recipe, you need to follow this naming |
| 1772 | convention: |
| 1773 | <literallayout class='monospaced'> |
| 1774 | <replaceable>basename</replaceable>_<replaceable>version</replaceable>.bb |
| 1775 | </literallayout> |
| 1776 | Use lower-cased characters and do not include the reserved |
| 1777 | suffixes <filename>-native</filename>, |
| 1778 | <filename>-cross</filename>, <filename>-initial</filename>, |
| 1779 | or <filename>-dev</filename> casually (i.e. do not use them |
| 1780 | as part of your recipe name unless the string applies). |
| 1781 | Here are some examples: |
| 1782 | <literallayout class='monospaced'> |
| 1783 | cups_1.7.0.bb |
| 1784 | gawk_4.0.2.bb |
| 1785 | irssi_0.8.16-rc1.bb |
| 1786 | </literallayout></para></listitem> |
| 1787 | </itemizedlist> |
| 1788 | </section> |
| 1789 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1790 | <section id='new-recipe-running-a-build-on-the-recipe'> |
| 1791 | <title>Running a Build on the Recipe</title> |
| 1792 | |
| 1793 | <para> |
| 1794 | Creating a new recipe is usually an iterative process that |
| 1795 | requires using BitBake to process the recipe multiple times in |
| 1796 | order to progressively discover and add information to the |
| 1797 | recipe file. |
| 1798 | </para> |
| 1799 | |
| 1800 | <para> |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 1801 | Assuming you have sourced the build environment setup script (i.e. |
| 1802 | <ulink url='&YOCTO_DOCS_REF_URL;#structure-core-script'><filename>&OE_INIT_FILE;</filename></ulink>) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1803 | and you are in the |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 1804 | <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink>, |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1805 | use BitBake to process your recipe. |
| 1806 | All you need to provide is the |
| 1807 | <filename><replaceable>basename</replaceable></filename> of the recipe as described |
| 1808 | in the previous section: |
| 1809 | <literallayout class='monospaced'> |
| 1810 | $ bitbake <replaceable>basename</replaceable> |
| 1811 | </literallayout> |
| 1812 | |
| 1813 | </para> |
| 1814 | |
| 1815 | <para> |
| 1816 | During the build, the OpenEmbedded build system creates a |
| 1817 | temporary work directory for each recipe |
| 1818 | (<filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-WORKDIR'><filename>WORKDIR</filename></ulink><filename>}</filename>) |
| 1819 | where it keeps extracted source files, log files, intermediate |
| 1820 | compilation and packaging files, and so forth. |
| 1821 | </para> |
| 1822 | |
| 1823 | <para> |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 1824 | The path to the per-recipe temporary work directory depends |
| 1825 | on the context in which it is being built. |
| 1826 | The quickest way to find this path is to have BitBake return it |
| 1827 | by running the following: |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1828 | <literallayout class='monospaced'> |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 1829 | $ bitbake -e <replaceable>basename</replaceable> | grep ^WORKDIR= |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1830 | </literallayout> |
| 1831 | As an example, assume a Source Directory top-level folder named |
| 1832 | <filename>poky</filename>, a default Build Directory at |
| 1833 | <filename>poky/build</filename>, and a |
| 1834 | <filename>qemux86-poky-linux</filename> machine target system. |
| 1835 | Furthermore, suppose your recipe is named |
| 1836 | <filename>foo_1.3.0.bb</filename>. |
| 1837 | In this case, the work directory the build system uses to |
| 1838 | build the package would be as follows: |
| 1839 | <literallayout class='monospaced'> |
| 1840 | poky/build/tmp/work/qemux86-poky-linux/foo/1.3.0-r0 |
| 1841 | </literallayout> |
| 1842 | Inside this directory you can find sub-directories such as |
| 1843 | <filename>image</filename>, <filename>packages-split</filename>, |
| 1844 | and <filename>temp</filename>. |
| 1845 | After the build, you can examine these to determine how well |
| 1846 | the build went. |
| 1847 | <note> |
| 1848 | You can find log files for each task in the recipe's |
| 1849 | <filename>temp</filename> directory (e.g. |
| 1850 | <filename>poky/build/tmp/work/qemux86-poky-linux/foo/1.3.0-r0/temp</filename>). |
| 1851 | Log files are named <filename>log.<replaceable>taskname</replaceable></filename> |
| 1852 | (e.g. <filename>log.do_configure</filename>, |
| 1853 | <filename>log.do_fetch</filename>, and |
| 1854 | <filename>log.do_compile</filename>). |
| 1855 | </note> |
| 1856 | </para> |
| 1857 | |
| 1858 | <para> |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 1859 | You can find more information about the build process in |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 1860 | "<ulink url='&YOCTO_DOCS_OM_URL;#overview-development-environment'>The Yocto Project Development Environment</ulink>" |
| 1861 | chapter of the Yocto Project Overview and Concepts Manual. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1862 | </para> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1863 | </section> |
| 1864 | |
| 1865 | <section id='new-recipe-fetching-code'> |
| 1866 | <title>Fetching Code</title> |
| 1867 | |
| 1868 | <para> |
| 1869 | The first thing your recipe must do is specify how to fetch |
| 1870 | the source files. |
| 1871 | Fetching is controlled mainly through the |
| 1872 | <ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'><filename>SRC_URI</filename></ulink> |
| 1873 | variable. |
| 1874 | Your recipe must have a <filename>SRC_URI</filename> variable |
| 1875 | that points to where the source is located. |
| 1876 | For a graphical representation of source locations, see the |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 1877 | "<ulink url='&YOCTO_DOCS_OM_URL;#sources-dev-environment'>Sources</ulink>" |
| 1878 | section in the Yocto Project Overview and Concepts Manual. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1879 | </para> |
| 1880 | |
| 1881 | <para> |
| 1882 | The |
| 1883 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-fetch'><filename>do_fetch</filename></ulink> |
| 1884 | task uses the prefix of each entry in the |
| 1885 | <filename>SRC_URI</filename> variable value to determine which |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 1886 | <ulink url='&YOCTO_DOCS_BB_URL;#bb-fetchers'>fetcher</ulink> |
| 1887 | to use to get your source files. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1888 | It is the <filename>SRC_URI</filename> variable that triggers |
| 1889 | the fetcher. |
| 1890 | The |
| 1891 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-patch'><filename>do_patch</filename></ulink> |
| 1892 | task uses the variable after source is fetched to apply |
| 1893 | patches. |
| 1894 | The OpenEmbedded build system uses |
| 1895 | <ulink url='&YOCTO_DOCS_REF_URL;#var-FILESOVERRIDES'><filename>FILESOVERRIDES</filename></ulink> |
| 1896 | for scanning directory locations for local files in |
| 1897 | <filename>SRC_URI</filename>. |
| 1898 | </para> |
| 1899 | |
| 1900 | <para> |
| 1901 | The <filename>SRC_URI</filename> variable in your recipe must |
| 1902 | define each unique location for your source files. |
| 1903 | It is good practice to not hard-code pathnames in an URL used |
| 1904 | in <filename>SRC_URI</filename>. |
| 1905 | Rather than hard-code these paths, use |
| 1906 | <filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-PV'><filename>PV</filename></ulink><filename>}</filename>, |
| 1907 | which causes the fetch process to use the version specified in |
| 1908 | the recipe filename. |
| 1909 | Specifying the version in this manner means that upgrading the |
| 1910 | recipe to a future version is as simple as renaming the recipe |
| 1911 | to match the new version. |
| 1912 | </para> |
| 1913 | |
| 1914 | <para> |
| 1915 | Here is a simple example from the |
| 1916 | <filename>meta/recipes-devtools/cdrtools/cdrtools-native_3.01a20.bb</filename> |
| 1917 | recipe where the source comes from a single tarball. |
| 1918 | Notice the use of the |
| 1919 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PV'><filename>PV</filename></ulink> |
| 1920 | variable: |
| 1921 | <literallayout class='monospaced'> |
| 1922 | SRC_URI = "ftp://ftp.berlios.de/pub/cdrecord/alpha/cdrtools-${PV}.tar.bz2" |
| 1923 | </literallayout> |
| 1924 | </para> |
| 1925 | |
| 1926 | <para> |
| 1927 | Files mentioned in <filename>SRC_URI</filename> whose names end |
| 1928 | in a typical archive extension (e.g. <filename>.tar</filename>, |
| 1929 | <filename>.tar.gz</filename>, <filename>.tar.bz2</filename>, |
| 1930 | <filename>.zip</filename>, and so forth), are automatically |
| 1931 | extracted during the |
| 1932 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-unpack'><filename>do_unpack</filename></ulink> |
| 1933 | task. |
| 1934 | For another example that specifies these types of files, see |
| 1935 | the |
| 1936 | "<link linkend='new-recipe-autotooled-package'>Autotooled Package</link>" |
| 1937 | section. |
| 1938 | </para> |
| 1939 | |
| 1940 | <para> |
| 1941 | Another way of specifying source is from an SCM. |
| 1942 | For Git repositories, you must specify |
| 1943 | <ulink url='&YOCTO_DOCS_REF_URL;#var-SRCREV'><filename>SRCREV</filename></ulink> |
| 1944 | and you should specify |
| 1945 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PV'><filename>PV</filename></ulink> |
| 1946 | to include the revision with |
| 1947 | <ulink url='&YOCTO_DOCS_REF_URL;#var-SRCPV'><filename>SRCPV</filename></ulink>. |
| 1948 | Here is an example from the recipe |
| 1949 | <filename>meta/recipes-kernel/blktrace/blktrace_git.bb</filename>: |
| 1950 | <literallayout class='monospaced'> |
| 1951 | SRCREV = "d6918c8832793b4205ed3bfede78c2f915c23385" |
| 1952 | |
| 1953 | PR = "r6" |
| 1954 | PV = "1.0.5+git${SRCPV}" |
| 1955 | |
| 1956 | SRC_URI = "git://git.kernel.dk/blktrace.git \ |
| 1957 | file://ldflags.patch" |
| 1958 | </literallayout> |
| 1959 | </para> |
| 1960 | |
| 1961 | <para> |
| 1962 | If your <filename>SRC_URI</filename> statement includes |
| 1963 | URLs pointing to individual files fetched from a remote server |
| 1964 | other than a version control system, BitBake attempts to |
| 1965 | verify the files against checksums defined in your recipe to |
| 1966 | ensure they have not been tampered with or otherwise modified |
| 1967 | since the recipe was written. |
| 1968 | Two checksums are used: |
| 1969 | <filename>SRC_URI[md5sum]</filename> and |
| 1970 | <filename>SRC_URI[sha256sum]</filename>. |
| 1971 | </para> |
| 1972 | |
| 1973 | <para> |
| 1974 | If your <filename>SRC_URI</filename> variable points to |
| 1975 | more than a single URL (excluding SCM URLs), you need to |
| 1976 | provide the <filename>md5</filename> and |
| 1977 | <filename>sha256</filename> checksums for each URL. |
| 1978 | For these cases, you provide a name for each URL as part of |
| 1979 | the <filename>SRC_URI</filename> and then reference that name |
| 1980 | in the subsequent checksum statements. |
| 1981 | Here is an example: |
| 1982 | <literallayout class='monospaced'> |
| 1983 | 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] | 1984 | ${DEBIAN_MIRROR}/main/a/apmd/apmd_${PV}.diff.gz;name=patch" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1985 | |
| 1986 | SRC_URI[tarball.md5sum] = "b1e6309e8331e0f4e6efd311c2d97fa8" |
| 1987 | SRC_URI[tarball.sha256sum] = "7f7d9f60b7766b852881d40b8ff91d8e39fccb0d1d913102a5c75a2dbb52332d" |
| 1988 | |
| 1989 | SRC_URI[patch.md5sum] = "57e1b689264ea80f78353519eece0c92" |
| 1990 | SRC_URI[patch.sha256sum] = "7905ff96be93d725544d0040e425c42f9c05580db3c272f11cff75b9aa89d430" |
| 1991 | </literallayout> |
| 1992 | </para> |
| 1993 | |
| 1994 | <para> |
| 1995 | Proper values for <filename>md5</filename> and |
| 1996 | <filename>sha256</filename> checksums might be available |
| 1997 | with other signatures on the download page for the upstream |
| 1998 | source (e.g. <filename>md5</filename>, |
| 1999 | <filename>sha1</filename>, <filename>sha256</filename>, |
| 2000 | <filename>GPG</filename>, and so forth). |
| 2001 | Because the OpenEmbedded build system only deals with |
| 2002 | <filename>sha256sum</filename> and <filename>md5sum</filename>, |
| 2003 | you should verify all the signatures you find by hand. |
| 2004 | </para> |
| 2005 | |
| 2006 | <para> |
| 2007 | If no <filename>SRC_URI</filename> checksums are specified |
| 2008 | when you attempt to build the recipe, or you provide an |
| 2009 | incorrect checksum, the build will produce an error for each |
| 2010 | missing or incorrect checksum. |
| 2011 | As part of the error message, the build system provides |
| 2012 | the checksum string corresponding to the fetched file. |
| 2013 | Once you have the correct checksums, you can copy and paste |
| 2014 | them into your recipe and then run the build again to continue. |
| 2015 | <note> |
| 2016 | As mentioned, if the upstream source provides signatures |
| 2017 | for verifying the downloaded source code, you should |
| 2018 | verify those manually before setting the checksum values |
| 2019 | in the recipe and continuing with the build. |
| 2020 | </note> |
| 2021 | </para> |
| 2022 | |
| 2023 | <para> |
| 2024 | This final example is a bit more complicated and is from the |
| 2025 | <filename>meta/recipes-sato/rxvt-unicode/rxvt-unicode_9.20.bb</filename> |
| 2026 | recipe. |
| 2027 | The example's <filename>SRC_URI</filename> statement identifies |
| 2028 | multiple files as the source files for the recipe: a tarball, a |
| 2029 | patch file, a desktop file, and an icon. |
| 2030 | <literallayout class='monospaced'> |
| 2031 | SRC_URI = "http://dist.schmorp.de/rxvt-unicode/Attic/rxvt-unicode-${PV}.tar.bz2 \ |
| 2032 | file://xwc.patch \ |
| 2033 | file://rxvt.desktop \ |
| 2034 | file://rxvt.png" |
| 2035 | </literallayout> |
| 2036 | </para> |
| 2037 | |
| 2038 | <para> |
| 2039 | When you specify local files using the |
| 2040 | <filename>file://</filename> URI protocol, the build system |
| 2041 | fetches files from the local machine. |
| 2042 | The path is relative to the |
| 2043 | <ulink url='&YOCTO_DOCS_REF_URL;#var-FILESPATH'><filename>FILESPATH</filename></ulink> |
| 2044 | variable and searches specific directories in a certain order: |
| 2045 | <filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-BP'><filename>BP</filename></ulink><filename>}</filename>, |
| 2046 | <filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-BPN'><filename>BPN</filename></ulink><filename>}</filename>, |
| 2047 | and <filename>files</filename>. |
| 2048 | The directories are assumed to be subdirectories of the |
| 2049 | directory in which the recipe or append file resides. |
| 2050 | For another example that specifies these types of files, see the |
| 2051 | "<link linkend='new-recipe-single-c-file-package-hello-world'>Single .c File Package (Hello World!)</link>" |
| 2052 | section. |
| 2053 | </para> |
| 2054 | |
| 2055 | <para> |
| 2056 | The previous example also specifies a patch file. |
| 2057 | Patch files are files whose names usually end in |
| 2058 | <filename>.patch</filename> or <filename>.diff</filename> but |
| 2059 | can end with compressed suffixes such as |
| 2060 | <filename>diff.gz</filename> and |
| 2061 | <filename>patch.bz2</filename>, for example. |
| 2062 | The build system automatically applies patches as described |
| 2063 | in the |
| 2064 | "<link linkend='new-recipe-patching-code'>Patching Code</link>" section. |
| 2065 | </para> |
| 2066 | </section> |
| 2067 | |
| 2068 | <section id='new-recipe-unpacking-code'> |
| 2069 | <title>Unpacking Code</title> |
| 2070 | |
| 2071 | <para> |
| 2072 | During the build, the |
| 2073 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-unpack'><filename>do_unpack</filename></ulink> |
| 2074 | task unpacks the source with |
| 2075 | <filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-S'><filename>S</filename></ulink><filename>}</filename> |
| 2076 | pointing to where it is unpacked. |
| 2077 | </para> |
| 2078 | |
| 2079 | <para> |
| 2080 | If you are fetching your source files from an upstream source |
| 2081 | archived tarball and the tarball's internal structure matches |
| 2082 | the common convention of a top-level subdirectory named |
| 2083 | <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>, |
| 2084 | then you do not need to set <filename>S</filename>. |
| 2085 | However, if <filename>SRC_URI</filename> specifies to fetch |
| 2086 | source from an archive that does not use this convention, |
| 2087 | or from an SCM like Git or Subversion, your recipe needs to |
| 2088 | define <filename>S</filename>. |
| 2089 | </para> |
| 2090 | |
| 2091 | <para> |
| 2092 | If processing your recipe using BitBake successfully unpacks |
| 2093 | the source files, you need to be sure that the directory |
| 2094 | pointed to by <filename>${S}</filename> matches the structure |
| 2095 | of the source. |
| 2096 | </para> |
| 2097 | </section> |
| 2098 | |
| 2099 | <section id='new-recipe-patching-code'> |
| 2100 | <title>Patching Code</title> |
| 2101 | |
| 2102 | <para> |
| 2103 | Sometimes it is necessary to patch code after it has been |
| 2104 | fetched. |
| 2105 | Any files mentioned in <filename>SRC_URI</filename> whose |
| 2106 | names end in <filename>.patch</filename> or |
| 2107 | <filename>.diff</filename> or compressed versions of these |
| 2108 | suffixes (e.g. <filename>diff.gz</filename> are treated as |
| 2109 | patches. |
| 2110 | The |
| 2111 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-patch'><filename>do_patch</filename></ulink> |
| 2112 | task automatically applies these patches. |
| 2113 | </para> |
| 2114 | |
| 2115 | <para> |
| 2116 | The build system should be able to apply patches with the "-p1" |
| 2117 | option (i.e. one directory level in the path will be stripped |
| 2118 | off). |
| 2119 | If your patch needs to have more directory levels stripped off, |
| 2120 | specify the number of levels using the "striplevel" option in |
| 2121 | the <filename>SRC_URI</filename> entry for the patch. |
| 2122 | Alternatively, if your patch needs to be applied in a specific |
| 2123 | subdirectory that is not specified in the patch file, use the |
| 2124 | "patchdir" option in the entry. |
| 2125 | </para> |
| 2126 | |
| 2127 | <para> |
| 2128 | As with all local files referenced in |
| 2129 | <ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'><filename>SRC_URI</filename></ulink> |
| 2130 | using <filename>file://</filename>, you should place |
| 2131 | patch files in a directory next to the recipe either |
| 2132 | named the same as the base name of the recipe |
| 2133 | (<ulink url='&YOCTO_DOCS_REF_URL;#var-BP'><filename>BP</filename></ulink> |
| 2134 | and |
| 2135 | <ulink url='&YOCTO_DOCS_REF_URL;#var-BPN'><filename>BPN</filename></ulink>) |
| 2136 | or "files". |
| 2137 | </para> |
| 2138 | </section> |
| 2139 | |
| 2140 | <section id='new-recipe-licensing'> |
| 2141 | <title>Licensing</title> |
| 2142 | |
| 2143 | <para> |
| 2144 | Your recipe needs to have both the |
| 2145 | <ulink url='&YOCTO_DOCS_REF_URL;#var-LICENSE'><filename>LICENSE</filename></ulink> |
| 2146 | and |
| 2147 | <ulink url='&YOCTO_DOCS_REF_URL;#var-LIC_FILES_CHKSUM'><filename>LIC_FILES_CHKSUM</filename></ulink> |
| 2148 | variables: |
| 2149 | <itemizedlist> |
| 2150 | <listitem><para><emphasis><filename>LICENSE</filename>:</emphasis> |
| 2151 | This variable specifies the license for the software. |
| 2152 | If you do not know the license under which the software |
| 2153 | you are building is distributed, you should go to the |
| 2154 | source code and look for that information. |
| 2155 | Typical files containing this information include |
| 2156 | <filename>COPYING</filename>, |
| 2157 | <filename>LICENSE</filename>, and |
| 2158 | <filename>README</filename> files. |
| 2159 | You could also find the information near the top of |
| 2160 | a source file. |
| 2161 | For example, given a piece of software licensed under |
| 2162 | the GNU General Public License version 2, you would |
| 2163 | set <filename>LICENSE</filename> as follows: |
| 2164 | <literallayout class='monospaced'> |
| 2165 | LICENSE = "GPLv2" |
| 2166 | </literallayout></para> |
| 2167 | <para>The licenses you specify within |
| 2168 | <filename>LICENSE</filename> can have any name as long |
| 2169 | as you do not use spaces, since spaces are used as |
| 2170 | separators between license names. |
| 2171 | For standard licenses, use the names of the files in |
| 2172 | <filename>meta/files/common-licenses/</filename> |
| 2173 | or the <filename>SPDXLICENSEMAP</filename> flag names |
| 2174 | defined in <filename>meta/conf/licenses.conf</filename>. |
| 2175 | </para></listitem> |
| 2176 | <listitem><para><emphasis><filename>LIC_FILES_CHKSUM</filename>:</emphasis> |
| 2177 | The OpenEmbedded build system uses this variable to |
| 2178 | make sure the license text has not changed. |
| 2179 | If it has, the build produces an error and it affords |
| 2180 | you the chance to figure it out and correct the problem. |
| 2181 | </para> |
| 2182 | <para>You need to specify all applicable licensing |
| 2183 | files for the software. |
| 2184 | At the end of the configuration step, the build process |
| 2185 | will compare the checksums of the files to be sure |
| 2186 | the text has not changed. |
| 2187 | Any differences result in an error with the message |
| 2188 | containing the current checksum. |
| 2189 | For more explanation and examples of how to set the |
| 2190 | <filename>LIC_FILES_CHKSUM</filename> variable, see the |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 2191 | "<link link='usingpoky-configuring-LIC_FILES_CHKSUM'>Tracking License Changes</link>" |
| 2192 | section.</para> |
| 2193 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 2194 | <para>To determine the correct checksum string, you |
| 2195 | can list the appropriate files in the |
| 2196 | <filename>LIC_FILES_CHKSUM</filename> variable with |
| 2197 | incorrect md5 strings, attempt to build the software, |
| 2198 | and then note the resulting error messages that will |
| 2199 | report the correct md5 strings. |
| 2200 | See the |
| 2201 | "<link linkend='new-recipe-fetching-code'>Fetching Code</link>" |
| 2202 | section for additional information. |
| 2203 | </para> |
| 2204 | |
| 2205 | <para> |
| 2206 | Here is an example that assumes the software has a |
| 2207 | <filename>COPYING</filename> file: |
| 2208 | <literallayout class='monospaced'> |
| 2209 | LIC_FILES_CHKSUM = "file://COPYING;md5=xxx" |
| 2210 | </literallayout> |
| 2211 | When you try to build the software, the build system |
| 2212 | will produce an error and give you the correct string |
| 2213 | that you can substitute into the recipe file for a |
| 2214 | subsequent build. |
| 2215 | </para></listitem> |
| 2216 | </itemizedlist> |
| 2217 | </para> |
| 2218 | |
| 2219 | <!-- |
| 2220 | |
| 2221 | <para> |
| 2222 | For trying this out I created a new recipe named |
| 2223 | <filename>htop_1.0.2.bb</filename> and put it in |
| 2224 | <filename>poky/meta/recipes-extended/htop</filename>. |
| 2225 | There are two license type statements in my very simple |
| 2226 | recipe: |
| 2227 | <literallayout class='monospaced'> |
| 2228 | LICENSE = "" |
| 2229 | |
| 2230 | LIC_FILES_CHKSUM = "" |
| 2231 | |
| 2232 | SRC_URI[md5sum] = "" |
| 2233 | SRC_URI[sha256sum] = "" |
| 2234 | </literallayout> |
| 2235 | Evidently, you need to run a <filename>bitbake -c cleanall htop</filename>. |
| 2236 | Next, you delete or comment out the two <filename>SRC_URI</filename> |
| 2237 | lines at the end and then attempt to build the software with |
| 2238 | <filename>bitbake htop</filename>. |
| 2239 | Doing so causes BitBake to report some errors and and give |
| 2240 | you the actual strings you need for the last two |
| 2241 | <filename>SRC_URI</filename> lines. |
| 2242 | Prior to this, you have to dig around in the home page of the |
| 2243 | source for <filename>htop</filename> and determine that the |
| 2244 | software is released under GPLv2. |
| 2245 | You can provide that in the <filename>LICENSE</filename> |
| 2246 | statement. |
| 2247 | Now you edit your recipe to have those two strings for |
| 2248 | the <filename>SRC_URI</filename> statements: |
| 2249 | <literallayout class='monospaced'> |
| 2250 | LICENSE = "GPLv2" |
| 2251 | |
| 2252 | LIC_FILES_CHKSUM = "" |
| 2253 | |
| 2254 | SRC_URI = "${SOURCEFORGE_MIRROR}/htop/htop-${PV}.tar.gz" |
| 2255 | SRC_URI[md5sum] = "0d01cca8df3349c74569cefebbd9919e" |
| 2256 | SRC_URI[sha256sum] = "ee60657b044ece0df096c053060df7abf3cce3a568ab34d260049e6a37ccd8a1" |
| 2257 | </literallayout> |
| 2258 | At this point, you can build the software again using the |
| 2259 | <filename>bitbake htop</filename> command. |
| 2260 | There is just a set of errors now associated with the |
| 2261 | empty <filename>LIC_FILES_CHKSUM</filename> variable now. |
| 2262 | </para> |
| 2263 | --> |
| 2264 | |
| 2265 | </section> |
| 2266 | |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 2267 | <section id='new-dependencies'> |
| 2268 | <title>Dependencies</title> |
| 2269 | |
| 2270 | <para> |
| 2271 | Most software packages have a short list of other packages |
| 2272 | that they require, which are called dependencies. |
| 2273 | These dependencies fall into two main categories: build-time |
| 2274 | dependencies, which are required when the software is built; |
| 2275 | and runtime dependencies, which are required to be installed |
| 2276 | on the target in order for the software to run. |
| 2277 | </para> |
| 2278 | |
| 2279 | <para> |
| 2280 | Within a recipe, you specify build-time dependencies using the |
| 2281 | <ulink url='&YOCTO_DOCS_REF_URL;#var-DEPENDS'><filename>DEPENDS</filename></ulink> |
| 2282 | variable. |
| 2283 | Although nuances exist, items specified in |
| 2284 | <filename>DEPENDS</filename> should be names of other recipes. |
| 2285 | It is important that you specify all build-time dependencies |
| 2286 | explicitly. |
| 2287 | If you do not, due to the parallel nature of BitBake's |
| 2288 | execution, you can end up with a race condition where the |
| 2289 | dependency is present for one task of a recipe (e.g. |
| 2290 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-configure'><filename>do_configure</filename></ulink>) |
| 2291 | and then gone when the next task runs (e.g. |
| 2292 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-compile'><filename>do_compile</filename></ulink>). |
| 2293 | </para> |
| 2294 | |
| 2295 | <para> |
| 2296 | Another consideration is that configure scripts might |
| 2297 | automatically check for optional dependencies and enable |
| 2298 | corresponding functionality if those dependencies are found. |
| 2299 | This behavior means that to ensure deterministic results and |
| 2300 | thus avoid more race conditions, you need to either explicitly |
| 2301 | specify these dependencies as well, or tell the configure |
| 2302 | script explicitly to disable the functionality. |
| 2303 | If you wish to make a recipe that is more generally useful |
| 2304 | (e.g. publish the recipe in a layer for others to use), |
| 2305 | instead of hard-disabling the functionality, you can use the |
| 2306 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGECONFIG'><filename>PACKAGECONFIG</filename></ulink> |
| 2307 | variable to allow functionality and the corresponding |
| 2308 | dependencies to be enabled and disabled easily by other |
| 2309 | users of the recipe. |
| 2310 | </para> |
| 2311 | |
| 2312 | <para> |
| 2313 | Similar to build-time dependencies, you specify runtime |
| 2314 | dependencies through a variable - |
| 2315 | <ulink url='&YOCTO_DOCS_REF_URL;#var-RDEPENDS'><filename>RDEPENDS</filename></ulink>, |
| 2316 | which is package-specific. |
| 2317 | All variables that are package-specific need to have the name |
| 2318 | of the package added to the end as an override. |
| 2319 | Since the main package for a recipe has the same name as the |
| 2320 | recipe, and the recipe's name can be found through the |
| 2321 | <filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-PN'><filename>PN</filename></ulink><filename>}</filename> |
| 2322 | variable, then you specify the dependencies for the main |
| 2323 | package by setting <filename>RDEPENDS_${PN}</filename>. |
| 2324 | If the package were named <filename>${PN}-tools</filename>, |
| 2325 | then you would set <filename>RDEPENDS_${PN}-tools</filename>, |
| 2326 | and so forth. |
| 2327 | </para> |
| 2328 | |
| 2329 | <para> |
| 2330 | Some runtime dependencies will be set automatically at |
| 2331 | packaging time. |
| 2332 | These dependencies include any shared library dependencies |
| 2333 | (i.e. if a package "example" contains "libexample" and |
| 2334 | another package "mypackage" contains a binary that links to |
| 2335 | "libexample" then the OpenEmbedded build system will |
| 2336 | automatically add a runtime dependency to "mypackage" on |
| 2337 | "example"). |
| 2338 | See the |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 2339 | "<ulink url='&YOCTO_DOCS_OM_URL;#automatically-added-runtime-dependencies'>Automatically Added Runtime Dependencies</ulink>" |
| 2340 | section in the Yocto Project Overview and Concepts Manual for |
| 2341 | further details. |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 2342 | </para> |
| 2343 | </section> |
| 2344 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 2345 | <section id='new-recipe-configuring-the-recipe'> |
| 2346 | <title>Configuring the Recipe</title> |
| 2347 | |
| 2348 | <para> |
| 2349 | Most software provides some means of setting build-time |
| 2350 | configuration options before compilation. |
| 2351 | Typically, setting these options is accomplished by running a |
Brad Bishop | 64c979e | 2019-11-04 13:55:29 -0500 | [diff] [blame] | 2352 | configure script with options, or by modifying a build |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 2353 | configuration file. |
Patrick Williams | f1e5d69 | 2016-03-30 15:21:19 -0500 | [diff] [blame] | 2354 | <note> |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 2355 | As of Yocto Project Release 1.7, some of the core recipes |
Patrick Williams | f1e5d69 | 2016-03-30 15:21:19 -0500 | [diff] [blame] | 2356 | that package binary configuration scripts now disable the |
| 2357 | scripts due to the scripts previously requiring error-prone |
| 2358 | path substitution. |
| 2359 | The OpenEmbedded build system uses |
| 2360 | <filename>pkg-config</filename> now, which is much more |
| 2361 | robust. |
| 2362 | You can find a list of the <filename>*-config</filename> |
| 2363 | scripts that are disabled list in the |
| 2364 | "<ulink url='&YOCTO_DOCS_REF_URL;#migration-1.7-binary-configuration-scripts-disabled'>Binary Configuration Scripts Disabled</ulink>" |
| 2365 | section in the Yocto Project Reference Manual. |
| 2366 | </note> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 2367 | </para> |
| 2368 | |
| 2369 | <para> |
| 2370 | A major part of build-time configuration is about checking for |
| 2371 | build-time dependencies and possibly enabling optional |
| 2372 | functionality as a result. |
| 2373 | You need to specify any build-time dependencies for the |
| 2374 | software you are building in your recipe's |
| 2375 | <ulink url='&YOCTO_DOCS_REF_URL;#var-DEPENDS'><filename>DEPENDS</filename></ulink> |
| 2376 | value, in terms of other recipes that satisfy those |
| 2377 | dependencies. |
| 2378 | You can often find build-time or runtime |
| 2379 | dependencies described in the software's documentation. |
| 2380 | </para> |
| 2381 | |
| 2382 | <para> |
| 2383 | The following list provides configuration items of note based |
| 2384 | on how your software is built: |
| 2385 | <itemizedlist> |
| 2386 | <listitem><para><emphasis>Autotools:</emphasis> |
| 2387 | If your source files have a |
| 2388 | <filename>configure.ac</filename> file, then your |
| 2389 | software is built using Autotools. |
| 2390 | If this is the case, you just need to worry about |
| 2391 | modifying the configuration.</para> |
Brad Bishop | 64c979e | 2019-11-04 13:55:29 -0500 | [diff] [blame] | 2392 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 2393 | <para>When using Autotools, your recipe needs to inherit |
| 2394 | the |
| 2395 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-autotools'><filename>autotools</filename></ulink> |
| 2396 | class and your recipe does not have to contain a |
| 2397 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-configure'><filename>do_configure</filename></ulink> |
| 2398 | task. |
| 2399 | However, you might still want to make some adjustments. |
| 2400 | For example, you can set |
| 2401 | <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] | 2402 | or |
| 2403 | <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] | 2404 | to pass any needed configure options that are specific |
Brad Bishop | 64c979e | 2019-11-04 13:55:29 -0500 | [diff] [blame] | 2405 | to the recipe. |
| 2406 | </para></listitem> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 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> |
Brad Bishop | 64c979e | 2019-11-04 13:55:29 -0500 | [diff] [blame] | 2413 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 2414 | <para>When you use CMake, your recipe needs to inherit |
| 2415 | the |
| 2416 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-cmake'><filename>cmake</filename></ulink> |
| 2417 | class and your recipe does not have to contain a |
| 2418 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-configure'><filename>do_configure</filename></ulink> |
| 2419 | task. |
| 2420 | You can make some adjustments by setting |
| 2421 | <ulink url='&YOCTO_DOCS_REF_URL;#var-EXTRA_OECMAKE'><filename>EXTRA_OECMAKE</filename></ulink> |
| 2422 | to pass any needed configure options that are specific |
Brad Bishop | 64c979e | 2019-11-04 13:55:29 -0500 | [diff] [blame] | 2423 | to the recipe. |
| 2424 | <note> |
| 2425 | If you need to install one or more custom CMake |
| 2426 | toolchain files that are supplied by the |
| 2427 | application you are building, install the files to |
| 2428 | <filename>${D}${datadir}/cmake/</filename> Modules |
| 2429 | during |
| 2430 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-install'><filename>do_install</filename></ulink>. |
| 2431 | </note> |
| 2432 | </para></listitem> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 2433 | <listitem><para><emphasis>Other:</emphasis> |
| 2434 | If your source files do not have a |
| 2435 | <filename>configure.ac</filename> or |
| 2436 | <filename>CMakeLists.txt</filename> file, then your |
| 2437 | software is built using some method other than Autotools |
| 2438 | or CMake. |
| 2439 | If this is the case, you normally need to provide a |
| 2440 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-configure'><filename>do_configure</filename></ulink> |
| 2441 | task in your recipe |
| 2442 | unless, of course, there is nothing to configure. |
| 2443 | </para> |
| 2444 | <para>Even if your software is not being built by |
| 2445 | Autotools or CMake, you still might not need to deal |
| 2446 | with any configuration issues. |
| 2447 | You need to determine if configuration is even a required step. |
| 2448 | You might need to modify a Makefile or some configuration file |
| 2449 | used for the build to specify necessary build options. |
| 2450 | Or, perhaps you might need to run a provided, custom |
| 2451 | configure script with the appropriate options.</para> |
| 2452 | <para>For the case involving a custom configure |
| 2453 | script, you would run |
| 2454 | <filename>./configure --help</filename> and look for |
| 2455 | the options you need to set.</para></listitem> |
| 2456 | </itemizedlist> |
| 2457 | </para> |
| 2458 | |
| 2459 | <para> |
| 2460 | Once configuration succeeds, it is always good practice to |
| 2461 | look at the <filename>log.do_configure</filename> file to |
| 2462 | ensure that the appropriate options have been enabled and no |
| 2463 | additional build-time dependencies need to be added to |
| 2464 | <filename>DEPENDS</filename>. |
| 2465 | For example, if the configure script reports that it found |
| 2466 | something not mentioned in <filename>DEPENDS</filename>, or |
| 2467 | that it did not find something that it needed for some |
| 2468 | desired optional functionality, then you would need to add |
| 2469 | those to <filename>DEPENDS</filename>. |
| 2470 | Looking at the log might also reveal items being checked for, |
| 2471 | enabled, or both that you do not want, or items not being found |
| 2472 | that are in <filename>DEPENDS</filename>, in which case |
| 2473 | you would need to look at passing extra options to the |
| 2474 | configure script as needed. |
| 2475 | For reference information on configure options specific to the |
| 2476 | software you are building, you can consult the output of the |
| 2477 | <filename>./configure --help</filename> command within |
| 2478 | <filename>${S}</filename> or consult the software's upstream |
| 2479 | documentation. |
| 2480 | </para> |
| 2481 | </section> |
| 2482 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 2483 | <section id='new-recipe-using-headers-to-interface-with-devices'> |
| 2484 | <title>Using Headers to Interface with Devices</title> |
| 2485 | |
| 2486 | <para> |
| 2487 | If your recipe builds an application that needs to |
| 2488 | communicate with some device or needs an API into a custom |
| 2489 | kernel, you will need to provide appropriate header files. |
| 2490 | Under no circumstances should you ever modify the existing |
| 2491 | <filename>meta/recipes-kernel/linux-libc-headers/linux-libc-headers.inc</filename> |
| 2492 | file. |
| 2493 | These headers are used to build <filename>libc</filename> and |
| 2494 | must not be compromised with custom or machine-specific |
| 2495 | header information. |
| 2496 | If you customize <filename>libc</filename> through modified |
| 2497 | headers all other applications that use |
| 2498 | <filename>libc</filename> thus become affected. |
| 2499 | <note><title>Warning</title> |
| 2500 | Never copy and customize the <filename>libc</filename> |
| 2501 | header file (i.e. |
| 2502 | <filename>meta/recipes-kernel/linux-libc-headers/linux-libc-headers.inc</filename>). |
| 2503 | </note> |
| 2504 | The correct way to interface to a device or custom kernel is |
| 2505 | to use a separate package that provides the additional headers |
| 2506 | for the driver or other unique interfaces. |
| 2507 | When doing so, your application also becomes responsible for |
| 2508 | creating a dependency on that specific provider. |
| 2509 | </para> |
| 2510 | |
| 2511 | <para> |
| 2512 | Consider the following: |
| 2513 | <itemizedlist> |
| 2514 | <listitem><para> |
| 2515 | Never modify |
| 2516 | <filename>linux-libc-headers.inc</filename>. |
| 2517 | Consider that file to be part of the |
| 2518 | <filename>libc</filename> system, and not something |
| 2519 | you use to access the kernel directly. |
| 2520 | You should access <filename>libc</filename> through |
| 2521 | specific <filename>libc</filename> calls. |
| 2522 | </para></listitem> |
| 2523 | <listitem><para> |
| 2524 | Applications that must talk directly to devices |
| 2525 | should either provide necessary headers themselves, |
| 2526 | or establish a dependency on a special headers package |
| 2527 | that is specific to that driver. |
| 2528 | </para></listitem> |
| 2529 | </itemizedlist> |
| 2530 | </para> |
| 2531 | |
| 2532 | <para> |
| 2533 | For example, suppose you want to modify an existing header |
| 2534 | that adds I/O control or network support. |
| 2535 | If the modifications are used by a small number programs, |
| 2536 | providing a unique version of a header is easy and has little |
| 2537 | impact. |
| 2538 | When doing so, bear in mind the guidelines in the previous |
| 2539 | list. |
| 2540 | <note> |
| 2541 | If for some reason your changes need to modify the behavior |
| 2542 | of the <filename>libc</filename>, and subsequently all |
| 2543 | other applications on the system, use a |
| 2544 | <filename>.bbappend</filename> to modify the |
| 2545 | <filename>linux-kernel-headers.inc</filename> file. |
| 2546 | However, take care to not make the changes |
| 2547 | machine specific. |
| 2548 | </note> |
| 2549 | </para> |
| 2550 | |
| 2551 | <para> |
| 2552 | Consider a case where your kernel is older and you need |
| 2553 | an older <filename>libc</filename> ABI. |
| 2554 | The headers installed by your recipe should still be a |
| 2555 | standard mainline kernel, not your own custom one. |
| 2556 | </para> |
| 2557 | |
| 2558 | <para> |
| 2559 | When you use custom kernel headers you need to get them from |
| 2560 | <ulink url='&YOCTO_DOCS_REF_URL;#var-STAGING_KERNEL_DIR'><filename>STAGING_KERNEL_DIR</filename></ulink>, |
| 2561 | which is the directory with kernel headers that are |
| 2562 | required to build out-of-tree modules. |
| 2563 | Your recipe will also need the following: |
| 2564 | <literallayout class='monospaced'> |
| 2565 | do_configure[depends] += "virtual/kernel:do_shared_workdir" |
| 2566 | </literallayout> |
| 2567 | </para> |
| 2568 | </section> |
| 2569 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 2570 | <section id='new-recipe-compilation'> |
| 2571 | <title>Compilation</title> |
| 2572 | |
| 2573 | <para> |
| 2574 | During a build, the <filename>do_compile</filename> task |
| 2575 | happens after source is fetched, unpacked, and configured. |
| 2576 | If the recipe passes through <filename>do_compile</filename> |
| 2577 | successfully, nothing needs to be done. |
| 2578 | </para> |
| 2579 | |
| 2580 | <para> |
| 2581 | However, if the compile step fails, you need to diagnose the |
| 2582 | failure. |
Patrick Williams | f1e5d69 | 2016-03-30 15:21:19 -0500 | [diff] [blame] | 2583 | Here are some common issues that cause failures. |
| 2584 | <note> |
| 2585 | For cases where improper paths are detected for |
| 2586 | configuration files or for when libraries/headers cannot |
| 2587 | be found, be sure you are using the more robust |
| 2588 | <filename>pkg-config</filename>. |
| 2589 | See the note in section |
| 2590 | "<link linkend='new-recipe-configuring-the-recipe'>Configuring the Recipe</link>" |
| 2591 | for additional information. |
| 2592 | </note> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 2593 | <itemizedlist> |
| 2594 | <listitem><para><emphasis>Parallel build failures:</emphasis> |
| 2595 | These failures manifest themselves as intermittent |
| 2596 | errors, or errors reporting that a file or directory |
| 2597 | that should be created by some other part of the build |
| 2598 | process could not be found. |
| 2599 | This type of failure can occur even if, upon inspection, |
| 2600 | the file or directory does exist after the build has |
| 2601 | failed, because that part of the build process happened |
| 2602 | in the wrong order.</para> |
| 2603 | <para>To fix the problem, you need to either satisfy |
| 2604 | the missing dependency in the Makefile or whatever |
| 2605 | script produced the Makefile, or (as a workaround) |
| 2606 | set |
| 2607 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PARALLEL_MAKE'><filename>PARALLEL_MAKE</filename></ulink> |
| 2608 | to an empty string: |
| 2609 | <literallayout class='monospaced'> |
| 2610 | PARALLEL_MAKE = "" |
| 2611 | </literallayout></para> |
| 2612 | <para> |
| 2613 | For information on parallel Makefile issues, see the |
| 2614 | "<link linkend='debugging-parallel-make-races'>Debugging Parallel Make Races</link>" |
| 2615 | section. |
| 2616 | </para></listitem> |
| 2617 | <listitem><para><emphasis>Improper host path usage:</emphasis> |
| 2618 | This failure applies to recipes building for the target |
| 2619 | or <filename>nativesdk</filename> only. |
| 2620 | The failure occurs when the compilation process uses |
| 2621 | improper headers, libraries, or other files from the |
| 2622 | host system when cross-compiling for the target. |
| 2623 | </para> |
| 2624 | <para>To fix the problem, examine the |
| 2625 | <filename>log.do_compile</filename> file to identify |
| 2626 | the host paths being used (e.g. |
| 2627 | <filename>/usr/include</filename>, |
| 2628 | <filename>/usr/lib</filename>, and so forth) and then |
| 2629 | either add configure options, apply a patch, or do both. |
| 2630 | </para></listitem> |
| 2631 | <listitem><para><emphasis>Failure to find required |
| 2632 | libraries/headers:</emphasis> |
| 2633 | If a build-time dependency is missing because it has |
| 2634 | not been declared in |
| 2635 | <ulink url='&YOCTO_DOCS_REF_URL;#var-DEPENDS'><filename>DEPENDS</filename></ulink>, |
| 2636 | or because the dependency exists but the path used by |
| 2637 | the build process to find the file is incorrect and the |
| 2638 | configure step did not detect it, the compilation |
| 2639 | process could fail. |
| 2640 | For either of these failures, the compilation process |
| 2641 | notes that files could not be found. |
| 2642 | In these cases, you need to go back and add additional |
| 2643 | options to the configure script as well as possibly |
| 2644 | add additional build-time dependencies to |
| 2645 | <filename>DEPENDS</filename>.</para> |
| 2646 | <para>Occasionally, it is necessary to apply a patch |
| 2647 | to the source to ensure the correct paths are used. |
| 2648 | If you need to specify paths to find files staged |
| 2649 | into the sysroot from other recipes, use the variables |
| 2650 | that the OpenEmbedded build system provides |
| 2651 | (e.g. |
| 2652 | <filename>STAGING_BINDIR</filename>, |
| 2653 | <filename>STAGING_INCDIR</filename>, |
| 2654 | <filename>STAGING_DATADIR</filename>, and so forth). |
| 2655 | <!-- |
| 2656 | (e.g. |
| 2657 | <ulink url='&YOCTO_DOCS_REF_URL;#var-STAGING_BINDIR'><filename>STAGING_BINDIR</filename></ulink>, |
| 2658 | <ulink url='&YOCTO_DOCS_REF_URL;#var-STAGING_INCDIR'><filename>STAGING_INCDIR</filename></ulink>, |
| 2659 | <ulink url='&YOCTO_DOCS_REF_URL;#var-STAGING_DATADIR'><filename>STAGING_DATADIR</filename></ulink>, |
| 2660 | and so forth). |
| 2661 | --> |
| 2662 | </para></listitem> |
| 2663 | </itemizedlist> |
| 2664 | </para> |
| 2665 | </section> |
| 2666 | |
| 2667 | <section id='new-recipe-installing'> |
| 2668 | <title>Installing</title> |
| 2669 | |
| 2670 | <para> |
| 2671 | During <filename>do_install</filename>, the task copies the |
| 2672 | built files along with their hierarchy to locations that |
| 2673 | would mirror their locations on the target device. |
| 2674 | The installation process copies files from the |
| 2675 | <filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-S'><filename>S</filename></ulink><filename>}</filename>, |
| 2676 | <filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-B'><filename>B</filename></ulink><filename>}</filename>, |
| 2677 | and |
| 2678 | <filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-WORKDIR'><filename>WORKDIR</filename></ulink><filename>}</filename> |
| 2679 | directories to the |
| 2680 | <filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-D'><filename>D</filename></ulink><filename>}</filename> |
| 2681 | directory to create the structure as it should appear on the |
| 2682 | target system. |
| 2683 | </para> |
| 2684 | |
| 2685 | <para> |
| 2686 | How your software is built affects what you must do to be |
| 2687 | sure your software is installed correctly. |
| 2688 | The following list describes what you must do for installation |
| 2689 | depending on the type of build system used by the software |
| 2690 | being built: |
| 2691 | <itemizedlist> |
| 2692 | <listitem><para><emphasis>Autotools and CMake:</emphasis> |
| 2693 | If the software your recipe is building uses Autotools |
| 2694 | or CMake, the OpenEmbedded build |
| 2695 | system understands how to install the software. |
| 2696 | Consequently, you do not have to have a |
| 2697 | <filename>do_install</filename> task as part of your |
| 2698 | recipe. |
| 2699 | You just need to make sure the install portion of the |
| 2700 | build completes with no issues. |
| 2701 | However, if you wish to install additional files not |
| 2702 | already being installed by |
| 2703 | <filename>make install</filename>, you should do this |
| 2704 | using a <filename>do_install_append</filename> function |
| 2705 | using the install command as described in |
| 2706 | the "Manual" bulleted item later in this list. |
| 2707 | </para></listitem> |
| 2708 | <listitem><para><emphasis>Other (using |
| 2709 | <filename>make install</filename>):</emphasis> |
| 2710 | You need to define a |
| 2711 | <filename>do_install</filename> function in your |
| 2712 | recipe. |
| 2713 | The function should call |
| 2714 | <filename>oe_runmake install</filename> and will likely |
| 2715 | need to pass in the destination directory as well. |
| 2716 | How you pass that path is dependent on how the |
| 2717 | <filename>Makefile</filename> being run is written |
| 2718 | (e.g. <filename>DESTDIR=${D}</filename>, |
| 2719 | <filename>PREFIX=${D}</filename>, |
| 2720 | <filename>INSTALLROOT=${D}</filename>, and so forth). |
| 2721 | </para> |
| 2722 | <para>For an example recipe using |
| 2723 | <filename>make install</filename>, see the |
| 2724 | "<link linkend='new-recipe-makefile-based-package'>Makefile-Based Package</link>" |
| 2725 | section.</para></listitem> |
| 2726 | <listitem><para><emphasis>Manual:</emphasis> |
| 2727 | You need to define a |
| 2728 | <filename>do_install</filename> function in your |
| 2729 | recipe. |
| 2730 | The function must first use |
| 2731 | <filename>install -d</filename> to create the |
| 2732 | directories under |
| 2733 | <filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-D'><filename>D</filename></ulink><filename>}</filename>. |
| 2734 | Once the directories exist, your function can use |
| 2735 | <filename>install</filename> to manually install the |
| 2736 | built software into the directories.</para> |
| 2737 | <para>You can find more information on |
| 2738 | <filename>install</filename> at |
| 2739 | <ulink url='http://www.gnu.org/software/coreutils/manual/html_node/install-invocation.html'></ulink>. |
| 2740 | </para></listitem> |
| 2741 | </itemizedlist> |
| 2742 | </para> |
| 2743 | |
| 2744 | <para> |
| 2745 | For the scenarios that do not use Autotools or |
| 2746 | CMake, you need to track the installation |
| 2747 | and diagnose and fix any issues until everything installs |
| 2748 | correctly. |
| 2749 | You need to look in the default location of |
| 2750 | <filename>${D}</filename>, which is |
| 2751 | <filename>${WORKDIR}/image</filename>, to be sure your |
| 2752 | files have been installed correctly. |
| 2753 | </para> |
| 2754 | |
| 2755 | <note><title>Notes</title> |
| 2756 | <itemizedlist> |
| 2757 | <listitem><para> |
| 2758 | During the installation process, you might need to |
| 2759 | modify some of the installed files to suit the target |
| 2760 | layout. |
| 2761 | For example, you might need to replace hard-coded paths |
| 2762 | in an initscript with values of variables provided by |
| 2763 | the build system, such as replacing |
| 2764 | <filename>/usr/bin/</filename> with |
| 2765 | <filename>${bindir}</filename>. |
| 2766 | If you do perform such modifications during |
| 2767 | <filename>do_install</filename>, be sure to modify the |
| 2768 | destination file after copying rather than before |
| 2769 | copying. |
| 2770 | Modifying after copying ensures that the build system |
| 2771 | can re-execute <filename>do_install</filename> if |
| 2772 | needed. |
| 2773 | </para></listitem> |
| 2774 | <listitem><para> |
| 2775 | <filename>oe_runmake install</filename>, which can be |
| 2776 | run directly or can be run indirectly by the |
| 2777 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-autotools'><filename>autotools</filename></ulink> |
| 2778 | and |
| 2779 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-cmake'><filename>cmake</filename></ulink> |
| 2780 | classes, runs <filename>make install</filename> in |
| 2781 | parallel. |
| 2782 | Sometimes, a Makefile can have missing dependencies |
| 2783 | between targets that can result in race conditions. |
| 2784 | If you experience intermittent failures during |
| 2785 | <filename>do_install</filename>, you might be able to |
| 2786 | work around them by disabling parallel Makefile |
| 2787 | installs by adding the following to the recipe: |
| 2788 | <literallayout class='monospaced'> |
| 2789 | PARALLEL_MAKEINST = "" |
| 2790 | </literallayout> |
| 2791 | See |
| 2792 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PARALLEL_MAKEINST'><filename>PARALLEL_MAKEINST</filename></ulink> |
| 2793 | for additional information. |
| 2794 | </para></listitem> |
Brad Bishop | 64c979e | 2019-11-04 13:55:29 -0500 | [diff] [blame] | 2795 | <listitem><para> |
| 2796 | If you need to install one or more custom CMake |
| 2797 | toolchain files that are supplied by the |
| 2798 | application you are building, install the files to |
| 2799 | <filename>${D}${datadir}/cmake/</filename> Modules |
| 2800 | during |
| 2801 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-install'><filename>do_install</filename></ulink>. |
| 2802 | </para></listitem> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 2803 | </itemizedlist> |
| 2804 | </note> |
| 2805 | </section> |
| 2806 | |
| 2807 | <section id='new-recipe-enabling-system-services'> |
| 2808 | <title>Enabling System Services</title> |
| 2809 | |
| 2810 | <para> |
| 2811 | If you want to install a service, which is a process that |
| 2812 | usually starts on boot and runs in the background, then |
| 2813 | you must include some additional definitions in your recipe. |
| 2814 | </para> |
| 2815 | |
| 2816 | <para> |
| 2817 | If you are adding services and the service initialization |
| 2818 | script or the service file itself is not installed, you must |
| 2819 | provide for that installation in your recipe using a |
| 2820 | <filename>do_install_append</filename> function. |
| 2821 | If your recipe already has a <filename>do_install</filename> |
| 2822 | function, update the function near its end rather than |
| 2823 | adding an additional <filename>do_install_append</filename> |
| 2824 | function. |
| 2825 | </para> |
| 2826 | |
| 2827 | <para> |
| 2828 | When you create the installation for your services, you need |
| 2829 | to accomplish what is normally done by |
| 2830 | <filename>make install</filename>. |
| 2831 | In other words, make sure your installation arranges the output |
| 2832 | similar to how it is arranged on the target system. |
| 2833 | </para> |
| 2834 | |
| 2835 | <para> |
| 2836 | The OpenEmbedded build system provides support for starting |
| 2837 | services two different ways: |
| 2838 | <itemizedlist> |
| 2839 | <listitem><para><emphasis>SysVinit:</emphasis> |
| 2840 | SysVinit is a system and service manager that |
| 2841 | manages the init system used to control the very basic |
| 2842 | functions of your system. |
| 2843 | The init program is the first program |
| 2844 | started by the Linux kernel when the system boots. |
| 2845 | Init then controls the startup, running and shutdown |
| 2846 | of all other programs.</para> |
| 2847 | <para>To enable a service using SysVinit, your recipe |
| 2848 | needs to inherit the |
| 2849 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-update-rc.d'><filename>update-rc.d</filename></ulink> |
| 2850 | class. |
| 2851 | The class helps facilitate safely installing the |
| 2852 | package on the target.</para> |
| 2853 | <para>You will need to set the |
| 2854 | <ulink url='&YOCTO_DOCS_REF_URL;#var-INITSCRIPT_PACKAGES'><filename>INITSCRIPT_PACKAGES</filename></ulink>, |
| 2855 | <ulink url='&YOCTO_DOCS_REF_URL;#var-INITSCRIPT_NAME'><filename>INITSCRIPT_NAME</filename></ulink>, |
| 2856 | and |
| 2857 | <ulink url='&YOCTO_DOCS_REF_URL;#var-INITSCRIPT_PARAMS'><filename>INITSCRIPT_PARAMS</filename></ulink> |
| 2858 | variables within your recipe.</para></listitem> |
| 2859 | <listitem><para><emphasis>systemd:</emphasis> |
| 2860 | System Management Daemon (systemd) was designed to |
| 2861 | replace SysVinit and to provide |
| 2862 | enhanced management of services. |
| 2863 | For more information on systemd, see the systemd |
| 2864 | homepage at |
| 2865 | <ulink url='http://freedesktop.org/wiki/Software/systemd/'></ulink>. |
| 2866 | </para> |
| 2867 | <para>To enable a service using systemd, your recipe |
| 2868 | needs to inherit the |
| 2869 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-systemd'><filename>systemd</filename></ulink> |
| 2870 | class. |
| 2871 | See the <filename>systemd.bbclass</filename> file |
| 2872 | located in your |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 2873 | <ulink url='&YOCTO_DOCS_REF_URL;#source-directory'>Source Directory</ulink>. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 2874 | section for more information. |
| 2875 | </para></listitem> |
| 2876 | </itemizedlist> |
| 2877 | </para> |
| 2878 | </section> |
| 2879 | |
| 2880 | <section id='new-recipe-packaging'> |
| 2881 | <title>Packaging</title> |
| 2882 | |
| 2883 | <para> |
| 2884 | Successful packaging is a combination of automated processes |
| 2885 | performed by the OpenEmbedded build system and some |
| 2886 | specific steps you need to take. |
| 2887 | The following list describes the process: |
| 2888 | <itemizedlist> |
| 2889 | <listitem><para><emphasis>Splitting Files</emphasis>: |
| 2890 | The <filename>do_package</filename> task splits the |
| 2891 | files produced by the recipe into logical components. |
| 2892 | Even software that produces a single binary might |
| 2893 | still have debug symbols, documentation, and other |
| 2894 | logical components that should be split out. |
| 2895 | The <filename>do_package</filename> task ensures |
| 2896 | that files are split up and packaged correctly. |
| 2897 | </para></listitem> |
| 2898 | <listitem><para><emphasis>Running QA Checks</emphasis>: |
| 2899 | The |
| 2900 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-insane'><filename>insane</filename></ulink> |
| 2901 | class adds a step to |
| 2902 | the package generation process so that output quality |
| 2903 | assurance checks are generated by the OpenEmbedded |
| 2904 | build system. |
| 2905 | This step performs a range of checks to be sure the |
| 2906 | build's output is free of common problems that show |
| 2907 | up during runtime. |
| 2908 | For information on these checks, see the |
| 2909 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-insane'><filename>insane</filename></ulink> |
| 2910 | class and the |
| 2911 | "<ulink url='&YOCTO_DOCS_REF_URL;#ref-qa-checks'>QA Error and Warning Messages</ulink>" |
| 2912 | chapter in the Yocto Project Reference Manual. |
| 2913 | </para></listitem> |
| 2914 | <listitem><para><emphasis>Hand-Checking Your Packages</emphasis>: |
| 2915 | After you build your software, you need to be sure |
| 2916 | your packages are correct. |
| 2917 | Examine the |
| 2918 | <filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-WORKDIR'><filename>WORKDIR</filename></ulink><filename>}/packages-split</filename> |
| 2919 | directory and make sure files are where you expect |
| 2920 | them to be. |
| 2921 | If you discover problems, you can set |
| 2922 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGES'><filename>PACKAGES</filename></ulink>, |
| 2923 | <ulink url='&YOCTO_DOCS_REF_URL;#var-FILES'><filename>FILES</filename></ulink>, |
| 2924 | <filename>do_install(_append)</filename>, and so forth as |
| 2925 | needed. |
| 2926 | </para></listitem> |
| 2927 | <listitem><para><emphasis>Splitting an Application into Multiple Packages</emphasis>: |
| 2928 | If you need to split an application into several |
| 2929 | packages, see the |
| 2930 | "<link linkend='splitting-an-application-into-multiple-packages'>Splitting an Application into Multiple Packages</link>" |
| 2931 | section for an example. |
| 2932 | </para></listitem> |
| 2933 | <listitem><para><emphasis>Installing a Post-Installation Script</emphasis>: |
| 2934 | For an example showing how to install a |
| 2935 | post-installation script, see the |
| 2936 | "<link linkend='new-recipe-post-installation-scripts'>Post-Installation Scripts</link>" |
| 2937 | section. |
| 2938 | </para></listitem> |
| 2939 | <listitem><para><emphasis>Marking Package Architecture</emphasis>: |
| 2940 | Depending on what your recipe is building and how it |
| 2941 | is configured, it might be important to mark the |
| 2942 | packages produced as being specific to a particular |
| 2943 | machine, or to mark them as not being specific to |
Patrick Williams | f1e5d69 | 2016-03-30 15:21:19 -0500 | [diff] [blame] | 2944 | a particular machine or architecture at all.</para> |
| 2945 | <para>By default, packages apply to any machine with the |
| 2946 | same architecture as the target machine. |
| 2947 | When a recipe produces packages that are |
| 2948 | machine-specific (e.g. the |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 2949 | <ulink url='&YOCTO_DOCS_REF_URL;#var-MACHINE'><filename>MACHINE</filename></ulink> |
| 2950 | value is passed into the configure script or a patch |
Patrick Williams | f1e5d69 | 2016-03-30 15:21:19 -0500 | [diff] [blame] | 2951 | is applied only for a particular machine), you should |
| 2952 | mark them as such by adding the following to the |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 2953 | recipe: |
| 2954 | <literallayout class='monospaced'> |
| 2955 | PACKAGE_ARCH = "${MACHINE_ARCH}" |
Patrick Williams | f1e5d69 | 2016-03-30 15:21:19 -0500 | [diff] [blame] | 2956 | </literallayout></para> |
| 2957 | <para>On the other hand, if the recipe produces packages |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 2958 | that do not contain anything specific to the target |
| 2959 | machine or architecture at all (e.g. recipes |
| 2960 | that simply package script files or configuration |
| 2961 | files), you should use the |
| 2962 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-allarch'><filename>allarch</filename></ulink> |
| 2963 | class to do this for you by adding this to your |
| 2964 | recipe: |
| 2965 | <literallayout class='monospaced'> |
| 2966 | inherit allarch |
| 2967 | </literallayout> |
| 2968 | Ensuring that the package architecture is correct is |
| 2969 | not critical while you are doing the first few builds |
| 2970 | of your recipe. |
| 2971 | However, it is important in order |
| 2972 | to ensure that your recipe rebuilds (or does not |
| 2973 | rebuild) appropriately in response to changes in |
| 2974 | configuration, and to ensure that you get the |
| 2975 | appropriate packages installed on the target machine, |
| 2976 | particularly if you run separate builds for more |
| 2977 | than one target machine. |
| 2978 | </para></listitem> |
| 2979 | </itemizedlist> |
| 2980 | </para> |
| 2981 | </section> |
| 2982 | |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 2983 | <section id='new-sharing-files-between-recipes'> |
| 2984 | <title>Sharing Files Between Recipes</title> |
| 2985 | |
| 2986 | <para> |
| 2987 | Recipes often need to use files provided by other recipes on |
| 2988 | the build host. |
| 2989 | For example, an application linking to a common library needs |
| 2990 | access to the library itself and its associated headers. |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 2991 | The way this access is accomplished is by populating a sysroot |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 2992 | with files. |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 2993 | Each recipe has two sysroots in its work directory, one for |
| 2994 | target files |
| 2995 | (<filename>recipe-sysroot</filename>) and one for files that |
| 2996 | are native to the build host |
| 2997 | (<filename>recipe-sysroot-native</filename>). |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 2998 | <note> |
| 2999 | You could find the term "staging" used within the Yocto |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 3000 | project regarding files populating sysroots (e.g. the |
Brad Bishop | 37a0e4d | 2017-12-04 01:01:44 -0500 | [diff] [blame] | 3001 | <ulink url='&YOCTO_DOCS_REF_URL;#var-STAGING_DIR'><filename>STAGING_DIR</filename></ulink> |
| 3002 | variable). |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 3003 | </note> |
| 3004 | </para> |
| 3005 | |
| 3006 | <para> |
| 3007 | Recipes should never populate the sysroot directly (i.e. write |
| 3008 | files into sysroot). |
| 3009 | Instead, files should be installed into standard locations |
| 3010 | during the |
| 3011 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-install'><filename>do_install</filename></ulink> |
| 3012 | task within the |
| 3013 | <filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-D'><filename>D</filename></ulink><filename>}</filename> |
| 3014 | directory. |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 3015 | The reason for this limitation is that almost all files that |
| 3016 | populate the sysroot are cataloged in manifests in order to |
| 3017 | ensure the files can be removed later when a recipe is either |
| 3018 | modified or removed. |
| 3019 | Thus, the sysroot is able to remain free from stale files. |
| 3020 | </para> |
| 3021 | |
| 3022 | <para> |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 3023 | A subset of the files installed by the |
| 3024 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-install'><filename>do_install</filename></ulink> |
| 3025 | task are used by the |
| 3026 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-populate_sysroot'><filename>do_populate_sysroot</filename></ulink> |
| 3027 | task as defined by the the |
| 3028 | <ulink url='&YOCTO_DOCS_REF_URL;#var-SYSROOT_DIRS'><filename>SYSROOT_DIRS</filename></ulink> |
| 3029 | variable to automatically populate the sysroot. |
Brad Bishop | 37a0e4d | 2017-12-04 01:01:44 -0500 | [diff] [blame] | 3030 | It is possible to modify the list of directories that populate |
| 3031 | the sysroot. |
| 3032 | The following example shows how you could add the |
| 3033 | <filename>/opt</filename> directory to the list of |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 3034 | directories within a recipe: |
Brad Bishop | 37a0e4d | 2017-12-04 01:01:44 -0500 | [diff] [blame] | 3035 | <literallayout class='monospaced'> |
| 3036 | SYSROOT_DIRS += "/opt" |
| 3037 | </literallayout> |
| 3038 | </para> |
| 3039 | |
| 3040 | <para> |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 3041 | For a more complete description of the |
| 3042 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-populate_sysroot'><filename>do_populate_sysroot</filename></ulink> |
| 3043 | task and its associated functions, see the |
| 3044 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-staging'><filename>staging</filename></ulink> |
| 3045 | class. |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 3046 | </para> |
| 3047 | </section> |
| 3048 | |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 3049 | <section id='metadata-virtual-providers'> |
| 3050 | <title>Using Virtual Providers</title> |
| 3051 | |
| 3052 | <para> |
| 3053 | Prior to a build, if you know that several different recipes |
| 3054 | provide the same functionality, you can use a virtual provider |
| 3055 | (i.e. <filename>virtual/*</filename>) as a placeholder for the |
| 3056 | actual provider. |
| 3057 | The actual provider is determined at build-time. |
| 3058 | </para> |
| 3059 | |
| 3060 | <para> |
| 3061 | A common scenario where a virtual provider is used would be |
| 3062 | for the kernel recipe. |
| 3063 | Suppose you have three kernel recipes whose |
| 3064 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PN'><filename>PN</filename></ulink> |
| 3065 | values map to <filename>kernel-big</filename>, |
| 3066 | <filename>kernel-mid</filename>, and |
| 3067 | <filename>kernel-small</filename>. |
| 3068 | Furthermore, each of these recipes in some way uses a |
| 3069 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PROVIDES'><filename>PROVIDES</filename></ulink> |
| 3070 | statement that essentially identifies itself as being able |
| 3071 | to provide <filename>virtual/kernel</filename>. |
| 3072 | Here is one way through the |
| 3073 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-kernel'><filename>kernel</filename></ulink> |
| 3074 | class: |
| 3075 | <literallayout class='monospaced'> |
| 3076 | PROVIDES += "${@ "virtual/kernel" if (d.getVar("KERNEL_PACKAGE_NAME") == "kernel") else "" }" |
| 3077 | </literallayout> |
| 3078 | Any recipe that inherits the <filename>kernel</filename> class |
| 3079 | is going to utilize a <filename>PROVIDES</filename> statement |
| 3080 | that identifies that recipe as being able to provide the |
| 3081 | <filename>virtual/kernel</filename> item. |
| 3082 | </para> |
| 3083 | |
| 3084 | <para> |
| 3085 | Now comes the time to actually build an image and you need a |
| 3086 | kernel recipe, but which one? |
| 3087 | You can configure your build to call out the kernel recipe |
| 3088 | you want by using the |
| 3089 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PREFERRED_PROVIDER'><filename>PREFERRED_PROVIDER</filename></ulink> |
| 3090 | variable. |
| 3091 | As an example, consider the |
| 3092 | <ulink url='https://git.yoctoproject.org/cgit/cgit.cgi/poky/tree/meta/conf/machine/include/x86-base.inc'><filename>x86-base.inc</filename></ulink> |
| 3093 | include file, which is a machine |
| 3094 | (i.e. <ulink url='&YOCTO_DOCS_REF_URL;#var-MACHINE'><filename>MACHINE</filename></ulink>) |
| 3095 | configuration file. |
| 3096 | This include file is the reason all x86-based machines use the |
| 3097 | <filename>linux-yocto</filename> kernel. |
| 3098 | Here are the relevant lines from the include file: |
| 3099 | <literallayout class='monospaced'> |
| 3100 | PREFERRED_PROVIDER_virtual/kernel ??= "linux-yocto" |
| 3101 | PREFERRED_VERSION_linux-yocto ??= "4.15%" |
| 3102 | </literallayout> |
| 3103 | </para> |
| 3104 | |
| 3105 | <para> |
| 3106 | When you use a virtual provider, you do not have to |
| 3107 | "hard code" a recipe name as a build dependency. |
| 3108 | You can use the |
| 3109 | <ulink url='&YOCTO_DOCS_REF_URL;#var-DEPENDS'><filename>DEPENDS</filename></ulink> |
| 3110 | variable to state the build is dependent on |
| 3111 | <filename>virtual/kernel</filename> for example: |
| 3112 | <literallayout class='monospaced'> |
| 3113 | DEPENDS = "virtual/kernel" |
| 3114 | </literallayout> |
| 3115 | During the build, the OpenEmbedded build system picks |
| 3116 | the correct recipe needed for the |
| 3117 | <filename>virtual/kernel</filename> dependency based on the |
| 3118 | <filename>PREFERRED_PROVIDER</filename> variable. |
| 3119 | If you want to use the small kernel mentioned at the beginning |
| 3120 | of this section, configure your build as follows: |
| 3121 | <literallayout class='monospaced'> |
| 3122 | PREFERRED_PROVIDER_virtual/kernel ??= "kernel-small" |
| 3123 | </literallayout> |
| 3124 | <note> |
| 3125 | Any recipe that |
| 3126 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PROVIDES'><filename>PROVIDES</filename></ulink> |
| 3127 | a <filename>virtual/*</filename> item that is ultimately |
| 3128 | not selected through |
| 3129 | <filename>PREFERRED_PROVIDER</filename> does not get built. |
| 3130 | Preventing these recipes from building is usually the |
| 3131 | desired behavior since this mechanism's purpose is to |
| 3132 | select between mutually exclusive alternative providers. |
| 3133 | </note> |
| 3134 | </para> |
| 3135 | |
| 3136 | <para> |
| 3137 | The following lists specific examples of virtual providers: |
| 3138 | <itemizedlist> |
| 3139 | <listitem><para> |
| 3140 | <filename>virtual/kernel</filename>: |
| 3141 | Provides the name of the kernel recipe to use when |
| 3142 | building a kernel image. |
| 3143 | </para></listitem> |
| 3144 | <listitem><para> |
| 3145 | <filename>virtual/bootloader</filename>: |
| 3146 | Provides the name of the bootloader to use when |
| 3147 | building an image. |
| 3148 | </para></listitem> |
| 3149 | <listitem><para> |
| 3150 | <filename>virtual/mesa</filename>: |
| 3151 | Provides <filename>gbm.pc</filename>. |
| 3152 | </para></listitem> |
| 3153 | <listitem><para> |
| 3154 | <filename>virtual/egl</filename>: |
| 3155 | Provides <filename>egl.pc</filename> and possibly |
| 3156 | <filename>wayland-egl.pc</filename>. |
| 3157 | </para></listitem> |
| 3158 | <listitem><para> |
| 3159 | <filename>virtual/libgl</filename>: |
| 3160 | Provides <filename>gl.pc</filename> (i.e. libGL). |
| 3161 | </para></listitem> |
| 3162 | <listitem><para> |
| 3163 | <filename>virtual/libgles1</filename>: |
| 3164 | Provides <filename>glesv1_cm.pc</filename> |
| 3165 | (i.e. libGLESv1_CM). |
| 3166 | </para></listitem> |
| 3167 | <listitem><para> |
| 3168 | <filename>virtual/libgles2</filename>: |
| 3169 | Provides <filename>glesv2.pc</filename> |
| 3170 | (i.e. libGLESv2). |
| 3171 | </para></listitem> |
| 3172 | </itemizedlist> |
| 3173 | </para> |
| 3174 | </section> |
| 3175 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 3176 | <section id='properly-versioning-pre-release-recipes'> |
| 3177 | <title>Properly Versioning Pre-Release Recipes</title> |
| 3178 | |
| 3179 | <para> |
| 3180 | Sometimes the name of a recipe can lead to versioning |
| 3181 | problems when the recipe is upgraded to a final release. |
| 3182 | For example, consider the |
| 3183 | <filename>irssi_0.8.16-rc1.bb</filename> recipe file in |
| 3184 | the list of example recipes in the |
| 3185 | "<link linkend='new-recipe-storing-and-naming-the-recipe'>Storing and Naming the Recipe</link>" |
| 3186 | section. |
| 3187 | This recipe is at a release candidate stage (i.e. |
| 3188 | "rc1"). |
| 3189 | When the recipe is released, the recipe filename becomes |
| 3190 | <filename>irssi_0.8.16.bb</filename>. |
| 3191 | The version change from <filename>0.8.16-rc1</filename> |
| 3192 | to <filename>0.8.16</filename> is seen as a decrease by the |
| 3193 | build system and package managers, so the resulting packages |
| 3194 | will not correctly trigger an upgrade. |
| 3195 | </para> |
| 3196 | |
| 3197 | <para> |
| 3198 | In order to ensure the versions compare properly, the |
| 3199 | recommended convention is to set |
| 3200 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PV'><filename>PV</filename></ulink> |
| 3201 | within the recipe to |
| 3202 | "<replaceable>previous_version</replaceable>+<replaceable>current_version</replaceable>". |
| 3203 | You can use an additional variable so that you can use the |
| 3204 | current version elsewhere. |
| 3205 | Here is an example: |
| 3206 | <literallayout class='monospaced'> |
| 3207 | REALPV = "0.8.16-rc1" |
| 3208 | PV = "0.8.15+${REALPV}" |
| 3209 | </literallayout> |
| 3210 | </para> |
| 3211 | </section> |
| 3212 | |
| 3213 | <section id='new-recipe-post-installation-scripts'> |
| 3214 | <title>Post-Installation Scripts</title> |
| 3215 | |
| 3216 | <para> |
| 3217 | Post-installation scripts run immediately after installing |
| 3218 | a package on the target or during image creation when a |
| 3219 | package is included in an image. |
| 3220 | To add a post-installation script to a package, add a |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 3221 | <filename>pkg_postinst_</filename><replaceable>PACKAGENAME</replaceable><filename>()</filename> function to |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 3222 | the recipe file (<filename>.bb</filename>) and replace |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 3223 | <replaceable>PACKAGENAME</replaceable> with the name of the package |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 3224 | you want to attach to the <filename>postinst</filename> |
| 3225 | script. |
| 3226 | To apply the post-installation script to the main package |
| 3227 | for the recipe, which is usually what is required, specify |
| 3228 | <filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-PN'><filename>PN</filename></ulink><filename>}</filename> |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 3229 | in place of <replaceable>PACKAGENAME</replaceable>. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 3230 | </para> |
| 3231 | |
| 3232 | <para> |
| 3233 | A post-installation function has the following structure: |
| 3234 | <literallayout class='monospaced'> |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 3235 | pkg_postinst_<replaceable>PACKAGENAME</replaceable>() { |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 3236 | # Commands to carry out |
| 3237 | } |
| 3238 | </literallayout> |
| 3239 | </para> |
| 3240 | |
| 3241 | <para> |
| 3242 | The script defined in the post-installation function is |
| 3243 | called when the root filesystem is created. |
| 3244 | If the script succeeds, the package is marked as installed. |
| 3245 | If the script fails, the package is marked as unpacked and |
| 3246 | the script is executed when the image boots again. |
Brad Bishop | 37a0e4d | 2017-12-04 01:01:44 -0500 | [diff] [blame] | 3247 | <note> |
| 3248 | Any RPM post-installation script that runs on the target |
| 3249 | should return a 0 exit code. |
| 3250 | RPM does not allow non-zero exit codes for these scripts, |
| 3251 | and the RPM package manager will cause the package to fail |
| 3252 | installation on the target. |
| 3253 | </note> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 3254 | </para> |
| 3255 | |
| 3256 | <para> |
| 3257 | Sometimes it is necessary for the execution of a |
| 3258 | post-installation script to be delayed until the first boot. |
| 3259 | For example, the script might need to be executed on the |
| 3260 | device itself. |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 3261 | To delay script execution until boot time, you must explicitly |
| 3262 | mark post installs to defer to the target. |
| 3263 | You can use <filename>pkg_postinst_ontarget()</filename> or |
| 3264 | call |
| 3265 | <filename>postinst-intercepts defer_to_first_boot</filename> |
| 3266 | from <filename>pkg_postinst()</filename>. |
| 3267 | Any failure of a <filename>pkg_postinst()</filename> script |
| 3268 | (including exit 1) triggers an error during the |
| 3269 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-rootfs'><filename>do_rootfs</filename></ulink> |
| 3270 | task. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 3271 | </para> |
| 3272 | |
| 3273 | <para> |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 3274 | If you have recipes that use |
| 3275 | <filename>pkg_postinst</filename> function |
| 3276 | and they require the use of non-standard native |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 3277 | tools that have dependencies during rootfs construction, you |
| 3278 | need to use the |
| 3279 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_WRITE_DEPS'><filename>PACKAGE_WRITE_DEPS</filename></ulink> |
| 3280 | variable in your recipe to list these tools. |
| 3281 | If you do not use this variable, the tools might be missing and |
| 3282 | execution of the post-installation script is deferred until |
| 3283 | first boot. |
| 3284 | Deferring the script to first boot is undesirable and for |
| 3285 | read-only rootfs impossible. |
| 3286 | </para> |
| 3287 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 3288 | <note> |
| 3289 | Equivalent support for pre-install, pre-uninstall, and |
| 3290 | post-uninstall scripts exist by way of |
| 3291 | <filename>pkg_preinst</filename>, |
| 3292 | <filename>pkg_prerm</filename>, and |
| 3293 | <filename>pkg_postrm</filename>, respectively. |
| 3294 | These scrips work in exactly the same way as does |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 3295 | <filename>pkg_postinst</filename> with the exception |
| 3296 | that they run at different times. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 3297 | Also, because of when they run, they are not applicable to |
| 3298 | being run at image creation time like |
| 3299 | <filename>pkg_postinst</filename>. |
| 3300 | </note> |
| 3301 | </section> |
| 3302 | |
| 3303 | <section id='new-recipe-testing'> |
| 3304 | <title>Testing</title> |
| 3305 | |
| 3306 | <para> |
| 3307 | The final step for completing your recipe is to be sure that |
| 3308 | the software you built runs correctly. |
| 3309 | To accomplish runtime testing, add the build's output |
| 3310 | packages to your image and test them on the target. |
| 3311 | </para> |
| 3312 | |
| 3313 | <para> |
| 3314 | For information on how to customize your image by adding |
| 3315 | specific packages, see the |
| 3316 | "<link linkend='usingpoky-extend-customimage'>Customizing Images</link>" |
| 3317 | section. |
| 3318 | </para> |
| 3319 | </section> |
| 3320 | |
| 3321 | <section id='new-recipe-testing-examples'> |
| 3322 | <title>Examples</title> |
| 3323 | |
| 3324 | <para> |
| 3325 | To help summarize how to write a recipe, this section provides |
| 3326 | some examples given various scenarios: |
| 3327 | <itemizedlist> |
| 3328 | <listitem><para>Recipes that use local files</para></listitem> |
| 3329 | <listitem><para>Using an Autotooled package</para></listitem> |
| 3330 | <listitem><para>Using a Makefile-based package</para></listitem> |
| 3331 | <listitem><para>Splitting an application into multiple packages</para></listitem> |
| 3332 | <listitem><para>Adding binaries to an image</para></listitem> |
| 3333 | </itemizedlist> |
| 3334 | </para> |
| 3335 | |
| 3336 | <section id='new-recipe-single-c-file-package-hello-world'> |
| 3337 | <title>Single .c File Package (Hello World!)</title> |
| 3338 | |
| 3339 | <para> |
| 3340 | Building an application from a single file that is stored |
| 3341 | locally (e.g. under <filename>files</filename>) requires |
| 3342 | a recipe that has the file listed in the |
| 3343 | <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'>SRC_URI</ulink></filename> |
| 3344 | variable. |
| 3345 | Additionally, you need to manually write the |
| 3346 | <filename>do_compile</filename> and |
| 3347 | <filename>do_install</filename> tasks. |
| 3348 | The <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-S'>S</ulink></filename> |
| 3349 | variable defines the directory containing the source code, |
| 3350 | which is set to |
| 3351 | <ulink url='&YOCTO_DOCS_REF_URL;#var-WORKDIR'><filename>WORKDIR</filename></ulink> |
| 3352 | in this case - the directory BitBake uses for the build. |
| 3353 | <literallayout class='monospaced'> |
| 3354 | SUMMARY = "Simple helloworld application" |
| 3355 | SECTION = "examples" |
| 3356 | LICENSE = "MIT" |
| 3357 | LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302" |
| 3358 | |
| 3359 | SRC_URI = "file://helloworld.c" |
| 3360 | |
| 3361 | S = "${WORKDIR}" |
| 3362 | |
| 3363 | do_compile() { |
| 3364 | ${CC} helloworld.c -o helloworld |
| 3365 | } |
| 3366 | |
| 3367 | do_install() { |
| 3368 | install -d ${D}${bindir} |
| 3369 | install -m 0755 helloworld ${D}${bindir} |
| 3370 | } |
| 3371 | </literallayout> |
| 3372 | </para> |
| 3373 | |
| 3374 | <para> |
| 3375 | By default, the <filename>helloworld</filename>, |
| 3376 | <filename>helloworld-dbg</filename>, and |
| 3377 | <filename>helloworld-dev</filename> packages are built. |
| 3378 | For information on how to customize the packaging process, |
| 3379 | see the |
| 3380 | "<link linkend='splitting-an-application-into-multiple-packages'>Splitting an Application into Multiple Packages</link>" |
| 3381 | section. |
| 3382 | </para> |
| 3383 | </section> |
| 3384 | |
| 3385 | <section id='new-recipe-autotooled-package'> |
| 3386 | <title>Autotooled Package</title> |
| 3387 | <para> |
| 3388 | Applications that use Autotools such as <filename>autoconf</filename> and |
| 3389 | <filename>automake</filename> require a recipe that has a source archive listed in |
| 3390 | <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'>SRC_URI</ulink></filename> and |
| 3391 | also inherit the |
| 3392 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-autotools'><filename>autotools</filename></ulink> |
| 3393 | class, which contains the definitions of all the steps |
| 3394 | needed to build an Autotool-based application. |
| 3395 | The result of the build is automatically packaged. |
| 3396 | And, if the application uses NLS for localization, packages with local information are |
| 3397 | generated (one package per language). |
| 3398 | Following is one example: (<filename>hello_2.3.bb</filename>) |
| 3399 | <literallayout class='monospaced'> |
| 3400 | SUMMARY = "GNU Helloworld application" |
| 3401 | SECTION = "examples" |
| 3402 | LICENSE = "GPLv2+" |
| 3403 | LIC_FILES_CHKSUM = "file://COPYING;md5=751419260aa954499f7abaabaa882bbe" |
| 3404 | |
| 3405 | SRC_URI = "${GNU_MIRROR}/hello/hello-${PV}.tar.gz" |
| 3406 | |
| 3407 | inherit autotools gettext |
| 3408 | </literallayout> |
| 3409 | </para> |
| 3410 | |
| 3411 | <para> |
| 3412 | The variable |
| 3413 | <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-LIC_FILES_CHKSUM'>LIC_FILES_CHKSUM</ulink></filename> |
| 3414 | is used to track source license changes as described in the |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 3415 | "<link linkend='usingpoky-configuring-LIC_FILES_CHKSUM'>Tracking License Changes</link>" |
| 3416 | section in the Yocto Project Overview and Concepts Manual. |
| 3417 | You can quickly create Autotool-based recipes in a manner |
| 3418 | similar to the previous example. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 3419 | </para> |
| 3420 | </section> |
| 3421 | |
| 3422 | <section id='new-recipe-makefile-based-package'> |
| 3423 | <title>Makefile-Based Package</title> |
| 3424 | |
| 3425 | <para> |
| 3426 | Applications that use GNU <filename>make</filename> also require a recipe that has |
| 3427 | the source archive listed in |
| 3428 | <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'>SRC_URI</ulink></filename>. |
| 3429 | You do not need to add a <filename>do_compile</filename> step since by default BitBake |
| 3430 | starts the <filename>make</filename> command to compile the application. |
| 3431 | 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] | 3432 | <ulink url='&YOCTO_DOCS_REF_URL;#var-EXTRA_OEMAKE'><filename>EXTRA_OEMAKE</filename></ulink> |
| 3433 | or |
| 3434 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGECONFIG_CONFARGS'><filename>PACKAGECONFIG_CONFARGS</filename></ulink> |
| 3435 | variables. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 3436 | BitBake passes these options into the GNU <filename>make</filename> invocation. |
| 3437 | Note that a <filename>do_install</filename> task is still required. |
| 3438 | Otherwise, BitBake runs an empty <filename>do_install</filename> task by default. |
| 3439 | </para> |
| 3440 | |
| 3441 | <para> |
| 3442 | Some applications might require extra parameters to be passed to the compiler. |
| 3443 | For example, the application might need an additional header path. |
| 3444 | You can accomplish this by adding to the |
| 3445 | <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-CFLAGS'>CFLAGS</ulink></filename> variable. |
| 3446 | The following example shows this: |
| 3447 | <literallayout class='monospaced'> |
| 3448 | CFLAGS_prepend = "-I ${S}/include " |
| 3449 | </literallayout> |
| 3450 | </para> |
| 3451 | |
| 3452 | <para> |
| 3453 | In the following example, <filename>mtd-utils</filename> is a makefile-based package: |
| 3454 | <literallayout class='monospaced'> |
| 3455 | SUMMARY = "Tools for managing memory technology devices" |
| 3456 | SECTION = "base" |
| 3457 | DEPENDS = "zlib lzo e2fsprogs util-linux" |
| 3458 | HOMEPAGE = "http://www.linux-mtd.infradead.org/" |
| 3459 | LICENSE = "GPLv2+" |
| 3460 | LIC_FILES_CHKSUM = "file://COPYING;md5=0636e73ff0215e8d672dc4c32c317bb3 \ |
| 3461 | file://include/common.h;beginline=1;endline=17;md5=ba05b07912a44ea2bf81ce409380049c" |
| 3462 | |
| 3463 | # Use the latest version at 26 Oct, 2013 |
| 3464 | SRCREV = "9f107132a6a073cce37434ca9cda6917dd8d866b" |
| 3465 | SRC_URI = "git://git.infradead.org/mtd-utils.git \ |
| 3466 | file://add-exclusion-to-mkfs-jffs2-git-2.patch \ |
| 3467 | " |
| 3468 | |
| 3469 | PV = "1.5.1+git${SRCPV}" |
| 3470 | |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 3471 | S = "${WORKDIR}/git" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 3472 | |
| 3473 | EXTRA_OEMAKE = "'CC=${CC}' 'RANLIB=${RANLIB}' 'AR=${AR}' 'CFLAGS=${CFLAGS} -I${S}/include -DWITHOUT_XATTR' 'BUILDDIR=${S}'" |
| 3474 | |
| 3475 | do_install () { |
| 3476 | oe_runmake install DESTDIR=${D} SBINDIR=${sbindir} MANDIR=${mandir} INCLUDEDIR=${includedir} |
| 3477 | } |
| 3478 | |
| 3479 | PACKAGES =+ "mtd-utils-jffs2 mtd-utils-ubifs mtd-utils-misc" |
| 3480 | |
| 3481 | FILES_mtd-utils-jffs2 = "${sbindir}/mkfs.jffs2 ${sbindir}/jffs2dump ${sbindir}/jffs2reader ${sbindir}/sumtool" |
| 3482 | FILES_mtd-utils-ubifs = "${sbindir}/mkfs.ubifs ${sbindir}/ubi*" |
| 3483 | FILES_mtd-utils-misc = "${sbindir}/nftl* ${sbindir}/ftl* ${sbindir}/rfd* ${sbindir}/doc* ${sbindir}/serve_image ${sbindir}/recv_image" |
| 3484 | |
| 3485 | PARALLEL_MAKE = "" |
| 3486 | |
| 3487 | BBCLASSEXTEND = "native" |
| 3488 | </literallayout> |
| 3489 | </para> |
| 3490 | </section> |
| 3491 | |
| 3492 | <section id='splitting-an-application-into-multiple-packages'> |
| 3493 | <title>Splitting an Application into Multiple Packages</title> |
| 3494 | |
| 3495 | <para> |
| 3496 | You can use the variables |
| 3497 | <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGES'>PACKAGES</ulink></filename> and |
| 3498 | <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-FILES'>FILES</ulink></filename> |
| 3499 | to split an application into multiple packages. |
| 3500 | </para> |
| 3501 | |
| 3502 | <para> |
| 3503 | Following is an example that uses the <filename>libxpm</filename> recipe. |
| 3504 | By default, this recipe generates a single package that contains the library along |
| 3505 | with a few binaries. |
| 3506 | You can modify the recipe to split the binaries into separate packages: |
| 3507 | <literallayout class='monospaced'> |
| 3508 | require xorg-lib-common.inc |
| 3509 | |
| 3510 | SUMMARY = "Xpm: X Pixmap extension library" |
| 3511 | LICENSE = "BSD" |
| 3512 | LIC_FILES_CHKSUM = "file://COPYING;md5=51f4270b012ecd4ab1a164f5f4ed6cf7" |
| 3513 | DEPENDS += "libxext libsm libxt" |
| 3514 | PE = "1" |
| 3515 | |
| 3516 | XORG_PN = "libXpm" |
| 3517 | |
| 3518 | PACKAGES =+ "sxpm cxpm" |
| 3519 | FILES_cxpm = "${bindir}/cxpm" |
| 3520 | FILES_sxpm = "${bindir}/sxpm" |
| 3521 | </literallayout> |
| 3522 | </para> |
| 3523 | |
| 3524 | <para> |
| 3525 | In the previous example, we want to ship the <filename>sxpm</filename> |
| 3526 | and <filename>cxpm</filename> binaries in separate packages. |
| 3527 | Since <filename>bindir</filename> would be packaged into the main |
| 3528 | <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-PN'>PN</ulink></filename> |
| 3529 | package by default, we prepend the <filename>PACKAGES</filename> |
| 3530 | variable so additional package names are added to the start of list. |
| 3531 | This results in the extra <filename>FILES_*</filename> |
| 3532 | variables then containing information that define which files and |
| 3533 | directories go into which packages. |
| 3534 | Files included by earlier packages are skipped by latter packages. |
| 3535 | Thus, the main <filename>PN</filename> package |
| 3536 | does not include the above listed files. |
| 3537 | </para> |
| 3538 | </section> |
| 3539 | |
| 3540 | <section id='packaging-externally-produced-binaries'> |
| 3541 | <title>Packaging Externally Produced Binaries</title> |
| 3542 | |
| 3543 | <para> |
| 3544 | Sometimes, you need to add pre-compiled binaries to an |
| 3545 | image. |
| 3546 | For example, suppose that binaries for proprietary code |
| 3547 | exist, which are created by a particular division of a |
| 3548 | company. |
| 3549 | Your part of the company needs to use those binaries as |
| 3550 | part of an image that you are building using the |
| 3551 | OpenEmbedded build system. |
| 3552 | Since you only have the binaries and not the source code, |
| 3553 | you cannot use a typical recipe that expects to fetch the |
| 3554 | source specified in |
| 3555 | <ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'><filename>SRC_URI</filename></ulink> |
| 3556 | and then compile it. |
| 3557 | </para> |
| 3558 | |
| 3559 | <para> |
| 3560 | One method is to package the binaries and then install them |
| 3561 | as part of the image. |
| 3562 | Generally, it is not a good idea to package binaries |
| 3563 | since, among other things, it can hinder the ability to |
| 3564 | reproduce builds and could lead to compatibility problems |
| 3565 | with ABI in the future. |
| 3566 | However, sometimes you have no choice. |
| 3567 | </para> |
| 3568 | |
| 3569 | <para> |
| 3570 | The easiest solution is to create a recipe that uses |
| 3571 | the |
| 3572 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-bin-package'><filename>bin_package</filename></ulink> |
| 3573 | class and to be sure that you are using default locations |
| 3574 | for build artifacts. |
| 3575 | In most cases, the <filename>bin_package</filename> class |
| 3576 | handles "skipping" the configure and compile steps as well |
| 3577 | as sets things up to grab packages from the appropriate |
| 3578 | area. |
| 3579 | In particular, this class sets <filename>noexec</filename> |
| 3580 | on both the |
| 3581 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-configure'><filename>do_configure</filename></ulink> |
| 3582 | and |
| 3583 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-compile'><filename>do_compile</filename></ulink> |
| 3584 | tasks, sets |
| 3585 | <filename>FILES_${PN}</filename> to "/" so that it picks |
| 3586 | up all files, and sets up a |
| 3587 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-install'><filename>do_install</filename></ulink> |
| 3588 | task, which effectively copies all files from |
| 3589 | <filename>${S}</filename> to <filename>${D}</filename>. |
| 3590 | The <filename>bin_package</filename> class works well when |
| 3591 | the files extracted into <filename>${S}</filename> are |
| 3592 | already laid out in the way they should be laid out |
| 3593 | on the target. |
| 3594 | For more information on these variables, see the |
| 3595 | <ulink url='&YOCTO_DOCS_REF_URL;#var-FILES'><filename>FILES</filename></ulink>, |
| 3596 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PN'><filename>PN</filename></ulink>, |
| 3597 | <ulink url='&YOCTO_DOCS_REF_URL;#var-S'><filename>S</filename></ulink>, |
| 3598 | and |
| 3599 | <ulink url='&YOCTO_DOCS_REF_URL;#var-D'><filename>D</filename></ulink> |
| 3600 | variables in the Yocto Project Reference Manual's variable |
| 3601 | glossary. |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 3602 | <note><title>Notes</title> |
| 3603 | <itemizedlist> |
| 3604 | <listitem><para> |
| 3605 | Using |
| 3606 | <ulink url='&YOCTO_DOCS_REF_URL;#var-DEPENDS'><filename>DEPENDS</filename></ulink> |
| 3607 | is a good idea even for components distributed |
| 3608 | in binary form, and is often necessary for |
| 3609 | shared libraries. |
| 3610 | For a shared library, listing the library |
| 3611 | dependencies in |
| 3612 | <filename>DEPENDS</filename> makes sure that |
| 3613 | the libraries are available in the staging |
| 3614 | sysroot when other recipes link against the |
| 3615 | library, which might be necessary for |
| 3616 | successful linking. |
| 3617 | </para></listitem> |
| 3618 | <listitem><para> |
| 3619 | Using <filename>DEPENDS</filename> also |
| 3620 | allows runtime dependencies between packages |
| 3621 | to be added automatically. |
| 3622 | See the |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 3623 | "<ulink url='&YOCTO_DOCS_OM_URL;#automatically-added-runtime-dependencies'>Automatically Added Runtime Dependencies</ulink>" |
| 3624 | section in the Yocto Project Overview and |
| 3625 | Concepts Manual for more information. |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 3626 | </para></listitem> |
| 3627 | </itemizedlist> |
| 3628 | </note> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 3629 | </para> |
| 3630 | |
| 3631 | <para> |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 3632 | If you cannot use the <filename>bin_package</filename> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 3633 | class, you need to be sure you are doing the following: |
| 3634 | <itemizedlist> |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 3635 | <listitem><para> |
| 3636 | Create a recipe where the |
| 3637 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-configure'><filename>do_configure</filename></ulink> |
| 3638 | and |
| 3639 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-compile'><filename>do_compile</filename></ulink> |
| 3640 | tasks do nothing: |
| 3641 | It is usually sufficient to just not define these |
| 3642 | tasks in the recipe, because the default |
| 3643 | implementations do nothing unless a Makefile is |
| 3644 | found in |
| 3645 | <filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-S'><filename>S</filename></ulink><filename>}</filename>. |
| 3646 | </para> |
| 3647 | |
| 3648 | <para>If |
| 3649 | <filename>${S}</filename> might contain a Makefile, |
| 3650 | or if you inherit some class that replaces |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 3651 | <filename>do_configure</filename> and |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 3652 | <filename>do_compile</filename> with custom |
| 3653 | versions, then you can use the |
| 3654 | <filename>[</filename><ulink url='&YOCTO_DOCS_BB_URL;#variable-flags'><filename>noexec</filename></ulink><filename>]</filename> |
| 3655 | flag to turn the tasks into no-ops, as follows: |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 3656 | <literallayout class='monospaced'> |
| 3657 | do_configure[noexec] = "1" |
| 3658 | do_compile[noexec] = "1" |
| 3659 | </literallayout> |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 3660 | Unlike |
| 3661 | <ulink url='&YOCTO_DOCS_BB_URL;#deleting-a-task'><filename>deleting the tasks</filename></ulink>, |
| 3662 | using the flag preserves the dependency chain from |
| 3663 | the |
| 3664 | <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>, |
| 3665 | and |
| 3666 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-patch'><filename>do_patch</filename></ulink> |
| 3667 | tasks to the |
| 3668 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-install'><filename>do_install</filename></ulink> |
| 3669 | task. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 3670 | </para></listitem> |
| 3671 | <listitem><para>Make sure your |
| 3672 | <filename>do_install</filename> task installs the |
| 3673 | binaries appropriately. |
| 3674 | </para></listitem> |
| 3675 | <listitem><para>Ensure that you set up |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 3676 | <ulink url='&YOCTO_DOCS_REF_URL;#var-FILES'><filename>FILES</filename></ulink> |
| 3677 | (usually |
| 3678 | <filename>FILES_${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-PN'><filename>PN</filename></ulink><filename>}</filename>) |
| 3679 | to point to the files you have installed, which of |
| 3680 | course depends on where you have installed them |
| 3681 | and whether those files are in different locations |
| 3682 | than the defaults. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 3683 | </para></listitem> |
| 3684 | </itemizedlist> |
| 3685 | </para> |
| 3686 | </section> |
| 3687 | </section> |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 3688 | |
| 3689 | <section id="following-recipe-style-guidelines"> |
| 3690 | <title>Following Recipe Style Guidelines</title> |
| 3691 | |
| 3692 | <para> |
| 3693 | When writing recipes, it is good to conform to existing |
| 3694 | style guidelines. |
| 3695 | The |
| 3696 | <ulink url='http://www.openembedded.org/wiki/Styleguide'>OpenEmbedded Styleguide</ulink> |
| 3697 | wiki page provides rough guidelines for preferred recipe style. |
| 3698 | </para> |
| 3699 | |
| 3700 | <para> |
| 3701 | It is common for existing recipes to deviate a bit from this |
| 3702 | style. |
| 3703 | However, aiming for at least a consistent style is a good idea. |
| 3704 | Some practices, such as omitting spaces around |
| 3705 | <filename>=</filename> operators in assignments or ordering |
| 3706 | recipe components in an erratic way, are widely seen as poor |
| 3707 | style. |
| 3708 | </para> |
| 3709 | </section> |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 3710 | |
| 3711 | <section id='recipe-syntax'> |
| 3712 | <title>Recipe Syntax</title> |
| 3713 | |
| 3714 | <para> |
| 3715 | Understanding recipe file syntax is important for writing |
| 3716 | recipes. |
| 3717 | The following list overviews the basic items that make up a |
| 3718 | BitBake recipe file. |
| 3719 | For more complete BitBake syntax descriptions, see the |
| 3720 | "<ulink url='&YOCTO_DOCS_BB_URL;#bitbake-user-manual-metadata'>Syntax and Operators</ulink>" |
| 3721 | chapter of the BitBake User Manual. |
| 3722 | <itemizedlist> |
| 3723 | <listitem><para> |
| 3724 | <emphasis>Variable Assignments and Manipulations:</emphasis> |
| 3725 | Variable assignments allow a value to be assigned to a |
| 3726 | variable. |
| 3727 | The assignment can be static text or might include |
| 3728 | the contents of other variables. |
| 3729 | In addition to the assignment, appending and prepending |
| 3730 | operations are also supported.</para> |
| 3731 | |
| 3732 | <para>The following example shows some of the ways |
| 3733 | you can use variables in recipes: |
| 3734 | <literallayout class='monospaced'> |
| 3735 | S = "${WORKDIR}/postfix-${PV}" |
| 3736 | CFLAGS += "-DNO_ASM" |
| 3737 | SRC_URI_append = " file://fixup.patch" |
| 3738 | </literallayout> |
| 3739 | </para></listitem> |
| 3740 | <listitem><para> |
| 3741 | <emphasis>Functions:</emphasis> |
| 3742 | Functions provide a series of actions to be performed. |
| 3743 | You usually use functions to override the default |
| 3744 | implementation of a task function or to complement |
| 3745 | a default function (i.e. append or prepend to an |
| 3746 | existing function). |
| 3747 | Standard functions use <filename>sh</filename> shell |
| 3748 | syntax, although access to OpenEmbedded variables and |
| 3749 | internal methods are also available.</para> |
| 3750 | |
| 3751 | <para>The following is an example function from the |
| 3752 | <filename>sed</filename> recipe: |
| 3753 | <literallayout class='monospaced'> |
| 3754 | do_install () { |
| 3755 | autotools_do_install |
| 3756 | install -d ${D}${base_bindir} |
| 3757 | mv ${D}${bindir}/sed ${D}${base_bindir}/sed |
| 3758 | rmdir ${D}${bindir}/ |
| 3759 | } |
| 3760 | </literallayout> |
| 3761 | It is also possible to implement new functions that |
| 3762 | are called between existing tasks as long as the |
| 3763 | new functions are not replacing or complementing the |
| 3764 | default functions. |
| 3765 | You can implement functions in Python |
| 3766 | instead of shell. |
| 3767 | Both of these options are not seen in the majority of |
| 3768 | recipes. |
| 3769 | </para></listitem> |
| 3770 | <listitem><para><emphasis>Keywords:</emphasis> |
| 3771 | BitBake recipes use only a few keywords. |
| 3772 | You use keywords to include common |
| 3773 | functions (<filename>inherit</filename>), load parts |
| 3774 | of a recipe from other files |
| 3775 | (<filename>include</filename> and |
| 3776 | <filename>require</filename>) and export variables |
| 3777 | to the environment (<filename>export</filename>). |
| 3778 | </para> |
| 3779 | |
| 3780 | <para>The following example shows the use of some of |
| 3781 | these keywords: |
| 3782 | <literallayout class='monospaced'> |
| 3783 | export POSTCONF = "${STAGING_BINDIR}/postconf" |
| 3784 | inherit autoconf |
| 3785 | require otherfile.inc |
| 3786 | </literallayout> |
| 3787 | </para></listitem> |
| 3788 | <listitem><para> |
| 3789 | <emphasis>Comments (#):</emphasis> |
| 3790 | Any lines that begin with the hash character |
| 3791 | (<filename>#</filename>) are treated as comment lines |
| 3792 | and are ignored: |
| 3793 | <literallayout class='monospaced'> |
| 3794 | # This is a comment |
| 3795 | </literallayout> |
| 3796 | </para></listitem> |
| 3797 | </itemizedlist> |
| 3798 | </para> |
| 3799 | |
| 3800 | <para> |
| 3801 | This next list summarizes the most important and most commonly |
| 3802 | used parts of the recipe syntax. |
| 3803 | For more information on these parts of the syntax, you can |
| 3804 | reference the |
| 3805 | <ulink url='&YOCTO_DOCS_BB_URL;#bitbake-user-manual-metadata'>Syntax and Operators</ulink> |
| 3806 | chapter in the BitBake User Manual. |
| 3807 | <itemizedlist> |
| 3808 | <listitem><para> |
| 3809 | <emphasis>Line Continuation (\):</emphasis> |
| 3810 | Use the backward slash (<filename>\</filename>) |
| 3811 | character to split a statement over multiple lines. |
| 3812 | Place the slash character at the end of the line that |
| 3813 | is to be continued on the next line: |
| 3814 | <literallayout class='monospaced'> |
| 3815 | VAR = "A really long \ |
| 3816 | line" |
| 3817 | </literallayout> |
| 3818 | <note> |
| 3819 | You cannot have any characters including spaces |
| 3820 | or tabs after the slash character. |
| 3821 | </note> |
| 3822 | </para></listitem> |
| 3823 | <listitem><para> |
| 3824 | <emphasis>Using Variables (${<replaceable>VARNAME</replaceable>}):</emphasis> |
| 3825 | Use the <filename>${<replaceable>VARNAME</replaceable>}</filename> |
| 3826 | syntax to access the contents of a variable: |
| 3827 | <literallayout class='monospaced'> |
| 3828 | SRC_URI = "${SOURCEFORGE_MIRROR}/libpng/zlib-${PV}.tar.gz" |
| 3829 | </literallayout> |
| 3830 | <note> |
| 3831 | It is important to understand that the value of a |
| 3832 | variable expressed in this form does not get |
| 3833 | substituted automatically. |
| 3834 | The expansion of these expressions happens |
| 3835 | on-demand later (e.g. usually when a function that |
| 3836 | makes reference to the variable executes). |
| 3837 | This behavior ensures that the values are most |
| 3838 | appropriate for the context in which they are |
| 3839 | finally used. |
| 3840 | On the rare occasion that you do need the variable |
| 3841 | expression to be expanded immediately, you can use |
| 3842 | the <filename>:=</filename> operator instead of |
| 3843 | <filename>=</filename> when you make the |
| 3844 | assignment, but this is not generally needed. |
| 3845 | </note> |
| 3846 | </para></listitem> |
| 3847 | <listitem><para> |
| 3848 | <emphasis>Quote All Assignments ("<replaceable>value</replaceable>"):</emphasis> |
| 3849 | Use double quotes around values in all variable |
| 3850 | assignments (e.g. |
| 3851 | <filename>"<replaceable>value</replaceable>"</filename>). |
| 3852 | Following is an example: |
| 3853 | <literallayout class='monospaced'> |
| 3854 | VAR1 = "${OTHERVAR}" |
| 3855 | VAR2 = "The version is ${PV}" |
| 3856 | </literallayout> |
| 3857 | </para></listitem> |
| 3858 | <listitem><para> |
| 3859 | <emphasis>Conditional Assignment (?=):</emphasis> |
| 3860 | Conditional assignment is used to assign a |
| 3861 | value to a variable, but only when the variable is |
| 3862 | currently unset. |
| 3863 | Use the question mark followed by the equal sign |
| 3864 | (<filename>?=</filename>) to make a "soft" assignment |
| 3865 | used for conditional assignment. |
| 3866 | Typically, "soft" assignments are used in the |
| 3867 | <filename>local.conf</filename> file for variables |
| 3868 | that are allowed to come through from the external |
| 3869 | environment. |
| 3870 | </para> |
| 3871 | |
| 3872 | <para>Here is an example where |
| 3873 | <filename>VAR1</filename> is set to "New value" if |
| 3874 | it is currently empty. |
| 3875 | However, if <filename>VAR1</filename> has already been |
| 3876 | set, it remains unchanged: |
| 3877 | <literallayout class='monospaced'> |
| 3878 | VAR1 ?= "New value" |
| 3879 | </literallayout> |
| 3880 | In this next example, <filename>VAR1</filename> |
| 3881 | is left with the value "Original value": |
| 3882 | <literallayout class='monospaced'> |
| 3883 | VAR1 = "Original value" |
| 3884 | VAR1 ?= "New value" |
| 3885 | </literallayout> |
| 3886 | </para></listitem> |
| 3887 | <listitem><para> |
| 3888 | <emphasis>Appending (+=):</emphasis> |
| 3889 | Use the plus character followed by the equals sign |
| 3890 | (<filename>+=</filename>) to append values to existing |
| 3891 | variables. |
| 3892 | <note> |
| 3893 | This operator adds a space between the existing |
| 3894 | content of the variable and the new content. |
| 3895 | </note></para> |
| 3896 | |
| 3897 | <para>Here is an example: |
| 3898 | <literallayout class='monospaced'> |
| 3899 | SRC_URI += "file://fix-makefile.patch" |
| 3900 | </literallayout> |
| 3901 | </para></listitem> |
| 3902 | <listitem><para> |
| 3903 | <emphasis>Prepending (=+):</emphasis> |
| 3904 | Use the equals sign followed by the plus character |
| 3905 | (<filename>=+</filename>) to prepend values to existing |
| 3906 | variables. |
| 3907 | <note> |
| 3908 | This operator adds a space between the new content |
| 3909 | and the existing content of the variable. |
| 3910 | </note></para> |
| 3911 | |
| 3912 | <para>Here is an example: |
| 3913 | <literallayout class='monospaced'> |
| 3914 | VAR =+ "Starts" |
| 3915 | </literallayout> |
| 3916 | </para></listitem> |
| 3917 | <listitem><para> |
| 3918 | <emphasis>Appending (_append):</emphasis> |
| 3919 | Use the <filename>_append</filename> operator to |
| 3920 | append values to existing variables. |
| 3921 | This operator does not add any additional space. |
| 3922 | Also, the operator is applied after all the |
| 3923 | <filename>+=</filename>, and |
| 3924 | <filename>=+</filename> operators have been applied and |
| 3925 | after all <filename>=</filename> assignments have |
| 3926 | occurred. |
| 3927 | </para> |
| 3928 | |
| 3929 | <para>The following example shows the space being |
| 3930 | explicitly added to the start to ensure the appended |
| 3931 | value is not merged with the existing value: |
| 3932 | <literallayout class='monospaced'> |
| 3933 | SRC_URI_append = " file://fix-makefile.patch" |
| 3934 | </literallayout> |
| 3935 | You can also use the <filename>_append</filename> |
| 3936 | operator with overrides, which results in the actions |
| 3937 | only being performed for the specified target or |
| 3938 | machine: |
| 3939 | <literallayout class='monospaced'> |
| 3940 | SRC_URI_append_sh4 = " file://fix-makefile.patch" |
| 3941 | </literallayout> |
| 3942 | </para></listitem> |
| 3943 | <listitem><para> |
| 3944 | <emphasis>Prepending (_prepend):</emphasis> |
| 3945 | Use the <filename>_prepend</filename> operator to |
| 3946 | prepend values to existing variables. |
| 3947 | This operator does not add any additional space. |
| 3948 | Also, the operator is applied after all the |
| 3949 | <filename>+=</filename>, and |
| 3950 | <filename>=+</filename> operators have been applied and |
| 3951 | after all <filename>=</filename> assignments have |
| 3952 | occurred. |
| 3953 | </para> |
| 3954 | |
| 3955 | <para>The following example shows the space being |
| 3956 | explicitly added to the end to ensure the prepended |
| 3957 | value is not merged with the existing value: |
| 3958 | <literallayout class='monospaced'> |
| 3959 | CFLAGS_prepend = "-I${S}/myincludes " |
| 3960 | </literallayout> |
| 3961 | You can also use the <filename>_prepend</filename> |
| 3962 | operator with overrides, which results in the actions |
| 3963 | only being performed for the specified target or |
| 3964 | machine: |
| 3965 | <literallayout class='monospaced'> |
| 3966 | CFLAGS_prepend_sh4 = "-I${S}/myincludes " |
| 3967 | </literallayout> |
| 3968 | </para></listitem> |
| 3969 | <listitem><para> |
| 3970 | <emphasis>Overrides:</emphasis> |
| 3971 | You can use overrides to set a value conditionally, |
| 3972 | typically based on how the recipe is being built. |
| 3973 | For example, to set the |
| 3974 | <ulink url='&YOCTO_DOCS_REF_URL;#var-KBRANCH'><filename>KBRANCH</filename></ulink> |
| 3975 | variable's value to "standard/base" for any target |
| 3976 | <ulink url='&YOCTO_DOCS_REF_URL;#var-MACHINE'><filename>MACHINE</filename></ulink>, |
| 3977 | except for qemuarm where it should be set to |
| 3978 | "standard/arm-versatile-926ejs", you would do the |
| 3979 | following: |
| 3980 | <literallayout class='monospaced'> |
| 3981 | KBRANCH = "standard/base" |
| 3982 | KBRANCH_qemuarm = "standard/arm-versatile-926ejs" |
| 3983 | </literallayout> |
| 3984 | Overrides are also used to separate alternate values |
| 3985 | of a variable in other situations. |
| 3986 | For example, when setting variables such as |
| 3987 | <ulink url='&YOCTO_DOCS_REF_URL;#var-FILES'><filename>FILES</filename></ulink> |
| 3988 | and |
| 3989 | <ulink url='&YOCTO_DOCS_REF_URL;#var-RDEPENDS'><filename>RDEPENDS</filename></ulink> |
| 3990 | that are specific to individual packages produced by |
| 3991 | a recipe, you should always use an override that |
| 3992 | specifies the name of the package. |
| 3993 | </para></listitem> |
| 3994 | <listitem><para> |
| 3995 | <emphasis>Indentation:</emphasis> |
| 3996 | Use spaces for indentation rather than than tabs. |
| 3997 | For shell functions, both currently work. |
| 3998 | However, it is a policy decision of the Yocto Project |
| 3999 | to use tabs in shell functions. |
| 4000 | Realize that some layers have a policy to use spaces |
| 4001 | for all indentation. |
| 4002 | </para></listitem> |
| 4003 | <listitem><para> |
| 4004 | <emphasis>Using Python for Complex Operations:</emphasis> |
| 4005 | For more advanced processing, it is possible to use |
| 4006 | Python code during variable assignments (e.g. |
| 4007 | search and replacement on a variable).</para> |
| 4008 | |
| 4009 | <para>You indicate Python code using the |
| 4010 | <filename>${@<replaceable>python_code</replaceable>}</filename> |
| 4011 | syntax for the variable assignment: |
| 4012 | <literallayout class='monospaced'> |
| 4013 | SRC_URI = "ftp://ftp.info-zip.org/pub/infozip/src/zip${@d.getVar('PV',1).replace('.', '')}.tgz |
| 4014 | </literallayout> |
| 4015 | </para></listitem> |
| 4016 | <listitem><para> |
| 4017 | <emphasis>Shell Function Syntax:</emphasis> |
| 4018 | Write shell functions as if you were writing a shell |
| 4019 | script when you describe a list of actions to take. |
| 4020 | You should ensure that your script works with a generic |
| 4021 | <filename>sh</filename> and that it does not require |
| 4022 | any <filename>bash</filename> or other shell-specific |
| 4023 | functionality. |
| 4024 | The same considerations apply to various system |
| 4025 | utilities (e.g. <filename>sed</filename>, |
| 4026 | <filename>grep</filename>, <filename>awk</filename>, |
| 4027 | and so forth) that you might wish to use. |
| 4028 | If in doubt, you should check with multiple |
| 4029 | implementations - including those from BusyBox. |
| 4030 | </para></listitem> |
| 4031 | </itemizedlist> |
| 4032 | </para> |
| 4033 | </section> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 4034 | </section> |
| 4035 | |
| 4036 | <section id="platdev-newmachine"> |
| 4037 | <title>Adding a New Machine</title> |
| 4038 | |
| 4039 | <para> |
| 4040 | Adding a new machine to the Yocto Project is a straightforward |
| 4041 | process. |
| 4042 | This section describes how to add machines that are similar |
| 4043 | to those that the Yocto Project already supports. |
| 4044 | <note> |
| 4045 | Although well within the capabilities of the Yocto Project, |
| 4046 | adding a totally new architecture might require |
| 4047 | changes to <filename>gcc/glibc</filename> and to the site |
| 4048 | information, which is beyond the scope of this manual. |
| 4049 | </note> |
| 4050 | </para> |
| 4051 | |
| 4052 | <para> |
| 4053 | For a complete example that shows how to add a new machine, |
| 4054 | see the |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 4055 | "<ulink url='&YOCTO_DOCS_BSP_URL;#creating-a-new-bsp-layer-using-the-bitbake-layers-script'>Creating a New BSP Layer Using the <filename>bitbake-layers</filename> Script</ulink>" |
| 4056 | section in the Yocto Project Board Support Package (BSP) |
| 4057 | Developer's Guide. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 4058 | </para> |
| 4059 | |
| 4060 | <section id="platdev-newmachine-conffile"> |
| 4061 | <title>Adding the Machine Configuration File</title> |
| 4062 | |
| 4063 | <para> |
| 4064 | To add a new machine, you need to add a new machine |
| 4065 | configuration file to the layer's |
| 4066 | <filename>conf/machine</filename> directory. |
| 4067 | This configuration file provides details about the device |
| 4068 | you are adding. |
| 4069 | </para> |
| 4070 | |
| 4071 | <para> |
| 4072 | The OpenEmbedded build system uses the root name of the |
| 4073 | machine configuration file to reference the new machine. |
| 4074 | For example, given a machine configuration file named |
| 4075 | <filename>crownbay.conf</filename>, the build system |
| 4076 | recognizes the machine as "crownbay". |
| 4077 | </para> |
| 4078 | |
| 4079 | <para> |
| 4080 | The most important variables you must set in your machine |
| 4081 | configuration file or include from a lower-level configuration |
| 4082 | file are as follows: |
| 4083 | <itemizedlist> |
| 4084 | <listitem><para><filename><ulink url='&YOCTO_DOCS_REF_URL;#var-TARGET_ARCH'>TARGET_ARCH</ulink></filename> |
| 4085 | (e.g. "arm")</para></listitem> |
| 4086 | <listitem><para><filename><ulink url='&YOCTO_DOCS_REF_URL;#var-PREFERRED_PROVIDER'>PREFERRED_PROVIDER</ulink>_virtual/kernel</filename> |
| 4087 | </para></listitem> |
| 4088 | <listitem><para><filename><ulink url='&YOCTO_DOCS_REF_URL;#var-MACHINE_FEATURES'>MACHINE_FEATURES</ulink></filename> |
| 4089 | (e.g. "apm screen wifi")</para></listitem> |
| 4090 | </itemizedlist> |
| 4091 | </para> |
| 4092 | |
| 4093 | <para> |
| 4094 | You might also need these variables: |
| 4095 | <itemizedlist> |
| 4096 | <listitem><para><filename><ulink url='&YOCTO_DOCS_REF_URL;#var-SERIAL_CONSOLES'>SERIAL_CONSOLES</ulink></filename> |
| 4097 | (e.g. "115200;ttyS0 115200;ttyS1")</para></listitem> |
| 4098 | <listitem><para><filename><ulink url='&YOCTO_DOCS_REF_URL;#var-KERNEL_IMAGETYPE'>KERNEL_IMAGETYPE</ulink></filename> |
| 4099 | (e.g. "zImage")</para></listitem> |
| 4100 | <listitem><para><filename><ulink url='&YOCTO_DOCS_REF_URL;#var-IMAGE_FSTYPES'>IMAGE_FSTYPES</ulink></filename> |
| 4101 | (e.g. "tar.gz jffs2")</para></listitem> |
| 4102 | </itemizedlist> |
| 4103 | </para> |
| 4104 | |
| 4105 | <para> |
| 4106 | You can find full details on these variables in the reference |
| 4107 | section. |
| 4108 | You can leverage existing machine <filename>.conf</filename> |
| 4109 | files from <filename>meta-yocto-bsp/conf/machine/</filename>. |
| 4110 | </para> |
| 4111 | </section> |
| 4112 | |
| 4113 | <section id="platdev-newmachine-kernel"> |
| 4114 | <title>Adding a Kernel for the Machine</title> |
| 4115 | |
| 4116 | <para> |
| 4117 | The OpenEmbedded build system needs to be able to build a kernel |
| 4118 | for the machine. |
| 4119 | You need to either create a new kernel recipe for this machine, |
| 4120 | or extend an existing kernel recipe. |
| 4121 | You can find several kernel recipe examples in the |
| 4122 | Source Directory at |
| 4123 | <filename>meta/recipes-kernel/linux</filename> |
| 4124 | that you can use as references. |
| 4125 | </para> |
| 4126 | |
| 4127 | <para> |
| 4128 | If you are creating a new kernel recipe, normal recipe-writing |
| 4129 | rules apply for setting up a |
| 4130 | <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'>SRC_URI</ulink></filename>. |
| 4131 | Thus, you need to specify any necessary patches and set |
| 4132 | <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-S'>S</ulink></filename> |
| 4133 | to point at the source code. |
| 4134 | You need to create a <filename>do_configure</filename> task that |
| 4135 | configures the unpacked kernel with a |
| 4136 | <filename>defconfig</filename> file. |
| 4137 | You can do this by using a <filename>make defconfig</filename> |
| 4138 | command or, more commonly, by copying in a suitable |
| 4139 | <filename>defconfig</filename> file and then running |
| 4140 | <filename>make oldconfig</filename>. |
| 4141 | By making use of <filename>inherit kernel</filename> and |
| 4142 | potentially some of the <filename>linux-*.inc</filename> files, |
| 4143 | most other functionality is centralized and the defaults of the |
| 4144 | class normally work well. |
| 4145 | </para> |
| 4146 | |
| 4147 | <para> |
| 4148 | If you are extending an existing kernel recipe, it is usually |
| 4149 | a matter of adding a suitable <filename>defconfig</filename> |
| 4150 | file. |
| 4151 | The file needs to be added into a location similar to |
| 4152 | <filename>defconfig</filename> files used for other machines |
| 4153 | in a given kernel recipe. |
| 4154 | A possible way to do this is by listing the file in the |
| 4155 | <filename>SRC_URI</filename> and adding the machine to the |
| 4156 | expression in |
| 4157 | <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-COMPATIBLE_MACHINE'>COMPATIBLE_MACHINE</ulink></filename>: |
| 4158 | <literallayout class='monospaced'> |
| 4159 | COMPATIBLE_MACHINE = '(qemux86|qemumips)' |
| 4160 | </literallayout> |
| 4161 | For more information on <filename>defconfig</filename> files, |
| 4162 | see the |
| 4163 | "<ulink url='&YOCTO_DOCS_KERNEL_DEV_URL;#changing-the-configuration'>Changing the Configuration</ulink>" |
| 4164 | section in the Yocto Project Linux Kernel Development Manual. |
| 4165 | </para> |
| 4166 | </section> |
| 4167 | |
| 4168 | <section id="platdev-newmachine-formfactor"> |
| 4169 | <title>Adding a Formfactor Configuration File</title> |
| 4170 | |
| 4171 | <para> |
| 4172 | A formfactor configuration file provides information about the |
| 4173 | target hardware for which the image is being built and information that |
| 4174 | the build system cannot obtain from other sources such as the kernel. |
| 4175 | Some examples of information contained in a formfactor configuration file include |
| 4176 | framebuffer orientation, whether or not the system has a keyboard, |
| 4177 | the positioning of the keyboard in relation to the screen, and |
| 4178 | the screen resolution. |
| 4179 | </para> |
| 4180 | |
| 4181 | <para> |
| 4182 | The build system uses reasonable defaults in most cases. |
| 4183 | However, if customization is |
| 4184 | necessary, you need to create a <filename>machconfig</filename> file |
| 4185 | in the <filename>meta/recipes-bsp/formfactor/files</filename> |
| 4186 | directory. |
| 4187 | This directory contains directories for specific machines such as |
| 4188 | <filename>qemuarm</filename> and <filename>qemux86</filename>. |
| 4189 | For information about the settings available and the defaults, see the |
| 4190 | <filename>meta/recipes-bsp/formfactor/files/config</filename> file found in the |
| 4191 | same area. |
| 4192 | </para> |
| 4193 | |
| 4194 | <para> |
| 4195 | Following is an example for "qemuarm" machine: |
| 4196 | <literallayout class='monospaced'> |
| 4197 | HAVE_TOUCHSCREEN=1 |
| 4198 | HAVE_KEYBOARD=1 |
| 4199 | |
| 4200 | DISPLAY_CAN_ROTATE=0 |
| 4201 | DISPLAY_ORIENTATION=0 |
| 4202 | #DISPLAY_WIDTH_PIXELS=640 |
| 4203 | #DISPLAY_HEIGHT_PIXELS=480 |
| 4204 | #DISPLAY_BPP=16 |
| 4205 | DISPLAY_DPI=150 |
| 4206 | DISPLAY_SUBPIXEL_ORDER=vrgb |
| 4207 | </literallayout> |
| 4208 | </para> |
| 4209 | </section> |
| 4210 | </section> |
| 4211 | |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 4212 | <section id='gs-upgrading-recipes'> |
| 4213 | <title>Upgrading Recipes</title> |
| 4214 | |
| 4215 | <para> |
| 4216 | Over time, upstream developers publish new versions for software |
| 4217 | built by layer recipes. |
| 4218 | It is recommended to keep recipes up-to-date with upstream |
| 4219 | version releases. |
Brad Bishop | 15ae250 | 2019-06-18 21:44:24 -0400 | [diff] [blame] | 4220 | </para> |
| 4221 | |
| 4222 | <para> |
| 4223 | While several methods exist that allow you upgrade a recipe, |
| 4224 | you might consider checking on the upgrade status of a recipe |
| 4225 | first. |
| 4226 | You can do so using the |
| 4227 | <filename>devtool check-upgrade-status</filename> command. |
| 4228 | See the |
| 4229 | "<ulink url='&YOCTO_DOCS_REF_URL;#devtool-checking-on-the-upgrade-status-of-a-recipe'>Checking on the Upgrade Status of a Recipe</ulink>" |
| 4230 | section in the Yocto Project Reference Manual for more information. |
| 4231 | </para> |
| 4232 | |
| 4233 | <para> |
| 4234 | The remainder of this section describes three ways you can |
| 4235 | upgrade a recipe. |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 4236 | You can use the Automated Upgrade Helper (AUH) to set up |
| 4237 | automatic version upgrades. |
| 4238 | Alternatively, you can use <filename>devtool upgrade</filename> |
| 4239 | to set up semi-automatic version upgrades. |
Brad Bishop | 15ae250 | 2019-06-18 21:44:24 -0400 | [diff] [blame] | 4240 | Finally, you can manually upgrade a recipe by editing the |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 4241 | recipe itself. |
| 4242 | </para> |
| 4243 | |
| 4244 | <section id='gs-using-the-auto-upgrade-helper'> |
| 4245 | <title>Using the Auto Upgrade Helper (AUH)</title> |
| 4246 | |
| 4247 | <para> |
| 4248 | The AUH utility works in conjunction with the |
| 4249 | OpenEmbedded build system in order to automatically generate |
| 4250 | upgrades for recipes based on new versions being |
| 4251 | published upstream. |
| 4252 | Use AUH when you want to create a service that performs the |
| 4253 | upgrades automatically and optionally sends you an email with |
| 4254 | the results. |
| 4255 | </para> |
| 4256 | |
| 4257 | <para> |
| 4258 | AUH allows you to update several recipes with a single use. |
| 4259 | You can also optionally perform build and integration tests |
| 4260 | using images with the results saved to your hard drive and |
| 4261 | emails of results optionally sent to recipe maintainers. |
| 4262 | Finally, AUH creates Git commits with appropriate commit |
| 4263 | messages in the layer's tree for the changes made to recipes. |
| 4264 | <note> |
| 4265 | Conditions do exist when you should not use AUH to upgrade |
| 4266 | recipes and you should instead use either |
| 4267 | <filename>devtool upgrade</filename> or upgrade your |
| 4268 | recipes manually: |
| 4269 | <itemizedlist> |
| 4270 | <listitem><para> |
| 4271 | When AUH cannot complete the upgrade sequence. |
| 4272 | This situation usually results because custom |
| 4273 | patches carried by the recipe cannot be |
| 4274 | automatically rebased to the new version. |
| 4275 | In this case, <filename>devtool upgrade</filename> |
| 4276 | allows you to manually resolve conflicts. |
| 4277 | </para></listitem> |
| 4278 | <listitem><para> |
| 4279 | When for any reason you want fuller control over |
| 4280 | the upgrade process. |
| 4281 | For example, when you want special arrangements |
| 4282 | for testing. |
| 4283 | </para></listitem> |
| 4284 | </itemizedlist> |
| 4285 | </note> |
| 4286 | </para> |
| 4287 | |
| 4288 | <para> |
| 4289 | The following steps describe how to set up the AUH utility: |
| 4290 | <orderedlist> |
| 4291 | <listitem><para> |
| 4292 | <emphasis>Be Sure the Development Host is Set Up:</emphasis> |
| 4293 | You need to be sure that your development host is |
| 4294 | set up to use the Yocto Project. |
| 4295 | For information on how to set up your host, see the |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 4296 | "<link linkend='dev-preparing-the-build-host'>Preparing the Build Host</link>" |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 4297 | section. |
| 4298 | </para></listitem> |
| 4299 | <listitem><para> |
| 4300 | <emphasis>Make Sure Git is Configured:</emphasis> |
| 4301 | The AUH utility requires Git to be configured because |
| 4302 | AUH uses Git to save upgrades. |
| 4303 | Thus, you must have Git user and email configured. |
| 4304 | The following command shows your configurations: |
| 4305 | <literallayout class='monospaced'> |
| 4306 | $ git config --list |
| 4307 | </literallayout> |
| 4308 | If you do not have the user and email configured, you |
| 4309 | can use the following commands to do so: |
| 4310 | <literallayout class='monospaced'> |
| 4311 | $ git config --global user.name <replaceable>some_name</replaceable> |
| 4312 | $ git config --global user.email <replaceable>username</replaceable>@<replaceable>domain</replaceable>.com |
| 4313 | </literallayout> |
| 4314 | </para></listitem> |
| 4315 | <listitem><para> |
| 4316 | <emphasis>Clone the AUH Repository:</emphasis> |
| 4317 | To use AUH, you must clone the repository onto your |
| 4318 | development host. |
| 4319 | The following command uses Git to create a local |
| 4320 | copy of the repository on your system: |
| 4321 | <literallayout class='monospaced'> |
| 4322 | $ git clone git://git.yoctoproject.org/auto-upgrade-helper |
| 4323 | Cloning into 'auto-upgrade-helper'... |
| 4324 | remote: Counting objects: 768, done. |
| 4325 | remote: Compressing objects: 100% (300/300), done. |
| 4326 | remote: Total 768 (delta 499), reused 703 (delta 434) |
| 4327 | Receiving objects: 100% (768/768), 191.47 KiB | 98.00 KiB/s, done. |
| 4328 | Resolving deltas: 100% (499/499), done. |
| 4329 | Checking connectivity... done. |
| 4330 | </literallayout> |
| 4331 | AUH is not part of the |
| 4332 | <ulink url='&YOCTO_DOCS_REF_URL;#oe-core'>OpenEmbedded-Core (OE-Core)</ulink> |
| 4333 | or |
| 4334 | <ulink url='&YOCTO_DOCS_REF_URL;#poky'>Poky</ulink> |
| 4335 | repositories. |
| 4336 | </para></listitem> |
| 4337 | <listitem><para> |
| 4338 | <emphasis>Create a Dedicated Build Directory:</emphasis> |
| 4339 | Run the |
| 4340 | <ulink url='&YOCTO_DOCS_REF_URL;#structure-core-script'><filename>oe-init-build-env</filename></ulink> |
| 4341 | script to create a fresh build directory that you |
| 4342 | use exclusively for running the AUH utility: |
| 4343 | <literallayout class='monospaced'> |
| 4344 | $ cd ~/poky |
| 4345 | $ source oe-init-build-env <replaceable>your_AUH_build_directory</replaceable> |
| 4346 | </literallayout> |
| 4347 | Re-using an existing build directory and its |
| 4348 | configurations is not recommended as existing settings |
| 4349 | could cause AUH to fail or behave undesirably. |
| 4350 | </para></listitem> |
| 4351 | <listitem><para> |
| 4352 | <emphasis>Make Configurations in Your Local Configuration File:</emphasis> |
| 4353 | Several settings need to exist in the |
| 4354 | <filename>local.conf</filename> file in the build |
| 4355 | directory you just created for AUH. |
| 4356 | Make these following configurations: |
| 4357 | <itemizedlist> |
| 4358 | <listitem><para> |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 4359 | If you want to enable |
| 4360 | <ulink url='&YOCTO_DOCS_DEV_URL;#maintaining-build-output-quality'>Build History</ulink>, |
| 4361 | which is optional, you need the following |
| 4362 | lines in the |
| 4363 | <filename>conf/local.conf</filename> file: |
| 4364 | <literallayout class='monospaced'> |
| 4365 | INHERIT =+ "buildhistory" |
| 4366 | BUILDHISTORY_COMMIT = "1" |
| 4367 | </literallayout> |
| 4368 | With this configuration and a successful |
| 4369 | upgrade, a build history "diff" file appears in |
| 4370 | the |
| 4371 | <filename>upgrade-helper/work/recipe/buildhistory-diff.txt</filename> |
| 4372 | file found in your build directory. |
| 4373 | </para></listitem> |
| 4374 | <listitem><para> |
| 4375 | If you want to enable testing through the |
| 4376 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-testimage*'><filename>testimage</filename></ulink> |
| 4377 | class, which is optional, you need to have the |
| 4378 | following set in your |
| 4379 | <filename>conf/local.conf</filename> file: |
| 4380 | <literallayout class='monospaced'> |
| 4381 | INHERIT += "testimage" |
| 4382 | </literallayout> |
| 4383 | <note> |
| 4384 | If your distro does not enable by default |
| 4385 | ptest, which Poky does, you need the |
| 4386 | following in your |
| 4387 | <filename>local.conf</filename> file: |
| 4388 | <literallayout class='monospaced'> |
| 4389 | DISTRO_FEATURES_append = " ptest" |
| 4390 | </literallayout> |
| 4391 | </note> |
| 4392 | </para></listitem> |
| 4393 | </itemizedlist> |
| 4394 | </para></listitem> |
| 4395 | <listitem><para> |
| 4396 | <emphasis>Optionally Start a vncserver:</emphasis> |
| 4397 | If you are running in a server without an X11 session, |
| 4398 | you need to start a vncserver: |
| 4399 | <literallayout class='monospaced'> |
| 4400 | $ vncserver :1 |
| 4401 | $ export DISPLAY=:1 |
| 4402 | </literallayout> |
| 4403 | </para></listitem> |
| 4404 | <listitem><para> |
| 4405 | <emphasis>Create and Edit an AUH Configuration File:</emphasis> |
| 4406 | You need to have the |
| 4407 | <filename>upgrade-helper/upgrade-helper.conf</filename> |
| 4408 | configuration file in your build directory. |
| 4409 | You can find a sample configuration file in the |
| 4410 | <ulink url='http://git.yoctoproject.org/cgit/cgit.cgi/auto-upgrade-helper/tree/'>AUH source repository</ulink>. |
| 4411 | </para> |
| 4412 | |
| 4413 | <para>Read through the sample file and make |
| 4414 | configurations as needed. |
| 4415 | For example, if you enabled build history in your |
| 4416 | <filename>local.conf</filename> as described earlier, |
| 4417 | you must enable it in |
| 4418 | <filename>upgrade-helper.conf</filename>.</para> |
| 4419 | |
| 4420 | <para>Also, if you are using the default |
| 4421 | <filename>maintainers.inc</filename> file supplied |
| 4422 | with Poky and located in |
| 4423 | <filename>meta-yocto</filename> and you do not set a |
| 4424 | "maintainers_whitelist" or "global_maintainer_override" |
| 4425 | in the <filename>upgrade-helper.conf</filename> |
| 4426 | configuration, and you specify "-e all" on the |
| 4427 | AUH command-line, the utility automatically sends out |
| 4428 | emails to all the default maintainers. |
| 4429 | Please avoid this. |
| 4430 | </para></listitem> |
| 4431 | </orderedlist> |
| 4432 | </para> |
| 4433 | |
| 4434 | <para> |
| 4435 | This next set of examples describes how to use the AUH: |
| 4436 | <itemizedlist> |
| 4437 | <listitem><para> |
| 4438 | <emphasis>Upgrading a Specific Recipe:</emphasis> |
| 4439 | To upgrade a specific recipe, use the following |
| 4440 | form: |
| 4441 | <literallayout class='monospaced'> |
| 4442 | $ upgrade-helper.py <replaceable>recipe_name</replaceable> |
| 4443 | </literallayout> |
| 4444 | For example, this command upgrades the |
| 4445 | <filename>xmodmap</filename> recipe: |
| 4446 | <literallayout class='monospaced'> |
| 4447 | $ upgrade-helper.py xmodmap |
| 4448 | </literallayout> |
| 4449 | </para></listitem> |
| 4450 | <listitem><para> |
| 4451 | <emphasis>Upgrading a Specific Recipe to a Particular Version:</emphasis> |
| 4452 | To upgrade a specific recipe to a particular version, |
| 4453 | use the following form: |
| 4454 | <literallayout class='monospaced'> |
| 4455 | $ upgrade-helper.py <replaceable>recipe_name</replaceable> -t <replaceable>version</replaceable> |
| 4456 | </literallayout> |
| 4457 | For example, this command upgrades the |
| 4458 | <filename>xmodmap</filename> recipe to version |
| 4459 | 1.2.3: |
| 4460 | <literallayout class='monospaced'> |
| 4461 | $ upgrade-helper.py xmodmap -t 1.2.3 |
| 4462 | </literallayout> |
| 4463 | </para></listitem> |
| 4464 | <listitem><para> |
| 4465 | <emphasis>Upgrading all Recipes to the Latest Versions and Suppressing Email Notifications:</emphasis> |
| 4466 | To upgrade all recipes to their most recent versions |
| 4467 | and suppress the email notifications, use the following |
| 4468 | command: |
| 4469 | <literallayout class='monospaced'> |
| 4470 | $ upgrade-helper.py all |
| 4471 | </literallayout> |
| 4472 | </para></listitem> |
| 4473 | <listitem><para> |
| 4474 | <emphasis>Upgrading all Recipes to the Latest Versions and Send Email Notifications:</emphasis> |
| 4475 | To upgrade all recipes to their most recent versions |
| 4476 | and send email messages to maintainers for each |
| 4477 | attempted recipe as well as a status email, use the |
| 4478 | following command: |
| 4479 | <literallayout class='monospaced'> |
| 4480 | $ upgrade-helper.py -e all |
| 4481 | </literallayout> |
| 4482 | </para></listitem> |
| 4483 | </itemizedlist> |
| 4484 | </para> |
| 4485 | |
| 4486 | <para> |
| 4487 | Once you have run the AUH utility, you can find the results |
| 4488 | in the AUH build directory: |
| 4489 | <literallayout class='monospaced'> |
| 4490 | ${BUILDDIR}/upgrade-helper/<replaceable>timestamp</replaceable> |
| 4491 | </literallayout> |
| 4492 | The AUH utility also creates recipe update commits from |
| 4493 | successful upgrade attempts in the layer tree. |
| 4494 | </para> |
| 4495 | |
| 4496 | <para> |
| 4497 | You can easily set up to run the AUH utility on a regular |
| 4498 | basis by using a cron job. |
| 4499 | See the |
| 4500 | <ulink url='http://git.yoctoproject.org/cgit/cgit.cgi/auto-upgrade-helper/tree/weeklyjob.sh'><filename>weeklyjob.sh</filename></ulink> |
| 4501 | file distributed with the utility for an example. |
| 4502 | </para> |
| 4503 | </section> |
| 4504 | |
| 4505 | <section id='gs-using-devtool-upgrade'> |
| 4506 | <title>Using <filename>devtool upgrade</filename></title> |
| 4507 | |
| 4508 | <para> |
| 4509 | As mentioned earlier, an alternative method for upgrading |
| 4510 | recipes to newer versions is to use |
| 4511 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-devtool-reference'><filename>devtool upgrade</filename></ulink>. |
| 4512 | You can read about <filename>devtool upgrade</filename> in |
| 4513 | general in the |
| 4514 | "<ulink url='&YOCTO_DOCS_SDK_URL;#sdk-devtool-use-devtool-upgrade-to-create-a-version-of-the-recipe-that-supports-a-newer-version-of-the-software'>Use <filename>devtool upgrade</filename> to Create a Version of the Recipe that Supports a Newer Version of the Software</ulink>" |
| 4515 | section in the Yocto Project Application Development and the |
| 4516 | Extensible Software Development Kit (eSDK) Manual. |
| 4517 | </para> |
| 4518 | |
| 4519 | <para> |
| 4520 | To see all the command-line options available with |
| 4521 | <filename>devtool upgrade</filename>, use the following help |
| 4522 | command: |
| 4523 | <literallayout class='monospaced'> |
| 4524 | $ devtool upgrade -h |
| 4525 | </literallayout> |
| 4526 | </para> |
| 4527 | |
| 4528 | <para> |
| 4529 | If you want to find out what version a recipe is currently at |
| 4530 | upstream without any attempt to upgrade your local version of |
| 4531 | the recipe, you can use the following command: |
| 4532 | <literallayout class='monospaced'> |
| 4533 | $ devtool latest-version <replaceable>recipe_name</replaceable> |
| 4534 | </literallayout> |
| 4535 | </para> |
| 4536 | |
| 4537 | <para> |
| 4538 | As mentioned in the previous section describing AUH, |
| 4539 | <filename>devtool upgrade</filename> works in a |
| 4540 | less-automated manner than AUH. |
| 4541 | Specifically, <filename>devtool upgrade</filename> only |
| 4542 | works on a single recipe that you name on the command line, |
| 4543 | cannot perform build and integration testing using images, |
| 4544 | and does not automatically generate commits for changes in |
| 4545 | the source tree. |
| 4546 | Despite all these "limitations", |
| 4547 | <filename>devtool upgrade</filename> updates the recipe file |
| 4548 | to the new upstream version and attempts to rebase custom |
| 4549 | patches contained by the recipe as needed. |
| 4550 | <note> |
| 4551 | AUH uses much of <filename>devtool upgrade</filename> |
| 4552 | behind the scenes making AUH somewhat of a "wrapper" |
| 4553 | application for <filename>devtool upgrade</filename>. |
| 4554 | </note> |
| 4555 | </para> |
| 4556 | |
| 4557 | <para> |
| 4558 | A typical scenario involves having used Git to clone an |
| 4559 | upstream repository that you use during build operations. |
| 4560 | Because you are (or have) built the recipe in the past, the |
| 4561 | layer is likely added to your configuration already. |
| 4562 | If for some reason, the layer is not added, you could add |
| 4563 | it easily using the |
| 4564 | <ulink url='&YOCTO_DOCS_BSP_URL;#creating-a-new-bsp-layer-using-the-bitbake-layers-script'><filename>bitbake-layers</filename></ulink> |
| 4565 | script. |
| 4566 | For example, suppose you use the <filename>nano.bb</filename> |
| 4567 | recipe from the <filename>meta-oe</filename> layer in the |
| 4568 | <filename>meta-openembedded</filename> repository. |
| 4569 | For this example, assume that the layer has been cloned into |
| 4570 | following area: |
| 4571 | <literallayout class='monospaced'> |
| 4572 | /home/scottrif/meta-openembedded |
| 4573 | </literallayout> |
| 4574 | The following command from your |
| 4575 | <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink> |
| 4576 | adds the layer to your build configuration (i.e. |
| 4577 | <filename>${BUILDDIR}/conf/bblayers.conf</filename>): |
| 4578 | <literallayout class='monospaced'> |
| 4579 | $ bitbake-layers add-layer /home/scottrif/meta-openembedded/meta-oe |
| 4580 | NOTE: Starting bitbake server... |
| 4581 | Parsing recipes: 100% |##########################################| Time: 0:00:55 |
| 4582 | Parsing of 1431 .bb files complete (0 cached, 1431 parsed). 2040 targets, 56 skipped, 0 masked, 0 errors. |
| 4583 | Removing 12 recipes from the x86_64 sysroot: 100% |##############| Time: 0:00:00 |
| 4584 | Removing 1 recipes from the x86_64_i586 sysroot: 100% |##########| Time: 0:00:00 |
| 4585 | Removing 5 recipes from the i586 sysroot: 100% |#################| Time: 0:00:00 |
| 4586 | Removing 5 recipes from the qemux86 sysroot: 100% |##############| Time: 0:00:00 |
| 4587 | </literallayout> |
| 4588 | For this example, assume that the <filename>nano.bb</filename> |
| 4589 | recipe that is upstream has a 2.9.3 version number. |
| 4590 | However, the version in the local repository is 2.7.4. |
| 4591 | The following command from your build directory automatically |
| 4592 | upgrades the recipe for you: |
| 4593 | <note> |
| 4594 | Using the <filename>-V</filename> option is not necessary. |
| 4595 | Omitting the version number causes |
| 4596 | <filename>devtool upgrade</filename> to upgrade the recipe |
| 4597 | to the most recent version. |
| 4598 | </note> |
| 4599 | <literallayout class='monospaced'> |
| 4600 | $ devtool upgrade nano -V 2.9.3 |
| 4601 | NOTE: Starting bitbake server... |
| 4602 | NOTE: Creating workspace layer in /home/scottrif/poky/build/workspace |
| 4603 | Parsing recipes: 100% |##########################################| Time: 0:00:46 |
| 4604 | Parsing of 1431 .bb files complete (0 cached, 1431 parsed). 2040 targets, 56 skipped, 0 masked, 0 errors. |
| 4605 | NOTE: Extracting current version source... |
| 4606 | NOTE: Resolving any missing task queue dependencies |
| 4607 | . |
| 4608 | . |
| 4609 | . |
| 4610 | NOTE: Executing SetScene Tasks |
| 4611 | NOTE: Executing RunQueue Tasks |
| 4612 | NOTE: Tasks Summary: Attempted 74 tasks of which 72 didn't need to be rerun and all succeeded. |
| 4613 | Adding changed files: 100% |#####################################| Time: 0:00:00 |
| 4614 | NOTE: Upgraded source extracted to /home/scottrif/poky/build/workspace/sources/nano |
| 4615 | NOTE: New recipe is /home/scottrif/poky/build/workspace/recipes/nano/nano_2.9.3.bb |
| 4616 | </literallayout> |
| 4617 | Continuing with this example, you can use |
| 4618 | <filename>devtool build</filename> to build the newly upgraded |
| 4619 | recipe: |
| 4620 | <literallayout class='monospaced'> |
| 4621 | $ devtool build nano |
| 4622 | NOTE: Starting bitbake server... |
| 4623 | Loading cache: 100% |################################################################################################| Time: 0:00:01 |
| 4624 | Loaded 2040 entries from dependency cache. |
| 4625 | Parsing recipes: 100% |##############################################################################################| Time: 0:00:00 |
| 4626 | Parsing of 1432 .bb files complete (1431 cached, 1 parsed). 2041 targets, 56 skipped, 0 masked, 0 errors. |
| 4627 | NOTE: Resolving any missing task queue dependencies |
| 4628 | . |
| 4629 | . |
| 4630 | . |
| 4631 | NOTE: Executing SetScene Tasks |
| 4632 | NOTE: Executing RunQueue Tasks |
| 4633 | NOTE: nano: compiling from external source tree /home/scottrif/poky/build/workspace/sources/nano |
| 4634 | NOTE: Tasks Summary: Attempted 520 tasks of which 304 didn't need to be rerun and all succeeded. |
| 4635 | </literallayout> |
| 4636 | Within the <filename>devtool upgrade</filename> workflow, |
| 4637 | opportunity exists to deploy and test your rebuilt software. |
| 4638 | For this example, however, running |
| 4639 | <filename>devtool finish</filename> cleans up the workspace |
| 4640 | once the source in your workspace is clean. |
| 4641 | This usually means using Git to stage and submit commits |
| 4642 | for the changes generated by the upgrade process. |
| 4643 | </para> |
| 4644 | |
| 4645 | <para> |
| 4646 | Once the tree is clean, you can clean things up in this |
| 4647 | example with the following command from the |
| 4648 | <filename>${BUILDDIR}/workspace/sources/nano</filename> |
| 4649 | directory: |
| 4650 | <literallayout class='monospaced'> |
| 4651 | $ devtool finish nano meta-oe |
| 4652 | NOTE: Starting bitbake server... |
| 4653 | Loading cache: 100% |################################################################################################| Time: 0:00:00 |
| 4654 | Loaded 2040 entries from dependency cache. |
| 4655 | Parsing recipes: 100% |##############################################################################################| Time: 0:00:01 |
| 4656 | Parsing of 1432 .bb files complete (1431 cached, 1 parsed). 2041 targets, 56 skipped, 0 masked, 0 errors. |
| 4657 | NOTE: Adding new patch 0001-nano.bb-Stuff-I-changed-when-upgrading-nano.bb.patch |
| 4658 | NOTE: Updating recipe nano_2.9.3.bb |
| 4659 | NOTE: Removing file /home/scottrif/meta-openembedded/meta-oe/recipes-support/nano/nano_2.7.4.bb |
| 4660 | NOTE: Moving recipe file to /home/scottrif/meta-openembedded/meta-oe/recipes-support/nano |
| 4661 | NOTE: Leaving source tree /home/scottrif/poky/build/workspace/sources/nano as-is; if you no longer need it then please delete it manually |
| 4662 | </literallayout> |
| 4663 | Using the <filename>devtool finish</filename> command cleans |
| 4664 | up the workspace and creates a patch file based on your |
| 4665 | commits. |
| 4666 | The tool puts all patch files back into the source directory |
| 4667 | in a sub-directory named <filename>nano</filename> in this |
| 4668 | case. |
| 4669 | </para> |
| 4670 | </section> |
| 4671 | |
| 4672 | <section id='dev-manually-upgrading-a-recipe'> |
| 4673 | <title>Manually Upgrading a Recipe</title> |
| 4674 | |
| 4675 | <para> |
| 4676 | If for some reason you choose not to upgrade recipes using the |
| 4677 | <link linkend='gs-using-the-auto-upgrade-helper'>Auto Upgrade Helper (AUH)</link> |
| 4678 | or by using |
| 4679 | <link linkend='gs-using-devtool-upgrade'><filename>devtool upgrade</filename></link>, |
| 4680 | you can manually edit the recipe files to upgrade the versions. |
| 4681 | <note><title>Caution</title> |
| 4682 | Manually updating multiple recipes scales poorly and |
| 4683 | involves many steps. |
| 4684 | The recommendation to upgrade recipe versions is through |
| 4685 | AUH or <filename>devtool upgrade</filename>, both of which |
| 4686 | automate some steps and provide guidance for others needed |
| 4687 | for the manual process. |
| 4688 | </note> |
| 4689 | </para> |
| 4690 | |
| 4691 | <para> |
| 4692 | To manually upgrade recipe versions, follow these general steps: |
| 4693 | <orderedlist> |
| 4694 | <listitem><para> |
| 4695 | <emphasis>Change the Version:</emphasis> |
| 4696 | Rename the recipe such that the version (i.e. the |
| 4697 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PV'><filename>PV</filename></ulink> |
| 4698 | part of the recipe name) changes appropriately. |
| 4699 | If the version is not part of the recipe name, change |
| 4700 | the value as it is set for <filename>PV</filename> |
| 4701 | within the recipe itself. |
| 4702 | </para></listitem> |
| 4703 | <listitem><para> |
| 4704 | <emphasis>Update <filename>SRCREV</filename> if Needed:</emphasis> |
| 4705 | If the source code your recipe builds is fetched from |
| 4706 | Git or some other version control system, update |
| 4707 | <ulink url='&YOCTO_DOCS_REF_URL;#var-SRCREV'><filename>SRCREV</filename></ulink> |
| 4708 | to point to the commit hash that matches the new |
| 4709 | version. |
| 4710 | </para></listitem> |
| 4711 | <listitem><para> |
| 4712 | <emphasis>Build the Software:</emphasis> |
| 4713 | Try to build the recipe using BitBake. |
| 4714 | Typical build failures include the following: |
| 4715 | <itemizedlist> |
| 4716 | <listitem><para> |
| 4717 | License statements were updated for the new |
| 4718 | version. |
| 4719 | For this case, you need to review any changes |
| 4720 | to the license and update the values of |
| 4721 | <ulink url='&YOCTO_DOCS_REF_URL;#var-LICENSE'><filename>LICENSE</filename></ulink> |
| 4722 | and |
| 4723 | <ulink url='&YOCTO_DOCS_REF_URL;#var-LIC_FILES_CHKSUM'><filename>LIC_FILES_CHKSUM</filename></ulink> |
| 4724 | as needed. |
| 4725 | <note> |
| 4726 | License changes are often inconsequential. |
| 4727 | For example, the license text's copyright |
| 4728 | year might have changed. |
| 4729 | </note> |
| 4730 | </para></listitem> |
| 4731 | <listitem><para> |
| 4732 | Custom patches carried by the older version of |
| 4733 | the recipe might fail to apply to the new |
| 4734 | version. |
| 4735 | For these cases, you need to review the |
| 4736 | failures. |
| 4737 | Patches might not be necessary for the new |
| 4738 | version of the software if the upgraded version |
| 4739 | has fixed those issues. |
| 4740 | If a patch is necessary and failing, you need |
| 4741 | to rebase it into the new version. |
| 4742 | </para></listitem> |
| 4743 | </itemizedlist> |
| 4744 | </para></listitem> |
| 4745 | <listitem><para> |
| 4746 | <emphasis>Optionally Attempt to Build for Several Architectures:</emphasis> |
| 4747 | Once you successfully build the new software for a |
| 4748 | given architecture, you could test the build for |
| 4749 | other architectures by changing the |
| 4750 | <ulink url='&YOCTO_DOCS_REF_URL;#var-MACHINE'><filename>MACHINE</filename></ulink> |
| 4751 | variable and rebuilding the software. |
| 4752 | This optional step is especially important if the |
| 4753 | recipe is to be released publicly. |
| 4754 | </para></listitem> |
| 4755 | <listitem><para> |
| 4756 | <emphasis>Check the Upstream Change Log or Release Notes:</emphasis> |
| 4757 | Checking both these reveals if new features exist that |
| 4758 | could break backwards-compatibility. |
| 4759 | If so, you need to take steps to mitigate or eliminate |
| 4760 | that situation. |
| 4761 | </para></listitem> |
| 4762 | <listitem><para> |
| 4763 | <emphasis>Optionally Create a Bootable Image and Test:</emphasis> |
| 4764 | If you want, you can test the new software by booting |
| 4765 | it onto actual hardware. |
| 4766 | </para></listitem> |
| 4767 | <listitem><para> |
| 4768 | <emphasis>Create a Commit with the Change in the Layer Repository:</emphasis> |
| 4769 | After all builds work and any testing is successful, |
| 4770 | you can create commits for any changes in the layer |
| 4771 | holding your upgraded recipe. |
| 4772 | </para></listitem> |
| 4773 | </orderedlist> |
| 4774 | </para> |
| 4775 | </section> |
| 4776 | </section> |
| 4777 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 4778 | <section id='finding-the-temporary-source-code'> |
| 4779 | <title>Finding Temporary Source Code</title> |
| 4780 | |
| 4781 | <para> |
| 4782 | You might find it helpful during development to modify the |
| 4783 | temporary source code used by recipes to build packages. |
| 4784 | For example, suppose you are developing a patch and you need to |
| 4785 | experiment a bit to figure out your solution. |
| 4786 | After you have initially built the package, you can iteratively |
| 4787 | tweak the source code, which is located in the |
| 4788 | <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink>, |
| 4789 | and then you can force a re-compile and quickly test your altered |
| 4790 | code. |
| 4791 | Once you settle on a solution, you can then preserve your changes |
| 4792 | in the form of patches. |
| 4793 | </para> |
| 4794 | |
| 4795 | <para> |
| 4796 | During a build, the unpacked temporary source code used by recipes |
| 4797 | to build packages is available in the Build Directory as |
| 4798 | defined by the |
| 4799 | <ulink url='&YOCTO_DOCS_REF_URL;#var-S'><filename>S</filename></ulink> |
| 4800 | variable. |
| 4801 | Below is the default value for the <filename>S</filename> variable |
| 4802 | as defined in the |
| 4803 | <filename>meta/conf/bitbake.conf</filename> configuration file |
| 4804 | in the |
| 4805 | <ulink url='&YOCTO_DOCS_REF_URL;#source-directory'>Source Directory</ulink>: |
| 4806 | <literallayout class='monospaced'> |
| 4807 | S = "${WORKDIR}/${BP}" |
| 4808 | </literallayout> |
| 4809 | You should be aware that many recipes override the |
| 4810 | <filename>S</filename> variable. |
| 4811 | For example, recipes that fetch their source from Git usually set |
| 4812 | <filename>S</filename> to <filename>${WORKDIR}/git</filename>. |
| 4813 | <note> |
| 4814 | The |
| 4815 | <ulink url='&YOCTO_DOCS_REF_URL;#var-BP'><filename>BP</filename></ulink> |
| 4816 | represents the base recipe name, which consists of the name |
| 4817 | and version: |
| 4818 | <literallayout class='monospaced'> |
| 4819 | BP = "${BPN}-${PV}" |
| 4820 | </literallayout> |
| 4821 | </note> |
| 4822 | </para> |
| 4823 | |
| 4824 | <para> |
| 4825 | The path to the work directory for the recipe |
| 4826 | (<ulink url='&YOCTO_DOCS_REF_URL;#var-WORKDIR'><filename>WORKDIR</filename></ulink>) |
| 4827 | is defined as follows: |
| 4828 | <literallayout class='monospaced'> |
| 4829 | ${TMPDIR}/work/${MULTIMACH_TARGET_SYS}/${PN}/${EXTENDPE}${PV}-${PR} |
| 4830 | </literallayout> |
| 4831 | The actual directory depends on several things: |
| 4832 | <itemizedlist> |
| 4833 | <listitem><para> |
| 4834 | <ulink url='&YOCTO_DOCS_REF_URL;#var-TMPDIR'><filename>TMPDIR</filename></ulink>: |
| 4835 | The top-level build output directory. |
| 4836 | </para></listitem> |
| 4837 | <listitem><para> |
| 4838 | <ulink url='&YOCTO_DOCS_REF_URL;#var-MULTIMACH_TARGET_SYS'><filename>MULTIMACH_TARGET_SYS</filename></ulink>: |
| 4839 | The target system identifier. |
| 4840 | </para></listitem> |
| 4841 | <listitem><para> |
| 4842 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PN'><filename>PN</filename></ulink>: |
| 4843 | The recipe name. |
| 4844 | </para></listitem> |
| 4845 | <listitem><para> |
| 4846 | <ulink url='&YOCTO_DOCS_REF_URL;#var-EXTENDPE'><filename>EXTENDPE</filename></ulink>: |
| 4847 | The epoch - (if |
| 4848 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PE'><filename>PE</filename></ulink> |
| 4849 | is not specified, which is usually the case for most |
| 4850 | recipes, then <filename>EXTENDPE</filename> is blank). |
| 4851 | </para></listitem> |
| 4852 | <listitem><para> |
| 4853 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PV'><filename>PV</filename></ulink>: |
| 4854 | The recipe version. |
| 4855 | </para></listitem> |
| 4856 | <listitem><para> |
| 4857 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PR'><filename>PR</filename></ulink>: |
| 4858 | The recipe revision. |
| 4859 | </para></listitem> |
| 4860 | </itemizedlist> |
| 4861 | </para> |
| 4862 | |
| 4863 | <para> |
| 4864 | As an example, assume a Source Directory top-level folder |
| 4865 | named <filename>poky</filename>, a default Build Directory at |
| 4866 | <filename>poky/build</filename>, and a |
| 4867 | <filename>qemux86-poky-linux</filename> machine target |
| 4868 | system. |
| 4869 | Furthermore, suppose your recipe is named |
| 4870 | <filename>foo_1.3.0.bb</filename>. |
| 4871 | In this case, the work directory the build system uses to |
| 4872 | build the package would be as follows: |
| 4873 | <literallayout class='monospaced'> |
| 4874 | poky/build/tmp/work/qemux86-poky-linux/foo/1.3.0-r0 |
| 4875 | </literallayout> |
| 4876 | </para> |
| 4877 | </section> |
| 4878 | |
| 4879 | <section id="using-a-quilt-workflow"> |
| 4880 | <title>Using Quilt in Your Workflow</title> |
| 4881 | |
| 4882 | <para> |
| 4883 | <ulink url='http://savannah.nongnu.org/projects/quilt'>Quilt</ulink> |
| 4884 | is a powerful tool that allows you to capture source code changes |
| 4885 | without having a clean source tree. |
| 4886 | This section outlines the typical workflow you can use to modify |
| 4887 | source code, test changes, and then preserve the changes in the |
| 4888 | form of a patch all using Quilt. |
| 4889 | <note><title>Tip</title> |
| 4890 | With regard to preserving changes to source files, if you |
| 4891 | clean a recipe or have <filename>rm_work</filename> enabled, |
| 4892 | the |
| 4893 | <ulink url='&YOCTO_DOCS_SDK_URL;#using-devtool-in-your-sdk-workflow'><filename>devtool</filename> workflow</ulink> |
| 4894 | as described in the Yocto Project Application Development |
| 4895 | and the Extensible Software Development Kit (eSDK) manual |
| 4896 | is a safer development flow than the flow that uses Quilt. |
| 4897 | </note> |
| 4898 | </para> |
| 4899 | |
| 4900 | <para> |
| 4901 | Follow these general steps: |
| 4902 | <orderedlist> |
| 4903 | <listitem><para> |
| 4904 | <emphasis>Find the Source Code:</emphasis> |
| 4905 | Temporary source code used by the OpenEmbedded build system |
| 4906 | is kept in the |
| 4907 | <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink>. |
| 4908 | See the |
| 4909 | "<link linkend='finding-the-temporary-source-code'>Finding Temporary Source Code</link>" |
| 4910 | section to learn how to locate the directory that has the |
| 4911 | temporary source code for a particular package. |
| 4912 | </para></listitem> |
| 4913 | <listitem><para> |
| 4914 | <emphasis>Change Your Working Directory:</emphasis> |
| 4915 | You need to be in the directory that has the temporary |
| 4916 | source code. |
| 4917 | That directory is defined by the |
| 4918 | <ulink url='&YOCTO_DOCS_REF_URL;#var-S'><filename>S</filename></ulink> |
| 4919 | variable.</para></listitem> |
| 4920 | <listitem><para> |
| 4921 | <emphasis>Create a New Patch:</emphasis> |
| 4922 | Before modifying source code, you need to create a new |
| 4923 | patch. |
| 4924 | To create a new patch file, use |
| 4925 | <filename>quilt new</filename> as below: |
| 4926 | <literallayout class='monospaced'> |
| 4927 | $ quilt new my_changes.patch |
| 4928 | </literallayout> |
| 4929 | </para></listitem> |
| 4930 | <listitem><para> |
| 4931 | <emphasis>Notify Quilt and Add Files:</emphasis> |
| 4932 | After creating the patch, you need to notify Quilt about |
| 4933 | the files you plan to edit. |
| 4934 | You notify Quilt by adding the files to the patch you |
| 4935 | just created: |
| 4936 | <literallayout class='monospaced'> |
| 4937 | $ quilt add file1.c file2.c file3.c |
| 4938 | </literallayout> |
| 4939 | </para></listitem> |
| 4940 | <listitem><para> |
| 4941 | <emphasis>Edit the Files:</emphasis> |
| 4942 | Make your changes in the source code to the files you added |
| 4943 | to the patch. |
| 4944 | </para></listitem> |
| 4945 | <listitem><para> |
| 4946 | <emphasis>Test Your Changes:</emphasis> |
| 4947 | Once you have modified the source code, the easiest way to |
| 4948 | test your changes is by calling the |
| 4949 | <filename>do_compile</filename> task as shown in the |
| 4950 | following example: |
| 4951 | <literallayout class='monospaced'> |
| 4952 | $ bitbake -c compile -f <replaceable>package</replaceable> |
| 4953 | </literallayout> |
| 4954 | The <filename>-f</filename> or <filename>--force</filename> |
| 4955 | option forces the specified task to execute. |
| 4956 | If you find problems with your code, you can just keep |
| 4957 | editing and re-testing iteratively until things work |
| 4958 | as expected. |
| 4959 | <note> |
| 4960 | All the modifications you make to the temporary |
| 4961 | source code disappear once you run the |
| 4962 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-clean'><filename>do_clean</filename></ulink> |
| 4963 | or |
| 4964 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-cleanall'><filename>do_cleanall</filename></ulink> |
| 4965 | tasks using BitBake (i.e. |
| 4966 | <filename>bitbake -c clean <replaceable>package</replaceable></filename> |
| 4967 | and |
| 4968 | <filename>bitbake -c cleanall <replaceable>package</replaceable></filename>). |
| 4969 | Modifications will also disappear if you use the |
| 4970 | <filename>rm_work</filename> feature as described |
| 4971 | in the |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 4972 | "<ulink url='&YOCTO_DOCS_DEV_URL;#dev-saving-memory-during-a-build'>Conserving Disk Space During Builds</ulink>" |
| 4973 | section. |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 4974 | </note> |
| 4975 | </para></listitem> |
| 4976 | <listitem><para> |
| 4977 | <emphasis>Generate the Patch:</emphasis> |
| 4978 | Once your changes work as expected, you need to use Quilt |
| 4979 | to generate the final patch that contains all your |
| 4980 | modifications. |
| 4981 | <literallayout class='monospaced'> |
| 4982 | $ quilt refresh |
| 4983 | </literallayout> |
| 4984 | At this point, the <filename>my_changes.patch</filename> |
| 4985 | file has all your edits made to the |
| 4986 | <filename>file1.c</filename>, <filename>file2.c</filename>, |
| 4987 | and <filename>file3.c</filename> files.</para> |
| 4988 | |
| 4989 | <para>You can find the resulting patch file in the |
| 4990 | <filename>patches/</filename> subdirectory of the source |
| 4991 | (<filename>S</filename>) directory. |
| 4992 | </para></listitem> |
| 4993 | <listitem><para> |
| 4994 | <emphasis>Copy the Patch File:</emphasis> |
| 4995 | For simplicity, copy the patch file into a directory |
| 4996 | named <filename>files</filename>, which you can create |
| 4997 | in the same directory that holds the recipe |
| 4998 | (<filename>.bb</filename>) file or the append |
| 4999 | (<filename>.bbappend</filename>) file. |
| 5000 | Placing the patch here guarantees that the OpenEmbedded |
| 5001 | build system will find the patch. |
| 5002 | Next, add the patch into the |
| 5003 | <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'>SRC_URI</ulink></filename> |
| 5004 | of the recipe. |
| 5005 | Here is an example: |
| 5006 | <literallayout class='monospaced'> |
| 5007 | SRC_URI += "file://my_changes.patch" |
| 5008 | </literallayout> |
| 5009 | </para></listitem> |
| 5010 | </orderedlist> |
| 5011 | </para> |
| 5012 | </section> |
| 5013 | |
| 5014 | <section id="platdev-appdev-devshell"> |
| 5015 | <title>Using a Development Shell</title> |
| 5016 | |
| 5017 | <para> |
| 5018 | When debugging certain commands or even when just editing packages, |
| 5019 | <filename>devshell</filename> can be a useful tool. |
| 5020 | When you invoke <filename>devshell</filename>, all tasks up to and |
| 5021 | including |
| 5022 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-patch'><filename>do_patch</filename></ulink> |
| 5023 | are run for the specified target. |
| 5024 | Then, a new terminal is opened and you are placed in |
| 5025 | <filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-S'><filename>S</filename></ulink><filename>}</filename>, |
| 5026 | the source directory. |
| 5027 | In the new terminal, all the OpenEmbedded build-related environment variables are |
| 5028 | still defined so you can use commands such as <filename>configure</filename> and |
| 5029 | <filename>make</filename>. |
| 5030 | The commands execute just as if the OpenEmbedded build system were executing them. |
| 5031 | Consequently, working this way can be helpful when debugging a build or preparing |
| 5032 | software to be used with the OpenEmbedded build system. |
| 5033 | </para> |
| 5034 | |
| 5035 | <para> |
| 5036 | Following is an example that uses <filename>devshell</filename> on a target named |
| 5037 | <filename>matchbox-desktop</filename>: |
| 5038 | <literallayout class='monospaced'> |
| 5039 | $ bitbake matchbox-desktop -c devshell |
| 5040 | </literallayout> |
| 5041 | </para> |
| 5042 | |
| 5043 | <para> |
| 5044 | This command spawns a terminal with a shell prompt within the OpenEmbedded build environment. |
| 5045 | The <ulink url='&YOCTO_DOCS_REF_URL;#var-OE_TERMINAL'><filename>OE_TERMINAL</filename></ulink> |
| 5046 | variable controls what type of shell is opened. |
| 5047 | </para> |
| 5048 | |
| 5049 | <para> |
| 5050 | For spawned terminals, the following occurs: |
| 5051 | <itemizedlist> |
| 5052 | <listitem><para>The <filename>PATH</filename> variable includes the |
| 5053 | cross-toolchain.</para></listitem> |
| 5054 | <listitem><para>The <filename>pkgconfig</filename> variables find the correct |
| 5055 | <filename>.pc</filename> files.</para></listitem> |
| 5056 | <listitem><para>The <filename>configure</filename> command finds the |
| 5057 | Yocto Project site files as well as any other necessary files.</para></listitem> |
| 5058 | </itemizedlist> |
| 5059 | </para> |
| 5060 | |
| 5061 | <para> |
| 5062 | Within this environment, you can run configure or compile |
| 5063 | commands as if they were being run by |
| 5064 | the OpenEmbedded build system itself. |
| 5065 | As noted earlier, the working directory also automatically changes to the |
| 5066 | Source Directory (<ulink url='&YOCTO_DOCS_REF_URL;#var-S'><filename>S</filename></ulink>). |
| 5067 | </para> |
| 5068 | |
| 5069 | <para> |
| 5070 | To manually run a specific task using <filename>devshell</filename>, |
| 5071 | run the corresponding <filename>run.*</filename> script in |
| 5072 | the |
| 5073 | <filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-WORKDIR'><filename>WORKDIR</filename></ulink><filename>}/temp</filename> |
| 5074 | directory (e.g., |
| 5075 | <filename>run.do_configure.</filename><replaceable>pid</replaceable>). |
| 5076 | If a task's script does not exist, which would be the case if the task was |
| 5077 | skipped by way of the sstate cache, you can create the task by first running |
| 5078 | it outside of the <filename>devshell</filename>: |
| 5079 | <literallayout class='monospaced'> |
| 5080 | $ bitbake -c <replaceable>task</replaceable> |
| 5081 | </literallayout> |
| 5082 | <note><title>Notes</title> |
| 5083 | <itemizedlist> |
| 5084 | <listitem><para>Execution of a task's <filename>run.*</filename> |
| 5085 | script and BitBake's execution of a task are identical. |
| 5086 | In other words, running the script re-runs the task |
| 5087 | just as it would be run using the |
| 5088 | <filename>bitbake -c</filename> command. |
| 5089 | </para></listitem> |
| 5090 | <listitem><para>Any <filename>run.*</filename> file that does not |
| 5091 | have a <filename>.pid</filename> extension is a |
| 5092 | symbolic link (symlink) to the most recent version of that |
| 5093 | file. |
| 5094 | </para></listitem> |
| 5095 | </itemizedlist> |
| 5096 | </note> |
| 5097 | </para> |
| 5098 | |
| 5099 | <para> |
| 5100 | Remember, that the <filename>devshell</filename> is a mechanism that allows |
| 5101 | you to get into the BitBake task execution environment. |
| 5102 | And as such, all commands must be called just as BitBake would call them. |
| 5103 | That means you need to provide the appropriate options for |
| 5104 | cross-compilation and so forth as applicable. |
| 5105 | </para> |
| 5106 | |
| 5107 | <para> |
| 5108 | When you are finished using <filename>devshell</filename>, exit the shell |
| 5109 | or close the terminal window. |
| 5110 | </para> |
| 5111 | |
| 5112 | <note><title>Notes</title> |
| 5113 | <itemizedlist> |
| 5114 | <listitem><para> |
| 5115 | It is worth remembering that when using <filename>devshell</filename> |
| 5116 | you need to use the full compiler name such as <filename>arm-poky-linux-gnueabi-gcc</filename> |
| 5117 | instead of just using <filename>gcc</filename>. |
| 5118 | The same applies to other applications such as <filename>binutils</filename>, |
| 5119 | <filename>libtool</filename> and so forth. |
| 5120 | BitBake sets up environment variables such as <filename>CC</filename> |
| 5121 | to assist applications, such as <filename>make</filename> to find the correct tools. |
| 5122 | </para></listitem> |
| 5123 | <listitem><para> |
| 5124 | It is also worth noting that <filename>devshell</filename> still works over |
| 5125 | X11 forwarding and similar situations. |
| 5126 | </para></listitem> |
| 5127 | </itemizedlist> |
| 5128 | </note> |
| 5129 | </section> |
| 5130 | |
| 5131 | <section id="platdev-appdev-devpyshell"> |
| 5132 | <title>Using a Development Python Shell</title> |
| 5133 | |
| 5134 | <para> |
| 5135 | Similar to working within a development shell as described in |
| 5136 | the previous section, you can also spawn and work within an |
| 5137 | interactive Python development shell. |
| 5138 | When debugging certain commands or even when just editing packages, |
| 5139 | <filename>devpyshell</filename> can be a useful tool. |
| 5140 | When you invoke <filename>devpyshell</filename>, all tasks up to and |
| 5141 | including |
| 5142 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-patch'><filename>do_patch</filename></ulink> |
| 5143 | are run for the specified target. |
| 5144 | Then a new terminal is opened. |
| 5145 | Additionally, key Python objects and code are available in the same |
| 5146 | way they are to BitBake tasks, in particular, the data store 'd'. |
| 5147 | So, commands such as the following are useful when exploring the data |
| 5148 | store and running functions: |
| 5149 | <literallayout class='monospaced'> |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 5150 | pydevshell> d.getVar("STAGING_DIR") |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 5151 | '/media/build1/poky/build/tmp/sysroots' |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 5152 | pydevshell> d.getVar("STAGING_DIR") |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 5153 | '${TMPDIR}/sysroots' |
| 5154 | pydevshell> d.setVar("FOO", "bar") |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 5155 | pydevshell> d.getVar("FOO") |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 5156 | 'bar' |
| 5157 | pydevshell> d.delVar("FOO") |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 5158 | pydevshell> d.getVar("FOO") |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 5159 | pydevshell> bb.build.exec_func("do_unpack", d) |
| 5160 | pydevshell> |
| 5161 | </literallayout> |
| 5162 | The commands execute just as if the OpenEmbedded build system were executing them. |
| 5163 | Consequently, working this way can be helpful when debugging a build or preparing |
| 5164 | software to be used with the OpenEmbedded build system. |
| 5165 | </para> |
| 5166 | |
| 5167 | <para> |
| 5168 | Following is an example that uses <filename>devpyshell</filename> on a target named |
| 5169 | <filename>matchbox-desktop</filename>: |
| 5170 | <literallayout class='monospaced'> |
| 5171 | $ bitbake matchbox-desktop -c devpyshell |
| 5172 | </literallayout> |
| 5173 | </para> |
| 5174 | |
| 5175 | <para> |
| 5176 | This command spawns a terminal and places you in an interactive |
| 5177 | Python interpreter within the OpenEmbedded build environment. |
| 5178 | The <ulink url='&YOCTO_DOCS_REF_URL;#var-OE_TERMINAL'><filename>OE_TERMINAL</filename></ulink> |
| 5179 | variable controls what type of shell is opened. |
| 5180 | </para> |
| 5181 | |
| 5182 | <para> |
| 5183 | When you are finished using <filename>devpyshell</filename>, you |
| 5184 | can exit the shell either by using Ctrl+d or closing the terminal |
| 5185 | window. |
| 5186 | </para> |
| 5187 | </section> |
| 5188 | |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 5189 | <section id='dev-building'> |
| 5190 | <title>Building</title> |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 5191 | |
| 5192 | <para> |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 5193 | This section describes various build procedures. |
| 5194 | For example, the steps needed for a simple build, a target that |
| 5195 | uses multiple configurations, building an image for more than |
| 5196 | one machine, and so forth. |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 5197 | </para> |
| 5198 | |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 5199 | <section id='dev-building-a-simple-image'> |
| 5200 | <title>Building a Simple Image</title> |
| 5201 | |
| 5202 | <para> |
| 5203 | In the development environment, you need to build an image |
| 5204 | whenever you change hardware support, add or change system |
| 5205 | libraries, or add or change services that have dependencies. |
| 5206 | Several methods exist that allow you to build an image within |
| 5207 | the Yocto Project. |
| 5208 | This section presents the basic steps you need to build a |
| 5209 | simple image using BitBake from a build host running Linux. |
| 5210 | <note><title>Notes</title> |
| 5211 | <itemizedlist> |
| 5212 | <listitem><para> |
| 5213 | For information on how to build an image using |
| 5214 | <ulink url='&YOCTO_DOCS_REF_URL;#toaster-term'>Toaster</ulink>, |
| 5215 | see the |
| 5216 | <ulink url='&YOCTO_DOCS_TOAST_URL;'>Toaster User Manual</ulink>. |
| 5217 | </para></listitem> |
| 5218 | <listitem><para> |
| 5219 | For information on how to use |
| 5220 | <filename>devtool</filename> to build images, see |
| 5221 | the |
| 5222 | "<ulink url='&YOCTO_DOCS_SDK_URL;#using-devtool-in-your-sdk-workflow'>Using <filename>devtool</filename> in Your SDK Workflow</ulink>" |
| 5223 | section in the Yocto Project Application |
| 5224 | Development and the Extensible Software Development |
| 5225 | Kit (eSDK) manual. |
| 5226 | </para></listitem> |
| 5227 | <listitem><para> |
| 5228 | For a quick example on how to build an image using |
| 5229 | the OpenEmbedded build system, see the |
| 5230 | <ulink url='&YOCTO_DOCS_BRIEF_URL;'>Yocto Project Quick Build</ulink> |
| 5231 | document. |
| 5232 | </para></listitem> |
| 5233 | </itemizedlist> |
| 5234 | </note> |
| 5235 | </para> |
| 5236 | |
| 5237 | <para> |
| 5238 | The build process creates an entire Linux distribution from |
| 5239 | source and places it in your |
| 5240 | <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink> |
| 5241 | under <filename>tmp/deploy/images</filename>. |
| 5242 | For detailed information on the build process using BitBake, |
| 5243 | see the |
| 5244 | "<ulink url='&YOCTO_DOCS_OM_URL;#images-dev-environment'>Images</ulink>" |
| 5245 | section in the Yocto Project Overview and Concepts Manual. |
| 5246 | </para> |
| 5247 | |
| 5248 | <para> |
| 5249 | The following figure and list overviews the build process: |
| 5250 | <imagedata fileref="figures/bitbake-build-flow.png" width="7in" depth="4in" align="center" scalefit="1" /> |
| 5251 | <orderedlist> |
| 5252 | <listitem><para> |
| 5253 | <emphasis>Set up Your Host Development System to Support |
| 5254 | Development Using the Yocto Project</emphasis>: |
| 5255 | See the |
| 5256 | "<link linkend='dev-manual-start'>Setting Up to Use the Yocto Project</link>" |
| 5257 | section for options on how to get a build host ready to |
| 5258 | use the Yocto Project. |
| 5259 | </para></listitem> |
| 5260 | <listitem><para> |
| 5261 | <emphasis>Initialize the Build Environment:</emphasis> |
| 5262 | Initialize the build environment by sourcing the build |
| 5263 | environment script (i.e. |
| 5264 | <ulink url='&YOCTO_DOCS_REF_URL;#structure-core-script'><filename>&OE_INIT_FILE;</filename></ulink>): |
| 5265 | <literallayout class='monospaced'> |
| 5266 | $ source &OE_INIT_FILE; [<replaceable>build_dir</replaceable>] |
| 5267 | </literallayout></para> |
| 5268 | |
| 5269 | <para>When you use the initialization script, the |
| 5270 | OpenEmbedded build system uses |
| 5271 | <filename>build</filename> as the default Build |
| 5272 | Directory in your current work directory. |
| 5273 | You can use a <replaceable>build_dir</replaceable> |
| 5274 | argument with the script to specify a different build |
| 5275 | directory. |
| 5276 | <note><title>Tip</title> |
| 5277 | A common practice is to use a different Build |
| 5278 | Directory for different targets. |
| 5279 | For example, <filename>~/build/x86</filename> for a |
| 5280 | <filename>qemux86</filename> target, and |
| 5281 | <filename>~/build/arm</filename> for a |
| 5282 | <filename>qemuarm</filename> target. |
| 5283 | </note> |
| 5284 | </para></listitem> |
| 5285 | <listitem><para> |
| 5286 | <emphasis>Make Sure Your <filename>local.conf</filename> |
| 5287 | File is Correct:</emphasis> |
| 5288 | Ensure the <filename>conf/local.conf</filename> |
| 5289 | configuration file, which is found in the Build |
| 5290 | Directory, is set up how you want it. |
| 5291 | This file defines many aspects of the build environment |
| 5292 | including the target machine architecture through the |
| 5293 | <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-MACHINE'>MACHINE</ulink></filename> variable, |
| 5294 | the packaging format used during the build |
| 5295 | (<ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_CLASSES'><filename>PACKAGE_CLASSES</filename></ulink>), |
| 5296 | and a centralized tarball download directory through the |
| 5297 | <ulink url='&YOCTO_DOCS_REF_URL;#var-DL_DIR'><filename>DL_DIR</filename></ulink> variable. |
| 5298 | </para></listitem> |
| 5299 | <listitem><para> |
| 5300 | <emphasis>Build the Image:</emphasis> |
| 5301 | Build the image using the <filename>bitbake</filename> |
| 5302 | command: |
| 5303 | <literallayout class='monospaced'> |
| 5304 | $ bitbake <replaceable>target</replaceable> |
| 5305 | </literallayout> |
| 5306 | <note> |
| 5307 | For information on BitBake, see the |
| 5308 | <ulink url='&YOCTO_DOCS_BB_URL;'>BitBake User Manual</ulink>. |
| 5309 | </note> |
| 5310 | The <replaceable>target</replaceable> is the name of the |
| 5311 | recipe you want to build. |
| 5312 | Common targets are the images in |
| 5313 | <filename>meta/recipes-core/images</filename>, |
| 5314 | <filename>meta/recipes-sato/images</filename>, and so |
| 5315 | forth all found in the |
| 5316 | <ulink url='&YOCTO_DOCS_REF_URL;#source-directory'>Source Directory</ulink>. |
| 5317 | Or, the target can be the name of a recipe for a |
| 5318 | specific piece of software such as BusyBox. |
| 5319 | For more details about the images the OpenEmbedded build |
| 5320 | system supports, see the |
| 5321 | "<ulink url='&YOCTO_DOCS_REF_URL;#ref-images'>Images</ulink>" |
| 5322 | chapter in the Yocto Project Reference Manual.</para> |
| 5323 | |
| 5324 | <para>As an example, the following command builds the |
| 5325 | <filename>core-image-minimal</filename> image: |
| 5326 | <literallayout class='monospaced'> |
| 5327 | $ bitbake core-image-minimal |
| 5328 | </literallayout> |
| 5329 | Once an image has been built, it often needs to be |
| 5330 | installed. |
| 5331 | The images and kernels built by the OpenEmbedded |
| 5332 | build system are placed in the Build Directory in |
| 5333 | <filename class="directory">tmp/deploy/images</filename>. |
| 5334 | For information on how to run pre-built images such as |
| 5335 | <filename>qemux86</filename> and <filename>qemuarm</filename>, |
| 5336 | see the |
| 5337 | <ulink url='&YOCTO_DOCS_SDK_URL;'>Yocto Project Application Development and the Extensible Software Development Kit (eSDK)</ulink> |
| 5338 | manual. |
| 5339 | For information about how to install these images, |
| 5340 | see the documentation for your particular board or |
| 5341 | machine. |
| 5342 | </para></listitem> |
| 5343 | </orderedlist> |
| 5344 | </para> |
| 5345 | </section> |
| 5346 | |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 5347 | <section id='dev-building-images-for-multiple-targets-using-multiple-configurations'> |
| 5348 | <title>Building Images for Multiple Targets Using Multiple Configurations</title> |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 5349 | |
| 5350 | <para> |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 5351 | You can use a single <filename>bitbake</filename> command |
| 5352 | to build multiple images or packages for different targets |
| 5353 | where each image or package requires a different configuration |
| 5354 | (multiple configuration builds). |
| 5355 | The builds, in this scenario, are sometimes referred to as |
| 5356 | "multiconfigs", and this section uses that term throughout. |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 5357 | </para> |
| 5358 | |
| 5359 | <para> |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 5360 | This section describes how to set up for multiple |
| 5361 | configuration builds and how to account for cross-build |
| 5362 | dependencies between the multiconfigs. |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 5363 | </para> |
| 5364 | |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 5365 | <section id='dev-setting-up-and-running-a-multiple-configuration-build'> |
| 5366 | <title>Setting Up and Running a Multiple Configuration Build</title> |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 5367 | |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 5368 | <para> |
| 5369 | To accomplish a multiple configuration build, you must |
| 5370 | define each target's configuration separately using |
| 5371 | a parallel configuration file in the |
| 5372 | <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink>, |
| 5373 | and you must follow a required file hierarchy. |
| 5374 | Additionally, you must enable the multiple configuration |
| 5375 | builds in your <filename>local.conf</filename> file. |
| 5376 | </para> |
| 5377 | |
| 5378 | <para> |
| 5379 | Follow these steps to set up and execute multiple |
| 5380 | configuration builds: |
| 5381 | <itemizedlist> |
| 5382 | <listitem><para> |
| 5383 | <emphasis>Create Separate Configuration Files</emphasis>: |
| 5384 | You need to create a single configuration file for |
| 5385 | each build target (each multiconfig). |
| 5386 | Minimally, each configuration file must define the |
| 5387 | machine and the temporary directory BitBake uses |
| 5388 | for the build. |
| 5389 | Suggested practice dictates that you do not |
| 5390 | overlap the temporary directories |
| 5391 | used during the builds. |
| 5392 | However, it is possible that you can share the |
| 5393 | temporary directory |
| 5394 | (<ulink url='&YOCTO_DOCS_REF_URL;#var-TMPDIR'><filename>TMPDIR</filename></ulink>). |
| 5395 | For example, consider a scenario with two |
| 5396 | different multiconfigs for the same |
| 5397 | <ulink url='&YOCTO_DOCS_REF_URL;#var-MACHINE'><filename>MACHINE</filename></ulink>: "qemux86" built for |
| 5398 | two distributions such as "poky" and "poky-lsb". |
| 5399 | In this case, you might want to use the same |
| 5400 | <filename>TMPDIR</filename>.</para> |
| 5401 | |
| 5402 | <para>Here is an example showing the minimal |
| 5403 | statements needed in a configuration file for |
| 5404 | a "qemux86" target whose temporary build directory |
| 5405 | is <filename>tmpmultix86</filename>: |
| 5406 | <literallayout class='monospaced'> |
| 5407 | MACHINE="qemux86" |
| 5408 | TMPDIR="${TOPDIR}/tmpmultix86" |
| 5409 | </literallayout></para> |
| 5410 | |
| 5411 | <para>The location for these multiconfig |
| 5412 | configuration files is specific. |
| 5413 | They must reside in the current build directory in |
| 5414 | a sub-directory of <filename>conf</filename> named |
| 5415 | <filename>multiconfig</filename>. |
| 5416 | Following is an example that defines two |
| 5417 | configuration files for the "x86" and "arm" |
| 5418 | multiconfigs: |
| 5419 | <imagedata fileref="figures/multiconfig_files.png" align="center" width="4in" depth="3in" /> |
| 5420 | </para> |
| 5421 | |
| 5422 | <para>The reason for this required file hierarchy |
| 5423 | is because the <filename>BBPATH</filename> variable |
| 5424 | is not constructed until the layers are parsed. |
| 5425 | Consequently, using the configuration file as a |
| 5426 | pre-configuration file is not possible unless it is |
| 5427 | located in the current working directory. |
| 5428 | </para></listitem> |
| 5429 | <listitem><para> |
| 5430 | <emphasis>Add the BitBake Multi-configuration Variable to the Local Configuration File</emphasis>: |
| 5431 | Use the |
| 5432 | <ulink url='&YOCTO_DOCS_REF_URL;#var-BBMULTICONFIG'><filename>BBMULTICONFIG</filename></ulink> |
| 5433 | variable in your |
| 5434 | <filename>conf/local.conf</filename> configuration |
| 5435 | file to specify each multiconfig. |
| 5436 | Continuing with the example from the previous |
| 5437 | figure, the <filename>BBMULTICONFIG</filename> |
| 5438 | variable needs to enable two multiconfigs: "x86" |
| 5439 | and "arm" by specifying each configuration file: |
| 5440 | <literallayout class='monospaced'> |
| 5441 | BBMULTICONFIG = "x86 arm" |
| 5442 | </literallayout> |
Brad Bishop | 64c979e | 2019-11-04 13:55:29 -0500 | [diff] [blame] | 5443 | <note> |
| 5444 | A "default" configuration already exists by |
| 5445 | definition. |
| 5446 | This configuration is named: "" (i.e. empty |
| 5447 | string) and is defined by the variables coming |
| 5448 | from your <filename>local.conf</filename> file. |
| 5449 | Consequently, the previous example actually |
| 5450 | adds two additional configurations to your |
| 5451 | build: "arm" and "x86" along with "". |
| 5452 | </note> |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 5453 | </para></listitem> |
| 5454 | <listitem><para> |
| 5455 | <emphasis>Launch BitBake</emphasis>: |
| 5456 | Use the following BitBake command form to launch the |
| 5457 | multiple configuration build: |
| 5458 | <literallayout class='monospaced'> |
Brad Bishop | f3f93bb | 2019-10-16 14:33:32 -0400 | [diff] [blame] | 5459 | $ bitbake [mc:<replaceable>multiconfigname</replaceable>:]<replaceable>target</replaceable> [[[mc:<replaceable>multiconfigname</replaceable>:]<replaceable>target</replaceable>] ... ] |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 5460 | </literallayout> |
| 5461 | For the example in this section, the following |
| 5462 | command applies: |
| 5463 | <literallayout class='monospaced'> |
Brad Bishop | f3f93bb | 2019-10-16 14:33:32 -0400 | [diff] [blame] | 5464 | $ bitbake mc:x86:core-image-minimal mc:arm:core-image-sato mc::core-image-base |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 5465 | </literallayout> |
| 5466 | The previous BitBake command builds a |
| 5467 | <filename>core-image-minimal</filename> image that |
| 5468 | is configured through the |
Brad Bishop | f3f93bb | 2019-10-16 14:33:32 -0400 | [diff] [blame] | 5469 | <filename>x86.conf</filename> configuration file, |
| 5470 | a <filename>core-image-sato</filename> |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 5471 | image that is configured through the |
Brad Bishop | 64c979e | 2019-11-04 13:55:29 -0500 | [diff] [blame] | 5472 | <filename>arm.conf</filename> configuration file |
| 5473 | and a <filename>core-image-base</filename> that is |
| 5474 | configured through your |
| 5475 | <filename>local.conf</filename> configuration file. |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 5476 | </para></listitem> |
| 5477 | </itemizedlist> |
| 5478 | <note> |
| 5479 | Support for multiple configuration builds in the |
| 5480 | Yocto Project &DISTRO; (&DISTRO_NAME;) Release does |
| 5481 | not include Shared State (sstate) optimizations. |
| 5482 | Consequently, if a build uses the same object twice |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 5483 | in, for example, two different |
| 5484 | <filename>TMPDIR</filename> directories, the build |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 5485 | either loads from an existing sstate cache for that |
| 5486 | build at the start or builds the object fresh. |
| 5487 | </note> |
| 5488 | </para> |
| 5489 | </section> |
| 5490 | |
| 5491 | <section id='dev-enabling-multiple-configuration-build-dependencies'> |
| 5492 | <title>Enabling Multiple Configuration Build Dependencies</title> |
| 5493 | |
| 5494 | <para> |
| 5495 | Sometimes dependencies can exist between targets |
| 5496 | (multiconfigs) in a multiple configuration build. |
| 5497 | For example, suppose that in order to build a |
| 5498 | <filename>core-image-sato</filename> image for an "x86" |
| 5499 | multiconfig, the root filesystem of an "arm" |
| 5500 | multiconfig must exist. |
| 5501 | This dependency is essentially that the |
| 5502 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-image'><filename>do_image</filename></ulink> |
| 5503 | task in the <filename>core-image-sato</filename> recipe |
| 5504 | depends on the completion of the |
| 5505 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-rootfs'><filename>do_rootfs</filename></ulink> |
| 5506 | task of the <filename>core-image-minimal</filename> |
| 5507 | recipe. |
| 5508 | </para> |
| 5509 | |
| 5510 | <para> |
| 5511 | To enable dependencies in a multiple configuration |
| 5512 | build, you must declare the dependencies in the recipe |
| 5513 | using the following statement form: |
| 5514 | <literallayout class='monospaced'> |
Brad Bishop | f3f93bb | 2019-10-16 14:33:32 -0400 | [diff] [blame] | 5515 | <replaceable>task_or_package</replaceable>[mcdepends] = "mc:<replaceable>from_multiconfig</replaceable>:<replaceable>to_multiconfig</replaceable>:<replaceable>recipe_name</replaceable>:<replaceable>task_on_which_to_depend</replaceable>" |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 5516 | </literallayout> |
| 5517 | To better show how to use this statement, consider the |
| 5518 | example scenario from the first paragraph of this section. |
| 5519 | The following statement needs to be added to the recipe |
| 5520 | that builds the <filename>core-image-sato</filename> |
| 5521 | image: |
| 5522 | <literallayout class='monospaced'> |
Brad Bishop | f3f93bb | 2019-10-16 14:33:32 -0400 | [diff] [blame] | 5523 | do_image[mcdepends] = "mc:x86:arm:core-image-minimal:do_rootfs" |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 5524 | </literallayout> |
| 5525 | In this example, the |
| 5526 | <replaceable>from_multiconfig</replaceable> is "x86". |
| 5527 | The <replaceable>to_multiconfig</replaceable> is "arm". |
| 5528 | The task on which the <filename>do_image</filename> task |
| 5529 | in the recipe depends is the <filename>do_rootfs</filename> |
| 5530 | task from the <filename>core-image-minimal</filename> |
| 5531 | recipe associated with the "arm" multiconfig. |
| 5532 | </para> |
| 5533 | |
| 5534 | <para> |
| 5535 | Once you set up this dependency, you can build the |
| 5536 | "x86" multiconfig using a BitBake command as follows: |
| 5537 | <literallayout class='monospaced'> |
Brad Bishop | f3f93bb | 2019-10-16 14:33:32 -0400 | [diff] [blame] | 5538 | $ bitbake mc:x86:core-image-sato |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 5539 | </literallayout> |
| 5540 | This command executes all the tasks needed to create |
| 5541 | the <filename>core-image-sato</filename> image for the |
| 5542 | "x86" multiconfig. |
| 5543 | Because of the dependency, BitBake also executes through |
| 5544 | the <filename>do_rootfs</filename> task for the "arm" |
| 5545 | multiconfig build. |
| 5546 | </para> |
| 5547 | |
| 5548 | <para> |
| 5549 | Having a recipe depend on the root filesystem of another |
| 5550 | build might not seem that useful. |
| 5551 | Consider this change to the statement in the |
| 5552 | <filename>core-image-sato</filename> recipe: |
| 5553 | <literallayout class='monospaced'> |
Brad Bishop | f3f93bb | 2019-10-16 14:33:32 -0400 | [diff] [blame] | 5554 | do_image[mcdepends] = "mc:x86:arm:core-image-minimal:do_image" |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 5555 | </literallayout> |
| 5556 | In this case, BitBake must create the |
| 5557 | <filename>core-image-minimal</filename> image for the |
| 5558 | "arm" build since the "x86" build depends on it. |
| 5559 | </para> |
| 5560 | |
| 5561 | <para> |
| 5562 | Because "x86" and "arm" are enabled for multiple |
| 5563 | configuration builds and have separate configuration |
| 5564 | files, BitBake places the artifacts for each build in the |
| 5565 | respective temporary build directories (i.e. |
| 5566 | <ulink url='&YOCTO_DOCS_REF_URL;#var-TMPDIR'><filename>TMPDIR</filename></ulink>). |
| 5567 | </para> |
| 5568 | </section> |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 5569 | </section> |
| 5570 | |
| 5571 | <section id='building-an-initramfs-image'> |
| 5572 | <title>Building an Initial RAM Filesystem (initramfs) Image</title> |
| 5573 | |
| 5574 | <para> |
| 5575 | An initial RAM filesystem (initramfs) image provides a temporary |
| 5576 | root filesystem used for early system initialization (e.g. |
| 5577 | loading of modules needed to locate and mount the "real" root |
| 5578 | filesystem). |
| 5579 | <note> |
| 5580 | The initramfs image is the successor of initial RAM disk |
| 5581 | (initrd). |
| 5582 | It is a "copy in and out" (cpio) archive of the initial |
| 5583 | filesystem that gets loaded into memory during the Linux |
| 5584 | startup process. |
| 5585 | Because Linux uses the contents of the archive during |
| 5586 | initialization, the initramfs image needs to contain all of the |
| 5587 | device drivers and tools needed to mount the final root |
| 5588 | filesystem. |
| 5589 | </note> |
| 5590 | </para> |
| 5591 | |
| 5592 | <para> |
| 5593 | Follow these steps to create an initramfs image: |
| 5594 | <orderedlist> |
| 5595 | <listitem><para> |
| 5596 | <emphasis>Create the initramfs Image Recipe:</emphasis> |
| 5597 | You can reference the |
| 5598 | <filename>core-image-minimal-initramfs.bb</filename> |
| 5599 | recipe found in the <filename>meta/recipes-core</filename> |
| 5600 | directory of the |
| 5601 | <ulink url='&YOCTO_DOCS_REF_URL;#source-directory'>Source Directory</ulink> |
| 5602 | as an example from which to work. |
| 5603 | </para></listitem> |
| 5604 | <listitem><para> |
| 5605 | <emphasis>Decide if You Need to Bundle the initramfs Image |
| 5606 | Into the Kernel Image:</emphasis> |
| 5607 | If you want the initramfs image that is built to be |
| 5608 | bundled in with the kernel image, set the |
| 5609 | <ulink url='&YOCTO_DOCS_REF_URL;#var-INITRAMFS_IMAGE_BUNDLE'><filename>INITRAMFS_IMAGE_BUNDLE</filename></ulink> |
| 5610 | variable to "1" in your <filename>local.conf</filename> |
| 5611 | configuration file and set the |
| 5612 | <ulink url='&YOCTO_DOCS_REF_URL;#var-INITRAMFS_IMAGE'><filename>INITRAMFS_IMAGE</filename></ulink> |
| 5613 | variable in the recipe that builds the kernel image. |
| 5614 | <note><title>Tip</title> |
| 5615 | It is recommended that you do bundle the initramfs |
| 5616 | image with the kernel image to avoid circular |
| 5617 | dependencies between the kernel recipe and the |
| 5618 | initramfs recipe should the initramfs image |
| 5619 | include kernel modules. |
| 5620 | </note> |
| 5621 | Setting the <filename>INITRAMFS_IMAGE_BUNDLE</filename> |
| 5622 | flag causes the initramfs image to be unpacked |
| 5623 | into the <filename>${B}/usr/</filename> directory. |
| 5624 | The unpacked initramfs image is then passed to the kernel's |
| 5625 | <filename>Makefile</filename> using the |
| 5626 | <ulink url='&YOCTO_DOCS_REF_URL;#var-CONFIG_INITRAMFS_SOURCE'><filename>CONFIG_INITRAMFS_SOURCE</filename></ulink> |
| 5627 | variable, allowing the initramfs image to be built into |
| 5628 | the kernel normally. |
| 5629 | <note> |
| 5630 | If you choose to not bundle the initramfs image with |
| 5631 | the kernel image, you are essentially using an |
| 5632 | <ulink url='https://en.wikipedia.org/wiki/Initrd'>Initial RAM Disk (initrd)</ulink>. |
| 5633 | Creating an initrd is handled primarily through the |
| 5634 | <ulink url='&YOCTO_DOCS_REF_URL;#var-INITRD_IMAGE'><filename>INITRD_IMAGE</filename></ulink>, |
| 5635 | <filename>INITRD_LIVE</filename>, and |
| 5636 | <filename>INITRD_IMAGE_LIVE</filename> variables. |
| 5637 | For more information, see the |
| 5638 | <ulink url='&YOCTO_GIT_URL;/cgit/cgit.cgi/poky/tree/meta/classes/image-live.bbclass'><filename>image-live.bbclass</filename></ulink> |
| 5639 | file. |
| 5640 | </note> |
| 5641 | </para></listitem> |
| 5642 | <listitem><para> |
| 5643 | <emphasis>Optionally Add Items to the initramfs Image |
| 5644 | Through the initramfs Image Recipe:</emphasis> |
| 5645 | If you add items to the initramfs image by way of its |
| 5646 | recipe, you should use |
| 5647 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_INSTALL'><filename>PACKAGE_INSTALL</filename></ulink> |
| 5648 | rather than |
| 5649 | <ulink url='&YOCTO_DOCS_REF_URL;#var-IMAGE_INSTALL'><filename>IMAGE_INSTALL</filename></ulink>. |
| 5650 | <filename>PACKAGE_INSTALL</filename> gives more direct |
| 5651 | control of what is added to the image as compared to |
| 5652 | the defaults you might not necessarily want that are |
| 5653 | set by the |
| 5654 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-image'><filename>image</filename></ulink> |
| 5655 | or |
| 5656 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-core-image'><filename>core-image</filename></ulink> |
| 5657 | classes. |
| 5658 | </para></listitem> |
| 5659 | <listitem><para> |
| 5660 | <emphasis>Build the Kernel Image and the initramfs |
| 5661 | Image:</emphasis> |
| 5662 | Build your kernel image using BitBake. |
| 5663 | Because the initramfs image recipe is a dependency of the |
| 5664 | kernel image, the initramfs image is built as well and |
| 5665 | bundled with the kernel image if you used the |
| 5666 | <ulink url='&YOCTO_DOCS_REF_URL;#var-INITRAMFS_IMAGE_BUNDLE'><filename>INITRAMFS_IMAGE_BUNDLE</filename></ulink> |
| 5667 | variable described earlier. |
| 5668 | </para></listitem> |
| 5669 | </orderedlist> |
| 5670 | </para> |
| 5671 | </section> |
| 5672 | |
| 5673 | <section id='building-a-tiny-system'> |
| 5674 | <title>Building a Tiny System</title> |
| 5675 | |
| 5676 | <para> |
| 5677 | Very small distributions have some significant advantages such |
| 5678 | as requiring less on-die or in-package memory (cheaper), better |
| 5679 | performance through efficient cache usage, lower power requirements |
| 5680 | due to less memory, faster boot times, and reduced development |
| 5681 | overhead. |
| 5682 | Some real-world examples where a very small distribution gives |
| 5683 | you distinct advantages are digital cameras, medical devices, |
| 5684 | and small headless systems. |
| 5685 | </para> |
| 5686 | |
| 5687 | <para> |
| 5688 | This section presents information that shows you how you can |
| 5689 | trim your distribution to even smaller sizes than the |
| 5690 | <filename>poky-tiny</filename> distribution, which is around |
| 5691 | 5 Mbytes, that can be built out-of-the-box using the Yocto Project. |
| 5692 | </para> |
| 5693 | |
| 5694 | <section id='tiny-system-overview'> |
| 5695 | <title>Overview</title> |
| 5696 | |
| 5697 | <para> |
| 5698 | The following list presents the overall steps you need to |
| 5699 | consider and perform to create distributions with smaller |
| 5700 | root filesystems, achieve faster boot times, maintain your critical |
| 5701 | functionality, and avoid initial RAM disks: |
| 5702 | <itemizedlist> |
| 5703 | <listitem><para> |
| 5704 | <link linkend='goals-and-guiding-principles'>Determine your goals and guiding principles.</link> |
| 5705 | </para></listitem> |
| 5706 | <listitem><para> |
| 5707 | <link linkend='understand-what-gives-your-image-size'>Understand what contributes to your image size.</link> |
| 5708 | </para></listitem> |
| 5709 | <listitem><para> |
| 5710 | <link linkend='trim-the-root-filesystem'>Reduce the size of the root filesystem.</link> |
| 5711 | </para></listitem> |
| 5712 | <listitem><para> |
| 5713 | <link linkend='trim-the-kernel'>Reduce the size of the kernel.</link> |
| 5714 | </para></listitem> |
| 5715 | <listitem><para> |
| 5716 | <link linkend='remove-package-management-requirements'>Eliminate packaging requirements.</link> |
| 5717 | </para></listitem> |
| 5718 | <listitem><para> |
| 5719 | <link linkend='look-for-other-ways-to-minimize-size'>Look for other ways to minimize size.</link> |
| 5720 | </para></listitem> |
| 5721 | <listitem><para> |
| 5722 | <link linkend='iterate-on-the-process'>Iterate on the process.</link> |
| 5723 | </para></listitem> |
| 5724 | </itemizedlist> |
| 5725 | </para> |
| 5726 | </section> |
| 5727 | |
| 5728 | <section id='goals-and-guiding-principles'> |
| 5729 | <title>Goals and Guiding Principles</title> |
| 5730 | |
| 5731 | <para> |
| 5732 | Before you can reach your destination, you need to know |
| 5733 | where you are going. |
| 5734 | Here is an example list that you can use as a guide when |
| 5735 | creating very small distributions: |
| 5736 | <itemizedlist> |
| 5737 | <listitem><para>Determine how much space you need |
| 5738 | (e.g. a kernel that is 1 Mbyte or less and |
| 5739 | a root filesystem that is 3 Mbytes or less). |
| 5740 | </para></listitem> |
| 5741 | <listitem><para>Find the areas that are currently |
| 5742 | taking 90% of the space and concentrate on reducing |
| 5743 | those areas. |
| 5744 | </para></listitem> |
| 5745 | <listitem><para>Do not create any difficult "hacks" |
| 5746 | to achieve your goals.</para></listitem> |
| 5747 | <listitem><para>Leverage the device-specific |
| 5748 | options.</para></listitem> |
| 5749 | <listitem><para>Work in a separate layer so that you |
| 5750 | keep changes isolated. |
| 5751 | For information on how to create layers, see |
| 5752 | the "<link linkend='understanding-and-creating-layers'>Understanding and Creating Layers</link>" section. |
| 5753 | </para></listitem> |
| 5754 | </itemizedlist> |
| 5755 | </para> |
| 5756 | </section> |
| 5757 | |
| 5758 | <section id='understand-what-gives-your-image-size'> |
| 5759 | <title>Understand What Contributes to Your Image Size</title> |
| 5760 | |
| 5761 | <para> |
| 5762 | It is easiest to have something to start with when creating |
| 5763 | your own distribution. |
| 5764 | You can use the Yocto Project out-of-the-box to create the |
| 5765 | <filename>poky-tiny</filename> distribution. |
| 5766 | Ultimately, you will want to make changes in your own |
| 5767 | distribution that are likely modeled after |
| 5768 | <filename>poky-tiny</filename>. |
| 5769 | <note> |
| 5770 | To use <filename>poky-tiny</filename> in your build, |
| 5771 | set the |
| 5772 | <ulink url='&YOCTO_DOCS_REF_URL;#var-DISTRO'><filename>DISTRO</filename></ulink> |
| 5773 | variable in your |
| 5774 | <filename>local.conf</filename> file to "poky-tiny" |
| 5775 | as described in the |
| 5776 | "<link linkend='creating-your-own-distribution'>Creating Your Own Distribution</link>" |
| 5777 | section. |
| 5778 | </note> |
| 5779 | </para> |
| 5780 | |
| 5781 | <para> |
| 5782 | Understanding some memory concepts will help you reduce the |
| 5783 | system size. |
| 5784 | Memory consists of static, dynamic, and temporary memory. |
| 5785 | Static memory is the TEXT (code), DATA (initialized data |
| 5786 | in the code), and BSS (uninitialized data) sections. |
| 5787 | Dynamic memory represents memory that is allocated at runtime: |
| 5788 | stacks, hash tables, and so forth. |
| 5789 | Temporary memory is recovered after the boot process. |
| 5790 | This memory consists of memory used for decompressing |
| 5791 | the kernel and for the <filename>__init__</filename> |
| 5792 | functions. |
| 5793 | </para> |
| 5794 | |
| 5795 | <para> |
| 5796 | To help you see where you currently are with kernel and root |
| 5797 | filesystem sizes, you can use two tools found in the |
| 5798 | <ulink url='&YOCTO_DOCS_REF_URL;#source-directory'>Source Directory</ulink> in |
| 5799 | the <filename>scripts/tiny/</filename> directory: |
| 5800 | <itemizedlist> |
| 5801 | <listitem><para><filename>ksize.py</filename>: Reports |
| 5802 | component sizes for the kernel build objects. |
| 5803 | </para></listitem> |
| 5804 | <listitem><para><filename>dirsize.py</filename>: Reports |
| 5805 | component sizes for the root filesystem.</para></listitem> |
| 5806 | </itemizedlist> |
| 5807 | This next tool and command help you organize configuration |
| 5808 | fragments and view file dependencies in a human-readable form: |
| 5809 | <itemizedlist> |
| 5810 | <listitem><para><filename>merge_config.sh</filename>: |
| 5811 | Helps you manage configuration files and fragments |
| 5812 | within the kernel. |
| 5813 | With this tool, you can merge individual configuration |
| 5814 | fragments together. |
| 5815 | The tool allows you to make overrides and warns you |
| 5816 | of any missing configuration options. |
| 5817 | The tool is ideal for allowing you to iterate on |
| 5818 | configurations, create minimal configurations, and |
| 5819 | create configuration files for different machines |
| 5820 | without having to duplicate your process.</para> |
| 5821 | <para>The <filename>merge_config.sh</filename> script is |
| 5822 | part of the Linux Yocto kernel Git repositories |
| 5823 | (i.e. <filename>linux-yocto-3.14</filename>, |
| 5824 | <filename>linux-yocto-3.10</filename>, |
| 5825 | <filename>linux-yocto-3.8</filename>, and so forth) |
| 5826 | in the |
| 5827 | <filename>scripts/kconfig</filename> directory.</para> |
| 5828 | <para>For more information on configuration fragments, |
| 5829 | see the |
| 5830 | "<ulink url='&YOCTO_DOCS_KERNEL_DEV_URL;#creating-config-fragments'>Creating Configuration Fragments</ulink>" |
| 5831 | section in the Yocto Project Linux Kernel Development |
| 5832 | Manual. |
| 5833 | </para></listitem> |
| 5834 | <listitem><para><filename>bitbake -u taskexp -g <replaceable>bitbake_target</replaceable></filename>: |
| 5835 | Using the BitBake command with these options brings up |
| 5836 | a Dependency Explorer from which you can view file |
| 5837 | dependencies. |
| 5838 | Understanding these dependencies allows you to make |
| 5839 | informed decisions when cutting out various pieces of the |
| 5840 | kernel and root filesystem.</para></listitem> |
| 5841 | </itemizedlist> |
| 5842 | </para> |
| 5843 | </section> |
| 5844 | |
| 5845 | <section id='trim-the-root-filesystem'> |
| 5846 | <title>Trim the Root Filesystem</title> |
| 5847 | |
| 5848 | <para> |
| 5849 | The root filesystem is made up of packages for booting, |
| 5850 | libraries, and applications. |
| 5851 | To change things, you can configure how the packaging happens, |
| 5852 | which changes the way you build them. |
| 5853 | You can also modify the filesystem itself or select a different |
| 5854 | filesystem. |
| 5855 | </para> |
| 5856 | |
| 5857 | <para> |
| 5858 | First, find out what is hogging your root filesystem by running the |
| 5859 | <filename>dirsize.py</filename> script from your root directory: |
| 5860 | <literallayout class='monospaced'> |
| 5861 | $ cd <replaceable>root-directory-of-image</replaceable> |
| 5862 | $ dirsize.py 100000 > dirsize-100k.log |
| 5863 | $ cat dirsize-100k.log |
| 5864 | </literallayout> |
| 5865 | You can apply a filter to the script to ignore files under |
| 5866 | a certain size. |
| 5867 | The previous example filters out any files below 100 Kbytes. |
| 5868 | The sizes reported by the tool are uncompressed, and thus |
| 5869 | will be smaller by a relatively constant factor in a |
| 5870 | compressed root filesystem. |
| 5871 | When you examine your log file, you can focus on areas of the |
| 5872 | root filesystem that take up large amounts of memory. |
| 5873 | </para> |
| 5874 | |
| 5875 | <para> |
| 5876 | You need to be sure that what you eliminate does not cripple |
| 5877 | the functionality you need. |
| 5878 | One way to see how packages relate to each other is by using |
| 5879 | the Dependency Explorer UI with the BitBake command: |
| 5880 | <literallayout class='monospaced'> |
| 5881 | $ cd <replaceable>image-directory</replaceable> |
| 5882 | $ bitbake -u taskexp -g <replaceable>image</replaceable> |
| 5883 | </literallayout> |
| 5884 | Use the interface to select potential packages you wish to |
| 5885 | eliminate and see their dependency relationships. |
| 5886 | </para> |
| 5887 | |
| 5888 | <para> |
| 5889 | When deciding how to reduce the size, get rid of packages that |
| 5890 | result in minimal impact on the feature set. |
| 5891 | For example, you might not need a VGA display. |
| 5892 | Or, you might be able to get by with <filename>devtmpfs</filename> |
| 5893 | and <filename>mdev</filename> instead of |
| 5894 | <filename>udev</filename>. |
| 5895 | </para> |
| 5896 | |
| 5897 | <para> |
| 5898 | Use your <filename>local.conf</filename> file to make changes. |
| 5899 | For example, to eliminate <filename>udev</filename> and |
| 5900 | <filename>glib</filename>, set the following in the |
| 5901 | local configuration file: |
| 5902 | <literallayout class='monospaced'> |
| 5903 | VIRTUAL-RUNTIME_dev_manager = "" |
| 5904 | </literallayout> |
| 5905 | </para> |
| 5906 | |
| 5907 | <para> |
| 5908 | Finally, you should consider exactly the type of root |
| 5909 | filesystem you need to meet your needs while also reducing |
| 5910 | its size. |
| 5911 | For example, consider <filename>cramfs</filename>, |
| 5912 | <filename>squashfs</filename>, <filename>ubifs</filename>, |
| 5913 | <filename>ext2</filename>, or an <filename>initramfs</filename> |
| 5914 | using <filename>initramfs</filename>. |
| 5915 | Be aware that <filename>ext3</filename> requires a 1 Mbyte |
| 5916 | journal. |
| 5917 | If you are okay with running read-only, you do not need this |
| 5918 | journal. |
| 5919 | </para> |
| 5920 | |
| 5921 | <note> |
| 5922 | After each round of elimination, you need to rebuild your |
| 5923 | system and then use the tools to see the effects of your |
| 5924 | reductions. |
| 5925 | </note> |
| 5926 | </section> |
| 5927 | |
| 5928 | <section id='trim-the-kernel'> |
| 5929 | <title>Trim the Kernel</title> |
| 5930 | |
| 5931 | <para> |
| 5932 | The kernel is built by including policies for hardware-independent |
| 5933 | aspects. |
| 5934 | What subsystems do you enable? |
| 5935 | For what architecture are you building? |
| 5936 | Which drivers do you build by default? |
| 5937 | <note>You can modify the kernel source if you want to help |
| 5938 | with boot time. |
| 5939 | </note> |
| 5940 | </para> |
| 5941 | |
| 5942 | <para> |
| 5943 | Run the <filename>ksize.py</filename> script from the top-level |
| 5944 | Linux build directory to get an idea of what is making up |
| 5945 | the kernel: |
| 5946 | <literallayout class='monospaced'> |
| 5947 | $ cd <replaceable>top-level-linux-build-directory</replaceable> |
| 5948 | $ ksize.py > ksize.log |
| 5949 | $ cat ksize.log |
| 5950 | </literallayout> |
| 5951 | When you examine the log, you will see how much space is |
| 5952 | taken up with the built-in <filename>.o</filename> files for |
| 5953 | drivers, networking, core kernel files, filesystem, sound, |
| 5954 | and so forth. |
| 5955 | The sizes reported by the tool are uncompressed, and thus |
| 5956 | will be smaller by a relatively constant factor in a compressed |
| 5957 | kernel image. |
| 5958 | Look to reduce the areas that are large and taking up around |
| 5959 | the "90% rule." |
| 5960 | </para> |
| 5961 | |
| 5962 | <para> |
| 5963 | To examine, or drill down, into any particular area, use the |
| 5964 | <filename>-d</filename> option with the script: |
| 5965 | <literallayout class='monospaced'> |
| 5966 | $ ksize.py -d > ksize.log |
| 5967 | </literallayout> |
| 5968 | Using this option breaks out the individual file information |
| 5969 | for each area of the kernel (e.g. drivers, networking, and |
| 5970 | so forth). |
| 5971 | </para> |
| 5972 | |
| 5973 | <para> |
| 5974 | Use your log file to see what you can eliminate from the kernel |
| 5975 | based on features you can let go. |
| 5976 | For example, if you are not going to need sound, you do not |
| 5977 | need any drivers that support sound. |
| 5978 | </para> |
| 5979 | |
| 5980 | <para> |
| 5981 | After figuring out what to eliminate, you need to reconfigure |
| 5982 | the kernel to reflect those changes during the next build. |
| 5983 | You could run <filename>menuconfig</filename> and make all your |
| 5984 | changes at once. |
| 5985 | However, that makes it difficult to see the effects of your |
| 5986 | individual eliminations and also makes it difficult to replicate |
| 5987 | the changes for perhaps another target device. |
| 5988 | A better method is to start with no configurations using |
| 5989 | <filename>allnoconfig</filename>, create configuration |
| 5990 | fragments for individual changes, and then manage the |
| 5991 | fragments into a single configuration file using |
| 5992 | <filename>merge_config.sh</filename>. |
| 5993 | The tool makes it easy for you to iterate using the |
| 5994 | configuration change and build cycle. |
| 5995 | </para> |
| 5996 | |
| 5997 | <para> |
| 5998 | Each time you make configuration changes, you need to rebuild |
| 5999 | the kernel and check to see what impact your changes had on |
| 6000 | the overall size. |
| 6001 | </para> |
| 6002 | </section> |
| 6003 | |
| 6004 | <section id='remove-package-management-requirements'> |
| 6005 | <title>Remove Package Management Requirements</title> |
| 6006 | |
| 6007 | <para> |
| 6008 | Packaging requirements add size to the image. |
| 6009 | One way to reduce the size of the image is to remove all the |
| 6010 | packaging requirements from the image. |
| 6011 | This reduction includes both removing the package manager |
| 6012 | and its unique dependencies as well as removing the package |
| 6013 | management data itself. |
| 6014 | </para> |
| 6015 | |
| 6016 | <para> |
| 6017 | To eliminate all the packaging requirements for an image, |
| 6018 | be sure that "package-management" is not part of your |
| 6019 | <ulink url='&YOCTO_DOCS_REF_URL;#var-IMAGE_FEATURES'><filename>IMAGE_FEATURES</filename></ulink> |
| 6020 | statement for the image. |
| 6021 | When you remove this feature, you are removing the package |
| 6022 | manager as well as its dependencies from the root filesystem. |
| 6023 | </para> |
| 6024 | </section> |
| 6025 | |
| 6026 | <section id='look-for-other-ways-to-minimize-size'> |
| 6027 | <title>Look for Other Ways to Minimize Size</title> |
| 6028 | |
| 6029 | <para> |
| 6030 | Depending on your particular circumstances, other areas that you |
| 6031 | can trim likely exist. |
| 6032 | The key to finding these areas is through tools and methods |
| 6033 | described here combined with experimentation and iteration. |
| 6034 | Here are a couple of areas to experiment with: |
| 6035 | <itemizedlist> |
| 6036 | <listitem><para><filename>glibc</filename>: |
| 6037 | In general, follow this process: |
| 6038 | <orderedlist> |
| 6039 | <listitem><para>Remove <filename>glibc</filename> |
| 6040 | features from |
| 6041 | <ulink url='&YOCTO_DOCS_REF_URL;#var-DISTRO_FEATURES'><filename>DISTRO_FEATURES</filename></ulink> |
| 6042 | that you think you do not need.</para></listitem> |
| 6043 | <listitem><para>Build your distribution. |
| 6044 | </para></listitem> |
| 6045 | <listitem><para>If the build fails due to missing |
| 6046 | symbols in a package, determine if you can |
| 6047 | reconfigure the package to not need those |
| 6048 | features. |
| 6049 | For example, change the configuration to not |
| 6050 | support wide character support as is done for |
| 6051 | <filename>ncurses</filename>. |
| 6052 | Or, if support for those characters is needed, |
| 6053 | determine what <filename>glibc</filename> |
| 6054 | features provide the support and restore the |
| 6055 | configuration. |
| 6056 | </para></listitem> |
| 6057 | <listitem><para>Rebuild and repeat the process. |
| 6058 | </para></listitem> |
| 6059 | </orderedlist></para></listitem> |
| 6060 | <listitem><para><filename>busybox</filename>: |
| 6061 | For BusyBox, use a process similar as described for |
| 6062 | <filename>glibc</filename>. |
| 6063 | A difference is you will need to boot the resulting |
| 6064 | system to see if you are able to do everything you |
| 6065 | expect from the running system. |
| 6066 | You need to be sure to integrate configuration fragments |
| 6067 | into Busybox because BusyBox handles its own core |
| 6068 | features and then allows you to add configuration |
| 6069 | fragments on top. |
| 6070 | </para></listitem> |
| 6071 | </itemizedlist> |
| 6072 | </para> |
| 6073 | </section> |
| 6074 | |
| 6075 | <section id='iterate-on-the-process'> |
| 6076 | <title>Iterate on the Process</title> |
| 6077 | |
| 6078 | <para> |
| 6079 | If you have not reached your goals on system size, you need |
| 6080 | to iterate on the process. |
| 6081 | The process is the same. |
| 6082 | Use the tools and see just what is taking up 90% of the root |
| 6083 | filesystem and the kernel. |
| 6084 | Decide what you can eliminate without limiting your device |
| 6085 | beyond what you need. |
| 6086 | </para> |
| 6087 | |
| 6088 | <para> |
| 6089 | Depending on your system, a good place to look might be |
| 6090 | Busybox, which provides a stripped down |
| 6091 | version of Unix tools in a single, executable file. |
| 6092 | You might be able to drop virtual terminal services or perhaps |
| 6093 | ipv6. |
| 6094 | </para> |
| 6095 | </section> |
| 6096 | </section> |
| 6097 | |
| 6098 | <section id='building-images-for-more-than-one-machine'> |
| 6099 | <title>Building Images for More than One Machine</title> |
| 6100 | |
| 6101 | <para> |
| 6102 | A common scenario developers face is creating images for several |
| 6103 | different machines that use the same software environment. |
| 6104 | In this situation, it is tempting to set the |
| 6105 | tunings and optimization flags for each build specifically for |
| 6106 | the targeted hardware (i.e. "maxing out" the tunings). |
| 6107 | Doing so can considerably add to build times and package feed |
| 6108 | maintenance collectively for the machines. |
| 6109 | For example, selecting tunes that are extremely specific to a |
| 6110 | CPU core used in a system might enable some micro optimizations |
| 6111 | in GCC for that particular system but would otherwise not gain |
| 6112 | you much of a performance difference across the other systems |
| 6113 | as compared to using a more general tuning across all the builds |
| 6114 | (e.g. setting |
| 6115 | <ulink url='&YOCTO_DOCS_REF_URL;#var-DEFAULTTUNE'><filename>DEFAULTTUNE</filename></ulink> |
| 6116 | specifically for each machine's build). |
| 6117 | Rather than "max out" each build's tunings, you can take steps that |
| 6118 | cause the OpenEmbedded build system to reuse software across the |
| 6119 | various machines where it makes sense. |
| 6120 | </para> |
| 6121 | |
| 6122 | <para> |
| 6123 | If build speed and package feed maintenance are considerations, |
| 6124 | you should consider the points in this section that can help you |
| 6125 | optimize your tunings to best consider build times and package |
| 6126 | feed maintenance. |
| 6127 | <itemizedlist> |
| 6128 | <listitem><para> |
| 6129 | <emphasis>Share the Build Directory:</emphasis> |
| 6130 | If at all possible, share the |
| 6131 | <ulink url='&YOCTO_DOCS_REF_URL;#var-TMPDIR'><filename>TMPDIR</filename></ulink> |
| 6132 | across builds. |
| 6133 | The Yocto Project supports switching between different |
| 6134 | <ulink url='&YOCTO_DOCS_REF_URL;#var-MACHINE'><filename>MACHINE</filename></ulink> |
| 6135 | values in the same <filename>TMPDIR</filename>. |
| 6136 | This practice is well supported and regularly used by |
| 6137 | developers when building for multiple machines. |
| 6138 | When you use the same <filename>TMPDIR</filename> for |
| 6139 | multiple machine builds, the OpenEmbedded build system can |
| 6140 | reuse the existing native and often cross-recipes for |
| 6141 | multiple machines. |
| 6142 | Thus, build time decreases. |
| 6143 | <note> |
| 6144 | If |
| 6145 | <ulink url='&YOCTO_DOCS_REF_URL;#var-DISTRO'><filename>DISTRO</filename></ulink> |
| 6146 | settings change or fundamental configuration settings |
| 6147 | such as the filesystem layout, you need to work with |
| 6148 | a clean <filename>TMPDIR</filename>. |
| 6149 | Sharing <filename>TMPDIR</filename> under these |
| 6150 | circumstances might work but since it is not |
| 6151 | guaranteed, you should use a clean |
| 6152 | <filename>TMPDIR</filename>. |
| 6153 | </note> |
| 6154 | </para></listitem> |
| 6155 | <listitem><para> |
| 6156 | <emphasis>Enable the Appropriate Package Architecture:</emphasis> |
| 6157 | By default, the OpenEmbedded build system enables three |
| 6158 | levels of package architectures: "all", "tune" or "package", |
| 6159 | and "machine". |
| 6160 | Any given recipe usually selects one of these package |
| 6161 | architectures (types) for its output. |
| 6162 | Depending for what a given recipe creates packages, making |
| 6163 | sure you enable the appropriate package architecture can |
| 6164 | directly impact the build time.</para> |
| 6165 | |
| 6166 | <para>A recipe that just generates scripts can enable |
| 6167 | "all" architecture because there are no binaries to build. |
| 6168 | To specifically enable "all" architecture, be sure your |
| 6169 | recipe inherits the |
| 6170 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-allarch'><filename>allarch</filename></ulink> |
| 6171 | class. |
| 6172 | This class is useful for "all" architectures because it |
| 6173 | configures many variables so packages can be used across |
| 6174 | multiple architectures.</para> |
| 6175 | |
| 6176 | <para>If your recipe needs to generate packages that are |
| 6177 | machine-specific or when one of the build or runtime |
| 6178 | dependencies is already machine-architecture dependent, |
| 6179 | which makes your recipe also machine-architecture dependent, |
| 6180 | make sure your recipe enables the "machine" package |
| 6181 | architecture through the |
| 6182 | <ulink url='&YOCTO_DOCS_REF_URL;#var-MACHINE_ARCH'><filename>MACHINE_ARCH</filename></ulink> |
| 6183 | variable: |
| 6184 | <literallayout class='monospaced'> |
| 6185 | PACKAGE_ARCH = "${MACHINE_ARCH}" |
| 6186 | </literallayout> |
| 6187 | When you do not specifically enable a package |
| 6188 | architecture through the |
| 6189 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_ARCH'><filename>PACKAGE_ARCH</filename></ulink>, |
| 6190 | The OpenEmbedded build system defaults to the |
| 6191 | <ulink url='&YOCTO_DOCS_REF_URL;#var-TUNE_PKGARCH'><filename>TUNE_PKGARCH</filename></ulink> |
| 6192 | setting: |
| 6193 | <literallayout class='monospaced'> |
| 6194 | PACKAGE_ARCH = "${TUNE_PKGARCH}" |
| 6195 | </literallayout> |
| 6196 | </para></listitem> |
| 6197 | <listitem><para> |
| 6198 | <emphasis>Choose a Generic Tuning File if Possible:</emphasis> |
| 6199 | Some tunes are more generic and can run on multiple targets |
| 6200 | (e.g. an <filename>armv5</filename> set of packages could |
| 6201 | run on <filename>armv6</filename> and |
| 6202 | <filename>armv7</filename> processors in most cases). |
| 6203 | Similarly, <filename>i486</filename> binaries could work |
| 6204 | on <filename>i586</filename> and higher processors. |
| 6205 | You should realize, however, that advances on newer |
| 6206 | processor versions would not be used.</para> |
| 6207 | |
| 6208 | <para>If you select the same tune for several different |
| 6209 | machines, the OpenEmbedded build system reuses software |
| 6210 | previously built, thus speeding up the overall build time. |
| 6211 | Realize that even though a new sysroot for each machine is |
| 6212 | generated, the software is not recompiled and only one |
| 6213 | package feed exists. |
| 6214 | </para></listitem> |
| 6215 | <listitem><para> |
| 6216 | <emphasis>Manage Granular Level Packaging:</emphasis> |
| 6217 | Sometimes cases exist where injecting another level of |
| 6218 | package architecture beyond the three higher levels noted |
| 6219 | earlier can be useful. |
| 6220 | For example, consider how NXP (formerly Freescale) allows |
| 6221 | for the easy reuse of binary packages in their layer |
| 6222 | <ulink url='&YOCTO_GIT_URL;/cgit/cgit.cgi/meta-freescale/'><filename>meta-freescale</filename></ulink>. |
| 6223 | In this example, the |
| 6224 | <ulink url='&YOCTO_GIT_URL;/cgit/cgit.cgi/meta-freescale/tree/classes/fsl-dynamic-packagearch.bbclass'><filename>fsl-dynamic-packagearch</filename></ulink> |
| 6225 | class shares GPU packages for i.MX53 boards because |
| 6226 | all boards share the AMD GPU. |
| 6227 | The i.MX6-based boards can do the same because all boards |
| 6228 | share the Vivante GPU. |
| 6229 | This class inspects the BitBake datastore to identify if |
| 6230 | the package provides or depends on one of the |
| 6231 | sub-architecture values. |
| 6232 | If so, the class sets the |
| 6233 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_ARCH'><filename>PACKAGE_ARCH</filename></ulink> |
| 6234 | value based on the <filename>MACHINE_SUBARCH</filename> |
| 6235 | value. |
| 6236 | If the package does not provide or depend on one of the |
| 6237 | sub-architecture values but it matches a value in the |
| 6238 | machine-specific filter, it sets |
| 6239 | <ulink url='&YOCTO_DOCS_REF_URL;#var-MACHINE_ARCH'><filename>MACHINE_ARCH</filename></ulink>. |
| 6240 | This behavior reduces the number of packages built and |
| 6241 | saves build time by reusing binaries. |
| 6242 | </para></listitem> |
| 6243 | <listitem><para> |
| 6244 | <emphasis>Use Tools to Debug Issues:</emphasis> |
| 6245 | Sometimes you can run into situations where software is |
| 6246 | being rebuilt when you think it should not be. |
| 6247 | For example, the OpenEmbedded build system might not be |
| 6248 | using shared state between machines when you think it |
| 6249 | should be. |
| 6250 | These types of situations are usually due to references |
| 6251 | to machine-specific variables such as |
| 6252 | <ulink url='&YOCTO_DOCS_REF_URL;#var-MACHINE'><filename>MACHINE</filename></ulink>, |
| 6253 | <ulink url='&YOCTO_DOCS_REF_URL;#var-SERIAL_CONSOLES'><filename>SERIAL_CONSOLES</filename></ulink>, |
| 6254 | <ulink url='&YOCTO_DOCS_REF_URL;#var-XSERVER'><filename>XSERVER</filename></ulink>, |
| 6255 | <ulink url='&YOCTO_DOCS_REF_URL;#var-MACHINE_FEATURES'><filename>MACHINE_FEATURES</filename></ulink>, |
| 6256 | and so forth in code that is supposed to only be |
| 6257 | tune-specific or when the recipe depends |
| 6258 | (<ulink url='&YOCTO_DOCS_REF_URL;#var-DEPENDS'><filename>DEPENDS</filename></ulink>, |
| 6259 | <ulink url='&YOCTO_DOCS_REF_URL;#var-RDEPENDS'><filename>RDEPENDS</filename></ulink>, |
| 6260 | <ulink url='&YOCTO_DOCS_REF_URL;#var-RRECOMMENDS'><filename>RRECOMMENDS</filename></ulink>, |
| 6261 | <ulink url='&YOCTO_DOCS_REF_URL;#var-RSUGGESTS'><filename>RSUGGESTS</filename></ulink>, |
| 6262 | and so forth) on some other recipe that already has |
| 6263 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_ARCH'><filename>PACKAGE_ARCH</filename></ulink> |
| 6264 | defined as "${MACHINE_ARCH}". |
| 6265 | <note> |
| 6266 | Patches to fix any issues identified are most welcome |
| 6267 | as these issues occasionally do occur. |
| 6268 | </note></para> |
| 6269 | |
| 6270 | <para>For such cases, you can use some tools to help you |
| 6271 | sort out the situation: |
| 6272 | <itemizedlist> |
| 6273 | <listitem><para> |
| 6274 | <emphasis><filename>sstate-diff-machines.sh</filename>:</emphasis> |
| 6275 | You can find this tool in the |
| 6276 | <filename>scripts</filename> directory of the |
| 6277 | Source Repositories. |
| 6278 | See the comments in the script for information on |
| 6279 | how to use the tool. |
| 6280 | </para></listitem> |
| 6281 | <listitem><para> |
| 6282 | <emphasis>BitBake's "-S printdiff" Option:</emphasis> |
| 6283 | Using this option causes BitBake to try to |
| 6284 | establish the closest signature match it can |
| 6285 | (e.g. in the shared state cache) and then run |
| 6286 | <filename>bitbake-diffsigs</filename> over the |
| 6287 | matches to determine the stamps and delta where |
| 6288 | these two stamp trees diverge. |
| 6289 | </para></listitem> |
| 6290 | </itemizedlist> |
| 6291 | </para></listitem> |
| 6292 | </itemizedlist> |
| 6293 | </para> |
| 6294 | </section> |
| 6295 | |
| 6296 | <section id="building-software-from-an-external-source"> |
| 6297 | <title>Building Software from an External Source</title> |
| 6298 | |
| 6299 | <para> |
| 6300 | By default, the OpenEmbedded build system uses the |
| 6301 | <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink> |
| 6302 | when building source code. |
| 6303 | The build process involves fetching the source files, unpacking |
| 6304 | them, and then patching them if necessary before the build takes |
| 6305 | place. |
| 6306 | </para> |
| 6307 | |
| 6308 | <para> |
| 6309 | Situations exist where you might want to build software from source |
| 6310 | files that are external to and thus outside of the |
| 6311 | OpenEmbedded build system. |
| 6312 | For example, suppose you have a project that includes a new BSP with |
| 6313 | a heavily customized kernel. |
| 6314 | And, you want to minimize exposing the build system to the |
| 6315 | development team so that they can focus on their project and |
| 6316 | maintain everyone's workflow as much as possible. |
| 6317 | In this case, you want a kernel source directory on the development |
| 6318 | machine where the development occurs. |
| 6319 | You want the recipe's |
| 6320 | <ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'><filename>SRC_URI</filename></ulink> |
| 6321 | variable to point to the external directory and use it as is, not |
| 6322 | copy it. |
| 6323 | </para> |
| 6324 | |
| 6325 | <para> |
| 6326 | To build from software that comes from an external source, all you |
| 6327 | need to do is inherit the |
| 6328 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-externalsrc'><filename>externalsrc</filename></ulink> |
| 6329 | class and then set the |
| 6330 | <ulink url='&YOCTO_DOCS_REF_URL;#var-EXTERNALSRC'><filename>EXTERNALSRC</filename></ulink> |
| 6331 | variable to point to your external source code. |
| 6332 | Here are the statements to put in your |
| 6333 | <filename>local.conf</filename> file: |
| 6334 | <literallayout class='monospaced'> |
| 6335 | INHERIT += "externalsrc" |
| 6336 | EXTERNALSRC_pn-<replaceable>myrecipe</replaceable> = "<replaceable>path-to-your-source-tree</replaceable>" |
| 6337 | </literallayout> |
| 6338 | </para> |
| 6339 | |
| 6340 | <para> |
| 6341 | This next example shows how to accomplish the same thing by setting |
| 6342 | <filename>EXTERNALSRC</filename> in the recipe itself or in the |
| 6343 | recipe's append file: |
| 6344 | <literallayout class='monospaced'> |
| 6345 | EXTERNALSRC = "<replaceable>path</replaceable>" |
| 6346 | EXTERNALSRC_BUILD = "<replaceable>path</replaceable>" |
| 6347 | </literallayout> |
| 6348 | <note> |
| 6349 | In order for these settings to take effect, you must globally |
| 6350 | or locally inherit the |
| 6351 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-externalsrc'><filename>externalsrc</filename></ulink> |
| 6352 | class. |
| 6353 | </note> |
| 6354 | </para> |
| 6355 | |
| 6356 | <para> |
| 6357 | By default, <filename>externalsrc.bbclass</filename> builds |
| 6358 | the source code in a directory separate from the external source |
| 6359 | directory as specified by |
| 6360 | <ulink url='&YOCTO_DOCS_REF_URL;#var-EXTERNALSRC'><filename>EXTERNALSRC</filename></ulink>. |
| 6361 | If you need to have the source built in the same directory in |
| 6362 | which it resides, or some other nominated directory, you can set |
| 6363 | <ulink url='&YOCTO_DOCS_REF_URL;#var-EXTERNALSRC_BUILD'><filename>EXTERNALSRC_BUILD</filename></ulink> |
| 6364 | to point to that directory: |
| 6365 | <literallayout class='monospaced'> |
| 6366 | EXTERNALSRC_BUILD_pn-<replaceable>myrecipe</replaceable> = "<replaceable>path-to-your-source-tree</replaceable>" |
| 6367 | </literallayout> |
| 6368 | </para> |
| 6369 | </section> |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 6370 | |
| 6371 | <section id="replicating-a-build-offline"> |
| 6372 | <title>Replicating a Build Offline</title> |
| 6373 | |
| 6374 | <para> |
| 6375 | It can be useful to take a "snapshot" of upstream sources |
| 6376 | used in a build and then use that "snapshot" later to |
| 6377 | replicate the build offline. |
| 6378 | To do so, you need to first prepare and populate your downloads |
| 6379 | directory your "snapshot" of files. |
| 6380 | Once your downloads directory is ready, you can use it at |
| 6381 | any time and from any machine to replicate your build. |
| 6382 | </para> |
| 6383 | |
| 6384 | <para> |
| 6385 | Follow these steps to populate your Downloads directory: |
| 6386 | <orderedlist> |
| 6387 | <listitem><para> |
| 6388 | <emphasis>Create a Clean Downloads Directory:</emphasis> |
| 6389 | Start with an empty downloads directory |
| 6390 | (<ulink url='&YOCTO_DOCS_REF_URL;#var-DL_DIR'><filename>DL_DIR</filename></ulink>). |
| 6391 | You start with an empty downloads directory by either |
| 6392 | removing the files in the existing directory or by |
| 6393 | setting |
| 6394 | <filename>DL_DIR</filename> to point to either an |
| 6395 | empty location or one that does not yet exist. |
| 6396 | </para></listitem> |
| 6397 | <listitem><para> |
| 6398 | <emphasis>Generate Tarballs of the Source Git Repositories:</emphasis> |
| 6399 | Edit your <filename>local.conf</filename> configuration |
| 6400 | file as follows: |
| 6401 | <literallayout class='monospaced'> |
| 6402 | DL_DIR = "/home/<replaceable>your-download-dir</replaceable>/" |
| 6403 | BB_GENERATE_MIRROR_TARBALLS = "1" |
| 6404 | </literallayout> |
| 6405 | During the fetch process in the next step, BitBake |
| 6406 | gathers the source files and creates tarballs in |
| 6407 | the directory pointed to by <filename>DL_DIR</filename>. |
| 6408 | See the |
| 6409 | <ulink url='&YOCTO_DOCS_REF_URL;#var-BB_GENERATE_MIRROR_TARBALLS'><filename>BB_GENERATE_MIRROR_TARBALLS</filename></ulink> |
| 6410 | variable for more information. |
| 6411 | </para></listitem> |
| 6412 | <listitem><para> |
| 6413 | <emphasis>Populate Your Downloads Directory Without Building:</emphasis> |
| 6414 | Use BitBake to fetch your sources but inhibit the |
| 6415 | build: |
| 6416 | <literallayout class='monospaced'> |
| 6417 | $ bitbake <replaceable>target</replaceable> --runonly=fetch |
| 6418 | </literallayout> |
| 6419 | The downloads directory (i.e. |
| 6420 | <filename>${DL_DIR}</filename>) now has a "snapshot" of |
| 6421 | the source files in the form of tarballs, which can |
| 6422 | be used for the build. |
| 6423 | </para></listitem> |
| 6424 | <listitem><para> |
| 6425 | <emphasis>Optionally Remove Any Git or other SCM Subdirectories From the Downloads Directory:</emphasis> |
| 6426 | If you want, you can clean up your downloads directory |
| 6427 | by removing any Git or other Source Control Management |
| 6428 | (SCM) subdirectories such as |
| 6429 | <filename>${DL_DIR}/git2/*</filename>. |
| 6430 | The tarballs already contain these subdirectories. |
| 6431 | </para></listitem> |
| 6432 | </orderedlist> |
| 6433 | </para> |
| 6434 | |
| 6435 | <para> |
| 6436 | Once your downloads directory has everything it needs regarding |
| 6437 | source files, you can create your "own-mirror" and build |
| 6438 | your target. |
| 6439 | Understand that you can use the files to build the target |
| 6440 | offline from any machine and at any time. |
| 6441 | </para> |
| 6442 | |
| 6443 | <para> |
| 6444 | Follow these steps to build your target using the files in the |
| 6445 | downloads directory: |
| 6446 | <orderedlist> |
| 6447 | <listitem><para> |
| 6448 | <emphasis>Using Local Files Only:</emphasis> |
| 6449 | Inside your <filename>local.conf</filename> file, add |
| 6450 | the |
| 6451 | <ulink url='&YOCTO_DOCS_REF_URL;#var-SOURCE_MIRROR_URL'><filename>SOURCE_MIRROR_URL</filename></ulink> |
| 6452 | variable, |
| 6453 | inherit the <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-own-mirrors'><filename>own-mirrors</filename></ulink> |
| 6454 | class, and use the |
| 6455 | <ulink url='&YOCTO_DOCS_BB_URL;#var-bb-BB_NO_NETWORK'><filename>BB_NO_NETWORK</filename></ulink> |
| 6456 | variable to your <filename>local.conf</filename>. |
| 6457 | <literallayout class='monospaced'> |
| 6458 | SOURCE_MIRROR_URL ?= "file:///home/<replaceable>your-download-dir</replaceable>/" |
| 6459 | INHERIT += "own-mirrors" |
| 6460 | BB_NO_NETWORK = "1" |
| 6461 | </literallayout> |
| 6462 | The <filename>SOURCE_MIRROR_URL</filename> and |
| 6463 | <filename>own-mirror</filename> class set up the system |
| 6464 | to use the downloads directory as your "own mirror". |
| 6465 | Using the <filename>BB_NO_NETWORK</filename> |
| 6466 | variable makes sure that BitBake's fetching process |
| 6467 | in step 3 stays local, which means files from |
| 6468 | your "own-mirror" are used. |
| 6469 | </para></listitem> |
| 6470 | <listitem><para> |
| 6471 | <emphasis>Start With a Clean Build:</emphasis> |
| 6472 | You can start with a clean build by removing the |
| 6473 | <filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-TMPDIR'><filename>TMPDIR</filename></ulink><filename>}</filename> |
| 6474 | directory or using a new |
| 6475 | <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink>. |
| 6476 | </para></listitem> |
| 6477 | <listitem><para> |
| 6478 | <emphasis>Build Your Target:</emphasis> |
| 6479 | Use BitBake to build your target: |
| 6480 | <literallayout class='monospaced'> |
| 6481 | $ bitbake <replaceable>target</replaceable> |
| 6482 | </literallayout> |
| 6483 | The build completes using the known local "snapshot" of |
| 6484 | source files from your mirror. |
| 6485 | The resulting tarballs for your "snapshot" of source |
| 6486 | files are in the downloads directory. |
| 6487 | <note> |
| 6488 | <para>The offline build does not work if recipes |
| 6489 | attempt to find the latest version of software |
| 6490 | by setting |
| 6491 | <ulink url='&YOCTO_DOCS_REF_URL;#var-SRCREV'><filename>SRCREV</filename></ulink> |
| 6492 | to |
| 6493 | <filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-AUTOREV'><filename>AUTOREV</filename></ulink><filename>}</filename>: |
| 6494 | <literallayout class='monospaced'> |
| 6495 | SRCREV = "${AUTOREV}" |
| 6496 | </literallayout> |
| 6497 | When a recipe sets |
| 6498 | <filename>SRCREV</filename> to |
| 6499 | <filename>${AUTOREV}</filename>, the build system |
| 6500 | accesses the network in an attempt to determine the |
| 6501 | latest version of software from the SCM. |
| 6502 | Typically, recipes that use |
| 6503 | <filename>AUTOREV</filename> are custom or |
| 6504 | modified recipes. |
| 6505 | Recipes that reside in public repositories |
| 6506 | usually do not use <filename>AUTOREV</filename>. |
| 6507 | </para> |
| 6508 | |
| 6509 | <para>If you do have recipes that use |
| 6510 | <filename>AUTOREV</filename>, you can take steps to |
| 6511 | still use the recipes in an offline build. |
| 6512 | Do the following: |
| 6513 | <orderedlist> |
| 6514 | <listitem><para> |
| 6515 | Use a configuration generated by |
| 6516 | enabling |
| 6517 | <link linkend='maintaining-build-output-quality'>build history</link>. |
| 6518 | </para></listitem> |
| 6519 | <listitem><para> |
| 6520 | Use the |
| 6521 | <filename>buildhistory-collect-srcrevs</filename> |
| 6522 | command to collect the stored |
| 6523 | <filename>SRCREV</filename> values from |
| 6524 | the build's history. |
| 6525 | For more information on collecting these |
| 6526 | values, see the |
| 6527 | "<link linkend='build-history-package-information'>Build History Package Information</link>" |
| 6528 | section. |
| 6529 | </para></listitem> |
| 6530 | <listitem><para> |
| 6531 | Once you have the correct source |
| 6532 | revisions, you can modify those recipes |
| 6533 | to to set <filename>SRCREV</filename> |
| 6534 | to specific versions of the software. |
| 6535 | </para></listitem> |
| 6536 | </orderedlist> |
| 6537 | </para> |
| 6538 | </note> |
| 6539 | </para></listitem> |
| 6540 | </orderedlist> |
| 6541 | </para> |
| 6542 | </section> |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 6543 | </section> |
| 6544 | |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 6545 | <section id='speeding-up-a-build'> |
| 6546 | <title>Speeding Up a Build</title> |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 6547 | |
| 6548 | <para> |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 6549 | Build time can be an issue. |
| 6550 | By default, the build system uses simple controls to try and maximize |
| 6551 | build efficiency. |
| 6552 | In general, the default settings for all the following variables |
| 6553 | result in the most efficient build times when dealing with single |
| 6554 | socket systems (i.e. a single CPU). |
| 6555 | If you have multiple CPUs, you might try increasing the default |
| 6556 | values to gain more speed. |
| 6557 | See the descriptions in the glossary for each variable for more |
| 6558 | information: |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 6559 | <itemizedlist> |
| 6560 | <listitem><para> |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 6561 | <ulink url='&YOCTO_DOCS_REF_URL;#var-BB_NUMBER_THREADS'><filename>BB_NUMBER_THREADS</filename>:</ulink> |
| 6562 | The maximum number of threads BitBake simultaneously executes. |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 6563 | </para></listitem> |
| 6564 | <listitem><para> |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 6565 | <ulink url='&YOCTO_DOCS_BB_URL;#var-BB_NUMBER_PARSE_THREADS'><filename>BB_NUMBER_PARSE_THREADS</filename>:</ulink> |
| 6566 | The number of threads BitBake uses during parsing. |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 6567 | </para></listitem> |
| 6568 | <listitem><para> |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 6569 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PARALLEL_MAKE'><filename>PARALLEL_MAKE</filename>:</ulink> |
| 6570 | Extra options passed to the <filename>make</filename> command |
| 6571 | during the |
| 6572 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-compile'><filename>do_compile</filename></ulink> |
| 6573 | task in order to specify parallel compilation on the |
| 6574 | local build host. |
| 6575 | </para></listitem> |
| 6576 | <listitem><para> |
| 6577 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PARALLEL_MAKEINST'><filename>PARALLEL_MAKEINST</filename>:</ulink> |
| 6578 | Extra options passed to the <filename>make</filename> command |
| 6579 | during the |
| 6580 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-install'><filename>do_install</filename></ulink> |
| 6581 | task in order to specify parallel installation on the |
| 6582 | local build host. |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 6583 | </para></listitem> |
| 6584 | </itemizedlist> |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 6585 | As mentioned, these variables all scale to the number of processor |
| 6586 | cores available on the build system. |
| 6587 | For single socket systems, this auto-scaling ensures that the build |
| 6588 | system fundamentally takes advantage of potential parallel operations |
| 6589 | during the build based on the build machine's capabilities. |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 6590 | </para> |
| 6591 | |
| 6592 | <para> |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 6593 | Following are additional factors that can affect build speed: |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 6594 | <itemizedlist> |
| 6595 | <listitem><para> |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 6596 | File system type: |
| 6597 | The file system type that the build is being performed on can |
| 6598 | also influence performance. |
| 6599 | Using <filename>ext4</filename> is recommended as compared |
| 6600 | to <filename>ext2</filename> and <filename>ext3</filename> |
| 6601 | due to <filename>ext4</filename> improved features |
| 6602 | such as extents. |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 6603 | </para></listitem> |
| 6604 | <listitem><para> |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 6605 | Disabling the updating of access time using |
| 6606 | <filename>noatime</filename>: |
| 6607 | The <filename>noatime</filename> mount option prevents the |
| 6608 | build system from updating file and directory access times. |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 6609 | </para></listitem> |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 6610 | <listitem><para> |
| 6611 | Setting a longer commit: |
| 6612 | Using the "commit=" mount option increases the interval |
| 6613 | in seconds between disk cache writes. |
| 6614 | Changing this interval from the five second default to |
| 6615 | something longer increases the risk of data loss but decreases |
| 6616 | the need to write to the disk, thus increasing the build |
| 6617 | performance. |
| 6618 | </para></listitem> |
| 6619 | <listitem><para> |
| 6620 | Choosing the packaging backend: |
| 6621 | Of the available packaging backends, IPK is the fastest. |
| 6622 | Additionally, selecting a singular packaging backend also |
| 6623 | helps. |
| 6624 | </para></listitem> |
| 6625 | <listitem><para> |
| 6626 | Using <filename>tmpfs</filename> for |
| 6627 | <ulink url='&YOCTO_DOCS_REF_URL;#var-TMPDIR'><filename>TMPDIR</filename></ulink> |
| 6628 | as a temporary file system: |
| 6629 | While this can help speed up the build, the benefits are |
| 6630 | limited due to the compiler using |
| 6631 | <filename>-pipe</filename>. |
| 6632 | The build system goes to some lengths to avoid |
| 6633 | <filename>sync()</filename> calls into the |
| 6634 | file system on the principle that if there was a significant |
| 6635 | failure, the |
| 6636 | <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink> |
| 6637 | contents could easily be rebuilt. |
| 6638 | </para></listitem> |
| 6639 | <listitem><para> |
| 6640 | Inheriting the |
| 6641 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-rm-work'><filename>rm_work</filename></ulink> |
| 6642 | class: |
| 6643 | Inheriting this class has shown to speed up builds due to |
| 6644 | significantly lower amounts of data stored in the data |
| 6645 | cache as well as on disk. |
| 6646 | Inheriting this class also makes cleanup of |
| 6647 | <ulink url='&YOCTO_DOCS_REF_URL;#var-TMPDIR'><filename>TMPDIR</filename></ulink> |
| 6648 | faster, at the expense of being easily able to dive into the |
| 6649 | source code. |
| 6650 | File system maintainers have recommended that the fastest way |
| 6651 | to clean up large numbers of files is to reformat partitions |
| 6652 | rather than delete files due to the linear nature of |
| 6653 | partitions. |
| 6654 | This, of course, assumes you structure the disk partitions and |
| 6655 | file systems in a way that this is practical. |
| 6656 | </para></listitem> |
| 6657 | </itemizedlist> |
| 6658 | Aside from the previous list, you should keep some trade offs in |
| 6659 | mind that can help you speed up the build: |
| 6660 | <itemizedlist> |
| 6661 | <listitem><para> |
| 6662 | Remove items from |
| 6663 | <ulink url='&YOCTO_DOCS_REF_URL;#var-DISTRO_FEATURES'><filename>DISTRO_FEATURES</filename></ulink> |
| 6664 | that you might not need. |
| 6665 | </para></listitem> |
| 6666 | <listitem><para> |
| 6667 | Exclude debug symbols and other debug information: |
| 6668 | If you do not need these symbols and other debug information, |
| 6669 | disabling the <filename>*-dbg</filename> package generation |
| 6670 | can speed up the build. |
| 6671 | You can disable this generation by setting the |
| 6672 | <ulink url='&YOCTO_DOCS_REF_URL;#var-INHIBIT_PACKAGE_DEBUG_SPLIT'><filename>INHIBIT_PACKAGE_DEBUG_SPLIT</filename></ulink> |
| 6673 | variable to "1". |
| 6674 | </para></listitem> |
| 6675 | <listitem><para> |
| 6676 | Disable static library generation for recipes derived from |
| 6677 | <filename>autoconf</filename> or <filename>libtool</filename>: |
| 6678 | Following is an example showing how to disable static |
| 6679 | libraries and still provide an override to handle exceptions: |
| 6680 | <literallayout class='monospaced'> |
| 6681 | STATICLIBCONF = "--disable-static" |
| 6682 | STATICLIBCONF_sqlite3-native = "" |
| 6683 | EXTRA_OECONF += "${STATICLIBCONF}" |
| 6684 | </literallayout> |
| 6685 | <note><title>Notes</title> |
| 6686 | <itemizedlist> |
| 6687 | <listitem><para> |
| 6688 | Some recipes need static libraries in order to work |
| 6689 | correctly (e.g. <filename>pseudo-native</filename> |
| 6690 | needs <filename>sqlite3-native</filename>). |
| 6691 | Overrides, as in the previous example, account for |
| 6692 | these kinds of exceptions. |
| 6693 | </para></listitem> |
| 6694 | <listitem><para> |
| 6695 | Some packages have packaging code that assumes the |
| 6696 | presence of the static libraries. |
| 6697 | If so, you might need to exclude them as well. |
| 6698 | </para></listitem> |
| 6699 | </itemizedlist> |
| 6700 | </note> |
| 6701 | </para></listitem> |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 6702 | </itemizedlist> |
| 6703 | </para> |
| 6704 | </section> |
| 6705 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 6706 | <section id="platdev-working-with-libraries"> |
| 6707 | <title>Working With Libraries</title> |
| 6708 | |
| 6709 | <para> |
| 6710 | Libraries are an integral part of your system. |
| 6711 | This section describes some common practices you might find |
| 6712 | helpful when working with libraries to build your system: |
| 6713 | <itemizedlist> |
| 6714 | <listitem><para><link linkend='including-static-library-files'>How to include static library files</link> |
| 6715 | </para></listitem> |
| 6716 | <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> |
| 6717 | </para></listitem> |
| 6718 | <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> |
| 6719 | </para></listitem> |
| 6720 | </itemizedlist> |
| 6721 | </para> |
| 6722 | |
| 6723 | <section id='including-static-library-files'> |
| 6724 | <title>Including Static Library Files</title> |
| 6725 | |
| 6726 | <para> |
| 6727 | If you are building a library and the library offers static linking, you can control |
| 6728 | which static library files (<filename>*.a</filename> files) get included in the |
| 6729 | built library. |
| 6730 | </para> |
| 6731 | |
| 6732 | <para> |
| 6733 | The <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGES'><filename>PACKAGES</filename></ulink> |
| 6734 | and <ulink url='&YOCTO_DOCS_REF_URL;#var-FILES'><filename>FILES_*</filename></ulink> |
| 6735 | variables in the |
| 6736 | <filename>meta/conf/bitbake.conf</filename> configuration file define how files installed |
| 6737 | by the <filename>do_install</filename> task are packaged. |
| 6738 | By default, the <filename>PACKAGES</filename> variable includes |
| 6739 | <filename>${PN}-staticdev</filename>, which represents all static library files. |
| 6740 | <note> |
| 6741 | Some previously released versions of the Yocto Project |
| 6742 | defined the static library files through |
| 6743 | <filename>${PN}-dev</filename>. |
| 6744 | </note> |
| 6745 | Following is part of the BitBake configuration file, where |
| 6746 | you can see how the static library files are defined: |
| 6747 | <literallayout class='monospaced'> |
| 6748 | PACKAGE_BEFORE_PN ?= "" |
| 6749 | PACKAGES = "${PN}-dbg ${PN}-staticdev ${PN}-dev ${PN}-doc ${PN}-locale ${PACKAGE_BEFORE_PN} ${PN}" |
| 6750 | PACKAGES_DYNAMIC = "^${PN}-locale-.*" |
| 6751 | FILES = "" |
| 6752 | |
| 6753 | FILES_${PN} = "${bindir}/* ${sbindir}/* ${libexecdir}/* ${libdir}/lib*${SOLIBS} \ |
| 6754 | ${sysconfdir} ${sharedstatedir} ${localstatedir} \ |
| 6755 | ${base_bindir}/* ${base_sbindir}/* \ |
| 6756 | ${base_libdir}/*${SOLIBS} \ |
| 6757 | ${base_prefix}/lib/udev/rules.d ${prefix}/lib/udev/rules.d \ |
| 6758 | ${datadir}/${BPN} ${libdir}/${BPN}/* \ |
| 6759 | ${datadir}/pixmaps ${datadir}/applications \ |
| 6760 | ${datadir}/idl ${datadir}/omf ${datadir}/sounds \ |
| 6761 | ${libdir}/bonobo/servers" |
| 6762 | |
| 6763 | FILES_${PN}-bin = "${bindir}/* ${sbindir}/*" |
| 6764 | |
| 6765 | FILES_${PN}-doc = "${docdir} ${mandir} ${infodir} ${datadir}/gtk-doc \ |
| 6766 | ${datadir}/gnome/help" |
| 6767 | SECTION_${PN}-doc = "doc" |
| 6768 | |
| 6769 | FILES_SOLIBSDEV ?= "${base_libdir}/lib*${SOLIBSDEV} ${libdir}/lib*${SOLIBSDEV}" |
| 6770 | FILES_${PN}-dev = "${includedir} ${FILES_SOLIBSDEV} ${libdir}/*.la \ |
| 6771 | ${libdir}/*.o ${libdir}/pkgconfig ${datadir}/pkgconfig \ |
| 6772 | ${datadir}/aclocal ${base_libdir}/*.o \ |
| 6773 | ${libdir}/${BPN}/*.la ${base_libdir}/*.la" |
| 6774 | SECTION_${PN}-dev = "devel" |
| 6775 | ALLOW_EMPTY_${PN}-dev = "1" |
| 6776 | RDEPENDS_${PN}-dev = "${PN} (= ${EXTENDPKGV})" |
| 6777 | |
| 6778 | FILES_${PN}-staticdev = "${libdir}/*.a ${base_libdir}/*.a ${libdir}/${BPN}/*.a" |
| 6779 | SECTION_${PN}-staticdev = "devel" |
| 6780 | RDEPENDS_${PN}-staticdev = "${PN}-dev (= ${EXTENDPKGV})" |
| 6781 | </literallayout> |
| 6782 | </para> |
| 6783 | </section> |
| 6784 | |
| 6785 | <section id="combining-multiple-versions-library-files-into-one-image"> |
| 6786 | <title>Combining Multiple Versions of Library Files into One Image</title> |
| 6787 | |
| 6788 | <para> |
| 6789 | The build system offers the ability to build libraries with different |
| 6790 | target optimizations or architecture formats and combine these together |
| 6791 | into one system image. |
| 6792 | You can link different binaries in the image |
| 6793 | against the different libraries as needed for specific use cases. |
| 6794 | This feature is called "Multilib." |
| 6795 | </para> |
| 6796 | |
| 6797 | <para> |
| 6798 | An example would be where you have most of a system compiled in 32-bit |
| 6799 | mode using 32-bit libraries, but you have something large, like a database |
| 6800 | engine, that needs to be a 64-bit application and uses 64-bit libraries. |
| 6801 | Multilib allows you to get the best of both 32-bit and 64-bit libraries. |
| 6802 | </para> |
| 6803 | |
| 6804 | <para> |
| 6805 | While the Multilib feature is most commonly used for 32 and 64-bit differences, |
| 6806 | the approach the build system uses facilitates different target optimizations. |
| 6807 | You could compile some binaries to use one set of libraries and other binaries |
| 6808 | to use a different set of libraries. |
| 6809 | The libraries could differ in architecture, compiler options, or other |
| 6810 | optimizations. |
| 6811 | </para> |
| 6812 | |
| 6813 | <para> |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 6814 | Several examples exist in the |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 6815 | <filename>meta-skeleton</filename> layer found in the |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 6816 | <ulink url='&YOCTO_DOCS_REF_URL;#source-directory'>Source Directory</ulink>: |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 6817 | <itemizedlist> |
| 6818 | <listitem><para><filename>conf/multilib-example.conf</filename> |
| 6819 | configuration file</para></listitem> |
| 6820 | <listitem><para><filename>conf/multilib-example2.conf</filename> |
| 6821 | configuration file</para></listitem> |
| 6822 | <listitem><para><filename>recipes-multilib/images/core-image-multilib-example.bb</filename> |
| 6823 | recipe</para></listitem> |
| 6824 | </itemizedlist> |
| 6825 | </para> |
| 6826 | |
| 6827 | <section id='preparing-to-use-multilib'> |
| 6828 | <title>Preparing to Use Multilib</title> |
| 6829 | |
| 6830 | <para> |
| 6831 | User-specific requirements drive the Multilib feature. |
| 6832 | Consequently, there is no one "out-of-the-box" configuration that likely |
| 6833 | exists to meet your needs. |
| 6834 | </para> |
| 6835 | |
| 6836 | <para> |
| 6837 | In order to enable Multilib, you first need to ensure your recipe is |
| 6838 | extended to support multiple libraries. |
| 6839 | Many standard recipes are already extended and support multiple libraries. |
| 6840 | You can check in the <filename>meta/conf/multilib.conf</filename> |
| 6841 | configuration file in the |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 6842 | <ulink url='&YOCTO_DOCS_REF_URL;#source-directory'>Source Directory</ulink> to see how this is |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 6843 | done using the |
| 6844 | <ulink url='&YOCTO_DOCS_REF_URL;#var-BBCLASSEXTEND'><filename>BBCLASSEXTEND</filename></ulink> |
| 6845 | variable. |
| 6846 | Eventually, all recipes will be covered and this list will |
| 6847 | not be needed. |
| 6848 | </para> |
| 6849 | |
| 6850 | <para> |
| 6851 | For the most part, the Multilib class extension works automatically to |
| 6852 | extend the package name from <filename>${PN}</filename> to |
| 6853 | <filename>${MLPREFIX}${PN}</filename>, where <filename>MLPREFIX</filename> |
| 6854 | is the particular multilib (e.g. "lib32-" or "lib64-"). |
| 6855 | Standard variables such as |
| 6856 | <ulink url='&YOCTO_DOCS_REF_URL;#var-DEPENDS'><filename>DEPENDS</filename></ulink>, |
| 6857 | <ulink url='&YOCTO_DOCS_REF_URL;#var-RDEPENDS'><filename>RDEPENDS</filename></ulink>, |
| 6858 | <ulink url='&YOCTO_DOCS_REF_URL;#var-RPROVIDES'><filename>RPROVIDES</filename></ulink>, |
| 6859 | <ulink url='&YOCTO_DOCS_REF_URL;#var-RRECOMMENDS'><filename>RRECOMMENDS</filename></ulink>, |
| 6860 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGES'><filename>PACKAGES</filename></ulink>, and |
| 6861 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGES_DYNAMIC'><filename>PACKAGES_DYNAMIC</filename></ulink> |
| 6862 | are automatically extended by the system. |
| 6863 | If you are extending any manual code in the recipe, you can use the |
| 6864 | <filename>${MLPREFIX}</filename> variable to ensure those names are extended |
| 6865 | correctly. |
| 6866 | This automatic extension code resides in <filename>multilib.bbclass</filename>. |
| 6867 | </para> |
| 6868 | </section> |
| 6869 | |
| 6870 | <section id='using-multilib'> |
| 6871 | <title>Using Multilib</title> |
| 6872 | |
| 6873 | <para> |
| 6874 | After you have set up the recipes, you need to define the actual |
| 6875 | combination of multiple libraries you want to build. |
| 6876 | You accomplish this through your <filename>local.conf</filename> |
| 6877 | configuration file in the |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 6878 | <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink>. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 6879 | An example configuration would be as follows: |
| 6880 | <literallayout class='monospaced'> |
| 6881 | MACHINE = "qemux86-64" |
| 6882 | require conf/multilib.conf |
| 6883 | MULTILIBS = "multilib:lib32" |
| 6884 | DEFAULTTUNE_virtclass-multilib-lib32 = "x86" |
Patrick Williams | f1e5d69 | 2016-03-30 15:21:19 -0500 | [diff] [blame] | 6885 | IMAGE_INSTALL_append = " lib32-glib-2.0" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 6886 | </literallayout> |
| 6887 | This example enables an |
| 6888 | additional library named <filename>lib32</filename> alongside the |
| 6889 | normal target packages. |
| 6890 | When combining these "lib32" alternatives, the example uses "x86" for tuning. |
| 6891 | For information on this particular tuning, see |
| 6892 | <filename>meta/conf/machine/include/ia32/arch-ia32.inc</filename>. |
| 6893 | </para> |
| 6894 | |
| 6895 | <para> |
Patrick Williams | f1e5d69 | 2016-03-30 15:21:19 -0500 | [diff] [blame] | 6896 | The example then includes <filename>lib32-glib-2.0</filename> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 6897 | in all the images, which illustrates one method of including a |
| 6898 | multiple library dependency. |
| 6899 | You can use a normal image build to include this dependency, |
| 6900 | for example: |
| 6901 | <literallayout class='monospaced'> |
| 6902 | $ bitbake core-image-sato |
| 6903 | </literallayout> |
| 6904 | You can also build Multilib packages specifically with a command like this: |
| 6905 | <literallayout class='monospaced'> |
Patrick Williams | f1e5d69 | 2016-03-30 15:21:19 -0500 | [diff] [blame] | 6906 | $ bitbake lib32-glib-2.0 |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 6907 | </literallayout> |
| 6908 | </para> |
| 6909 | </section> |
| 6910 | |
| 6911 | <section id='additional-implementation-details'> |
| 6912 | <title>Additional Implementation Details</title> |
| 6913 | |
| 6914 | <para> |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 6915 | Generic implementation details as well as details that are |
| 6916 | specific to package management systems exist. |
| 6917 | Following are implementation details that exist regardless |
| 6918 | of the package management system: |
| 6919 | <itemizedlist> |
| 6920 | <listitem><para>The typical convention used for the |
| 6921 | class extension code as used by |
| 6922 | Multilib assumes that all package names specified |
| 6923 | in |
| 6924 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGES'><filename>PACKAGES</filename></ulink> |
| 6925 | that contain <filename>${PN}</filename> have |
| 6926 | <filename>${PN}</filename> at the start of the name. |
| 6927 | When that convention is not followed and |
| 6928 | <filename>${PN}</filename> appears at |
| 6929 | the middle or the end of a name, problems occur. |
| 6930 | </para></listitem> |
| 6931 | <listitem><para>The |
| 6932 | <ulink url='&YOCTO_DOCS_REF_URL;#var-TARGET_VENDOR'><filename>TARGET_VENDOR</filename></ulink> |
| 6933 | value under Multilib will be extended to |
| 6934 | "-<replaceable>vendor</replaceable>ml<replaceable>multilib</replaceable>" |
| 6935 | (e.g. "-pokymllib32" for a "lib32" Multilib with |
| 6936 | Poky). |
| 6937 | The reason for this slightly unwieldy contraction |
| 6938 | is that any "-" characters in the vendor |
| 6939 | string presently break Autoconf's |
| 6940 | <filename>config.sub</filename>, and |
| 6941 | other separators are problematic for different |
| 6942 | reasons. |
| 6943 | </para></listitem> |
| 6944 | </itemizedlist> |
| 6945 | </para> |
Brad Bishop | 37a0e4d | 2017-12-04 01:01:44 -0500 | [diff] [blame] | 6946 | |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 6947 | <para> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 6948 | For the RPM Package Management System, the following implementation details |
| 6949 | exist: |
| 6950 | <itemizedlist> |
| 6951 | <listitem><para>A unique architecture is defined for the Multilib packages, |
| 6952 | along with creating a unique deploy folder under |
| 6953 | <filename>tmp/deploy/rpm</filename> in the |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 6954 | <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink>. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 6955 | For example, consider <filename>lib32</filename> in a |
| 6956 | <filename>qemux86-64</filename> image. |
| 6957 | The possible architectures in the system are "all", "qemux86_64", |
| 6958 | "lib32_qemux86_64", and "lib32_x86".</para></listitem> |
| 6959 | <listitem><para>The <filename>${MLPREFIX}</filename> variable is stripped from |
| 6960 | <filename>${PN}</filename> during RPM packaging. |
| 6961 | The naming for a normal RPM package and a Multilib RPM package in a |
| 6962 | <filename>qemux86-64</filename> system resolves to something similar to |
| 6963 | <filename>bash-4.1-r2.x86_64.rpm</filename> and |
| 6964 | <filename>bash-4.1.r2.lib32_x86.rpm</filename>, respectively. |
| 6965 | </para></listitem> |
| 6966 | <listitem><para>When installing a Multilib image, the RPM backend first |
| 6967 | installs the base image and then installs the Multilib libraries. |
| 6968 | </para></listitem> |
| 6969 | <listitem><para>The build system relies on RPM to resolve the identical files in the |
| 6970 | two (or more) Multilib packages.</para></listitem> |
| 6971 | </itemizedlist> |
| 6972 | </para> |
| 6973 | |
| 6974 | <para> |
| 6975 | For the IPK Package Management System, the following implementation details exist: |
| 6976 | <itemizedlist> |
| 6977 | <listitem><para>The <filename>${MLPREFIX}</filename> is not stripped from |
| 6978 | <filename>${PN}</filename> during IPK packaging. |
| 6979 | The naming for a normal RPM package and a Multilib IPK package in a |
| 6980 | <filename>qemux86-64</filename> system resolves to something like |
| 6981 | <filename>bash_4.1-r2.x86_64.ipk</filename> and |
| 6982 | <filename>lib32-bash_4.1-rw_x86.ipk</filename>, respectively. |
| 6983 | </para></listitem> |
| 6984 | <listitem><para>The IPK deploy folder is not modified with |
| 6985 | <filename>${MLPREFIX}</filename> because packages with and without |
| 6986 | the Multilib feature can exist in the same folder due to the |
| 6987 | <filename>${PN}</filename> differences.</para></listitem> |
| 6988 | <listitem><para>IPK defines a sanity check for Multilib installation |
| 6989 | using certain rules for file comparison, overridden, etc. |
| 6990 | </para></listitem> |
| 6991 | </itemizedlist> |
| 6992 | </para> |
| 6993 | </section> |
| 6994 | </section> |
| 6995 | |
| 6996 | <section id='installing-multiple-versions-of-the-same-library'> |
| 6997 | <title>Installing Multiple Versions of the Same Library</title> |
| 6998 | |
| 6999 | <para> |
| 7000 | Situations can exist where you need to install and use |
| 7001 | multiple versions of the same library on the same system |
| 7002 | at the same time. |
| 7003 | These situations almost always exist when a library API |
| 7004 | changes and you have multiple pieces of software that |
| 7005 | depend on the separate versions of the library. |
| 7006 | To accommodate these situations, you can install multiple |
| 7007 | versions of the same library in parallel on the same system. |
| 7008 | </para> |
| 7009 | |
| 7010 | <para> |
| 7011 | The process is straightforward as long as the libraries use |
| 7012 | proper versioning. |
| 7013 | With properly versioned libraries, all you need to do to |
| 7014 | individually specify the libraries is create separate, |
| 7015 | appropriately named recipes where the |
| 7016 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PN'><filename>PN</filename></ulink> part of the |
| 7017 | name includes a portion that differentiates each library version |
| 7018 | (e.g.the major part of the version number). |
| 7019 | Thus, instead of having a single recipe that loads one version |
| 7020 | of a library (e.g. <filename>clutter</filename>), you provide |
| 7021 | multiple recipes that result in different versions |
| 7022 | of the libraries you want. |
| 7023 | As an example, the following two recipes would allow the |
| 7024 | two separate versions of the <filename>clutter</filename> |
| 7025 | library to co-exist on the same system: |
| 7026 | <literallayout class='monospaced'> |
| 7027 | clutter-1.6_1.6.20.bb |
| 7028 | clutter-1.8_1.8.4.bb |
| 7029 | </literallayout> |
| 7030 | Additionally, if you have other recipes that depend on a given |
| 7031 | library, you need to use the |
| 7032 | <ulink url='&YOCTO_DOCS_REF_URL;#var-DEPENDS'><filename>DEPENDS</filename></ulink> |
| 7033 | variable to create the dependency. |
| 7034 | Continuing with the same example, if you want to have a recipe |
| 7035 | depend on the 1.8 version of the <filename>clutter</filename> |
| 7036 | library, use the following in your recipe: |
| 7037 | <literallayout class='monospaced'> |
| 7038 | DEPENDS = "clutter-1.8" |
| 7039 | </literallayout> |
| 7040 | </para> |
| 7041 | </section> |
| 7042 | </section> |
| 7043 | |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 7044 | <section id='using-x32-psabi'> |
| 7045 | <title>Using x32 psABI</title> |
| 7046 | |
| 7047 | <para> |
| 7048 | x32 processor-specific Application Binary Interface |
| 7049 | (<ulink url='https://software.intel.com/en-us/node/628948'>x32 psABI</ulink>) |
| 7050 | is a native 32-bit processor-specific ABI for |
| 7051 | <trademark class='registered'>Intel</trademark> 64 (x86-64) |
| 7052 | architectures. |
| 7053 | An ABI defines the calling conventions between functions in a |
| 7054 | processing environment. |
| 7055 | The interface determines what registers are used and what the |
| 7056 | sizes are for various C data types. |
| 7057 | </para> |
| 7058 | |
| 7059 | <para> |
| 7060 | Some processing environments prefer using 32-bit applications even |
| 7061 | when running on Intel 64-bit platforms. |
| 7062 | Consider the i386 psABI, which is a very old 32-bit ABI for Intel |
| 7063 | 64-bit platforms. |
| 7064 | The i386 psABI does not provide efficient use and access of the |
| 7065 | Intel 64-bit processor resources, leaving the system underutilized. |
| 7066 | Now consider the x86_64 psABI. |
| 7067 | This ABI is newer and uses 64-bits for data sizes and program |
| 7068 | pointers. |
| 7069 | The extra bits increase the footprint size of the programs, |
| 7070 | libraries, and also increases the memory and file system size |
| 7071 | requirements. |
| 7072 | Executing under the x32 psABI enables user programs to utilize CPU |
| 7073 | and system resources more efficiently while keeping the memory |
| 7074 | footprint of the applications low. |
| 7075 | Extra bits are used for registers but not for addressing mechanisms. |
| 7076 | </para> |
| 7077 | |
| 7078 | <para> |
| 7079 | The Yocto Project supports the final specifications of x32 psABI |
| 7080 | as follows: |
| 7081 | <itemizedlist> |
| 7082 | <listitem><para> |
| 7083 | You can create packages and images in x32 psABI format on |
| 7084 | x86_64 architecture targets. |
| 7085 | </para></listitem> |
| 7086 | <listitem><para> |
| 7087 | You can successfully build recipes with the x32 toolchain. |
| 7088 | </para></listitem> |
| 7089 | <listitem><para> |
| 7090 | You can create and boot |
| 7091 | <filename>core-image-minimal</filename> and |
| 7092 | <filename>core-image-sato</filename> images. |
| 7093 | </para></listitem> |
| 7094 | <listitem><para> |
| 7095 | RPM Package Manager (RPM) support exists for x32 binaries. |
| 7096 | </para></listitem> |
| 7097 | <listitem><para> |
| 7098 | Support for large images exists. |
| 7099 | </para></listitem> |
| 7100 | </itemizedlist> |
| 7101 | </para> |
| 7102 | |
| 7103 | <para> |
| 7104 | To use the x32 psABI, you need to edit your |
| 7105 | <filename>conf/local.conf</filename> configuration file as |
| 7106 | follows: |
| 7107 | <literallayout class='monospaced'> |
| 7108 | MACHINE = "qemux86-64" |
| 7109 | DEFAULTTUNE = "x86-64-x32" |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 7110 | baselib = "${@d.getVar('BASE_LIB_tune-' + (d.getVar('DEFAULTTUNE') \ |
| 7111 | or 'INVALID')) or 'lib'}" |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 7112 | </literallayout> |
| 7113 | Once you have set up your configuration file, use BitBake to |
| 7114 | build an image that supports the x32 psABI. |
| 7115 | Here is an example: |
| 7116 | <literallayout class='monospaced'> |
| 7117 | $ bitbake core-image-sato |
| 7118 | </literallayout> |
| 7119 | </para> |
| 7120 | </section> |
| 7121 | |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 7122 | <section id='enabling-gobject-introspection-support'> |
| 7123 | <title>Enabling GObject Introspection Support</title> |
| 7124 | |
| 7125 | <para> |
| 7126 | <ulink url='https://wiki.gnome.org/Projects/GObjectIntrospection'>GObject introspection</ulink> |
| 7127 | is the standard mechanism for accessing GObject-based software |
| 7128 | from runtime environments. |
| 7129 | GObject is a feature of the GLib library that provides an object |
| 7130 | framework for the GNOME desktop and related software. |
| 7131 | GObject Introspection adds information to GObject that allows |
| 7132 | objects created within it to be represented across different |
| 7133 | programming languages. |
| 7134 | If you want to construct GStreamer pipelines using Python, or |
| 7135 | control UPnP infrastructure using Javascript and GUPnP, |
| 7136 | GObject introspection is the only way to do it. |
| 7137 | </para> |
| 7138 | |
| 7139 | <para> |
| 7140 | This section describes the Yocto Project support for generating |
| 7141 | and packaging GObject introspection data. |
| 7142 | GObject introspection data is a description of the |
| 7143 | API provided by libraries built on top of GLib framework, |
| 7144 | and, in particular, that framework's GObject mechanism. |
| 7145 | GObject Introspection Repository (GIR) files go to |
| 7146 | <filename>-dev</filename> packages, |
| 7147 | <filename>typelib</filename> files go to main packages as they |
| 7148 | are packaged together with libraries that are introspected. |
| 7149 | </para> |
| 7150 | |
| 7151 | <para> |
| 7152 | The data is generated when building such a library, by linking |
| 7153 | the library with a small executable binary that asks the library |
| 7154 | to describe itself, and then executing the binary and |
| 7155 | processing its output. |
| 7156 | </para> |
| 7157 | |
| 7158 | <para> |
| 7159 | Generating this data in a cross-compilation environment |
| 7160 | is difficult because the library is produced for the target |
| 7161 | architecture, but its code needs to be executed on the build host. |
| 7162 | This problem is solved with the OpenEmbedded build system by |
| 7163 | running the code through QEMU, which allows precisely that. |
| 7164 | Unfortunately, QEMU does not always work perfectly as mentioned |
Brad Bishop | 96ff198 | 2019-08-19 13:50:42 -0400 | [diff] [blame] | 7165 | in the |
| 7166 | "<link linkend='known-issues'>Known Issues</link>" section. |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 7167 | </para> |
| 7168 | |
| 7169 | <section id='enabling-the-generation-of-introspection-data'> |
| 7170 | <title>Enabling the Generation of Introspection Data</title> |
| 7171 | |
| 7172 | <para> |
| 7173 | Enabling the generation of introspection data (GIR files) |
| 7174 | in your library package involves the following: |
| 7175 | <orderedlist> |
| 7176 | <listitem><para> |
| 7177 | Inherit the |
| 7178 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-gobject-introspection'><filename>gobject-introspection</filename></ulink> |
| 7179 | class. |
| 7180 | </para></listitem> |
| 7181 | <listitem><para> |
| 7182 | Make sure introspection is not disabled anywhere in |
| 7183 | the recipe or from anything the recipe includes. |
| 7184 | Also, make sure that "gobject-introspection-data" is |
| 7185 | not in |
| 7186 | <ulink url='&YOCTO_DOCS_REF_URL;#var-DISTRO_FEATURES_BACKFILL_CONSIDERED'><filename>DISTRO_FEATURES_BACKFILL_CONSIDERED</filename></ulink> |
| 7187 | and that "qemu-usermode" is not in |
| 7188 | <ulink url='&YOCTO_DOCS_REF_URL;#var-MACHINE_FEATURES_BACKFILL_CONSIDERED'><filename>MACHINE_FEATURES_BACKFILL_CONSIDERED</filename></ulink>. |
| 7189 | If either of these conditions exist, nothing will |
| 7190 | happen. |
| 7191 | </para></listitem> |
| 7192 | <listitem><para> |
| 7193 | Try to build the recipe. |
| 7194 | If you encounter build errors that look like |
| 7195 | something is unable to find |
| 7196 | <filename>.so</filename> libraries, check where these |
| 7197 | libraries are located in the source tree and add |
| 7198 | the following to the recipe: |
| 7199 | <literallayout class='monospaced'> |
| 7200 | GIR_EXTRA_LIBS_PATH = "${B}/<replaceable>something</replaceable>/.libs" |
| 7201 | </literallayout> |
| 7202 | <note> |
| 7203 | See recipes in the <filename>oe-core</filename> |
| 7204 | repository that use that |
| 7205 | <filename>GIR_EXTRA_LIBS_PATH</filename> variable |
| 7206 | as an example. |
| 7207 | </note> |
| 7208 | </para></listitem> |
| 7209 | <listitem><para> |
| 7210 | Look for any other errors, which probably mean that |
| 7211 | introspection support in a package is not entirely |
| 7212 | standard, and thus breaks down in a cross-compilation |
| 7213 | environment. |
| 7214 | For such cases, custom-made fixes are needed. |
| 7215 | A good place to ask and receive help in these cases |
| 7216 | is the |
| 7217 | <ulink url='&YOCTO_DOCS_REF_URL;#resources-mailinglist'>Yocto Project mailing lists</ulink>. |
| 7218 | </para></listitem> |
| 7219 | </orderedlist> |
| 7220 | <note> |
| 7221 | Using a library that no longer builds against the latest |
| 7222 | Yocto Project release and prints introspection related |
| 7223 | errors is a good candidate for the previous procedure. |
| 7224 | </note> |
| 7225 | </para> |
| 7226 | </section> |
| 7227 | |
| 7228 | <section id='disabling-the-generation-of-introspection-data'> |
| 7229 | <title>Disabling the Generation of Introspection Data</title> |
| 7230 | |
| 7231 | <para> |
| 7232 | You might find that you do not want to generate |
| 7233 | introspection data. |
| 7234 | Or, perhaps QEMU does not work on your build host and |
| 7235 | target architecture combination. |
| 7236 | If so, you can use either of the following methods to |
| 7237 | disable GIR file generations: |
| 7238 | <itemizedlist> |
| 7239 | <listitem><para> |
| 7240 | Add the following to your distro configuration: |
| 7241 | <literallayout class='monospaced'> |
| 7242 | DISTRO_FEATURES_BACKFILL_CONSIDERED = "gobject-introspection-data" |
| 7243 | </literallayout> |
| 7244 | Adding this statement disables generating |
| 7245 | introspection data using QEMU but will still enable |
| 7246 | building introspection tools and libraries |
| 7247 | (i.e. building them does not require the use of QEMU). |
| 7248 | </para></listitem> |
| 7249 | <listitem><para> |
| 7250 | Add the following to your machine configuration: |
| 7251 | <literallayout class='monospaced'> |
| 7252 | MACHINE_FEATURES_BACKFILL_CONSIDERED = "qemu-usermode" |
| 7253 | </literallayout> |
| 7254 | Adding this statement disables the use of QEMU |
| 7255 | when building packages for your machine. |
| 7256 | Currently, this feature is used only by introspection |
| 7257 | recipes and has the same effect as the previously |
| 7258 | described option. |
| 7259 | <note> |
| 7260 | Future releases of the Yocto Project might have |
| 7261 | other features affected by this option. |
| 7262 | </note> |
| 7263 | </para></listitem> |
| 7264 | </itemizedlist> |
| 7265 | If you disable introspection data, you can still |
| 7266 | obtain it through other means such as copying the data |
| 7267 | from a suitable sysroot, or by generating it on the |
| 7268 | target hardware. |
| 7269 | The OpenEmbedded build system does not currently |
| 7270 | provide specific support for these techniques. |
| 7271 | </para> |
| 7272 | </section> |
| 7273 | |
| 7274 | <section id='testing-that-introspection-works-in-an-image'> |
| 7275 | <title>Testing that Introspection Works in an Image</title> |
| 7276 | |
| 7277 | <para> |
| 7278 | Use the following procedure to test if generating |
| 7279 | introspection data is working in an image: |
| 7280 | <orderedlist> |
| 7281 | <listitem><para> |
| 7282 | Make sure that "gobject-introspection-data" is not in |
| 7283 | <ulink url='&YOCTO_DOCS_REF_URL;#var-DISTRO_FEATURES_BACKFILL_CONSIDERED'><filename>DISTRO_FEATURES_BACKFILL_CONSIDERED</filename></ulink> |
| 7284 | and that "qemu-usermode" is not in |
| 7285 | <ulink url='&YOCTO_DOCS_REF_URL;#var-MACHINE_FEATURES_BACKFILL_CONSIDERED'><filename>MACHINE_FEATURES_BACKFILL_CONSIDERED</filename></ulink>. |
| 7286 | </para></listitem> |
| 7287 | <listitem><para> |
| 7288 | Build <filename>core-image-sato</filename>. |
| 7289 | </para></listitem> |
| 7290 | <listitem><para> |
| 7291 | Launch a Terminal and then start Python in the |
| 7292 | terminal. |
| 7293 | </para></listitem> |
| 7294 | <listitem><para> |
| 7295 | Enter the following in the terminal: |
| 7296 | <literallayout class='monospaced'> |
| 7297 | >>> from gi.repository import GLib |
| 7298 | >>> GLib.get_host_name() |
| 7299 | </literallayout> |
| 7300 | </para></listitem> |
| 7301 | <listitem><para> |
| 7302 | For something a little more advanced, enter the |
| 7303 | following: |
| 7304 | <literallayout class='monospaced'> |
| 7305 | http://python-gtk-3-tutorial.readthedocs.org/en/latest/introduction.html |
| 7306 | </literallayout> |
| 7307 | </para></listitem> |
| 7308 | </orderedlist> |
| 7309 | </para> |
| 7310 | </section> |
| 7311 | |
| 7312 | <section id='known-issues'> |
| 7313 | <title>Known Issues</title> |
| 7314 | |
| 7315 | <para> |
| 7316 | The following know issues exist for |
| 7317 | GObject Introspection Support: |
| 7318 | <itemizedlist> |
| 7319 | <listitem><para> |
| 7320 | <filename>qemu-ppc64</filename> immediately crashes. |
| 7321 | Consequently, you cannot build introspection data on |
| 7322 | that architecture. |
| 7323 | </para></listitem> |
| 7324 | <listitem><para> |
| 7325 | x32 is not supported by QEMU. |
| 7326 | Consequently, introspection data is disabled. |
| 7327 | </para></listitem> |
| 7328 | <listitem><para> |
| 7329 | musl causes transient GLib binaries to crash on |
| 7330 | assertion failures. |
| 7331 | Consequently, generating introspection data is |
| 7332 | disabled. |
| 7333 | </para></listitem> |
| 7334 | <listitem><para> |
| 7335 | Because QEMU is not able to run the binaries correctly, |
| 7336 | introspection is disabled for some specific packages |
| 7337 | under specific architectures (e.g. |
| 7338 | <filename>gcr</filename>, |
| 7339 | <filename>libsecret</filename>, and |
| 7340 | <filename>webkit</filename>). |
| 7341 | </para></listitem> |
| 7342 | <listitem><para> |
| 7343 | QEMU usermode might not work properly when running |
| 7344 | 64-bit binaries under 32-bit host machines. |
| 7345 | In particular, "qemumips64" is known to not work under |
| 7346 | i686. |
| 7347 | </para></listitem> |
| 7348 | </itemizedlist> |
| 7349 | </para> |
| 7350 | </section> |
| 7351 | </section> |
| 7352 | |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 7353 | <section id='dev-optionally-using-an-external-toolchain'> |
| 7354 | <title>Optionally Using an External Toolchain</title> |
| 7355 | |
| 7356 | <para> |
| 7357 | You might want to use an external toolchain as part of your |
| 7358 | development. |
| 7359 | If this is the case, the fundamental steps you need to accomplish |
| 7360 | are as follows: |
| 7361 | <itemizedlist> |
| 7362 | <listitem><para> |
| 7363 | Understand where the installed toolchain resides. |
| 7364 | For cases where you need to build the external toolchain, |
| 7365 | you would need to take separate steps to build and install |
| 7366 | the toolchain. |
| 7367 | </para></listitem> |
| 7368 | <listitem><para> |
| 7369 | Make sure you add the layer that contains the toolchain to |
| 7370 | your <filename>bblayers.conf</filename> file through the |
| 7371 | <ulink url='&YOCTO_DOCS_REF_URL;#var-BBLAYERS'><filename>BBLAYERS</filename></ulink> |
| 7372 | variable. |
| 7373 | </para></listitem> |
| 7374 | <listitem><para> |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 7375 | Set the <filename>EXTERNAL_TOOLCHAIN</filename> |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 7376 | variable in your <filename>local.conf</filename> file |
| 7377 | to the location in which you installed the toolchain. |
| 7378 | </para></listitem> |
| 7379 | </itemizedlist> |
| 7380 | A good example of an external toolchain used with the Yocto Project |
| 7381 | is <trademark class='registered'>Mentor Graphics</trademark> |
| 7382 | Sourcery G++ Toolchain. |
| 7383 | You can see information on how to use that particular layer in the |
| 7384 | <filename>README</filename> file at |
| 7385 | <ulink url='http://github.com/MentorEmbedded/meta-sourcery/'></ulink>. |
| 7386 | You can find further information by reading about the |
| 7387 | <ulink url='&YOCTO_DOCS_REF_URL;#var-TCMODE'><filename>TCMODE</filename></ulink> |
| 7388 | variable in the Yocto Project Reference Manual's variable glossary. |
| 7389 | </para> |
| 7390 | </section> |
| 7391 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 7392 | <section id='creating-partitioned-images-using-wic'> |
| 7393 | <title>Creating Partitioned Images Using Wic</title> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 7394 | |
| 7395 | <para> |
| 7396 | Creating an image for a particular hardware target using the |
| 7397 | OpenEmbedded build system does not necessarily mean you can boot |
| 7398 | that image as is on your device. |
| 7399 | Physical devices accept and boot images in various ways depending |
| 7400 | on the specifics of the device. |
| 7401 | Usually, information about the hardware can tell you what image |
| 7402 | format the device requires. |
| 7403 | Should your device require multiple partitions on an SD card, flash, |
| 7404 | or an HDD, you can use the OpenEmbedded Image Creator, |
Brad Bishop | 37a0e4d | 2017-12-04 01:01:44 -0500 | [diff] [blame] | 7405 | Wic, to create the properly partitioned image. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 7406 | </para> |
| 7407 | |
| 7408 | <para> |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 7409 | The <filename>wic</filename> command generates partitioned |
| 7410 | images from existing OpenEmbedded build artifacts. |
| 7411 | Image generation is driven by partitioning commands |
| 7412 | contained in an Openembedded kickstart file |
| 7413 | (<filename>.wks</filename>) specified either directly on |
| 7414 | the command line or as one of a selection of canned |
| 7415 | kickstart files as shown with the |
| 7416 | <filename>wic list images</filename> command in the |
| 7417 | "<link linkend='using-a-provided-kickstart-file'>Using an Existing Kickstart File</link>" |
| 7418 | section. |
| 7419 | When you apply the command to a given set of build |
| 7420 | artifacts, the result is an image or set of images that |
| 7421 | can be directly written onto media and used on a particular |
| 7422 | system. |
| 7423 | <note> |
| 7424 | For a kickstart file reference, see the |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 7425 | "<ulink url='&YOCTO_DOCS_REF_URL;#ref-kickstart'>OpenEmbedded Kickstart (<filename>.wks</filename>) Reference</ulink>" |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 7426 | Chapter in the Yocto Project Reference Manual. |
| 7427 | </note> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 7428 | </para> |
| 7429 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 7430 | <para> |
| 7431 | The <filename>wic</filename> command and the infrastructure |
| 7432 | it is based on is by definition incomplete. |
| 7433 | The purpose of the command is to allow the generation of |
| 7434 | customized images, and as such, was designed to be |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 7435 | completely extensible through a plugin interface. |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 7436 | See the |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 7437 | "<link linkend='wic-using-the-wic-plugin-interface'>Using the Wic PlugIn Interface</link>" |
| 7438 | section for information on these plugins. |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 7439 | </para> |
| 7440 | |
| 7441 | <para> |
| 7442 | This section provides some background information on Wic, |
| 7443 | describes what you need to have in |
| 7444 | place to run the tool, provides instruction on how to use |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 7445 | the Wic utility, provides information on using the Wic plugins |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 7446 | interface, and provides several examples that show how to use |
| 7447 | Wic. |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 7448 | </para> |
| 7449 | |
| 7450 | <section id='wic-background'> |
| 7451 | <title>Background</title> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 7452 | |
| 7453 | <para> |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 7454 | This section provides some background on the Wic utility. |
| 7455 | While none of this information is required to use |
| 7456 | Wic, you might find it interesting. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 7457 | <itemizedlist> |
| 7458 | <listitem><para> |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 7459 | The name "Wic" is derived from OpenEmbedded |
| 7460 | Image Creator (oeic). |
| 7461 | The "oe" diphthong in "oeic" was promoted to the |
| 7462 | letter "w", because "oeic" is both difficult to |
| 7463 | remember and to pronounce. |
| 7464 | </para></listitem> |
| 7465 | <listitem><para> |
| 7466 | Wic is loosely based on the |
| 7467 | Meego Image Creator (<filename>mic</filename>) |
| 7468 | framework. |
| 7469 | The Wic implementation has been |
| 7470 | heavily modified to make direct use of OpenEmbedded |
| 7471 | build artifacts instead of package installation and |
| 7472 | configuration, which are already incorporated within |
| 7473 | the OpenEmbedded artifacts. |
| 7474 | </para></listitem> |
| 7475 | <listitem><para> |
| 7476 | Wic is a completely independent |
| 7477 | standalone utility that initially provides |
| 7478 | easier-to-use and more flexible replacements for an |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 7479 | existing functionality in OE-Core's |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 7480 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-image-live'><filename>image-live</filename></ulink> |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 7481 | class. |
| 7482 | The difference between Wic and those examples is |
| 7483 | that with Wic the functionality of those scripts is |
| 7484 | implemented by a general-purpose partitioning language, |
| 7485 | which is based on Redhat kickstart syntax. |
| 7486 | </para></listitem> |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 7487 | </itemizedlist> |
| 7488 | </para> |
| 7489 | </section> |
| 7490 | |
| 7491 | <section id='wic-requirements'> |
| 7492 | <title>Requirements</title> |
| 7493 | |
| 7494 | <para> |
| 7495 | In order to use the Wic utility with the OpenEmbedded Build |
| 7496 | system, your system needs to meet the following |
| 7497 | requirements: |
| 7498 | <itemizedlist> |
| 7499 | <listitem><para> |
| 7500 | The Linux distribution on your development host must |
| 7501 | support the Yocto Project. |
| 7502 | See the |
| 7503 | "<ulink url='&YOCTO_DOCS_REF_URL;#detailed-supported-distros'>Supported Linux Distributions</ulink>" |
| 7504 | section in the Yocto Project Reference Manual for |
| 7505 | the list of distributions that support the |
| 7506 | Yocto Project. |
| 7507 | </para></listitem> |
| 7508 | <listitem><para> |
| 7509 | The standard system utilities, such as |
| 7510 | <filename>cp</filename>, must be installed on your |
| 7511 | development host system. |
| 7512 | </para></listitem> |
| 7513 | <listitem><para> |
| 7514 | You must have sourced the build environment |
| 7515 | setup script (i.e. |
| 7516 | <ulink url='&YOCTO_DOCS_REF_URL;#structure-core-script'><filename>&OE_INIT_FILE;</filename></ulink>) |
| 7517 | found in the |
| 7518 | <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink>. |
| 7519 | </para></listitem> |
| 7520 | <listitem><para> |
| 7521 | You need to have the build artifacts already |
| 7522 | available, which typically means that you must |
| 7523 | have already created an image using the |
| 7524 | Openembedded build system (e.g. |
| 7525 | <filename>core-image-minimal</filename>). |
| 7526 | While it might seem redundant to generate an image |
| 7527 | in order to create an image using |
| 7528 | Wic, the current version of |
| 7529 | Wic requires the artifacts |
| 7530 | in the form generated by the OpenEmbedded build |
| 7531 | system. |
| 7532 | </para></listitem> |
| 7533 | <listitem><para> |
| 7534 | You must build several native tools, which are |
| 7535 | built to run on the build system: |
| 7536 | <literallayout class='monospaced'> |
| 7537 | $ bitbake parted-native dosfstools-native mtools-native |
| 7538 | </literallayout> |
| 7539 | </para></listitem> |
| 7540 | <listitem><para> |
Brad Bishop | 37a0e4d | 2017-12-04 01:01:44 -0500 | [diff] [blame] | 7541 | Include "wic" as part of the |
| 7542 | <ulink url='&YOCTO_DOCS_REF_URL;#var-IMAGE_FSTYPES'><filename>IMAGE_FSTYPES</filename></ulink> |
| 7543 | variable. |
| 7544 | </para></listitem> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 7545 | <listitem><para> |
Brad Bishop | 37a0e4d | 2017-12-04 01:01:44 -0500 | [diff] [blame] | 7546 | Include the name of the |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 7547 | <ulink url='&YOCTO_DOCS_REF_URL;#openembedded-kickstart-wks-reference'>wic kickstart file</ulink> |
Brad Bishop | 37a0e4d | 2017-12-04 01:01:44 -0500 | [diff] [blame] | 7548 | as part of the |
| 7549 | <ulink url='&YOCTO_DOCS_REF_URL;#var-WKS_FILE'><filename>WKS_FILE</filename></ulink> |
| 7550 | variable |
| 7551 | </para></listitem> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 7552 | </itemizedlist> |
| 7553 | </para> |
| 7554 | </section> |
| 7555 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 7556 | <section id='wic-getting-help'> |
| 7557 | <title>Getting Help</title> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 7558 | |
| 7559 | <para> |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 7560 | You can get general help for the <filename>wic</filename> |
| 7561 | command by entering the <filename>wic</filename> command |
| 7562 | by itself or by entering the command with a help argument |
| 7563 | as follows: |
| 7564 | <literallayout class='monospaced'> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 7565 | $ wic -h |
| 7566 | $ wic --help |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 7567 | $ wic help |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 7568 | </literallayout> |
| 7569 | </para> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 7570 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 7571 | <para> |
| 7572 | Currently, Wic supports seven commands: |
| 7573 | <filename>cp</filename>, <filename>create</filename>, |
| 7574 | <filename>help</filename>, <filename>list</filename>, |
| 7575 | <filename>ls</filename>, <filename>rm</filename>, and |
| 7576 | <filename>write</filename>. |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 7577 | You can get help for all these commands except "help" by |
| 7578 | using the following form: |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 7579 | <literallayout class='monospaced'> |
Brad Bishop | 37a0e4d | 2017-12-04 01:01:44 -0500 | [diff] [blame] | 7580 | $ wic help <replaceable>command</replaceable> |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 7581 | </literallayout> |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 7582 | For example, the following command returns help for the |
| 7583 | <filename>write</filename> command: |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 7584 | <literallayout class='monospaced'> |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 7585 | $ wic help write |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 7586 | </literallayout> |
| 7587 | </para> |
Brad Bishop | 37a0e4d | 2017-12-04 01:01:44 -0500 | [diff] [blame] | 7588 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 7589 | <para> |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 7590 | Wic supports help for three topics: |
| 7591 | <filename>overview</filename>, |
| 7592 | <filename>plugins</filename>, and |
| 7593 | <filename>kickstart</filename>. |
| 7594 | You can get help for any topic using the following form: |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 7595 | <literallayout class='monospaced'> |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 7596 | $ wic help <replaceable>topic</replaceable> |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 7597 | </literallayout> |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 7598 | For example, the following returns overview help for Wic: |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 7599 | <literallayout class='monospaced'> |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 7600 | $ wic help overview |
| 7601 | </literallayout> |
| 7602 | </para> |
| 7603 | |
| 7604 | <para> |
| 7605 | One additional level of help exists for Wic. |
| 7606 | You can get help on individual images through the |
| 7607 | <filename>list</filename> command. |
| 7608 | You can use the <filename>list</filename> command to return the |
| 7609 | available Wic images as follows: |
| 7610 | <literallayout class='monospaced'> |
| 7611 | $ wic list images |
| 7612 | mpc8315e-rdb Create SD card image for MPC8315E-RDB |
| 7613 | genericx86 Create an EFI disk image for genericx86* |
| 7614 | beaglebone-yocto Create SD card image for Beaglebone |
| 7615 | edgerouter Create SD card image for Edgerouter |
| 7616 | qemux86-directdisk Create a qemu machine 'pcbios' direct disk image |
| 7617 | directdisk-gpt Create a 'pcbios' direct disk image |
| 7618 | mkefidisk Create an EFI disk image |
| 7619 | directdisk Create a 'pcbios' direct disk image |
| 7620 | systemd-bootdisk Create an EFI disk image with systemd-boot |
| 7621 | mkhybridiso Create a hybrid ISO image |
| 7622 | sdimage-bootpart Create SD card image with a boot partition |
| 7623 | directdisk-multi-rootfs Create multi rootfs image using rootfs plugin |
| 7624 | directdisk-bootloader-config Create a 'pcbios' direct disk image with custom bootloader config |
| 7625 | </literallayout> |
| 7626 | Once you know the list of available Wic images, you can use |
| 7627 | <filename>help</filename> with the command to get help on a |
| 7628 | particular image. |
| 7629 | For example, the following command returns help on the |
| 7630 | "beaglebone-yocto" image: |
| 7631 | <literallayout class='monospaced'> |
| 7632 | $ wic list beaglebone-yocto help |
| 7633 | |
| 7634 | |
| 7635 | Creates a partitioned SD card image for Beaglebone. |
| 7636 | Boot files are located in the first vfat partition. |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 7637 | </literallayout> |
| 7638 | </para> |
| 7639 | </section> |
Brad Bishop | 37a0e4d | 2017-12-04 01:01:44 -0500 | [diff] [blame] | 7640 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 7641 | <section id='operational-modes'> |
| 7642 | <title>Operational Modes</title> |
| 7643 | |
| 7644 | <para> |
| 7645 | You can use Wic in two different |
| 7646 | modes, depending on how much control you need for |
| 7647 | specifying the Openembedded build artifacts that are |
| 7648 | used for creating the image: Raw and Cooked: |
| 7649 | <itemizedlist> |
| 7650 | <listitem><para> |
| 7651 | <emphasis>Raw Mode:</emphasis> |
| 7652 | You explicitly specify build artifacts through |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 7653 | Wic command-line arguments. |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 7654 | </para></listitem> |
| 7655 | <listitem><para> |
| 7656 | <emphasis>Cooked Mode:</emphasis> |
| 7657 | The current |
| 7658 | <ulink url='&YOCTO_DOCS_REF_URL;#var-MACHINE'><filename>MACHINE</filename></ulink> |
| 7659 | setting and image name are used to automatically |
| 7660 | locate and provide the build artifacts. |
| 7661 | You just supply a kickstart file and the name |
| 7662 | of the image from which to use artifacts. |
| 7663 | </para></listitem> |
| 7664 | </itemizedlist> |
| 7665 | </para> |
| 7666 | |
| 7667 | <para> |
| 7668 | Regardless of the mode you use, you need to have the build |
| 7669 | artifacts ready and available. |
| 7670 | </para> |
| 7671 | |
| 7672 | <section id='raw-mode'> |
| 7673 | <title>Raw Mode</title> |
Brad Bishop | 37a0e4d | 2017-12-04 01:01:44 -0500 | [diff] [blame] | 7674 | |
| 7675 | <para> |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 7676 | Running Wic in raw mode allows you to specify all the |
| 7677 | partitions through the <filename>wic</filename> |
| 7678 | command line. |
| 7679 | The primary use for raw mode is if you have built |
| 7680 | your kernel outside of the Yocto Project |
| 7681 | <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink>. |
| 7682 | In other words, you can point to arbitrary kernel, |
| 7683 | root filesystem locations, and so forth. |
| 7684 | Contrast this behavior with cooked mode where Wic |
| 7685 | looks in the Build Directory (e.g. |
| 7686 | <filename>tmp/deploy/images/</filename><replaceable>machine</replaceable>). |
Brad Bishop | 37a0e4d | 2017-12-04 01:01:44 -0500 | [diff] [blame] | 7687 | </para> |
| 7688 | |
| 7689 | <para> |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 7690 | The general form of the |
| 7691 | <filename>wic</filename> command in raw mode is: |
| 7692 | <literallayout class='monospaced'> |
| 7693 | $ wic create <replaceable>wks_file</replaceable> <replaceable>options</replaceable> ... |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 7694 | |
Brad Bishop | 37a0e4d | 2017-12-04 01:01:44 -0500 | [diff] [blame] | 7695 | Where: |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 7696 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 7697 | <replaceable>wks_file</replaceable>: |
Brad Bishop | 37a0e4d | 2017-12-04 01:01:44 -0500 | [diff] [blame] | 7698 | An OpenEmbedded kickstart file. You can provide |
| 7699 | your own custom file or use a file from a set of |
| 7700 | existing files as described by further options. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 7701 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 7702 | optional arguments: |
| 7703 | -h, --help show this help message and exit |
| 7704 | -o <replaceable>OUTDIR</replaceable>, --outdir <replaceable>OUTDIR</replaceable> |
| 7705 | name of directory to create image in |
| 7706 | -e <replaceable>IMAGE_NAME</replaceable>, --image-name <replaceable>IMAGE_NAME</replaceable> |
| 7707 | name of the image to use the artifacts from e.g. core- |
| 7708 | image-sato |
| 7709 | -r <replaceable>ROOTFS_DIR</replaceable>, --rootfs-dir <replaceable>ROOTFS_DIR</replaceable> |
| 7710 | path to the /rootfs dir to use as the .wks rootfs |
| 7711 | source |
| 7712 | -b <replaceable>BOOTIMG_DIR</replaceable>, --bootimg-dir <replaceable>BOOTIMG_DIR</replaceable> |
| 7713 | path to the dir containing the boot artifacts (e.g. |
| 7714 | /EFI or /syslinux dirs) to use as the .wks bootimg |
| 7715 | source |
| 7716 | -k <replaceable>KERNEL_DIR</replaceable>, --kernel-dir <replaceable>KERNEL_DIR</replaceable> |
| 7717 | path to the dir containing the kernel to use in the |
| 7718 | .wks bootimg |
| 7719 | -n <replaceable>NATIVE_SYSROOT</replaceable>, --native-sysroot <replaceable>NATIVE_SYSROOT</replaceable> |
| 7720 | path to the native sysroot containing the tools to use |
| 7721 | to build the image |
| 7722 | -s, --skip-build-check |
| 7723 | skip the build check |
| 7724 | -f, --build-rootfs build rootfs |
| 7725 | -c {gzip,bzip2,xz}, --compress-with {gzip,bzip2,xz} |
| 7726 | compress image with specified compressor |
| 7727 | -m, --bmap generate .bmap |
| 7728 | --no-fstab-update Do not change fstab file. |
| 7729 | -v <replaceable>VARS_DIR</replaceable>, --vars <replaceable>VARS_DIR</replaceable> |
| 7730 | directory with <image>.env files that store bitbake |
| 7731 | variables |
| 7732 | -D, --debug output debug information |
| 7733 | </literallayout> |
| 7734 | <note> |
| 7735 | You do not need root privileges to run |
| 7736 | Wic. |
| 7737 | In fact, you should not run as root when using the |
| 7738 | utility. |
| 7739 | </note> |
| 7740 | </para> |
| 7741 | </section> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 7742 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 7743 | <section id='cooked-mode'> |
| 7744 | <title>Cooked Mode</title> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 7745 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 7746 | <para> |
| 7747 | Running Wic in cooked mode leverages off artifacts in |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 7748 | the Build Directory. |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 7749 | In other words, you do not have to specify kernel or |
| 7750 | root filesystem locations as part of the command. |
| 7751 | All you need to provide is a kickstart file and the |
| 7752 | name of the image from which to use artifacts by using |
| 7753 | the "-e" option. |
| 7754 | Wic looks in the Build Directory (e.g. |
| 7755 | <filename>tmp/deploy/images/</filename><replaceable>machine</replaceable>) |
| 7756 | for artifacts. |
| 7757 | </para> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 7758 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 7759 | <para> |
| 7760 | The general form of the <filename>wic</filename> |
| 7761 | command using Cooked Mode is as follows: |
| 7762 | <literallayout class='monospaced'> |
| 7763 | $ wic create <replaceable>wks_file</replaceable> -e <replaceable>IMAGE_NAME</replaceable> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 7764 | |
Brad Bishop | 37a0e4d | 2017-12-04 01:01:44 -0500 | [diff] [blame] | 7765 | Where: |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 7766 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 7767 | <replaceable>wks_file</replaceable>: |
| 7768 | An OpenEmbedded kickstart file. You can provide |
| 7769 | your own custom file or use a file from a set of |
| 7770 | existing files provided with the Yocto Project |
| 7771 | release. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 7772 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 7773 | required argument: |
| 7774 | -e <replaceable>IMAGE_NAME</replaceable>, --image-name <replaceable>IMAGE_NAME</replaceable> |
| 7775 | name of the image to use the artifacts from e.g. core- |
| 7776 | image-sato |
Brad Bishop | 37a0e4d | 2017-12-04 01:01:44 -0500 | [diff] [blame] | 7777 | </literallayout> |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 7778 | </para> |
| 7779 | </section> |
| 7780 | </section> |
| 7781 | |
| 7782 | <section id='using-a-provided-kickstart-file'> |
| 7783 | <title>Using an Existing Kickstart File</title> |
| 7784 | |
| 7785 | <para> |
| 7786 | If you do not want to create your own kickstart file, you |
| 7787 | can use an existing file provided by the Wic installation. |
| 7788 | As shipped, kickstart files can be found in the |
| 7789 | Yocto Project |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 7790 | <ulink url='&YOCTO_DOCS_OM_URL;#source-repositories'>Source Repositories</ulink> |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 7791 | in the following two locations: |
| 7792 | <literallayout class='monospaced'> |
| 7793 | poky/meta-yocto-bsp/wic |
| 7794 | poky/scripts/lib/wic/canned-wks |
| 7795 | </literallayout> |
| 7796 | Use the following command to list the available kickstart |
| 7797 | files: |
| 7798 | <literallayout class='monospaced'> |
| 7799 | $ wic list images |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 7800 | mpc8315e-rdb Create SD card image for MPC8315E-RDB |
| 7801 | genericx86 Create an EFI disk image for genericx86* |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 7802 | beaglebone-yocto Create SD card image for Beaglebone |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 7803 | edgerouter Create SD card image for Edgerouter |
| 7804 | qemux86-directdisk Create a qemu machine 'pcbios' direct disk image |
| 7805 | directdisk-gpt Create a 'pcbios' direct disk image |
| 7806 | mkefidisk Create an EFI disk image |
| 7807 | directdisk Create a 'pcbios' direct disk image |
| 7808 | systemd-bootdisk Create an EFI disk image with systemd-boot |
| 7809 | mkhybridiso Create a hybrid ISO image |
| 7810 | sdimage-bootpart Create SD card image with a boot partition |
| 7811 | directdisk-multi-rootfs Create multi rootfs image using rootfs plugin |
| 7812 | directdisk-bootloader-config Create a 'pcbios' direct disk image with custom bootloader config |
| 7813 | </literallayout> |
| 7814 | When you use an existing file, you do not have to use the |
| 7815 | <filename>.wks</filename> extension. |
| 7816 | Here is an example in Raw Mode that uses the |
| 7817 | <filename>directdisk</filename> file: |
| 7818 | <literallayout class='monospaced'> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 7819 | $ wic create directdisk -r <replaceable>rootfs_dir</replaceable> -b <replaceable>bootimg_dir</replaceable> \ |
| 7820 | -k <replaceable>kernel_dir</replaceable> -n <replaceable>native_sysroot</replaceable> |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 7821 | </literallayout> |
| 7822 | </para> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 7823 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 7824 | <para> |
| 7825 | Here are the actual partition language commands |
| 7826 | used in the <filename>genericx86.wks</filename> file to |
| 7827 | generate an image: |
| 7828 | <literallayout class='monospaced'> |
| 7829 | # short-description: Create an EFI disk image for genericx86* |
| 7830 | # long-description: Creates a partitioned EFI disk image for genericx86* machines |
| 7831 | part /boot --source bootimg-efi --sourceparams="loader=grub-efi" --ondisk sda --label msdos --active --align 1024 |
| 7832 | part / --source rootfs --ondisk sda --fstype=ext4 --label platform --align 1024 --use-uuid |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 7833 | part swap --ondisk sda --size 44 --label swap1 --fstype=swap |
| 7834 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 7835 | bootloader --ptable gpt --timeout=5 --append="rootfstype=ext4 console=ttyS0,115200 console=tty0" |
| 7836 | </literallayout> |
| 7837 | </para> |
| 7838 | </section> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 7839 | |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 7840 | <section id='wic-using-the-wic-plugin-interface'> |
| 7841 | <title>Using the Wic Plugin Interface</title> |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 7842 | |
| 7843 | <para> |
| 7844 | You can extend and specialize Wic functionality by using |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 7845 | Wic plugins. |
| 7846 | This section explains the Wic plugin interface. |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 7847 | <note> |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 7848 | Wic plugins consist of "source" and "imager" plugins. |
| 7849 | Imager plugins are beyond the scope of this section. |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 7850 | </note> |
| 7851 | </para> |
| 7852 | |
| 7853 | <para> |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 7854 | Source plugins provide a mechanism to customize partition |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 7855 | content during the Wic image generation process. |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 7856 | You can use source plugins to map values that you specify |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 7857 | using <filename>--source</filename> commands in kickstart |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 7858 | files (i.e. <filename>*.wks</filename>) to a plugin |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 7859 | implementation used to populate a given partition. |
| 7860 | <note> |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 7861 | If you use plugins that have build-time dependencies |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 7862 | (e.g. native tools, bootloaders, and so forth) |
| 7863 | when building a Wic image, you need to specify those |
| 7864 | dependencies using the |
| 7865 | <ulink url='&YOCTO_DOCS_REF_URL;#var-WKS_FILE_DEPENDS'><filename>WKS_FILE_DEPENDS</filename></ulink> |
| 7866 | variable. |
| 7867 | </note> |
| 7868 | </para> |
| 7869 | |
| 7870 | <para> |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 7871 | Source plugins are subclasses defined in plugin files. |
| 7872 | As shipped, the Yocto Project provides several plugin |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 7873 | files. |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 7874 | You can see the source plugin files that ship with the |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 7875 | Yocto Project |
| 7876 | <ulink url='&YOCTO_GIT_URL;/cgit/cgit.cgi/poky/tree/scripts/lib/wic/plugins/source'>here</ulink>. |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 7877 | Each of these plugin files contains source plugins that |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 7878 | are designed to populate a specific Wic image partition. |
| 7879 | </para> |
| 7880 | |
| 7881 | <para> |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 7882 | Source plugins are subclasses of the |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 7883 | <filename>SourcePlugin</filename> class, which is |
| 7884 | defined in the |
| 7885 | <filename>poky/scripts/lib/wic/pluginbase.py</filename> |
| 7886 | file. |
| 7887 | For example, the <filename>BootimgEFIPlugin</filename> |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 7888 | source plugin found in the |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 7889 | <filename>bootimg-efi.py</filename> file is a subclass of |
| 7890 | the <filename>SourcePlugin</filename> class, which is found |
| 7891 | in the <filename>pluginbase.py</filename> file. |
| 7892 | </para> |
| 7893 | |
| 7894 | <para> |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 7895 | You can also implement source plugins in a layer outside |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 7896 | of the Source Repositories (external layer). |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 7897 | To do so, be sure that your plugin files are located in |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 7898 | a directory whose path is |
| 7899 | <filename>scripts/lib/wic/plugins/source/</filename> |
| 7900 | within your external layer. |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 7901 | When the plugin files are located there, the source |
| 7902 | plugins they contain are made available to Wic. |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 7903 | </para> |
| 7904 | |
| 7905 | <para> |
| 7906 | When the Wic implementation needs to invoke a |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 7907 | partition-specific implementation, it looks for the plugin |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 7908 | with the same name as the <filename>--source</filename> |
| 7909 | parameter used in the kickstart file given to that |
| 7910 | partition. |
| 7911 | For example, if the partition is set up using the following |
| 7912 | command in a kickstart file: |
| 7913 | <literallayout class='monospaced'> |
| 7914 | part /boot --source bootimg-pcbios --ondisk sda --label boot --active --align 1024 |
| 7915 | </literallayout> |
| 7916 | The methods defined as class members of the matching |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 7917 | source plugin (i.e. <filename>bootimg-pcbios</filename>) |
| 7918 | in the <filename>bootimg-pcbios.py</filename> plugin file |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 7919 | are used. |
| 7920 | </para> |
| 7921 | |
| 7922 | <para> |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 7923 | To be more concrete, here is the corresponding plugin |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 7924 | definition from the <filename>bootimg-pcbios.py</filename> |
| 7925 | file for the previous command along with an example |
| 7926 | method called by the Wic implementation when it needs to |
| 7927 | prepare a partition using an implementation-specific |
| 7928 | function: |
| 7929 | <literallayout class='monospaced'> |
| 7930 | . |
| 7931 | . |
| 7932 | . |
| 7933 | class BootimgPcbiosPlugin(SourcePlugin): |
| 7934 | """ |
| 7935 | Create MBR boot partition and install syslinux on it. |
| 7936 | """ |
| 7937 | |
| 7938 | name = 'bootimg-pcbios' |
| 7939 | . |
| 7940 | . |
| 7941 | . |
| 7942 | @classmethod |
| 7943 | def do_prepare_partition(cls, part, source_params, creator, cr_workdir, |
| 7944 | oe_builddir, bootimg_dir, kernel_dir, |
| 7945 | rootfs_dir, native_sysroot): |
| 7946 | """ |
| 7947 | Called to do the actual content population for a partition i.e. it |
| 7948 | 'prepares' the partition to be incorporated into the image. |
| 7949 | In this case, prepare content for legacy bios boot partition. |
| 7950 | """ |
| 7951 | . |
| 7952 | . |
| 7953 | . |
| 7954 | </literallayout> |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 7955 | If a subclass (plugin) itself does not implement a |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 7956 | particular function, Wic locates and uses the default |
| 7957 | version in the superclass. |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 7958 | It is for this reason that all source plugins are derived |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 7959 | from the <filename>SourcePlugin</filename> class. |
| 7960 | </para> |
| 7961 | |
| 7962 | <para> |
| 7963 | The <filename>SourcePlugin</filename> class defined in |
| 7964 | the <filename>pluginbase.py</filename> file defines |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 7965 | a set of methods that source plugins can implement or |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 7966 | override. |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 7967 | Any plugins (subclass of |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 7968 | <filename>SourcePlugin</filename>) that do not implement |
| 7969 | a particular method inherit the implementation of the |
| 7970 | method from the <filename>SourcePlugin</filename> class. |
| 7971 | For more information, see the |
| 7972 | <filename>SourcePlugin</filename> class in the |
| 7973 | <filename>pluginbase.py</filename> file for details: |
| 7974 | </para> |
| 7975 | |
| 7976 | <para> |
| 7977 | The following list describes the methods implemented in the |
| 7978 | <filename>SourcePlugin</filename> class: |
| 7979 | <itemizedlist> |
| 7980 | <listitem><para> |
| 7981 | <emphasis><filename>do_prepare_partition()</filename>:</emphasis> |
| 7982 | Called to populate a partition with actual content. |
| 7983 | In other words, the method prepares the final |
| 7984 | partition image that is incorporated into the |
| 7985 | disk image. |
| 7986 | </para></listitem> |
| 7987 | <listitem><para> |
| 7988 | <emphasis><filename>do_configure_partition()</filename>:</emphasis> |
| 7989 | Called before |
| 7990 | <filename>do_prepare_partition()</filename> to |
| 7991 | create custom configuration files for a partition |
| 7992 | (e.g. syslinux or grub configuration files). |
| 7993 | </para></listitem> |
| 7994 | <listitem><para> |
| 7995 | <emphasis><filename>do_install_disk()</filename>:</emphasis> |
| 7996 | Called after all partitions have been prepared and |
| 7997 | assembled into a disk image. |
| 7998 | This method provides a hook to allow finalization |
| 7999 | of a disk image (e.g. writing an MBR). |
| 8000 | </para></listitem> |
| 8001 | <listitem><para> |
| 8002 | <emphasis><filename>do_stage_partition()</filename>:</emphasis> |
| 8003 | Special content-staging hook called before |
| 8004 | <filename>do_prepare_partition()</filename>. |
| 8005 | This method is normally empty.</para> |
| 8006 | |
| 8007 | <para>Typically, a partition just uses the passed-in |
| 8008 | parameters (e.g. the unmodified value of |
| 8009 | <filename>bootimg_dir</filename>). |
| 8010 | However, in some cases, things might need to be |
| 8011 | more tailored. |
| 8012 | As an example, certain files might additionally |
| 8013 | need to be taken from |
| 8014 | <filename>bootimg_dir + /boot</filename>. |
| 8015 | This hook allows those files to be staged in a |
| 8016 | customized fashion. |
| 8017 | <note> |
| 8018 | <filename>get_bitbake_var()</filename> |
| 8019 | allows you to access non-standard variables |
| 8020 | that you might want to use for this |
| 8021 | behavior. |
| 8022 | </note> |
| 8023 | </para></listitem> |
| 8024 | </itemizedlist> |
| 8025 | </para> |
| 8026 | |
| 8027 | <para> |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 8028 | You can extend the source plugin mechanism. |
| 8029 | To add more hooks, create more source plugin methods |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 8030 | within <filename>SourcePlugin</filename> and the |
| 8031 | corresponding derived subclasses. |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 8032 | The code that calls the plugin methods uses the |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 8033 | <filename>plugin.get_source_plugin_methods()</filename> |
| 8034 | function to find the method or methods needed by the call. |
| 8035 | Retrieval of those methods is accomplished by filling up |
| 8036 | a dict with keys that contain the method names of interest. |
| 8037 | On success, these will be filled in with the actual |
| 8038 | methods. |
| 8039 | See the Wic implementation for examples and details. |
| 8040 | </para> |
| 8041 | </section> |
| 8042 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 8043 | <section id='wic-usage-examples'> |
| 8044 | <title>Examples</title> |
| 8045 | |
| 8046 | <para> |
| 8047 | This section provides several examples that show how to use |
| 8048 | the Wic utility. |
| 8049 | All the examples assume the list of requirements in the |
| 8050 | "<link linkend='wic-requirements'>Requirements</link>" |
| 8051 | section have been met. |
| 8052 | The examples assume the previously generated image is |
| 8053 | <filename>core-image-minimal</filename>. |
| 8054 | </para> |
| 8055 | |
| 8056 | <section id='generate-an-image-using-a-provided-kickstart-file'> |
| 8057 | <title>Generate an Image using an Existing Kickstart File</title> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 8058 | |
| 8059 | <para> |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 8060 | This example runs in Cooked Mode and uses the |
| 8061 | <filename>mkefidisk</filename> kickstart file: |
| 8062 | <literallayout class='monospaced'> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 8063 | $ wic create mkefidisk -e core-image-minimal |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 8064 | INFO: Building wic-tools... |
| 8065 | . |
| 8066 | . |
| 8067 | . |
| 8068 | INFO: The new image(s) can be found here: |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 8069 | ./mkefidisk-201804191017-sda.direct |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 8070 | |
| 8071 | The following build artifacts were used to create the image(s): |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 8072 | ROOTFS_DIR: /home/stephano/build/master/build/tmp-glibc/work/qemux86-oe-linux/core-image-minimal/1.0-r0/rootfs |
| 8073 | BOOTIMG_DIR: /home/stephano/build/master/build/tmp-glibc/work/qemux86-oe-linux/core-image-minimal/1.0-r0/recipe-sysroot/usr/share |
| 8074 | KERNEL_DIR: /home/stephano/build/master/build/tmp-glibc/deploy/images/qemux86 |
| 8075 | NATIVE_SYSROOT: /home/stephano/build/master/build/tmp-glibc/work/i586-oe-linux/wic-tools/1.0-r0/recipe-sysroot-native |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 8076 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 8077 | INFO: The image(s) were created using OE kickstart file: |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 8078 | /home/stephano/build/master/openembedded-core/scripts/lib/wic/canned-wks/mkefidisk.wks |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 8079 | </literallayout> |
| 8080 | The previous example shows the easiest way to create |
| 8081 | an image by running in cooked mode and supplying |
| 8082 | a kickstart file and the "-e" option to point to the |
| 8083 | existing build artifacts. |
| 8084 | Your <filename>local.conf</filename> file needs to have |
| 8085 | the |
| 8086 | <ulink url='&YOCTO_DOCS_REF_URL;#var-MACHINE'><filename>MACHINE</filename></ulink> |
| 8087 | variable set to the machine you are using, which is |
| 8088 | "qemux86" in this example. |
| 8089 | </para> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 8090 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 8091 | <para> |
| 8092 | Once the image builds, the output provides image |
| 8093 | location, artifact use, and kickstart file information. |
| 8094 | <note> |
| 8095 | You should always verify the details provided in the |
| 8096 | output to make sure that the image was indeed |
| 8097 | created exactly as expected. |
| 8098 | </note> |
| 8099 | </para> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 8100 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 8101 | <para> |
| 8102 | Continuing with the example, you can now write the |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 8103 | image from the Build Directory onto a USB stick, or |
| 8104 | whatever media for which you built your image, and boot |
| 8105 | from the media. |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 8106 | You can write the image by using |
| 8107 | <filename>bmaptool</filename> or |
| 8108 | <filename>dd</filename>: |
| 8109 | <literallayout class='monospaced'> |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 8110 | $ oe-run-native bmaptool copy mkefidisk-201804191017-sda.direct /dev/sd<replaceable>X</replaceable> |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 8111 | </literallayout> |
| 8112 | or |
| 8113 | <literallayout class='monospaced'> |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 8114 | $ sudo dd if=mkefidisk-201804191017-sda.direct of=/dev/sd<replaceable>X</replaceable> |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 8115 | </literallayout> |
| 8116 | <note> |
| 8117 | For more information on how to use the |
| 8118 | <filename>bmaptool</filename> to flash a device |
| 8119 | with an image, see the |
| 8120 | "<link linkend='flashing-images-using-bmaptool'>Flashing Images Using <filename>bmaptool</filename></link>" |
| 8121 | section. |
| 8122 | </note> |
| 8123 | </para> |
| 8124 | </section> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 8125 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 8126 | <section id='using-a-modified-kickstart-file'> |
| 8127 | <title>Using a Modified Kickstart File</title> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 8128 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 8129 | <para> |
| 8130 | Because partitioned image creation is driven by the |
| 8131 | kickstart file, it is easy to affect image creation by |
| 8132 | changing the parameters in the file. |
| 8133 | This next example demonstrates that through modification |
| 8134 | of the <filename>directdisk-gpt</filename> kickstart |
| 8135 | file. |
| 8136 | </para> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 8137 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 8138 | <para> |
| 8139 | As mentioned earlier, you can use the command |
| 8140 | <filename>wic list images</filename> to show the list |
| 8141 | of existing kickstart files. |
| 8142 | The directory in which the |
| 8143 | <filename>directdisk-gpt.wks</filename> file resides is |
| 8144 | <filename>scripts/lib/image/canned-wks/</filename>, |
| 8145 | which is located in the |
| 8146 | <ulink url='&YOCTO_DOCS_REF_URL;#source-directory'>Source Directory</ulink> |
| 8147 | (e.g. <filename>poky</filename>). |
| 8148 | Because available files reside in this directory, |
| 8149 | you can create and add your own custom files to the |
| 8150 | directory. |
| 8151 | Subsequent use of the |
| 8152 | <filename>wic list images</filename> command would then |
| 8153 | include your kickstart files. |
| 8154 | </para> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 8155 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 8156 | <para> |
| 8157 | In this example, the existing |
| 8158 | <filename>directdisk-gpt</filename> file already does |
| 8159 | most of what is needed. |
| 8160 | However, for the hardware in this example, the image |
| 8161 | will need to boot from <filename>sdb</filename> instead |
| 8162 | of <filename>sda</filename>, which is what the |
| 8163 | <filename>directdisk-gpt</filename> kickstart file |
| 8164 | uses. |
| 8165 | </para> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 8166 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 8167 | <para> |
| 8168 | The example begins by making a copy of the |
| 8169 | <filename>directdisk-gpt.wks</filename> file in the |
| 8170 | <filename>scripts/lib/image/canned-wks</filename> |
| 8171 | directory and then by changing the lines that specify |
| 8172 | the target disk from which to boot. |
| 8173 | <literallayout class='monospaced'> |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 8174 | $ cp /home/stephano/poky/scripts/lib/wic/canned-wks/directdisk-gpt.wks \ |
| 8175 | /home/stephano/poky/scripts/lib/wic/canned-wks/directdisksdb-gpt.wks |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 8176 | </literallayout> |
| 8177 | Next, the example modifies the |
| 8178 | <filename>directdisksdb-gpt.wks</filename> file and |
| 8179 | changes all instances of |
| 8180 | "<filename>--ondisk sda</filename>" to |
| 8181 | "<filename>--ondisk sdb</filename>". |
| 8182 | The example changes the following two lines and leaves |
| 8183 | the remaining lines untouched: |
| 8184 | <literallayout class='monospaced'> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 8185 | part /boot --source bootimg-pcbios --ondisk sdb --label boot --active --align 1024 |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 8186 | part / --source rootfs --ondisk sdb --fstype=ext4 --label platform --align 1024 --use-uuid |
| 8187 | </literallayout> |
| 8188 | Once the lines are changed, the example generates the |
| 8189 | <filename>directdisksdb-gpt</filename> image. |
| 8190 | The command points the process at the |
| 8191 | <filename>core-image-minimal</filename> artifacts for |
| 8192 | the Next Unit of Computing (nuc) |
| 8193 | <ulink url='&YOCTO_DOCS_REF_URL;#var-MACHINE'><filename>MACHINE</filename></ulink> |
| 8194 | the <filename>local.conf</filename>. |
| 8195 | <literallayout class='monospaced'> |
| 8196 | $ wic create directdisksdb-gpt -e core-image-minimal |
| 8197 | INFO: Building wic-tools... |
| 8198 | . |
| 8199 | . |
| 8200 | . |
| 8201 | Initialising tasks: 100% |#######################################| Time: 0:00:01 |
| 8202 | NOTE: Executing SetScene Tasks |
| 8203 | NOTE: Executing RunQueue Tasks |
| 8204 | NOTE: Tasks Summary: Attempted 1161 tasks of which 1157 didn't need to be rerun and all succeeded. |
| 8205 | INFO: Creating image(s)... |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 8206 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 8207 | INFO: The new image(s) can be found here: |
| 8208 | ./directdisksdb-gpt-201710090938-sdb.direct |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 8209 | |
| 8210 | The following build artifacts were used to create the image(s): |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 8211 | ROOTFS_DIR: /home/stephano/build/master/build/tmp-glibc/work/qemux86-oe-linux/core-image-minimal/1.0-r0/rootfs |
| 8212 | BOOTIMG_DIR: /home/stephano/build/master/build/tmp-glibc/work/qemux86-oe-linux/core-image-minimal/1.0-r0/recipe-sysroot/usr/share |
| 8213 | KERNEL_DIR: /home/stephano/build/master/build/tmp-glibc/deploy/images/qemux86 |
| 8214 | NATIVE_SYSROOT: /home/stephano/build/master/build/tmp-glibc/work/i586-oe-linux/wic-tools/1.0-r0/recipe-sysroot-native |
Brad Bishop | 37a0e4d | 2017-12-04 01:01:44 -0500 | [diff] [blame] | 8215 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 8216 | INFO: The image(s) were created using OE kickstart file: |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 8217 | /home/stephano/poky/scripts/lib/wic/canned-wks/directdisksdb-gpt.wks |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 8218 | </literallayout> |
| 8219 | Continuing with the example, you can now directly |
| 8220 | <filename>dd</filename> the image to a USB stick, or |
| 8221 | whatever media for which you built your image, |
| 8222 | and boot the resulting media: |
| 8223 | <literallayout class='monospaced'> |
| 8224 | $ sudo dd if=directdisksdb-gpt-201710090938-sdb.direct of=/dev/sdb |
| 8225 | 140966+0 records in |
| 8226 | 140966+0 records out |
| 8227 | 72174592 bytes (72 MB, 69 MiB) copied, 78.0282 s, 925 kB/s |
| 8228 | $ sudo eject /dev/sdb |
| 8229 | </literallayout> |
| 8230 | </para> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 8231 | </section> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 8232 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 8233 | <section id='using-a-modified-kickstart-file-and-running-in-raw-mode'> |
| 8234 | <title>Using a Modified Kickstart File and Running in Raw Mode</title> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 8235 | |
Brad Bishop | 37a0e4d | 2017-12-04 01:01:44 -0500 | [diff] [blame] | 8236 | <para> |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 8237 | This next example manually specifies each build artifact |
| 8238 | (runs in Raw Mode) and uses a modified kickstart file. |
| 8239 | The example also uses the <filename>-o</filename> option |
| 8240 | to cause Wic to create the output |
| 8241 | somewhere other than the default output directory, |
| 8242 | which is the current directory: |
| 8243 | <literallayout class='monospaced'> |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 8244 | $ wic create /home/stephano/my_yocto/test.wks -o /home/stephano/testwic \ |
| 8245 | --rootfs-dir /home/stephano/build/master/build/tmp/work/qemux86-poky-linux/core-image-minimal/1.0-r0/rootfs \ |
| 8246 | --bootimg-dir /home/stephano/build/master/build/tmp/work/qemux86-poky-linux/core-image-minimal/1.0-r0/recipe-sysroot/usr/share \ |
| 8247 | --kernel-dir /home/stephano/build/master/build/tmp/deploy/images/qemux86 \ |
| 8248 | --native-sysroot /home/stephano/build/master/build/tmp/work/i586-poky-linux/wic-tools/1.0-r0/recipe-sysroot-native |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 8249 | |
| 8250 | INFO: Creating image(s)... |
| 8251 | |
| 8252 | INFO: The new image(s) can be found here: |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 8253 | /home/stephano/testwic/test-201710091445-sdb.direct |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 8254 | |
| 8255 | The following build artifacts were used to create the image(s): |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 8256 | ROOTFS_DIR: /home/stephano/build/master/build/tmp-glibc/work/qemux86-oe-linux/core-image-minimal/1.0-r0/rootfs |
| 8257 | BOOTIMG_DIR: /home/stephano/build/master/build/tmp-glibc/work/qemux86-oe-linux/core-image-minimal/1.0-r0/recipe-sysroot/usr/share |
| 8258 | KERNEL_DIR: /home/stephano/build/master/build/tmp-glibc/deploy/images/qemux86 |
| 8259 | NATIVE_SYSROOT: /home/stephano/build/master/build/tmp-glibc/work/i586-oe-linux/wic-tools/1.0-r0/recipe-sysroot-native |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 8260 | |
| 8261 | INFO: The image(s) were created using OE kickstart file: |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 8262 | /home/stephano/my_yocto/test.wks |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 8263 | </literallayout> |
| 8264 | For this example, |
| 8265 | <ulink url='&YOCTO_DOCS_REF_URL;#var-MACHINE'><filename>MACHINE</filename></ulink> |
| 8266 | did not have to be specified in the |
| 8267 | <filename>local.conf</filename> file since the |
| 8268 | artifact is manually specified. |
Brad Bishop | 37a0e4d | 2017-12-04 01:01:44 -0500 | [diff] [blame] | 8269 | </para> |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 8270 | </section> |
| 8271 | |
| 8272 | <section id='using-wic-to-manipulate-an-image'> |
| 8273 | <title>Using Wic to Manipulate an Image</title> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 8274 | |
Brad Bishop | 37a0e4d | 2017-12-04 01:01:44 -0500 | [diff] [blame] | 8275 | <para> |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 8276 | Wic image manipulation allows you to shorten turnaround |
| 8277 | time during image development. |
| 8278 | For example, you can use Wic to delete the kernel partition |
| 8279 | of a Wic image and then insert a newly built kernel. |
| 8280 | This saves you time from having to rebuild the entire image |
| 8281 | each time you modify the kernel. |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 8282 | <note> |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 8283 | In order to use Wic to manipulate a Wic image as in |
| 8284 | this example, your development machine must have the |
| 8285 | <filename>mtools</filename> package installed. |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 8286 | </note> |
Brad Bishop | 37a0e4d | 2017-12-04 01:01:44 -0500 | [diff] [blame] | 8287 | </para> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 8288 | |
Brad Bishop | 37a0e4d | 2017-12-04 01:01:44 -0500 | [diff] [blame] | 8289 | <para> |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 8290 | The following example examines the contents of the Wic |
| 8291 | image, deletes the existing kernel, and then inserts a |
| 8292 | new kernel: |
| 8293 | <orderedlist> |
Brad Bishop | 37a0e4d | 2017-12-04 01:01:44 -0500 | [diff] [blame] | 8294 | <listitem><para> |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 8295 | <emphasis>List the Partitions:</emphasis> |
| 8296 | Use the <filename>wic ls</filename> command to list |
| 8297 | all the partitions in the Wic image: |
| 8298 | <literallayout class='monospaced'> |
| 8299 | $ wic ls tmp/deploy/images/qemux86/core-image-minimal-qemux86.wic |
| 8300 | Num Start End Size Fstype |
| 8301 | 1 1048576 25041919 23993344 fat16 |
| 8302 | 2 25165824 72157183 46991360 ext4 |
| 8303 | </literallayout> |
| 8304 | The previous output shows two partitions in the |
| 8305 | <filename>core-image-minimal-qemux86.wic</filename> |
| 8306 | image. |
| 8307 | </para></listitem> |
| 8308 | <listitem><para> |
| 8309 | <emphasis>Examine a Particular Partition:</emphasis> |
| 8310 | Use the <filename>wic ls</filename> command again |
| 8311 | but in a different form to examine a particular |
Brad Bishop | 37a0e4d | 2017-12-04 01:01:44 -0500 | [diff] [blame] | 8312 | partition. |
Brad Bishop | 37a0e4d | 2017-12-04 01:01:44 -0500 | [diff] [blame] | 8313 | <note> |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 8314 | You can get command usage on any Wic command |
| 8315 | using the following form: |
| 8316 | <literallayout class='monospaced'> |
| 8317 | $ wic help <replaceable>command</replaceable> |
| 8318 | </literallayout> |
| 8319 | For example, the following command shows you |
| 8320 | the various ways to use the |
| 8321 | <filename>wic ls</filename> command: |
| 8322 | <literallayout class='monospaced'> |
| 8323 | $ wic help ls |
| 8324 | </literallayout> |
Brad Bishop | 37a0e4d | 2017-12-04 01:01:44 -0500 | [diff] [blame] | 8325 | </note> |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 8326 | The following command shows what is in Partition |
| 8327 | one: |
| 8328 | <literallayout class='monospaced'> |
| 8329 | $ wic ls tmp/deploy/images/qemux86/core-image-minimal-qemux86.wic:1 |
| 8330 | Volume in drive : is boot |
| 8331 | Volume Serial Number is E894-1809 |
| 8332 | Directory for ::/ |
Brad Bishop | 37a0e4d | 2017-12-04 01:01:44 -0500 | [diff] [blame] | 8333 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 8334 | libcom32 c32 186500 2017-10-09 16:06 |
| 8335 | libutil c32 24148 2017-10-09 16:06 |
| 8336 | syslinux cfg 220 2017-10-09 16:06 |
| 8337 | vesamenu c32 27104 2017-10-09 16:06 |
| 8338 | vmlinuz 6904608 2017-10-09 16:06 |
| 8339 | 5 files 7 142 580 bytes |
| 8340 | 16 582 656 bytes free |
| 8341 | </literallayout> |
| 8342 | The previous output shows five files, with the |
| 8343 | <filename>vmlinuz</filename> being the kernel. |
| 8344 | <note> |
| 8345 | If you see the following error, you need to |
| 8346 | update or create a |
| 8347 | <filename>~/.mtoolsrc</filename> file and |
| 8348 | be sure to have the line “mtools_skip_check=1“ |
| 8349 | in the file. |
| 8350 | Then, run the Wic command again: |
| 8351 | <literallayout class='monospaced'> |
| 8352 | ERROR: _exec_cmd: /usr/bin/mdir -i /tmp/wic-parttfokuwra ::/ returned '1' instead of 0 |
| 8353 | output: Total number of sectors (47824) not a multiple of sectors per track (32)! |
| 8354 | Add mtools_skip_check=1 to your .mtoolsrc file to skip this test |
| 8355 | </literallayout> |
| 8356 | </note> |
| 8357 | </para></listitem> |
| 8358 | <listitem><para> |
| 8359 | <emphasis>Remove the Old Kernel:</emphasis> |
| 8360 | Use the <filename>wic rm</filename> command to |
| 8361 | remove the <filename>vmlinuz</filename> file |
| 8362 | (kernel): |
| 8363 | <literallayout class='monospaced'> |
| 8364 | $ wic rm tmp/deploy/images/qemux86/core-image-minimal-qemux86.wic:1/vmlinuz |
| 8365 | </literallayout> |
| 8366 | </para></listitem> |
| 8367 | <listitem><para> |
| 8368 | <emphasis>Add In the New Kernel:</emphasis> |
| 8369 | Use the <filename>wic cp</filename> command to |
| 8370 | add the updated kernel to the Wic image. |
| 8371 | Depending on how you built your kernel, it could |
| 8372 | be in different places. |
| 8373 | If you used <filename>devtool</filename> and |
| 8374 | an SDK to build your kernel, it resides in the |
| 8375 | <filename>tmp/work</filename> directory of the |
| 8376 | extensible SDK. |
| 8377 | If you used <filename>make</filename> to build the |
| 8378 | kernel, the kernel will be in the |
| 8379 | <filename>workspace/sources</filename> area. |
| 8380 | </para> |
Brad Bishop | 37a0e4d | 2017-12-04 01:01:44 -0500 | [diff] [blame] | 8381 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 8382 | <para>The following example assumes |
| 8383 | <filename>devtool</filename> was used to build |
| 8384 | the kernel: |
| 8385 | <literallayout class='monospaced'> |
| 8386 | cp ~/poky_sdk/tmp/work/qemux86-poky-linux/linux-yocto/4.12.12+git999-r0/linux-yocto-4.12.12+git999/arch/x86/boot/bzImage \ |
| 8387 | ~/poky/build/tmp/deploy/images/qemux86/core-image-minimal-qemux86.wic:1/vmlinuz |
| 8388 | </literallayout> |
| 8389 | Once the new kernel is added back into the image, |
| 8390 | you can use the <filename>dd</filename> |
| 8391 | command or |
| 8392 | <link linkend='flashing-images-using-bmaptool'><filename>bmaptool</filename></link> |
| 8393 | to flash your wic image onto an SD card |
| 8394 | or USB stick and test your target. |
| 8395 | <note> |
| 8396 | Using <filename>bmaptool</filename> is |
| 8397 | generally 10 to 20 times faster than using |
| 8398 | <filename>dd</filename>. |
| 8399 | </note> |
| 8400 | </para></listitem> |
| 8401 | </orderedlist> |
| 8402 | </para> |
| 8403 | </section> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 8404 | </section> |
| 8405 | </section> |
| 8406 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 8407 | <section id='flashing-images-using-bmaptool'> |
| 8408 | <title>Flashing Images Using <filename>bmaptool</filename></title> |
| 8409 | |
| 8410 | <para> |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 8411 | A fast and easy way to flash an image to a bootable device |
| 8412 | is to use Bmaptool, which is integrated into the OpenEmbedded |
| 8413 | build system. |
| 8414 | Bmaptool is a generic tool that creates a file's block map (bmap) |
| 8415 | and then uses that map to copy the file. |
| 8416 | As compared to traditional tools such as dd or cp, Bmaptool |
| 8417 | can copy (or flash) large files like raw system image files |
| 8418 | much faster. |
| 8419 | <note><title>Notes</title> |
| 8420 | <itemizedlist> |
| 8421 | <listitem><para> |
| 8422 | If you are using Ubuntu or Debian distributions, you |
| 8423 | can install the <filename>bmap-tools</filename> package |
| 8424 | using the following command and then use the tool |
| 8425 | without specifying <filename>PATH</filename> even from |
| 8426 | the root account: |
| 8427 | <literallayout class='monospaced'> |
| 8428 | $ sudo apt-get install bmap-tools |
| 8429 | </literallayout> |
| 8430 | </para></listitem> |
| 8431 | <listitem><para> |
| 8432 | If you are unable to install the |
| 8433 | <filename>bmap-tools</filename> package, you will |
| 8434 | need to build Bmaptool before using it. |
| 8435 | Use the following command: |
| 8436 | <literallayout class='monospaced'> |
| 8437 | $ bitbake bmap-tools-native |
| 8438 | </literallayout> |
| 8439 | </para></listitem> |
| 8440 | </itemizedlist> |
| 8441 | </note> |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 8442 | </para> |
| 8443 | |
| 8444 | <para> |
| 8445 | Following, is an example that shows how to flash a Wic image. |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 8446 | Realize that while this example uses a Wic image, you can use |
| 8447 | Bmaptool to flash any type of image. |
| 8448 | Use these steps to flash an image using Bmaptool: |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 8449 | <orderedlist> |
| 8450 | <listitem><para> |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 8451 | <emphasis>Update your <filename>local.conf</filename> File:</emphasis> |
| 8452 | You need to have the following set in your |
| 8453 | <filename>local.conf</filename> file before building |
| 8454 | your image: |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 8455 | <literallayout class='monospaced'> |
| 8456 | IMAGE_FSTYPES += "wic wic.bmap" |
| 8457 | </literallayout> |
| 8458 | </para></listitem> |
| 8459 | <listitem><para> |
| 8460 | <emphasis>Get Your Image:</emphasis> |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 8461 | Either have your image ready (pre-built with the |
| 8462 | <ulink url='&YOCTO_DOCS_REF_URL;#var-IMAGE_FSTYPES'><filename>IMAGE_FSTYPES</filename></ulink> |
| 8463 | setting previously mentioned) or take the step to build |
| 8464 | the image: |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 8465 | <literallayout class='monospaced'> |
| 8466 | $ bitbake <replaceable>image</replaceable> |
| 8467 | </literallayout> |
| 8468 | </para></listitem> |
| 8469 | <listitem><para> |
| 8470 | <emphasis>Flash the Device:</emphasis> |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 8471 | Flash the device with the image by using Bmaptool |
| 8472 | depending on your particular setup. |
| 8473 | The following commands assume the image resides in the |
| 8474 | Build Directory's <filename>deploy/images/</filename> |
| 8475 | area: |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 8476 | <itemizedlist> |
| 8477 | <listitem><para> |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 8478 | If you have write access to the media, use this |
| 8479 | command form: |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 8480 | <literallayout class='monospaced'> |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 8481 | $ oe-run-native bmap-tools-native bmaptool copy <replaceable>build-directory</replaceable>/tmp/deploy/images/<replaceable>machine</replaceable>/<replaceable>image</replaceable>.wic /dev/sd<replaceable>X</replaceable> |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 8482 | </literallayout> |
| 8483 | </para></listitem> |
| 8484 | <listitem><para> |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 8485 | If you do not have write access to the media, set |
| 8486 | your permissions first and then use the same |
| 8487 | command form: |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 8488 | <literallayout class='monospaced'> |
| 8489 | $ sudo chmod 666 /dev/sd<replaceable>X</replaceable> |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 8490 | $ oe-run-native bmap-tools-native bmaptool copy <replaceable>build-directory</replaceable>/tmp/deploy/images/<replaceable>machine</replaceable>/<replaceable>image</replaceable>.wic /dev/sd<replaceable>X</replaceable> |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 8491 | </literallayout> |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 8492 | </para></listitem> |
| 8493 | </itemizedlist> |
| 8494 | </para></listitem> |
| 8495 | </orderedlist> |
| 8496 | </para> |
| 8497 | |
| 8498 | <para> |
| 8499 | For help on the <filename>bmaptool</filename> command, use the |
| 8500 | following command: |
Brad Bishop | 37a0e4d | 2017-12-04 01:01:44 -0500 | [diff] [blame] | 8501 | <literallayout class='monospaced'> |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 8502 | $ bmaptool --help |
Brad Bishop | 37a0e4d | 2017-12-04 01:01:44 -0500 | [diff] [blame] | 8503 | </literallayout> |
Brad Bishop | 37a0e4d | 2017-12-04 01:01:44 -0500 | [diff] [blame] | 8504 | </para> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 8505 | </section> |
| 8506 | |
| 8507 | <section id='making-images-more-secure'> |
| 8508 | <title>Making Images More Secure</title> |
| 8509 | |
| 8510 | <para> |
| 8511 | Security is of increasing concern for embedded devices. |
| 8512 | Consider the issues and problems discussed in just this |
| 8513 | sampling of work found across the Internet: |
| 8514 | <itemizedlist> |
| 8515 | <listitem><para><emphasis> |
| 8516 | "<ulink url='https://www.schneier.com/blog/archives/2014/01/security_risks_9.html'>Security Risks of Embedded Systems</ulink>"</emphasis> |
| 8517 | by Bruce Schneier |
| 8518 | </para></listitem> |
| 8519 | <listitem><para><emphasis> |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 8520 | "<ulink url='http://census2012.sourceforge.net/paper.html'>Internet Census 2012</ulink>"</emphasis> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 8521 | by Carna Botnet</para></listitem> |
| 8522 | <listitem><para><emphasis> |
| 8523 | "<ulink url='http://elinux.org/images/6/6f/Security-issues.pdf'>Security Issues for Embedded Devices</ulink>"</emphasis> |
| 8524 | by Jake Edge |
| 8525 | </para></listitem> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 8526 | </itemizedlist> |
| 8527 | </para> |
| 8528 | |
| 8529 | <para> |
| 8530 | When securing your image is of concern, there are steps, tools, |
| 8531 | and variables that you can consider to help you reach the |
| 8532 | security goals you need for your particular device. |
| 8533 | Not all situations are identical when it comes to making an |
| 8534 | image secure. |
| 8535 | Consequently, this section provides some guidance and suggestions |
| 8536 | for consideration when you want to make your image more secure. |
| 8537 | <note> |
| 8538 | Because the security requirements and risks are |
| 8539 | different for every type of device, this section cannot |
| 8540 | provide a complete reference on securing your custom OS. |
| 8541 | It is strongly recommended that you also consult other sources |
| 8542 | of information on embedded Linux system hardening and on |
| 8543 | security. |
| 8544 | </note> |
| 8545 | </para> |
| 8546 | |
| 8547 | <section id='general-considerations'> |
| 8548 | <title>General Considerations</title> |
| 8549 | |
| 8550 | <para> |
| 8551 | General considerations exist that help you create more |
| 8552 | secure images. |
| 8553 | You should consider the following suggestions to help |
| 8554 | make your device more secure: |
| 8555 | <itemizedlist> |
| 8556 | <listitem><para> |
| 8557 | Scan additional code you are adding to the system |
| 8558 | (e.g. application code) by using static analysis |
| 8559 | tools. |
| 8560 | Look for buffer overflows and other potential |
| 8561 | security problems. |
| 8562 | </para></listitem> |
| 8563 | <listitem><para> |
| 8564 | Pay particular attention to the security for |
| 8565 | any web-based administration interface. |
| 8566 | </para> |
| 8567 | <para>Web interfaces typically need to perform |
| 8568 | administrative functions and tend to need to run with |
| 8569 | elevated privileges. |
| 8570 | Thus, the consequences resulting from the interface's |
| 8571 | security becoming compromised can be serious. |
| 8572 | Look for common web vulnerabilities such as |
| 8573 | cross-site-scripting (XSS), unvalidated inputs, |
| 8574 | and so forth.</para> |
| 8575 | <para>As with system passwords, the default credentials |
| 8576 | for accessing a web-based interface should not be the |
| 8577 | same across all devices. |
| 8578 | This is particularly true if the interface is enabled |
| 8579 | by default as it can be assumed that many end-users |
| 8580 | will not change the credentials. |
| 8581 | </para></listitem> |
| 8582 | <listitem><para> |
| 8583 | Ensure you can update the software on the device to |
| 8584 | mitigate vulnerabilities discovered in the future. |
| 8585 | This consideration especially applies when your |
| 8586 | device is network-enabled. |
| 8587 | </para></listitem> |
| 8588 | <listitem><para> |
| 8589 | Ensure you remove or disable debugging functionality |
| 8590 | before producing the final image. |
| 8591 | For information on how to do this, see the |
| 8592 | "<link linkend='considerations-specific-to-the-openembedded-build-system'>Considerations Specific to the OpenEmbedded Build System</link>" |
| 8593 | section. |
| 8594 | </para></listitem> |
| 8595 | <listitem><para> |
| 8596 | Ensure you have no network services listening that |
| 8597 | are not needed. |
| 8598 | </para></listitem> |
| 8599 | <listitem><para> |
| 8600 | Remove any software from the image that is not needed. |
| 8601 | </para></listitem> |
| 8602 | <listitem><para> |
| 8603 | Enable hardware support for secure boot functionality |
| 8604 | when your device supports this functionality. |
| 8605 | </para></listitem> |
| 8606 | </itemizedlist> |
| 8607 | </para> |
| 8608 | </section> |
| 8609 | |
| 8610 | <section id='security-flags'> |
| 8611 | <title>Security Flags</title> |
| 8612 | |
| 8613 | <para> |
| 8614 | The Yocto Project has security flags that you can enable that |
| 8615 | help make your build output more secure. |
| 8616 | The security flags are in the |
| 8617 | <filename>meta/conf/distro/include/security_flags.inc</filename> |
| 8618 | file in your |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 8619 | <ulink url='&YOCTO_DOCS_REF_URL;#source-directory'>Source Directory</ulink> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 8620 | (e.g. <filename>poky</filename>). |
| 8621 | <note> |
| 8622 | Depending on the recipe, certain security flags are enabled |
| 8623 | and disabled by default. |
| 8624 | </note> |
| 8625 | </para> |
| 8626 | |
| 8627 | <para> |
| 8628 | <!-- |
| 8629 | The GCC/LD flags in <filename>security_flags.inc</filename> |
| 8630 | enable more secure code generation. |
| 8631 | By including the <filename>security_flags.inc</filename> |
| 8632 | file, you enable flags to the compiler and linker that cause |
| 8633 | them to generate more secure code. |
| 8634 | <note> |
| 8635 | The GCC/LD flags are enabled by default in the |
| 8636 | <filename>poky-lsb</filename> distribution. |
| 8637 | </note> |
| 8638 | --> |
| 8639 | Use the following line in your |
| 8640 | <filename>local.conf</filename> file or in your custom |
| 8641 | distribution configuration file to enable the security |
| 8642 | compiler and linker flags for your build: |
| 8643 | <literallayout class='monospaced'> |
| 8644 | require conf/distro/include/security_flags.inc |
| 8645 | </literallayout> |
| 8646 | </para> |
| 8647 | </section> |
| 8648 | |
| 8649 | <section id='considerations-specific-to-the-openembedded-build-system'> |
| 8650 | <title>Considerations Specific to the OpenEmbedded Build System</title> |
| 8651 | |
| 8652 | <para> |
| 8653 | You can take some steps that are specific to the |
| 8654 | OpenEmbedded build system to make your images more secure: |
| 8655 | <itemizedlist> |
| 8656 | <listitem><para> |
| 8657 | Ensure "debug-tweaks" is not one of your selected |
| 8658 | <ulink url='&YOCTO_DOCS_REF_URL;#var-IMAGE_FEATURES'><filename>IMAGE_FEATURES</filename></ulink>. |
| 8659 | When creating a new project, the default is to provide you |
| 8660 | with an initial <filename>local.conf</filename> file that |
| 8661 | enables this feature using the |
| 8662 | <ulink url='&YOCTO_DOCS_REF_URL;#var-EXTRA_IMAGE_FEATURES'><filename>EXTRA_IMAGE_FEATURES</filename></ulink> variable with the line: |
| 8663 | <literallayout class='monospaced'> |
| 8664 | EXTRA_IMAGE_FEATURES = "debug-tweaks" |
| 8665 | </literallayout> |
| 8666 | To disable that feature, simply comment out that line in your |
| 8667 | <filename>local.conf</filename> file, or |
| 8668 | make sure <filename>IMAGE_FEATURES</filename> does not contain |
| 8669 | "debug-tweaks" before producing your final image. |
| 8670 | Among other things, leaving this in place sets the |
| 8671 | root password as blank, which makes logging in for |
| 8672 | debugging or inspection easy during |
| 8673 | development but also means anyone can easily log in |
| 8674 | during production. |
| 8675 | </para></listitem> |
| 8676 | <listitem><para> |
| 8677 | It is possible to set a root password for the image |
| 8678 | and also to set passwords for any extra users you might |
| 8679 | add (e.g. administrative or service type users). |
| 8680 | When you set up passwords for multiple images or |
| 8681 | users, you should not duplicate passwords. |
| 8682 | </para> |
| 8683 | <para> |
| 8684 | To set up passwords, use the |
| 8685 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-extrausers'><filename>extrausers</filename></ulink> |
| 8686 | class, which is the preferred method. |
| 8687 | For an example on how to set up both root and user |
| 8688 | passwords, see the |
| 8689 | "<ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-extrausers'><filename>extrausers.bbclass</filename></ulink>" |
| 8690 | section. |
| 8691 | <note> |
| 8692 | When adding extra user accounts or setting a |
| 8693 | root password, be cautious about setting the |
| 8694 | same password on every device. |
| 8695 | If you do this, and the password you have set |
| 8696 | is exposed, then every device is now potentially |
| 8697 | compromised. |
| 8698 | If you need this access but want to ensure |
| 8699 | security, consider setting a different, |
| 8700 | random password for each device. |
| 8701 | Typically, you do this as a separate step after |
| 8702 | you deploy the image onto the device. |
| 8703 | </note> |
| 8704 | </para></listitem> |
| 8705 | <listitem><para> |
| 8706 | Consider enabling a Mandatory Access Control (MAC) |
| 8707 | framework such as SMACK or SELinux and tuning it |
| 8708 | appropriately for your device's usage. |
| 8709 | You can find more information in the |
| 8710 | <ulink url='http://git.yoctoproject.org/cgit/cgit.cgi/meta-selinux/'><filename>meta-selinux</filename></ulink> |
| 8711 | layer. |
| 8712 | </para></listitem> |
| 8713 | </itemizedlist> |
| 8714 | </para> |
| 8715 | |
| 8716 | <para> |
| 8717 | </para> |
| 8718 | </section> |
| 8719 | |
| 8720 | <section id='tools-for-hardening-your-image'> |
| 8721 | <title>Tools for Hardening Your Image</title> |
| 8722 | |
| 8723 | <para> |
| 8724 | The Yocto Project provides tools for making your image |
| 8725 | more secure. |
| 8726 | You can find these tools in the |
| 8727 | <filename>meta-security</filename> layer of the |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 8728 | <ulink url='&YOCTO_GIT_URL;'>Yocto Project Source Repositories</ulink>. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 8729 | </para> |
| 8730 | </section> |
| 8731 | </section> |
| 8732 | |
| 8733 | <section id='creating-your-own-distribution'> |
| 8734 | <title>Creating Your Own Distribution</title> |
| 8735 | |
| 8736 | <para> |
| 8737 | When you build an image using the Yocto Project and |
| 8738 | do not alter any distribution |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 8739 | <ulink url='&YOCTO_DOCS_REF_URL;#metadata'>Metadata</ulink>, |
| 8740 | you are creating a Poky distribution. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 8741 | If you wish to gain more control over package alternative |
| 8742 | selections, compile-time options, and other low-level |
| 8743 | configurations, you can create your own distribution. |
| 8744 | </para> |
| 8745 | |
| 8746 | <para> |
| 8747 | To create your own distribution, the basic steps consist of |
| 8748 | creating your own distribution layer, creating your own |
| 8749 | distribution configuration file, and then adding any needed |
| 8750 | code and Metadata to the layer. |
| 8751 | The following steps provide some more detail: |
| 8752 | <itemizedlist> |
| 8753 | <listitem><para><emphasis>Create a layer for your new distro:</emphasis> |
| 8754 | Create your distribution layer so that you can keep your |
| 8755 | Metadata and code for the distribution separate. |
| 8756 | It is strongly recommended that you create and use your own |
| 8757 | layer for configuration and code. |
| 8758 | Using your own layer as compared to just placing |
| 8759 | configurations in a <filename>local.conf</filename> |
| 8760 | configuration file makes it easier to reproduce the same |
| 8761 | build configuration when using multiple build machines. |
| 8762 | See the |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 8763 | "<link linkend='creating-a-general-layer-using-the-bitbake-layers-script'>Creating a General Layer Using the <filename>bitbake-layers</filename> Script</link>" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 8764 | section for information on how to quickly set up a layer. |
| 8765 | </para></listitem> |
| 8766 | <listitem><para><emphasis>Create the distribution configuration file:</emphasis> |
| 8767 | The distribution configuration file needs to be created in |
| 8768 | the <filename>conf/distro</filename> directory of your |
| 8769 | layer. |
| 8770 | You need to name it using your distribution name |
| 8771 | (e.g. <filename>mydistro.conf</filename>). |
| 8772 | <note> |
| 8773 | The |
| 8774 | <ulink url='&YOCTO_DOCS_REF_URL;#var-DISTRO'><filename>DISTRO</filename></ulink> |
| 8775 | variable in your |
| 8776 | <filename>local.conf</filename> file determines the |
| 8777 | name of your distribution. |
| 8778 | </note></para> |
| 8779 | <para>You can split out parts of your configuration file |
| 8780 | into include files and then "require" them from within |
| 8781 | your distribution configuration file. |
| 8782 | Be sure to place the include files in the |
| 8783 | <filename>conf/distro/include</filename> directory of |
| 8784 | your layer. |
| 8785 | A common example usage of include files would be to |
| 8786 | separate out the selection of desired version and revisions |
| 8787 | for individual recipes. |
| 8788 | </para> |
| 8789 | <para>Your configuration file needs to set the following |
| 8790 | required variables: |
| 8791 | <literallayout class='monospaced'> |
| 8792 | <ulink url='&YOCTO_DOCS_REF_URL;#var-DISTRO_NAME'><filename>DISTRO_NAME</filename></ulink> |
| 8793 | <ulink url='&YOCTO_DOCS_REF_URL;#var-DISTRO_VERSION'><filename>DISTRO_VERSION</filename></ulink> |
| 8794 | </literallayout> |
| 8795 | These following variables are optional and you typically |
| 8796 | set them from the distribution configuration file: |
| 8797 | <literallayout class='monospaced'> |
| 8798 | <ulink url='&YOCTO_DOCS_REF_URL;#var-DISTRO_FEATURES'><filename>DISTRO_FEATURES</filename></ulink> |
| 8799 | <ulink url='&YOCTO_DOCS_REF_URL;#var-DISTRO_EXTRA_RDEPENDS'><filename>DISTRO_EXTRA_RDEPENDS</filename></ulink> |
| 8800 | <ulink url='&YOCTO_DOCS_REF_URL;#var-DISTRO_EXTRA_RRECOMMENDS'><filename>DISTRO_EXTRA_RRECOMMENDS</filename></ulink> |
| 8801 | <ulink url='&YOCTO_DOCS_REF_URL;#var-TCLIBC'><filename>TCLIBC</filename></ulink> |
| 8802 | </literallayout> |
| 8803 | <tip> |
| 8804 | If you want to base your distribution configuration file |
| 8805 | on the very basic configuration from OE-Core, you |
| 8806 | can use |
| 8807 | <filename>conf/distro/defaultsetup.conf</filename> as |
| 8808 | a reference and just include variables that differ |
| 8809 | as compared to <filename>defaultsetup.conf</filename>. |
| 8810 | Alternatively, you can create a distribution |
| 8811 | configuration file from scratch using the |
| 8812 | <filename>defaultsetup.conf</filename> file |
| 8813 | or configuration files from other distributions |
| 8814 | such as Poky or Angstrom as references. |
| 8815 | </tip></para></listitem> |
| 8816 | <listitem><para><emphasis>Provide miscellaneous variables:</emphasis> |
| 8817 | Be sure to define any other variables for which you want to |
| 8818 | create a default or enforce as part of the distribution |
| 8819 | configuration. |
| 8820 | You can include nearly any variable from the |
| 8821 | <filename>local.conf</filename> file. |
| 8822 | The variables you use are not limited to the list in the |
| 8823 | previous bulleted item.</para></listitem> |
| 8824 | <listitem><para><emphasis>Point to Your distribution configuration file:</emphasis> |
| 8825 | In your <filename>local.conf</filename> file in the |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 8826 | <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink>, |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 8827 | set your |
| 8828 | <ulink url='&YOCTO_DOCS_REF_URL;#var-DISTRO'><filename>DISTRO</filename></ulink> |
| 8829 | variable to point to your distribution's configuration file. |
| 8830 | For example, if your distribution's configuration file is |
| 8831 | named <filename>mydistro.conf</filename>, then you point |
| 8832 | to it as follows: |
| 8833 | <literallayout class='monospaced'> |
| 8834 | DISTRO = "mydistro" |
| 8835 | </literallayout></para></listitem> |
| 8836 | <listitem><para><emphasis>Add more to the layer if necessary:</emphasis> |
| 8837 | Use your layer to hold other information needed for the |
| 8838 | distribution: |
| 8839 | <itemizedlist> |
| 8840 | <listitem><para>Add recipes for installing |
| 8841 | distro-specific configuration files that are not |
| 8842 | already installed by another recipe. |
| 8843 | If you have distro-specific configuration files |
| 8844 | that are included by an existing recipe, you should |
| 8845 | add an append file (<filename>.bbappend</filename>) |
| 8846 | for those. |
| 8847 | For general information and recommendations |
| 8848 | on how to add recipes to your layer, see the |
| 8849 | "<link linkend='creating-your-own-layer'>Creating Your Own Layer</link>" |
| 8850 | and |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 8851 | "<link linkend='best-practices-to-follow-when-creating-layers'>Following Best Practices When Creating Layers</link>" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 8852 | sections.</para></listitem> |
| 8853 | <listitem><para>Add any image recipes that are specific |
| 8854 | to your distribution.</para></listitem> |
| 8855 | <listitem><para>Add a <filename>psplash</filename> |
| 8856 | append file for a branded splash screen. |
| 8857 | For information on append files, see the |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 8858 | "<link linkend='using-bbappend-files'>Using .bbappend Files in Your Layer</link>" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 8859 | section.</para></listitem> |
| 8860 | <listitem><para>Add any other append files to make |
| 8861 | custom changes that are specific to individual |
| 8862 | recipes.</para></listitem> |
| 8863 | </itemizedlist></para></listitem> |
| 8864 | </itemizedlist> |
| 8865 | </para> |
| 8866 | </section> |
| 8867 | |
| 8868 | <section id='creating-a-custom-template-configuration-directory'> |
| 8869 | <title>Creating a Custom Template Configuration Directory</title> |
| 8870 | |
| 8871 | <para> |
| 8872 | If you are producing your own customized version |
| 8873 | of the build system for use by other users, you might |
| 8874 | want to customize the message shown by the setup script or |
| 8875 | you might want to change the template configuration files (i.e. |
| 8876 | <filename>local.conf</filename> and |
| 8877 | <filename>bblayers.conf</filename>) that are created in |
| 8878 | a new build directory. |
| 8879 | </para> |
| 8880 | |
| 8881 | <para> |
| 8882 | The OpenEmbedded build system uses the environment variable |
| 8883 | <filename>TEMPLATECONF</filename> to locate the directory |
| 8884 | from which it gathers configuration information that ultimately |
| 8885 | ends up in the |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 8886 | <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 8887 | <filename>conf</filename> directory. |
| 8888 | By default, <filename>TEMPLATECONF</filename> is set as |
| 8889 | follows in the <filename>poky</filename> repository: |
| 8890 | <literallayout class='monospaced'> |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 8891 | TEMPLATECONF=${TEMPLATECONF:-meta-poky/conf} |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 8892 | </literallayout> |
| 8893 | This is the directory used by the build system to find templates |
| 8894 | from which to build some key configuration files. |
| 8895 | If you look at this directory, you will see the |
| 8896 | <filename>bblayers.conf.sample</filename>, |
| 8897 | <filename>local.conf.sample</filename>, and |
| 8898 | <filename>conf-notes.txt</filename> files. |
| 8899 | The build system uses these files to form the respective |
| 8900 | <filename>bblayers.conf</filename> file, |
| 8901 | <filename>local.conf</filename> file, and display the list of |
| 8902 | BitBake targets when running the setup script. |
| 8903 | </para> |
| 8904 | |
| 8905 | <para> |
| 8906 | To override these default configuration files with |
| 8907 | configurations you want used within every new |
| 8908 | Build Directory, simply set the |
| 8909 | <filename>TEMPLATECONF</filename> variable to your directory. |
| 8910 | The <filename>TEMPLATECONF</filename> variable is set in the |
| 8911 | <filename>.templateconf</filename> file, which is in the |
| 8912 | top-level |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 8913 | <ulink url='&YOCTO_DOCS_REF_URL;#source-directory'>Source Directory</ulink> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 8914 | folder (e.g. <filename>poky</filename>). |
| 8915 | Edit the <filename>.templateconf</filename> so that it can locate |
| 8916 | your directory. |
| 8917 | </para> |
| 8918 | |
| 8919 | <para> |
| 8920 | Best practices dictate that you should keep your |
| 8921 | template configuration directory in your custom distribution layer. |
| 8922 | For example, suppose you have a layer named |
| 8923 | <filename>meta-mylayer</filename> located in your home directory |
| 8924 | and you want your template configuration directory named |
| 8925 | <filename>myconf</filename>. |
| 8926 | Changing the <filename>.templateconf</filename> as follows |
| 8927 | causes the OpenEmbedded build system to look in your directory |
| 8928 | and base its configuration files on the |
| 8929 | <filename>*.sample</filename> configuration files it finds. |
| 8930 | The final configuration files (i.e. |
| 8931 | <filename>local.conf</filename> and |
| 8932 | <filename>bblayers.conf</filename> ultimately still end up in |
| 8933 | your Build Directory, but they are based on your |
| 8934 | <filename>*.sample</filename> files. |
| 8935 | <literallayout class='monospaced'> |
| 8936 | TEMPLATECONF=${TEMPLATECONF:-meta-mylayer/myconf} |
| 8937 | </literallayout> |
| 8938 | </para> |
| 8939 | |
| 8940 | <para> |
| 8941 | Aside from the <filename>*.sample</filename> configuration files, |
| 8942 | the <filename>conf-notes.txt</filename> also resides in the |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 8943 | default <filename>meta-poky/conf</filename> directory. |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 8944 | The script that sets up the build environment |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 8945 | (i.e. |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 8946 | <ulink url="&YOCTO_DOCS_REF_URL;#structure-core-script"><filename>&OE_INIT_FILE;</filename></ulink>) |
| 8947 | uses this file to display BitBake targets as part of the script |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 8948 | output. |
| 8949 | Customizing this <filename>conf-notes.txt</filename> file is a |
| 8950 | good way to make sure your list of custom targets appears |
| 8951 | as part of the script's output. |
| 8952 | </para> |
| 8953 | |
| 8954 | <para> |
| 8955 | Here is the default list of targets displayed as a result of |
| 8956 | running either of the setup scripts: |
| 8957 | <literallayout class='monospaced'> |
| 8958 | You can now run 'bitbake <target>' |
| 8959 | |
| 8960 | Common targets are: |
| 8961 | core-image-minimal |
| 8962 | core-image-sato |
| 8963 | meta-toolchain |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 8964 | meta-ide-support |
| 8965 | </literallayout> |
| 8966 | </para> |
| 8967 | |
| 8968 | <para> |
| 8969 | Changing the listed common targets is as easy as editing your |
| 8970 | version of <filename>conf-notes.txt</filename> in your |
| 8971 | custom template configuration directory and making sure you |
| 8972 | have <filename>TEMPLATECONF</filename> set to your directory. |
| 8973 | </para> |
| 8974 | </section> |
| 8975 | |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 8976 | <section id='dev-saving-memory-during-a-build'> |
| 8977 | <title>Conserving Disk Space During Builds</title> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 8978 | |
| 8979 | <para> |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 8980 | To help conserve disk space during builds, you can add the |
| 8981 | following statement to your project's |
| 8982 | <filename>local.conf</filename> configuration file found in the |
| 8983 | <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink>: |
| 8984 | <literallayout class='monospaced'> |
| 8985 | INHERIT += "rm_work" |
| 8986 | </literallayout> |
| 8987 | Adding this statement deletes the work directory used for building |
| 8988 | a recipe once the recipe is built. |
| 8989 | For more information on "rm_work", see the |
| 8990 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-rm-work'><filename>rm_work</filename></ulink> |
| 8991 | class in the Yocto Project Reference Manual. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 8992 | </para> |
| 8993 | </section> |
| 8994 | |
| 8995 | <section id='working-with-packages'> |
| 8996 | <title>Working with Packages</title> |
| 8997 | |
| 8998 | <para> |
| 8999 | This section describes a few tasks that involve packages: |
| 9000 | <itemizedlist> |
| 9001 | <listitem><para> |
| 9002 | <link linkend='excluding-packages-from-an-image'>Excluding packages from an image</link> |
| 9003 | </para></listitem> |
| 9004 | <listitem><para> |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 9005 | <link linkend='incrementing-a-binary-package-version'>Incrementing a binary package version</link> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 9006 | </para></listitem> |
| 9007 | <listitem><para> |
| 9008 | <link linkend='handling-optional-module-packaging'>Handling optional module packaging</link> |
| 9009 | </para></listitem> |
| 9010 | <listitem><para> |
Brad Bishop | 15ae250 | 2019-06-18 21:44:24 -0400 | [diff] [blame] | 9011 | <link linkend='using-runtime-package-management'>Using runtime package management</link> |
| 9012 | </para></listitem> |
| 9013 | <listitem><para> |
| 9014 | <link linkend='generating-and-using-signed-packages'>Generating and using signed packages</link> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 9015 | </para></listitem> |
| 9016 | <listitem><para> |
| 9017 | <link linkend='testing-packages-with-ptest'>Setting up and running package test (ptest)</link> |
| 9018 | </para></listitem> |
Brad Bishop | 15ae250 | 2019-06-18 21:44:24 -0400 | [diff] [blame] | 9019 | <listitem><para> |
| 9020 | <link linkend='creating-node-package-manager-npm-packages'>Creating node package manager (NPM) packages</link> |
| 9021 | </para></listitem> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 9022 | </itemizedlist> |
| 9023 | </para> |
| 9024 | |
| 9025 | <section id='excluding-packages-from-an-image'> |
| 9026 | <title>Excluding Packages from an Image</title> |
| 9027 | |
| 9028 | <para> |
| 9029 | You might find it necessary to prevent specific packages |
| 9030 | from being installed into an image. |
| 9031 | If so, you can use several variables to direct the build |
| 9032 | system to essentially ignore installing recommended packages |
| 9033 | or to not install a package at all. |
| 9034 | </para> |
| 9035 | |
| 9036 | <para> |
| 9037 | The following list introduces variables you can use to |
| 9038 | prevent packages from being installed into your image. |
| 9039 | Each of these variables only works with IPK and RPM |
| 9040 | package types. |
| 9041 | Support for Debian packages does not exist. |
| 9042 | Also, you can use these variables from your |
| 9043 | <filename>local.conf</filename> file or attach them to a |
| 9044 | specific image recipe by using a recipe name override. |
| 9045 | For more detail on the variables, see the descriptions in the |
| 9046 | Yocto Project Reference Manual's glossary chapter. |
| 9047 | <itemizedlist> |
| 9048 | <listitem><para><ulink url='&YOCTO_DOCS_REF_URL;#var-BAD_RECOMMENDATIONS'><filename>BAD_RECOMMENDATIONS</filename></ulink>: |
| 9049 | Use this variable to specify "recommended-only" |
| 9050 | packages that you do not want installed. |
| 9051 | </para></listitem> |
| 9052 | <listitem><para><ulink url='&YOCTO_DOCS_REF_URL;#var-NO_RECOMMENDATIONS'><filename>NO_RECOMMENDATIONS</filename></ulink>: |
| 9053 | Use this variable to prevent all "recommended-only" |
| 9054 | packages from being installed. |
| 9055 | </para></listitem> |
| 9056 | <listitem><para><ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_EXCLUDE'><filename>PACKAGE_EXCLUDE</filename></ulink>: |
| 9057 | Use this variable to prevent specific packages from |
| 9058 | being installed regardless of whether they are |
| 9059 | "recommended-only" or not. |
| 9060 | You need to realize that the build process could |
| 9061 | fail with an error when you |
| 9062 | prevent the installation of a package whose presence |
| 9063 | is required by an installed package. |
| 9064 | </para></listitem> |
| 9065 | </itemizedlist> |
| 9066 | </para> |
| 9067 | </section> |
| 9068 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 9069 | <section id='incrementing-a-binary-package-version'> |
| 9070 | <title>Incrementing a Package Version</title> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 9071 | |
| 9072 | <para> |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 9073 | This section provides some background on how binary package |
| 9074 | versioning is accomplished and presents some of the services, |
| 9075 | variables, and terminology involved. |
| 9076 | </para> |
| 9077 | |
| 9078 | <para> |
| 9079 | In order to understand binary package versioning, you need |
| 9080 | to consider the following: |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 9081 | <itemizedlist> |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 9082 | <listitem><para> |
| 9083 | Binary Package: The binary package that is eventually |
| 9084 | built and installed into an image. |
| 9085 | </para></listitem> |
| 9086 | <listitem><para> |
| 9087 | Binary Package Version: The binary package version |
| 9088 | is composed of two components - a version and a |
| 9089 | revision. |
| 9090 | <note> |
| 9091 | Technically, a third component, the "epoch" (i.e. |
| 9092 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PE'><filename>PE</filename></ulink>) |
| 9093 | is involved but this discussion for the most part |
| 9094 | ignores <filename>PE</filename>. |
| 9095 | </note> |
| 9096 | The version and revision are taken from the |
| 9097 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PV'><filename>PV</filename></ulink> |
| 9098 | and |
| 9099 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PR'><filename>PR</filename></ulink> |
| 9100 | variables, respectively. |
| 9101 | </para></listitem> |
| 9102 | <listitem><para> |
| 9103 | <filename>PV</filename>: The recipe version. |
| 9104 | <filename>PV</filename> represents the version of the |
| 9105 | software being packaged. |
| 9106 | Do not confuse <filename>PV</filename> with the |
| 9107 | binary package version. |
| 9108 | </para></listitem> |
| 9109 | <listitem><para> |
| 9110 | <filename>PR</filename>: The recipe revision. |
| 9111 | </para></listitem> |
| 9112 | <listitem><para> |
| 9113 | <ulink url='&YOCTO_DOCS_REF_URL;#var-SRCPV'><filename>SRCPV</filename></ulink>: |
| 9114 | The OpenEmbedded build system uses this string |
| 9115 | to help define the value of <filename>PV</filename> |
| 9116 | when the source code revision needs to be included |
| 9117 | in it. |
| 9118 | </para></listitem> |
| 9119 | <listitem><para> |
| 9120 | <ulink url='https://wiki.yoctoproject.org/wiki/PR_Service'>PR Service</ulink>: |
| 9121 | A network-based service that helps automate keeping |
| 9122 | package feeds compatible with existing package |
| 9123 | manager applications such as RPM, APT, and OPKG. |
| 9124 | </para></listitem> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 9125 | </itemizedlist> |
| 9126 | </para> |
| 9127 | |
| 9128 | <para> |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 9129 | Whenever the binary package content changes, the binary package |
| 9130 | version must change. |
| 9131 | Changing the binary package version is accomplished by changing |
| 9132 | or "bumping" the <filename>PR</filename> and/or |
| 9133 | <filename>PV</filename> values. |
| 9134 | Increasing these values occurs one of two ways: |
| 9135 | <itemizedlist> |
| 9136 | <listitem><para>Automatically using a Package Revision |
| 9137 | Service (PR Service). |
| 9138 | </para></listitem> |
| 9139 | <listitem><para>Manually incrementing the |
| 9140 | <filename>PR</filename> and/or |
| 9141 | <filename>PV</filename> variables. |
| 9142 | </para></listitem> |
| 9143 | </itemizedlist> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 9144 | </para> |
| 9145 | |
| 9146 | <para> |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 9147 | Given a primary challenge of any build system and its users |
| 9148 | is how to maintain a package feed that is compatible with |
| 9149 | existing package manager applications such as RPM, APT, and |
| 9150 | OPKG, using an automated system is much preferred over a |
| 9151 | manual system. |
| 9152 | In either system, the main requirement is that binary package |
| 9153 | version numbering increases in a linear fashion and that a |
| 9154 | number of version components exist that support that linear |
| 9155 | progression. |
| 9156 | For information on how to ensure package revisioning remains |
| 9157 | linear, see the |
| 9158 | "<link linkend='automatically-incrementing-a-binary-package-revision-number'>Automatically Incrementing a Binary Package Revision Number</link>" |
| 9159 | section. |
| 9160 | </para> |
| 9161 | |
| 9162 | <para> |
| 9163 | The following three sections provide related information on the |
| 9164 | PR Service, the manual method for "bumping" |
| 9165 | <filename>PR</filename> and/or <filename>PV</filename>, and |
| 9166 | on how to ensure binary package revisioning remains linear. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 9167 | </para> |
| 9168 | |
| 9169 | <section id='working-with-a-pr-service'> |
| 9170 | <title>Working With a PR Service</title> |
| 9171 | |
| 9172 | <para> |
| 9173 | As mentioned, attempting to maintain revision numbers in the |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 9174 | <ulink url='&YOCTO_DOCS_REF_URL;#metadata'>Metadata</ulink> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 9175 | is error prone, inaccurate, and causes problems for people |
| 9176 | submitting recipes. |
| 9177 | Conversely, the PR Service automatically generates |
| 9178 | increasing numbers, particularly the revision field, |
| 9179 | which removes the human element. |
| 9180 | <note> |
| 9181 | For additional information on using a PR Service, you |
| 9182 | can see the |
| 9183 | <ulink url='&YOCTO_WIKI_URL;/wiki/PR_Service'>PR Service</ulink> |
| 9184 | wiki page. |
| 9185 | </note> |
| 9186 | </para> |
| 9187 | |
| 9188 | <para> |
| 9189 | The Yocto Project uses variables in order of |
| 9190 | decreasing priority to facilitate revision numbering (i.e. |
| 9191 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PE'><filename>PE</filename></ulink>, |
| 9192 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PV'><filename>PV</filename></ulink>, and |
| 9193 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PR'><filename>PR</filename></ulink> |
| 9194 | for epoch, version, and revision, respectively). |
| 9195 | The values are highly dependent on the policies and |
| 9196 | procedures of a given distribution and package feed. |
| 9197 | </para> |
| 9198 | |
| 9199 | <para> |
| 9200 | Because the OpenEmbedded build system uses |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 9201 | "<ulink url='&YOCTO_DOCS_OM_URL;#overview-checksums'>signatures</ulink>", |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 9202 | which are unique to a given build, the build system |
| 9203 | knows when to rebuild packages. |
| 9204 | All the inputs into a given task are represented by a |
| 9205 | signature, which can trigger a rebuild when different. |
| 9206 | Thus, the build system itself does not rely on the |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 9207 | <filename>PR</filename>, <filename>PV</filename>, and |
| 9208 | <filename>PE</filename> numbers to trigger a rebuild. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 9209 | The signatures, however, can be used to generate |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 9210 | these values. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 9211 | </para> |
| 9212 | |
| 9213 | <para> |
| 9214 | The PR Service works with both |
| 9215 | <filename>OEBasic</filename> and |
| 9216 | <filename>OEBasicHash</filename> generators. |
| 9217 | The value of <filename>PR</filename> bumps when the |
| 9218 | checksum changes and the different generator mechanisms |
| 9219 | change signatures under different circumstances. |
| 9220 | </para> |
| 9221 | |
| 9222 | <para> |
| 9223 | As implemented, the build system includes values from |
| 9224 | the PR Service into the <filename>PR</filename> field as |
| 9225 | an addition using the form "<filename>.x</filename>" so |
| 9226 | <filename>r0</filename> becomes <filename>r0.1</filename>, |
| 9227 | <filename>r0.2</filename> and so forth. |
| 9228 | This scheme allows existing <filename>PR</filename> values |
| 9229 | to be used for whatever reasons, which include manual |
| 9230 | <filename>PR</filename> bumps, should it be necessary. |
| 9231 | </para> |
| 9232 | |
| 9233 | <para> |
| 9234 | By default, the PR Service is not enabled or running. |
| 9235 | Thus, the packages generated are just "self consistent". |
| 9236 | The build system adds and removes packages and |
| 9237 | there are no guarantees about upgrade paths but images |
| 9238 | will be consistent and correct with the latest changes. |
| 9239 | </para> |
| 9240 | |
| 9241 | <para> |
| 9242 | The simplest form for a PR Service is for it to exist |
| 9243 | for a single host development system that builds the |
| 9244 | package feed (building system). |
| 9245 | For this scenario, you can enable a local PR Service by |
| 9246 | setting |
| 9247 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PRSERV_HOST'><filename>PRSERV_HOST</filename></ulink> |
| 9248 | in your <filename>local.conf</filename> file in the |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 9249 | <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink>: |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 9250 | <literallayout class='monospaced'> |
| 9251 | PRSERV_HOST = "localhost:0" |
| 9252 | </literallayout> |
| 9253 | Once the service is started, packages will automatically |
| 9254 | get increasing <filename>PR</filename> values and |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 9255 | BitBake takes care of starting and stopping the server. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 9256 | </para> |
| 9257 | |
| 9258 | <para> |
| 9259 | If you have a more complex setup where multiple host |
| 9260 | development systems work against a common, shared package |
| 9261 | feed, you have a single PR Service running and it is |
| 9262 | connected to each building system. |
| 9263 | For this scenario, you need to start the PR Service using |
| 9264 | the <filename>bitbake-prserv</filename> command: |
| 9265 | <literallayout class='monospaced'> |
| 9266 | bitbake-prserv --host <replaceable>ip</replaceable> --port <replaceable>port</replaceable> --start |
| 9267 | </literallayout> |
| 9268 | In addition to hand-starting the service, you need to |
| 9269 | update the <filename>local.conf</filename> file of each |
| 9270 | building system as described earlier so each system |
| 9271 | points to the server and port. |
| 9272 | </para> |
| 9273 | |
| 9274 | <para> |
| 9275 | It is also recommended you use build history, which adds |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 9276 | some sanity checks to binary package versions, in |
| 9277 | conjunction with the server that is running the PR Service. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 9278 | To enable build history, add the following to each building |
| 9279 | system's <filename>local.conf</filename> file: |
| 9280 | <literallayout class='monospaced'> |
| 9281 | # It is recommended to activate "buildhistory" for testing the PR service |
| 9282 | INHERIT += "buildhistory" |
| 9283 | BUILDHISTORY_COMMIT = "1" |
| 9284 | </literallayout> |
| 9285 | For information on build history, see the |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 9286 | "<link linkend='maintaining-build-output-quality'>Maintaining Build Output Quality</link>" |
| 9287 | section. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 9288 | </para> |
| 9289 | |
| 9290 | <note> |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 9291 | <para> |
| 9292 | The OpenEmbedded build system does not maintain |
| 9293 | <filename>PR</filename> information as part of the |
| 9294 | shared state (sstate) packages. |
| 9295 | If you maintain an sstate feed, its expected that either |
| 9296 | all your building systems that contribute to the sstate |
| 9297 | feed use a shared PR Service, or you do not run a PR |
| 9298 | Service on any of your building systems. |
| 9299 | Having some systems use a PR Service while others do |
| 9300 | not leads to obvious problems. |
| 9301 | </para> |
| 9302 | |
| 9303 | <para> |
| 9304 | For more information on shared state, see the |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 9305 | "<ulink url='&YOCTO_DOCS_OM_URL;#shared-state-cache'>Shared State Cache</ulink>" |
| 9306 | section in the Yocto Project Overview and Concepts |
| 9307 | Manual. |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 9308 | </para> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 9309 | </note> |
| 9310 | </section> |
| 9311 | |
| 9312 | <section id='manually-bumping-pr'> |
| 9313 | <title>Manually Bumping PR</title> |
| 9314 | |
| 9315 | <para> |
| 9316 | The alternative to setting up a PR Service is to manually |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 9317 | "bump" the |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 9318 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PR'><filename>PR</filename></ulink> |
| 9319 | variable. |
| 9320 | </para> |
| 9321 | |
| 9322 | <para> |
Brad Bishop | 37a0e4d | 2017-12-04 01:01:44 -0500 | [diff] [blame] | 9323 | If a committed change results in changing the package |
| 9324 | output, then the value of the PR variable needs to be |
| 9325 | increased (or "bumped") as part of that commit. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 9326 | For new recipes you should add the <filename>PR</filename> |
Brad Bishop | 37a0e4d | 2017-12-04 01:01:44 -0500 | [diff] [blame] | 9327 | variable and set its initial value equal to "r0", which is |
| 9328 | the default. |
| 9329 | Even though the default value is "r0", the practice of |
| 9330 | adding it to a new recipe makes it harder to forget to bump |
| 9331 | the variable when you make changes to the recipe in future. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 9332 | </para> |
| 9333 | |
| 9334 | <para> |
Brad Bishop | 37a0e4d | 2017-12-04 01:01:44 -0500 | [diff] [blame] | 9335 | If you are sharing a common <filename>.inc</filename> file |
| 9336 | with multiple recipes, you can also use the |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 9337 | <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-INC_PR'>INC_PR</ulink></filename> |
Brad Bishop | 37a0e4d | 2017-12-04 01:01:44 -0500 | [diff] [blame] | 9338 | variable to ensure that the recipes sharing the |
| 9339 | <filename>.inc</filename> file are rebuilt when the |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 9340 | <filename>.inc</filename> file itself is changed. |
Brad Bishop | 37a0e4d | 2017-12-04 01:01:44 -0500 | [diff] [blame] | 9341 | The <filename>.inc</filename> file must set |
| 9342 | <filename>INC_PR</filename> (initially to "r0"), and all |
| 9343 | recipes referring to it should set <filename>PR</filename> |
| 9344 | to "${INC_PR}.0" initially, incrementing the last number |
| 9345 | when the recipe is changed. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 9346 | If the <filename>.inc</filename> file is changed then its |
| 9347 | <filename>INC_PR</filename> should be incremented. |
| 9348 | </para> |
| 9349 | |
| 9350 | <para> |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 9351 | When upgrading the version of a binary package, assuming the |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 9352 | <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-PV'>PV</ulink></filename> |
| 9353 | changes, the <filename>PR</filename> variable should be |
Brad Bishop | 37a0e4d | 2017-12-04 01:01:44 -0500 | [diff] [blame] | 9354 | reset to "r0" (or "${INC_PR}.0" if you are using |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 9355 | <filename>INC_PR</filename>). |
| 9356 | </para> |
| 9357 | |
| 9358 | <para> |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 9359 | Usually, version increases occur only to binary packages. |
Brad Bishop | 37a0e4d | 2017-12-04 01:01:44 -0500 | [diff] [blame] | 9360 | However, if for some reason <filename>PV</filename> changes |
| 9361 | but does not increase, you can increase the |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 9362 | <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-PE'>PE</ulink></filename> |
| 9363 | variable (Package Epoch). |
| 9364 | The <filename>PE</filename> variable defaults to "0". |
| 9365 | </para> |
| 9366 | |
| 9367 | <para> |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 9368 | Binary package version numbering strives to follow the |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 9369 | <ulink url='http://www.debian.org/doc/debian-policy/ch-controlfields.html'> |
| 9370 | Debian Version Field Policy Guidelines</ulink>. |
Brad Bishop | 37a0e4d | 2017-12-04 01:01:44 -0500 | [diff] [blame] | 9371 | These guidelines define how versions are compared and what |
| 9372 | "increasing" a version means. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 9373 | </para> |
| 9374 | </section> |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 9375 | |
| 9376 | <section id='automatically-incrementing-a-binary-package-revision-number'> |
| 9377 | <title>Automatically Incrementing a Package Version Number</title> |
| 9378 | |
| 9379 | <para> |
| 9380 | When fetching a repository, BitBake uses the |
| 9381 | <ulink url='&YOCTO_DOCS_REF_URL;#var-SRCREV'><filename>SRCREV</filename></ulink> |
| 9382 | variable to determine the specific source code revision |
| 9383 | from which to build. |
| 9384 | You set the <filename>SRCREV</filename> variable to |
| 9385 | <ulink url='&YOCTO_DOCS_REF_URL;#var-AUTOREV'><filename>AUTOREV</filename></ulink> |
| 9386 | to cause the OpenEmbedded build system to automatically use the |
| 9387 | latest revision of the software: |
| 9388 | <literallayout class='monospaced'> |
| 9389 | SRCREV = "${AUTOREV}" |
| 9390 | </literallayout> |
| 9391 | </para> |
| 9392 | |
| 9393 | <para> |
| 9394 | Furthermore, you need to reference <filename>SRCPV</filename> |
| 9395 | in <filename>PV</filename> in order to automatically update |
| 9396 | the version whenever the revision of the source code |
| 9397 | changes. |
| 9398 | Here is an example: |
| 9399 | <literallayout class='monospaced'> |
| 9400 | PV = "1.0+git${SRCPV}" |
| 9401 | </literallayout> |
| 9402 | The OpenEmbedded build system substitutes |
| 9403 | <filename>SRCPV</filename> with the following: |
| 9404 | <literallayout class='monospaced'> |
| 9405 | AUTOINC+<replaceable>source_code_revision</replaceable> |
| 9406 | </literallayout> |
| 9407 | The build system replaces the <filename>AUTOINC</filename> with |
| 9408 | a number. |
| 9409 | The number used depends on the state of the PR Service: |
| 9410 | <itemizedlist> |
| 9411 | <listitem><para> |
| 9412 | If PR Service is enabled, the build system increments |
| 9413 | the number, which is similar to the behavior of |
| 9414 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PR'><filename>PR</filename></ulink>. |
| 9415 | This behavior results in linearly increasing package |
| 9416 | versions, which is desirable. |
| 9417 | Here is an example: |
| 9418 | <literallayout class='monospaced'> |
| 9419 | hello-world-git_0.0+git0+b6558dd387-r0.0_armv7a-neon.ipk |
| 9420 | hello-world-git_0.0+git1+dd2f5c3565-r0.0_armv7a-neon.ipk |
| 9421 | </literallayout> |
| 9422 | </para></listitem> |
| 9423 | <listitem><para> |
| 9424 | If PR Service is not enabled, the build system |
| 9425 | replaces the <filename>AUTOINC</filename> |
| 9426 | placeholder with zero (i.e. "0"). |
| 9427 | This results in changing the package version since |
| 9428 | the source revision is included. |
| 9429 | However, package versions are not increased linearly. |
| 9430 | Here is an example: |
| 9431 | <literallayout class='monospaced'> |
| 9432 | hello-world-git_0.0+git0+b6558dd387-r0.0_armv7a-neon.ipk |
| 9433 | hello-world-git_0.0+git0+dd2f5c3565-r0.0_armv7a-neon.ipk |
| 9434 | </literallayout> |
| 9435 | </para></listitem> |
| 9436 | </itemizedlist> |
| 9437 | </para> |
| 9438 | |
| 9439 | <para> |
| 9440 | In summary, the OpenEmbedded build system does not track the |
| 9441 | history of binary package versions for this purpose. |
| 9442 | <filename>AUTOINC</filename>, in this case, is comparable to |
| 9443 | <filename>PR</filename>. |
| 9444 | If PR server is not enabled, <filename>AUTOINC</filename> |
| 9445 | in the package version is simply replaced by "0". |
| 9446 | If PR server is enabled, the build system keeps track of the |
| 9447 | package versions and bumps the number when the package |
| 9448 | revision changes. |
| 9449 | </para> |
| 9450 | </section> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 9451 | </section> |
| 9452 | |
| 9453 | <section id='handling-optional-module-packaging'> |
| 9454 | <title>Handling Optional Module Packaging</title> |
| 9455 | |
| 9456 | <para> |
| 9457 | Many pieces of software split functionality into optional |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 9458 | modules (or plugins) and the plugins that are built |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 9459 | might depend on configuration options. |
| 9460 | To avoid having to duplicate the logic that determines what |
| 9461 | modules are available in your recipe or to avoid having |
| 9462 | to package each module by hand, the OpenEmbedded build system |
| 9463 | provides functionality to handle module packaging dynamically. |
| 9464 | </para> |
| 9465 | |
| 9466 | <para> |
| 9467 | To handle optional module packaging, you need to do two things: |
| 9468 | <itemizedlist> |
| 9469 | <listitem><para>Ensure the module packaging is actually |
| 9470 | done.</para></listitem> |
| 9471 | <listitem><para>Ensure that any dependencies on optional |
| 9472 | modules from other recipes are satisfied by your recipe. |
| 9473 | </para></listitem> |
| 9474 | </itemizedlist> |
| 9475 | </para> |
| 9476 | |
| 9477 | <section id='making-sure-the-packaging-is-done'> |
| 9478 | <title>Making Sure the Packaging is Done</title> |
| 9479 | |
| 9480 | <para> |
| 9481 | To ensure the module packaging actually gets done, you use |
| 9482 | the <filename>do_split_packages</filename> function within |
| 9483 | the <filename>populate_packages</filename> Python function |
| 9484 | in your recipe. |
| 9485 | The <filename>do_split_packages</filename> function |
| 9486 | searches for a pattern of files or directories under a |
| 9487 | specified path and creates a package for each one it finds |
| 9488 | by appending to the |
| 9489 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGES'><filename>PACKAGES</filename></ulink> |
| 9490 | variable and setting the appropriate values for |
| 9491 | <filename>FILES_packagename</filename>, |
| 9492 | <filename>RDEPENDS_packagename</filename>, |
| 9493 | <filename>DESCRIPTION_packagename</filename>, and so forth. |
| 9494 | Here is an example from the <filename>lighttpd</filename> |
| 9495 | recipe: |
| 9496 | <literallayout class='monospaced'> |
| 9497 | python populate_packages_prepend () { |
| 9498 | lighttpd_libdir = d.expand('${libdir}') |
| 9499 | do_split_packages(d, lighttpd_libdir, '^mod_(.*)\.so$', |
| 9500 | 'lighttpd-module-%s', 'Lighttpd module for %s', |
| 9501 | extra_depends='') |
| 9502 | } |
| 9503 | </literallayout> |
| 9504 | The previous example specifies a number of things in the |
| 9505 | call to <filename>do_split_packages</filename>. |
| 9506 | <itemizedlist> |
| 9507 | <listitem><para>A directory within the files installed |
| 9508 | by your recipe through <filename>do_install</filename> |
| 9509 | in which to search.</para></listitem> |
| 9510 | <listitem><para>A regular expression used to match module |
| 9511 | files in that directory. |
| 9512 | In the example, note the parentheses () that mark |
| 9513 | the part of the expression from which the module |
| 9514 | name should be derived.</para></listitem> |
| 9515 | <listitem><para>A pattern to use for the package names. |
| 9516 | </para></listitem> |
| 9517 | <listitem><para>A description for each package. |
| 9518 | </para></listitem> |
| 9519 | <listitem><para>An empty string for |
| 9520 | <filename>extra_depends</filename>, which disables |
| 9521 | the default dependency on the main |
| 9522 | <filename>lighttpd</filename> package. |
| 9523 | Thus, if a file in <filename>${libdir}</filename> |
| 9524 | called <filename>mod_alias.so</filename> is found, |
| 9525 | a package called <filename>lighttpd-module-alias</filename> |
| 9526 | is created for it and the |
| 9527 | <ulink url='&YOCTO_DOCS_REF_URL;#var-DESCRIPTION'><filename>DESCRIPTION</filename></ulink> |
| 9528 | is set to "Lighttpd module for alias".</para></listitem> |
| 9529 | </itemizedlist> |
| 9530 | </para> |
| 9531 | |
| 9532 | <para> |
| 9533 | Often, packaging modules is as simple as the previous |
| 9534 | example. |
| 9535 | However, more advanced options exist that you can use |
| 9536 | within <filename>do_split_packages</filename> to modify its |
| 9537 | behavior. |
| 9538 | And, if you need to, you can add more logic by specifying |
| 9539 | a hook function that is called for each package. |
| 9540 | It is also perfectly acceptable to call |
| 9541 | <filename>do_split_packages</filename> multiple times if |
| 9542 | you have more than one set of modules to package. |
| 9543 | </para> |
| 9544 | |
| 9545 | <para> |
| 9546 | For more examples that show how to use |
| 9547 | <filename>do_split_packages</filename>, see the |
| 9548 | <filename>connman.inc</filename> file in the |
| 9549 | <filename>meta/recipes-connectivity/connman/</filename> |
| 9550 | directory of the <filename>poky</filename> |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 9551 | <ulink url='&YOCTO_DOCS_OM_URL;#yocto-project-repositories'>source repository</ulink>. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 9552 | You can also find examples in |
| 9553 | <filename>meta/classes/kernel.bbclass</filename>. |
| 9554 | </para> |
| 9555 | |
| 9556 | <para> |
| 9557 | Following is a reference that shows |
| 9558 | <filename>do_split_packages</filename> mandatory and |
| 9559 | optional arguments: |
| 9560 | <literallayout class='monospaced'> |
| 9561 | Mandatory arguments |
| 9562 | |
| 9563 | root |
| 9564 | The path in which to search |
| 9565 | file_regex |
| 9566 | Regular expression to match searched files. |
| 9567 | Use parentheses () to mark the part of this |
| 9568 | expression that should be used to derive the |
| 9569 | module name (to be substituted where %s is |
| 9570 | used in other function arguments as noted below) |
| 9571 | output_pattern |
| 9572 | Pattern to use for the package names. Must |
| 9573 | include %s. |
| 9574 | description |
| 9575 | Description to set for each package. Must |
| 9576 | include %s. |
| 9577 | |
| 9578 | Optional arguments |
| 9579 | |
| 9580 | postinst |
| 9581 | Postinstall script to use for all packages |
| 9582 | (as a string) |
| 9583 | recursive |
| 9584 | True to perform a recursive search - default |
| 9585 | False |
| 9586 | hook |
| 9587 | A hook function to be called for every match. |
| 9588 | The function will be called with the following |
| 9589 | arguments (in the order listed): |
| 9590 | |
| 9591 | f |
| 9592 | Full path to the file/directory match |
| 9593 | pkg |
| 9594 | The package name |
| 9595 | file_regex |
| 9596 | As above |
| 9597 | output_pattern |
| 9598 | As above |
| 9599 | modulename |
| 9600 | The module name derived using file_regex |
| 9601 | |
| 9602 | extra_depends |
| 9603 | Extra runtime dependencies (RDEPENDS) to be |
| 9604 | set for all packages. The default value of None |
| 9605 | causes a dependency on the main package |
| 9606 | (${PN}) - if you do not want this, pass empty |
| 9607 | string '' for this parameter. |
| 9608 | aux_files_pattern |
| 9609 | Extra item(s) to be added to FILES for each |
| 9610 | package. Can be a single string item or a list |
| 9611 | of strings for multiple items. Must include %s. |
| 9612 | postrm |
| 9613 | postrm script to use for all packages (as a |
| 9614 | string) |
| 9615 | allow_dirs |
| 9616 | True to allow directories to be matched - |
| 9617 | default False |
| 9618 | prepend |
| 9619 | If True, prepend created packages to PACKAGES |
| 9620 | instead of the default False which appends them |
| 9621 | match_path |
| 9622 | match file_regex on the whole relative path to |
| 9623 | the root rather than just the file name |
| 9624 | aux_files_pattern_verbatim |
| 9625 | Extra item(s) to be added to FILES for each |
| 9626 | package, using the actual derived module name |
| 9627 | rather than converting it to something legal |
| 9628 | for a package name. Can be a single string item |
| 9629 | or a list of strings for multiple items. Must |
| 9630 | include %s. |
| 9631 | allow_links |
| 9632 | True to allow symlinks to be matched - default |
| 9633 | False |
| 9634 | summary |
| 9635 | Summary to set for each package. Must include %s; |
| 9636 | defaults to description if not set. |
| 9637 | </literallayout> |
| 9638 | </para> |
| 9639 | </section> |
| 9640 | |
| 9641 | <section id='satisfying-dependencies'> |
| 9642 | <title>Satisfying Dependencies</title> |
| 9643 | |
| 9644 | <para> |
| 9645 | The second part for handling optional module packaging |
| 9646 | is to ensure that any dependencies on optional modules |
| 9647 | from other recipes are satisfied by your recipe. |
| 9648 | You can be sure these dependencies are satisfied by |
| 9649 | using the |
| 9650 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGES_DYNAMIC'><filename>PACKAGES_DYNAMIC</filename></ulink> variable. |
| 9651 | Here is an example that continues with the |
| 9652 | <filename>lighttpd</filename> recipe shown earlier: |
| 9653 | <literallayout class='monospaced'> |
| 9654 | PACKAGES_DYNAMIC = "lighttpd-module-.*" |
| 9655 | </literallayout> |
| 9656 | The name specified in the regular expression can of |
| 9657 | course be anything. |
| 9658 | In this example, it is <filename>lighttpd-module-</filename> |
| 9659 | and is specified as the prefix to ensure that any |
| 9660 | <ulink url='&YOCTO_DOCS_REF_URL;#var-RDEPENDS'><filename>RDEPENDS</filename></ulink> |
| 9661 | and <ulink url='&YOCTO_DOCS_REF_URL;#var-RRECOMMENDS'><filename>RRECOMMENDS</filename></ulink> |
| 9662 | on a package name starting with the prefix are satisfied |
| 9663 | during build time. |
| 9664 | If you are using <filename>do_split_packages</filename> |
| 9665 | as described in the previous section, the value you put in |
| 9666 | <filename>PACKAGES_DYNAMIC</filename> should correspond to |
| 9667 | the name pattern specified in the call to |
| 9668 | <filename>do_split_packages</filename>. |
| 9669 | </para> |
| 9670 | </section> |
| 9671 | </section> |
| 9672 | |
| 9673 | <section id='using-runtime-package-management'> |
| 9674 | <title>Using Runtime Package Management</title> |
| 9675 | |
| 9676 | <para> |
| 9677 | During a build, BitBake always transforms a recipe into one or |
| 9678 | more packages. |
| 9679 | For example, BitBake takes the <filename>bash</filename> recipe |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 9680 | and produces a number of packages (e.g. |
| 9681 | <filename>bash</filename>, <filename>bash-bashbug</filename>, |
| 9682 | <filename>bash-completion</filename>, |
| 9683 | <filename>bash-completion-dbg</filename>, |
| 9684 | <filename>bash-completion-dev</filename>, |
| 9685 | <filename>bash-completion-extra</filename>, |
| 9686 | <filename>bash-dbg</filename>, and so forth). |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 9687 | Not all generated packages are included in an image. |
| 9688 | </para> |
| 9689 | |
| 9690 | <para> |
| 9691 | In several situations, you might need to update, add, remove, |
| 9692 | or query the packages on a target device at runtime |
| 9693 | (i.e. without having to generate a new image). |
| 9694 | Examples of such situations include: |
| 9695 | <itemizedlist> |
| 9696 | <listitem><para> |
| 9697 | You want to provide in-the-field updates to deployed |
| 9698 | devices (e.g. security updates). |
| 9699 | </para></listitem> |
| 9700 | <listitem><para> |
| 9701 | You want to have a fast turn-around development cycle |
| 9702 | for one or more applications that run on your device. |
| 9703 | </para></listitem> |
| 9704 | <listitem><para> |
| 9705 | You want to temporarily install the "debug" packages |
| 9706 | of various applications on your device so that |
| 9707 | debugging can be greatly improved by allowing |
| 9708 | access to symbols and source debugging. |
| 9709 | </para></listitem> |
| 9710 | <listitem><para> |
| 9711 | You want to deploy a more minimal package selection of |
| 9712 | your device but allow in-the-field updates to add a |
| 9713 | larger selection for customization. |
| 9714 | </para></listitem> |
| 9715 | </itemizedlist> |
| 9716 | </para> |
| 9717 | |
| 9718 | <para> |
| 9719 | In all these situations, you have something similar to a more |
| 9720 | traditional Linux distribution in that in-field devices |
| 9721 | are able to receive pre-compiled packages from a server for |
| 9722 | installation or update. |
| 9723 | Being able to install these packages on a running, |
| 9724 | in-field device is what is termed "runtime package |
| 9725 | management". |
| 9726 | </para> |
| 9727 | |
| 9728 | <para> |
| 9729 | In order to use runtime package management, you |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 9730 | need a host or server machine that serves up the pre-compiled |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 9731 | packages plus the required metadata. |
| 9732 | You also need package manipulation tools on the target. |
| 9733 | The build machine is a likely candidate to act as the server. |
| 9734 | However, that machine does not necessarily have to be the |
| 9735 | package server. |
| 9736 | The build machine could push its artifacts to another machine |
| 9737 | that acts as the server (e.g. Internet-facing). |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 9738 | In fact, doing so is advantageous for a production |
| 9739 | environment as getting the packages away from the |
| 9740 | development system's build directory prevents accidental |
| 9741 | overwrites. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 9742 | </para> |
| 9743 | |
| 9744 | <para> |
| 9745 | A simple build that targets just one device produces |
| 9746 | more than one package database. |
| 9747 | In other words, the packages produced by a build are separated |
| 9748 | out into a couple of different package groupings based on |
| 9749 | criteria such as the target's CPU architecture, the target |
| 9750 | board, or the C library used on the target. |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 9751 | For example, a build targeting the <filename>qemux86</filename> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 9752 | device produces the following three package databases: |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 9753 | <filename>noarch</filename>, <filename>i586</filename>, and |
| 9754 | <filename>qemux86</filename>. |
| 9755 | If you wanted your <filename>qemux86</filename> device to be |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 9756 | aware of all the packages that were available to it, |
| 9757 | you would need to point it to each of these databases |
| 9758 | individually. |
| 9759 | In a similar way, a traditional Linux distribution usually is |
| 9760 | configured to be aware of a number of software repositories |
| 9761 | from which it retrieves packages. |
| 9762 | </para> |
| 9763 | |
| 9764 | <para> |
| 9765 | Using runtime package management is completely optional and |
| 9766 | not required for a successful build or deployment in any |
| 9767 | way. |
| 9768 | But if you want to make use of runtime package management, |
| 9769 | you need to do a couple things above and beyond the basics. |
| 9770 | The remainder of this section describes what you need to do. |
| 9771 | </para> |
| 9772 | |
| 9773 | <section id='runtime-package-management-build'> |
| 9774 | <title>Build Considerations</title> |
| 9775 | |
| 9776 | <para> |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 9777 | This section describes build considerations of which you |
| 9778 | need to be aware in order to provide support for runtime |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 9779 | package management. |
| 9780 | </para> |
| 9781 | |
| 9782 | <para> |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 9783 | When BitBake generates packages, it needs to know |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 9784 | what format or formats to use. |
| 9785 | In your configuration, you use the |
| 9786 | <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] | 9787 | variable to specify the format: |
| 9788 | <orderedlist> |
| 9789 | <listitem><para> |
| 9790 | Open the <filename>local.conf</filename> file |
| 9791 | inside your |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 9792 | <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink> |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 9793 | (e.g. <filename>~/poky/build/conf/local.conf</filename>). |
| 9794 | </para></listitem> |
| 9795 | <listitem><para> |
| 9796 | Select the desired package format as follows: |
| 9797 | <literallayout class='monospaced'> |
| 9798 | PACKAGE_CLASSES ?= “package_<replaceable>packageformat</replaceable>” |
| 9799 | </literallayout> |
| 9800 | where <replaceable>packageformat</replaceable> |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 9801 | can be "ipk", "rpm", "deb", or "tar" which are the |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 9802 | supported package formats. |
| 9803 | <note> |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 9804 | Because the Yocto Project supports four |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 9805 | different package formats, you can set the |
| 9806 | variable with more than one argument. |
| 9807 | However, the OpenEmbedded build system only |
| 9808 | uses the first argument when creating an image |
| 9809 | or Software Development Kit (SDK). |
| 9810 | </note> |
| 9811 | </para></listitem> |
| 9812 | </orderedlist> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 9813 | </para> |
| 9814 | |
| 9815 | <para> |
| 9816 | If you would like your image to start off with a basic |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 9817 | package database containing the packages in your current |
| 9818 | build as well as to have the relevant tools available on the |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 9819 | target for runtime package management, you can include |
| 9820 | "package-management" in the |
| 9821 | <ulink url='&YOCTO_DOCS_REF_URL;#var-IMAGE_FEATURES'><filename>IMAGE_FEATURES</filename></ulink> |
| 9822 | variable. |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 9823 | Including "package-management" in this configuration |
| 9824 | variable ensures that when the image is assembled for your |
| 9825 | target, the image includes the currently-known package |
| 9826 | databases as well as the target-specific tools required |
| 9827 | for runtime package management to be performed on the |
| 9828 | target. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 9829 | However, this is not strictly necessary. |
| 9830 | You could start your image off without any databases |
| 9831 | but only include the required on-target package |
| 9832 | tool(s). |
| 9833 | As an example, you could include "opkg" in your |
| 9834 | <ulink url='&YOCTO_DOCS_REF_URL;#var-IMAGE_INSTALL'><filename>IMAGE_INSTALL</filename></ulink> |
| 9835 | variable if you are using the IPK package format. |
| 9836 | You can then initialize your target's package database(s) |
| 9837 | later once your image is up and running. |
| 9838 | </para> |
| 9839 | |
| 9840 | <para> |
| 9841 | Whenever you perform any sort of build step that can |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 9842 | potentially generate a package or modify existing |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 9843 | package, it is always a good idea to re-generate the |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 9844 | package index after the build by using the following |
| 9845 | command: |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 9846 | <literallayout class='monospaced'> |
| 9847 | $ bitbake package-index |
| 9848 | </literallayout> |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 9849 | It might be tempting to build the package and the |
| 9850 | package index at the same time with a command such as |
| 9851 | the following: |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 9852 | <literallayout class='monospaced'> |
| 9853 | $ bitbake <replaceable>some-package</replaceable> package-index |
| 9854 | </literallayout> |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 9855 | Do not do this as BitBake does not schedule the package |
| 9856 | index for after the completion of the package you are |
| 9857 | building. |
| 9858 | Consequently, you cannot be sure of the package index |
| 9859 | including information for the package you just built. |
| 9860 | Thus, be sure to run the package update step separately |
| 9861 | after building any packages. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 9862 | </para> |
| 9863 | |
| 9864 | <para> |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 9865 | You can use the |
| 9866 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_FEED_ARCHS'><filename>PACKAGE_FEED_ARCHS</filename></ulink>, |
| 9867 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_FEED_BASE_PATHS'><filename>PACKAGE_FEED_BASE_PATHS</filename></ulink>, |
| 9868 | and |
| 9869 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_FEED_URIS'><filename>PACKAGE_FEED_URIS</filename></ulink> |
| 9870 | variables to pre-configure target images to use a package |
| 9871 | feed. |
| 9872 | If you do not define these variables, then manual steps |
| 9873 | as described in the subsequent sections are necessary to |
| 9874 | configure the target. |
| 9875 | You should set these variables before building the image |
| 9876 | in order to produce a correctly configured image. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 9877 | </para> |
| 9878 | |
| 9879 | <para> |
| 9880 | When your build is complete, your packages reside in the |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 9881 | <filename>${TMPDIR}/deploy/<replaceable>packageformat</replaceable></filename> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 9882 | directory. |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 9883 | For example, if |
| 9884 | <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] | 9885 | is <filename>tmp</filename> and your selected package type |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 9886 | is RPM, then your RPM packages are available in |
| 9887 | <filename>tmp/deploy/rpm</filename>. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 9888 | </para> |
| 9889 | </section> |
| 9890 | |
| 9891 | <section id='runtime-package-management-server'> |
| 9892 | <title>Host or Server Machine Setup</title> |
| 9893 | |
| 9894 | <para> |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 9895 | Although other protocols are possible, a server using HTTP |
| 9896 | typically serves packages. |
| 9897 | If you want to use HTTP, then set up and configure a |
| 9898 | web server such as Apache 2, lighttpd, or |
| 9899 | SimpleHTTPServer on the machine serving the packages. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 9900 | </para> |
| 9901 | |
| 9902 | <para> |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 9903 | To keep things simple, this section describes how to set |
| 9904 | up a SimpleHTTPServer web server to share package feeds |
| 9905 | from the developer's machine. |
| 9906 | Although this server might not be the best for a production |
| 9907 | environment, the setup is simple and straight forward. |
| 9908 | Should you want to use a different server more suited for |
| 9909 | production (e.g. Apache 2, Lighttpd, or Nginx), take the |
| 9910 | appropriate steps to do so. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 9911 | </para> |
| 9912 | |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 9913 | <para> |
| 9914 | From within the build directory where you have built an |
| 9915 | image based on your packaging choice (i.e. the |
| 9916 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_CLASSES'><filename>PACKAGE_CLASSES</filename></ulink> |
| 9917 | setting), simply start the server. |
| 9918 | The following example assumes a build directory of |
| 9919 | <filename>~/poky/build/tmp/deploy/rpm</filename> and a |
| 9920 | <filename>PACKAGE_CLASSES</filename> setting of |
| 9921 | "package_rpm": |
| 9922 | <literallayout class='monospaced'> |
| 9923 | $ cd ~/poky/build/tmp/deploy/rpm |
| 9924 | $ python -m SimpleHTTPServer |
| 9925 | </literallayout> |
| 9926 | </para> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 9927 | </section> |
| 9928 | |
| 9929 | <section id='runtime-package-management-target'> |
| 9930 | <title>Target Setup</title> |
| 9931 | |
| 9932 | <para> |
| 9933 | Setting up the target differs depending on the |
| 9934 | package management system. |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 9935 | This section provides information for RPM, IPK, and DEB. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 9936 | </para> |
| 9937 | |
| 9938 | <section id='runtime-package-management-target-rpm'> |
| 9939 | <title>Using RPM</title> |
| 9940 | |
| 9941 | <para> |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 9942 | The |
| 9943 | <ulink url='https://en.wikipedia.org/wiki/DNF_(software)'>Dandified Packaging Tool</ulink> |
| 9944 | (DNF) performs runtime package management of RPM |
| 9945 | packages. |
| 9946 | In order to use DNF for runtime package management, |
| 9947 | you must perform an initial setup on the target |
| 9948 | machine for cases where the |
| 9949 | <filename>PACKAGE_FEED_*</filename> variables were not |
| 9950 | set as part of the image that is running on the |
| 9951 | target. |
| 9952 | This means if you built your image and did not not use |
| 9953 | these variables as part of the build and your image is |
| 9954 | now running on the target, you need to perform the |
| 9955 | steps in this section if you want to use runtime |
| 9956 | package management. |
| 9957 | <note> |
| 9958 | For information on the |
| 9959 | <filename>PACKAGE_FEED_*</filename> variables, see |
| 9960 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_FEED_ARCHS'><filename>PACKAGE_FEED_ARCHS</filename></ulink>, |
| 9961 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_FEED_BASE_PATHS'><filename>PACKAGE_FEED_BASE_PATHS</filename></ulink>, |
| 9962 | and |
| 9963 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_FEED_URIS'><filename>PACKAGE_FEED_URIS</filename></ulink> |
| 9964 | in the Yocto Project Reference Manual variables |
| 9965 | glossary. |
| 9966 | </note> |
| 9967 | </para> |
| 9968 | |
| 9969 | <para> |
| 9970 | On the target, you must inform DNF that package |
| 9971 | databases are available. |
| 9972 | You do this by creating a file named |
| 9973 | <filename>/etc/yum.repos.d/oe-packages.repo</filename> |
| 9974 | and defining the <filename>oe-packages</filename>. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 9975 | </para> |
| 9976 | |
| 9977 | <para> |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 9978 | As an example, assume the target is able to use the |
| 9979 | following package databases: |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 9980 | <filename>all</filename>, <filename>i586</filename>, |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 9981 | and <filename>qemux86</filename> from a server named |
| 9982 | <filename>my.server</filename>. |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 9983 | The specifics for setting up the web server are up to |
| 9984 | you. |
| 9985 | The critical requirement is that the URIs in the |
| 9986 | target repository configuration point to the |
| 9987 | correct remote location for the feeds. |
| 9988 | <note><title>Tip</title> |
| 9989 | For development purposes, you can point the web |
| 9990 | server to the build system's |
| 9991 | <filename>deploy</filename> directory. |
| 9992 | However, for production use, it is better to copy |
| 9993 | the package directories to a location outside of |
| 9994 | the build area and use that location. |
| 9995 | Doing so avoids situations where the build system |
| 9996 | overwrites or changes the |
| 9997 | <filename>deploy</filename> directory. |
| 9998 | </note> |
| 9999 | </para> |
| 10000 | |
| 10001 | <para> |
| 10002 | When telling DNF where to look for the package |
| 10003 | databases, you must declare individual locations |
| 10004 | per architecture or a single location used for all |
| 10005 | architectures. |
| 10006 | You cannot do both: |
| 10007 | <itemizedlist> |
| 10008 | <listitem><para> |
| 10009 | <emphasis>Create an Explicit List of Architectures:</emphasis> |
| 10010 | Define individual base URLs to identify where |
| 10011 | each package database is located: |
| 10012 | <literallayout class='monospaced'> |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 10013 | [oe-packages] |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 10014 | baseurl=http://my.server/rpm/i586 http://my.server/rpm/qemux86 http://my.server/rpm/all |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 10015 | </literallayout> |
| 10016 | This example informs DNF about individual |
| 10017 | package databases for all three architectures. |
| 10018 | </para></listitem> |
| 10019 | <listitem><para> |
| 10020 | <emphasis>Create a Single (Full) Package Index:</emphasis> |
| 10021 | Define a single base URL that identifies where |
| 10022 | a full package database is located: |
| 10023 | <literallayout class='monospaced'> |
| 10024 | [oe-packages] |
| 10025 | baseurl=http://my.server/rpm |
| 10026 | </literallayout> |
| 10027 | This example informs DNF about a single package |
| 10028 | database that contains all the package index |
| 10029 | information for all supported architectures. |
| 10030 | </para></listitem> |
| 10031 | </itemizedlist> |
| 10032 | </para> |
| 10033 | |
| 10034 | <para> |
| 10035 | Once you have informed DNF where to find the package |
| 10036 | databases, you need to fetch them: |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 10037 | <literallayout class='monospaced'> |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 10038 | # dnf makecache |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 10039 | </literallayout> |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 10040 | DNF is now able to find, install, and upgrade packages |
| 10041 | from the specified repository or repositories. |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 10042 | <note> |
| 10043 | See the |
| 10044 | <ulink url='http://dnf.readthedocs.io/en/latest/'>DNF documentation</ulink> |
| 10045 | for additional information. |
| 10046 | </note> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 10047 | </para> |
| 10048 | </section> |
| 10049 | |
| 10050 | <section id='runtime-package-management-target-ipk'> |
| 10051 | <title>Using IPK</title> |
| 10052 | |
| 10053 | <para> |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 10054 | The <filename>opkg</filename> application performs |
| 10055 | runtime package management of IPK packages. |
| 10056 | You must perform an initial setup for |
| 10057 | <filename>opkg</filename> on the target machine |
| 10058 | if the |
| 10059 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_FEED_ARCHS'><filename>PACKAGE_FEED_ARCHS</filename></ulink>, |
| 10060 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_FEED_BASE_PATHS'><filename>PACKAGE_FEED_BASE_PATHS</filename></ulink>, and |
| 10061 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_FEED_URIS'><filename>PACKAGE_FEED_URIS</filename></ulink> |
| 10062 | variables have not been set or the target image was |
| 10063 | built before the variables were set. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 10064 | </para> |
| 10065 | |
| 10066 | <para> |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 10067 | The <filename>opkg</filename> application uses |
| 10068 | configuration files to find available package |
| 10069 | databases. |
| 10070 | Thus, you need to create a configuration file inside |
| 10071 | the <filename>/etc/opkg/</filename> direction, which |
| 10072 | informs <filename>opkg</filename> of any repository |
| 10073 | you want to use. |
| 10074 | </para> |
| 10075 | |
| 10076 | <para> |
| 10077 | As an example, suppose you are serving packages from a |
| 10078 | <filename>ipk/</filename> directory containing the |
| 10079 | <filename>i586</filename>, |
| 10080 | <filename>all</filename>, and |
| 10081 | <filename>qemux86</filename> databases through an |
| 10082 | HTTP server named <filename>my.server</filename>. |
| 10083 | On the target, create a configuration file |
| 10084 | (e.g. <filename>my_repo.conf</filename>) inside the |
| 10085 | <filename>/etc/opkg/</filename> directory containing |
| 10086 | the following: |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 10087 | <literallayout class='monospaced'> |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 10088 | src/gz all http://my.server/ipk/all |
| 10089 | src/gz i586 http://my.server/ipk/i586 |
| 10090 | src/gz qemux86 http://my.server/ipk/qemux86 |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 10091 | </literallayout> |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 10092 | Next, instruct <filename>opkg</filename> to fetch |
| 10093 | the repository information: |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 10094 | <literallayout class='monospaced'> |
| 10095 | # opkg update |
| 10096 | </literallayout> |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 10097 | The <filename>opkg</filename> application is now able |
| 10098 | to find, install, and upgrade packages from the |
| 10099 | specified repository. |
| 10100 | </para> |
| 10101 | </section> |
| 10102 | |
| 10103 | <section id='runtime-package-management-target-deb'> |
| 10104 | <title>Using DEB</title> |
| 10105 | |
| 10106 | <para> |
| 10107 | The <filename>apt</filename> application performs |
| 10108 | runtime package management of DEB packages. |
| 10109 | This application uses a source list file to find |
| 10110 | available package databases. |
| 10111 | You must perform an initial setup for |
| 10112 | <filename>apt</filename> on the target machine |
| 10113 | if the |
| 10114 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_FEED_ARCHS'><filename>PACKAGE_FEED_ARCHS</filename></ulink>, |
| 10115 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_FEED_BASE_PATHS'><filename>PACKAGE_FEED_BASE_PATHS</filename></ulink>, and |
| 10116 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_FEED_URIS'><filename>PACKAGE_FEED_URIS</filename></ulink> |
| 10117 | variables have not been set or the target image was |
| 10118 | built before the variables were set. |
| 10119 | </para> |
| 10120 | |
| 10121 | <para> |
| 10122 | To inform <filename>apt</filename> of the repository |
| 10123 | you want to use, you might create a list file (e.g. |
| 10124 | <filename>my_repo.list</filename>) inside the |
| 10125 | <filename>/etc/apt/sources.list.d/</filename> |
| 10126 | directory. |
| 10127 | As an example, suppose you are serving packages from a |
| 10128 | <filename>deb/</filename> directory containing the |
| 10129 | <filename>i586</filename>, |
| 10130 | <filename>all</filename>, and |
| 10131 | <filename>qemux86</filename> databases through an |
| 10132 | HTTP server named <filename>my.server</filename>. |
| 10133 | The list file should contain: |
| 10134 | <literallayout class='monospaced'> |
| 10135 | deb http://my.server/deb/all ./ |
| 10136 | deb http://my.server/deb/i586 ./ |
| 10137 | deb http://my.server/deb/qemux86 ./ |
| 10138 | </literallayout> |
| 10139 | Next, instruct the <filename>apt</filename> |
| 10140 | application to fetch the repository information: |
| 10141 | <literallayout class='monospaced'> |
| 10142 | # apt-get update |
| 10143 | </literallayout> |
| 10144 | After this step, <filename>apt</filename> is able |
| 10145 | to find, install, and upgrade packages from the |
| 10146 | specified repository. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 10147 | </para> |
| 10148 | </section> |
| 10149 | </section> |
| 10150 | </section> |
| 10151 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 10152 | <section id='generating-and-using-signed-packages'> |
| 10153 | <title>Generating and Using Signed Packages</title> |
| 10154 | <para> |
| 10155 | In order to add security to RPM packages used during a build, |
| 10156 | you can take steps to securely sign them. |
| 10157 | Once a signature is verified, the OpenEmbedded build system |
| 10158 | can use the package in the build. |
| 10159 | If security fails for a signed package, the build system |
| 10160 | aborts the build. |
| 10161 | </para> |
| 10162 | |
| 10163 | <para> |
| 10164 | This section describes how to sign RPM packages during a build |
| 10165 | and how to use signed package feeds (repositories) when |
| 10166 | doing a build. |
| 10167 | </para> |
| 10168 | |
| 10169 | <section id='signing-rpm-packages'> |
| 10170 | <title>Signing RPM Packages</title> |
| 10171 | |
| 10172 | <para> |
| 10173 | To enable signing RPM packages, you must set up the |
| 10174 | following configurations in either your |
| 10175 | <filename>local.config</filename> or |
| 10176 | <filename>distro.config</filename> file: |
| 10177 | <literallayout class='monospaced'> |
| 10178 | # Inherit sign_rpm.bbclass to enable signing functionality |
| 10179 | INHERIT += " sign_rpm" |
| 10180 | # Define the GPG key that will be used for signing. |
| 10181 | RPM_GPG_NAME = "<replaceable>key_name</replaceable>" |
| 10182 | # Provide passphrase for the key |
| 10183 | RPM_GPG_PASSPHRASE = "<replaceable>passphrase</replaceable>" |
| 10184 | </literallayout> |
| 10185 | <note> |
| 10186 | Be sure to supply appropriate values for both |
| 10187 | <replaceable>key_name</replaceable> and |
| 10188 | <replaceable>passphrase</replaceable> |
| 10189 | </note> |
| 10190 | Aside from the |
| 10191 | <filename>RPM_GPG_NAME</filename> and |
| 10192 | <filename>RPM_GPG_PASSPHRASE</filename> variables in the |
| 10193 | previous example, two optional variables related to signing |
| 10194 | exist: |
| 10195 | <itemizedlist> |
| 10196 | <listitem><para> |
| 10197 | <emphasis><filename>GPG_BIN</filename>:</emphasis> |
| 10198 | Specifies a <filename>gpg</filename> binary/wrapper |
| 10199 | that is executed when the package is signed. |
| 10200 | </para></listitem> |
| 10201 | <listitem><para> |
| 10202 | <emphasis><filename>GPG_PATH</filename>:</emphasis> |
| 10203 | Specifies the <filename>gpg</filename> home |
| 10204 | directory used when the package is signed. |
| 10205 | </para></listitem> |
| 10206 | </itemizedlist> |
| 10207 | </para> |
| 10208 | </section> |
| 10209 | |
| 10210 | <section id='processing-package-feeds'> |
| 10211 | <title>Processing Package Feeds</title> |
| 10212 | |
| 10213 | <para> |
| 10214 | In addition to being able to sign RPM packages, you can |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 10215 | also enable signed package feeds for IPK and RPM packages. |
| 10216 | </para> |
| 10217 | |
| 10218 | <para> |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 10219 | The steps you need to take to enable signed package feed |
| 10220 | use are similar to the steps used to sign RPM packages. |
| 10221 | You must define the following in your |
| 10222 | <filename>local.config</filename> or |
| 10223 | <filename>distro.config</filename> file: |
| 10224 | <literallayout class='monospaced'> |
| 10225 | INHERIT += "sign_package_feed" |
| 10226 | PACKAGE_FEED_GPG_NAME = "<replaceable>key_name</replaceable>" |
| 10227 | PACKAGE_FEED_GPG_PASSPHRASE_FILE = "<replaceable>path_to_file_containing_passphrase</replaceable>" |
| 10228 | </literallayout> |
| 10229 | For signed package feeds, the passphrase must exist in a |
| 10230 | separate file, which is pointed to by the |
| 10231 | <filename>PACKAGE_FEED_GPG_PASSPHRASE_FILE</filename> |
| 10232 | variable. |
| 10233 | Regarding security, keeping a plain text passphrase out of |
| 10234 | the configuration is more secure. |
| 10235 | </para> |
| 10236 | |
| 10237 | <para> |
| 10238 | Aside from the |
| 10239 | <filename>PACKAGE_FEED_GPG_NAME</filename> and |
| 10240 | <filename>PACKAGE_FEED_GPG_PASSPHRASE_FILE</filename> |
| 10241 | variables, three optional variables related to signed |
| 10242 | package feeds exist: |
| 10243 | <itemizedlist> |
| 10244 | <listitem><para> |
| 10245 | <emphasis><filename>GPG_BIN</filename>:</emphasis> |
| 10246 | Specifies a <filename>gpg</filename> binary/wrapper |
| 10247 | that is executed when the package is signed. |
| 10248 | </para></listitem> |
| 10249 | <listitem><para> |
| 10250 | <emphasis><filename>GPG_PATH</filename>:</emphasis> |
| 10251 | Specifies the <filename>gpg</filename> home |
| 10252 | directory used when the package is signed. |
| 10253 | </para></listitem> |
| 10254 | <listitem><para> |
| 10255 | <emphasis><filename>PACKAGE_FEED_GPG_SIGNATURE_TYPE</filename>:</emphasis> |
| 10256 | Specifies the type of <filename>gpg</filename> |
| 10257 | signature. |
| 10258 | This variable applies only to RPM and IPK package |
| 10259 | feeds. |
| 10260 | Allowable values for the |
| 10261 | <filename>PACKAGE_FEED_GPG_SIGNATURE_TYPE</filename> |
| 10262 | are "ASC", which is the default and specifies ascii |
| 10263 | armored, and "BIN", which specifies binary. |
| 10264 | </para></listitem> |
| 10265 | </itemizedlist> |
| 10266 | </para> |
| 10267 | </section> |
| 10268 | </section> |
| 10269 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 10270 | <section id='testing-packages-with-ptest'> |
| 10271 | <title>Testing Packages With ptest</title> |
| 10272 | |
| 10273 | <para> |
| 10274 | A Package Test (ptest) runs tests against packages built |
| 10275 | by the OpenEmbedded build system on the target machine. |
| 10276 | A ptest contains at least two items: the actual test, and |
| 10277 | a shell script (<filename>run-ptest</filename>) that starts |
| 10278 | the test. |
| 10279 | The shell script that starts the test must not contain |
| 10280 | the actual test - the script only starts the test. |
| 10281 | On the other hand, the test can be anything from a simple |
| 10282 | shell script that runs a binary and checks the output to |
| 10283 | an elaborate system of test binaries and data files. |
| 10284 | </para> |
| 10285 | |
| 10286 | <para> |
| 10287 | The test generates output in the format used by |
| 10288 | Automake: |
| 10289 | <literallayout class='monospaced'> |
| 10290 | <replaceable>result</replaceable>: <replaceable>testname</replaceable> |
| 10291 | </literallayout> |
| 10292 | where the result can be <filename>PASS</filename>, |
| 10293 | <filename>FAIL</filename>, or <filename>SKIP</filename>, |
| 10294 | and the testname can be any identifying string. |
| 10295 | </para> |
| 10296 | |
| 10297 | <para> |
| 10298 | For a list of Yocto Project recipes that are already |
| 10299 | enabled with ptest, see the |
| 10300 | <ulink url='https://wiki.yoctoproject.org/wiki/Ptest'>Ptest</ulink> |
| 10301 | wiki page. |
| 10302 | <note> |
| 10303 | A recipe is "ptest-enabled" if it inherits the |
| 10304 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-ptest'><filename>ptest</filename></ulink> |
| 10305 | class. |
| 10306 | </note> |
| 10307 | </para> |
| 10308 | |
| 10309 | <section id='adding-ptest-to-your-build'> |
| 10310 | <title>Adding ptest to Your Build</title> |
| 10311 | |
| 10312 | <para> |
| 10313 | To add package testing to your build, add the |
| 10314 | <ulink url='&YOCTO_DOCS_REF_URL;#var-DISTRO_FEATURES'><filename>DISTRO_FEATURES</filename></ulink> |
| 10315 | and <ulink url='&YOCTO_DOCS_REF_URL;#var-EXTRA_IMAGE_FEATURES'><filename>EXTRA_IMAGE_FEATURES</filename></ulink> |
| 10316 | variables to your <filename>local.conf</filename> file, |
| 10317 | which is found in the |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 10318 | <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink>: |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 10319 | <literallayout class='monospaced'> |
| 10320 | DISTRO_FEATURES_append = " ptest" |
| 10321 | EXTRA_IMAGE_FEATURES += "ptest-pkgs" |
| 10322 | </literallayout> |
| 10323 | Once your build is complete, the ptest files are installed |
| 10324 | into the |
| 10325 | <filename>/usr/lib/<replaceable>package</replaceable>/ptest</filename> |
| 10326 | directory within the image, where |
| 10327 | <filename><replaceable>package</replaceable></filename> |
| 10328 | is the name of the package. |
| 10329 | </para> |
| 10330 | </section> |
| 10331 | |
| 10332 | <section id='running-ptest'> |
| 10333 | <title>Running ptest</title> |
| 10334 | |
| 10335 | <para> |
| 10336 | The <filename>ptest-runner</filename> package installs a |
| 10337 | shell script that loops through all installed ptest test |
| 10338 | suites and runs them in sequence. |
| 10339 | Consequently, you might want to add this package to |
| 10340 | your image. |
| 10341 | </para> |
| 10342 | </section> |
| 10343 | |
| 10344 | <section id='getting-your-package-ready'> |
| 10345 | <title>Getting Your Package Ready</title> |
| 10346 | |
| 10347 | <para> |
| 10348 | In order to enable a recipe to run installed ptests |
| 10349 | on target hardware, |
| 10350 | you need to prepare the recipes that build the packages |
| 10351 | you want to test. |
| 10352 | Here is what you have to do for each recipe: |
| 10353 | <itemizedlist> |
| 10354 | <listitem><para><emphasis>Be sure the recipe |
| 10355 | inherits the |
| 10356 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-ptest'><filename>ptest</filename></ulink> |
| 10357 | class:</emphasis> |
| 10358 | Include the following line in each recipe: |
| 10359 | <literallayout class='monospaced'> |
| 10360 | inherit ptest |
| 10361 | </literallayout> |
| 10362 | </para></listitem> |
| 10363 | <listitem><para><emphasis>Create <filename>run-ptest</filename>:</emphasis> |
| 10364 | This script starts your test. |
| 10365 | Locate the script where you will refer to it |
| 10366 | using |
| 10367 | <ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'><filename>SRC_URI</filename></ulink>. |
| 10368 | Here is an example that starts a test for |
| 10369 | <filename>dbus</filename>: |
| 10370 | <literallayout class='monospaced'> |
| 10371 | #!/bin/sh |
| 10372 | cd test |
| 10373 | make -k runtest-TESTS |
| 10374 | </literallayout> |
| 10375 | </para></listitem> |
| 10376 | <listitem><para><emphasis>Ensure dependencies are |
| 10377 | met:</emphasis> |
| 10378 | If the test adds build or runtime dependencies |
| 10379 | that normally do not exist for the package |
| 10380 | (such as requiring "make" to run the test suite), |
| 10381 | use the |
| 10382 | <ulink url='&YOCTO_DOCS_REF_URL;#var-DEPENDS'><filename>DEPENDS</filename></ulink> |
| 10383 | and |
| 10384 | <ulink url='&YOCTO_DOCS_REF_URL;#var-RDEPENDS'><filename>RDEPENDS</filename></ulink> |
| 10385 | variables in your recipe in order for the package |
| 10386 | to meet the dependencies. |
| 10387 | Here is an example where the package has a runtime |
| 10388 | dependency on "make": |
| 10389 | <literallayout class='monospaced'> |
| 10390 | RDEPENDS_${PN}-ptest += "make" |
| 10391 | </literallayout> |
| 10392 | </para></listitem> |
| 10393 | <listitem><para><emphasis>Add a function to build the |
| 10394 | test suite:</emphasis> |
| 10395 | Not many packages support cross-compilation of |
| 10396 | their test suites. |
| 10397 | Consequently, you usually need to add a |
| 10398 | cross-compilation function to the package. |
| 10399 | </para> |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 10400 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 10401 | <para>Many packages based on Automake compile and |
| 10402 | run the test suite by using a single command |
| 10403 | such as <filename>make check</filename>. |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 10404 | However, the host <filename>make check</filename> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 10405 | builds and runs on the same computer, while |
| 10406 | cross-compiling requires that the package is built |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 10407 | on the host but executed for the target |
| 10408 | architecture (though often, as in the case for |
| 10409 | ptest, the execution occurs on the host). |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 10410 | The built version of Automake that ships with the |
| 10411 | Yocto Project includes a patch that separates |
| 10412 | building and execution. |
| 10413 | Consequently, packages that use the unaltered, |
| 10414 | patched version of <filename>make check</filename> |
| 10415 | automatically cross-compiles.</para> |
| 10416 | <para>Regardless, you still must add a |
| 10417 | <filename>do_compile_ptest</filename> function to |
| 10418 | build the test suite. |
| 10419 | Add a function similar to the following to your |
| 10420 | recipe: |
| 10421 | <literallayout class='monospaced'> |
| 10422 | do_compile_ptest() { |
| 10423 | oe_runmake buildtest-TESTS |
| 10424 | } |
| 10425 | </literallayout> |
| 10426 | </para></listitem> |
| 10427 | <listitem><para><emphasis>Ensure special configurations |
| 10428 | are set:</emphasis> |
| 10429 | If the package requires special configurations |
| 10430 | prior to compiling the test code, you must |
| 10431 | insert a <filename>do_configure_ptest</filename> |
| 10432 | function into the recipe. |
| 10433 | </para></listitem> |
| 10434 | <listitem><para><emphasis>Install the test |
| 10435 | suite:</emphasis> |
| 10436 | The <filename>ptest</filename> class |
| 10437 | automatically copies the file |
| 10438 | <filename>run-ptest</filename> to the target and |
| 10439 | then runs make <filename>install-ptest</filename> |
| 10440 | to run the tests. |
| 10441 | If this is not enough, you need to create a |
| 10442 | <filename>do_install_ptest</filename> function and |
| 10443 | make sure it gets called after the |
| 10444 | "make install-ptest" completes. |
| 10445 | </para></listitem> |
| 10446 | </itemizedlist> |
| 10447 | </para> |
| 10448 | </section> |
| 10449 | </section> |
Brad Bishop | 15ae250 | 2019-06-18 21:44:24 -0400 | [diff] [blame] | 10450 | |
| 10451 | <section id='creating-node-package-manager-npm-packages'> |
| 10452 | <title>Creating Node Package Manager (NPM) Packages</title> |
| 10453 | |
| 10454 | <para> |
| 10455 | <ulink url='https://en.wikipedia.org/wiki/Npm_(software)'>NPM</ulink> |
| 10456 | is a package manager for the JavaScript programming |
| 10457 | language. |
| 10458 | The Yocto Project supports the NPM |
| 10459 | <ulink url='&YOCTO_DOCS_BB_URL;#bb-fetchers'>fetcher</ulink>. |
| 10460 | You can use this fetcher in combination with |
| 10461 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-devtool-reference'><filename>devtool</filename></ulink> |
| 10462 | to create recipes that produce NPM packages. |
| 10463 | </para> |
| 10464 | |
| 10465 | <para> |
| 10466 | Two workflows exist that allow you to create NPM packages |
| 10467 | using <filename>devtool</filename>: the NPM registry modules |
| 10468 | method and the NPM project code method. |
| 10469 | <note> |
| 10470 | While it is possible to create NPM recipes manually, |
| 10471 | using <filename>devtool</filename> is far simpler. |
| 10472 | </note> |
| 10473 | Additionally, some requirements and caveats exist. |
| 10474 | </para> |
| 10475 | |
| 10476 | <section id='npm-package-creation-requirements'> |
| 10477 | <title>Requirements and Caveats</title> |
| 10478 | |
| 10479 | <para> |
| 10480 | You need to be aware of the following before using |
| 10481 | <filename>devtool</filename> to create NPM packages: |
| 10482 | <itemizedlist> |
| 10483 | <listitem><para> |
| 10484 | Of the two methods that you can use |
| 10485 | <filename>devtool</filename> to create NPM |
| 10486 | packages, the registry approach is slightly |
| 10487 | simpler. |
| 10488 | However, you might consider the project |
| 10489 | approach because you do not have to publish |
| 10490 | your module in the NPM registry |
| 10491 | (<ulink url='https://docs.npmjs.com/misc/registry'><filename>npm-registry</filename></ulink>), |
| 10492 | which is NPM's public registry. |
| 10493 | </para></listitem> |
| 10494 | <listitem><para> |
| 10495 | Be familiar with |
| 10496 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-devtool-reference'><filename>devtool</filename></ulink>. |
| 10497 | </para></listitem> |
| 10498 | <listitem><para> |
| 10499 | The NPM host tools need the native |
| 10500 | <filename>nodejs-npm</filename> package, which |
| 10501 | is part of the OpenEmbedded environment. |
| 10502 | You need to get the package by cloning the |
| 10503 | <ulink url='https://github.com/openembedded/meta-openembedded'></ulink> |
| 10504 | repository out of GitHub. |
| 10505 | Be sure to add the path to your local copy to |
| 10506 | your <filename>bblayers.conf</filename> file. |
| 10507 | </para></listitem> |
| 10508 | <listitem><para> |
| 10509 | <filename>devtool</filename> cannot detect |
| 10510 | native libraries in module dependencies. |
| 10511 | Consequently, you must manually add packages |
| 10512 | to your recipe. |
| 10513 | </para></listitem> |
| 10514 | <listitem><para> |
| 10515 | While deploying NPM packages, |
| 10516 | <filename>devtool</filename> cannot determine |
| 10517 | which dependent packages are missing on the |
| 10518 | target (e.g. the node runtime |
| 10519 | <filename>nodejs</filename>). |
| 10520 | Consequently, you need to find out what |
| 10521 | files are missing and be sure they are on the |
| 10522 | target. |
| 10523 | </para></listitem> |
| 10524 | <listitem><para> |
| 10525 | Although you might not need NPM to run your |
| 10526 | node package, it is useful to have NPM on your |
| 10527 | target. |
| 10528 | The NPM package name is |
| 10529 | <filename>nodejs-npm</filename>. |
| 10530 | </para></listitem> |
| 10531 | </itemizedlist> |
| 10532 | </para> |
| 10533 | </section> |
| 10534 | |
| 10535 | <section id='npm-using-the-registry-modules-method'> |
| 10536 | <title>Using the Registry Modules Method</title> |
| 10537 | |
| 10538 | <para> |
| 10539 | This section presents an example that uses the |
| 10540 | <filename>cute-files</filename> module, which is a |
| 10541 | file browser web application. |
| 10542 | <note> |
| 10543 | You must know the <filename>cute-files</filename> |
| 10544 | module version. |
| 10545 | </note> |
| 10546 | </para> |
| 10547 | |
| 10548 | <para> |
| 10549 | The first thing you need to do is use |
| 10550 | <filename>devtool</filename> and the NPM fetcher to |
| 10551 | create the recipe: |
| 10552 | <literallayout class='monospaced'> |
| 10553 | $ devtool add "npm://registry.npmjs.org;name=cute-files;version=1.0.2" |
| 10554 | </literallayout> |
| 10555 | The <filename>devtool add</filename> command runs |
| 10556 | <filename>recipetool create</filename> and uses the |
| 10557 | same fetch URI to download each dependency and capture |
| 10558 | license details where possible. |
| 10559 | The result is a generated recipe. |
| 10560 | </para> |
| 10561 | |
| 10562 | <para> |
| 10563 | The recipe file is fairly simple and contains every |
| 10564 | license that <filename>recipetool</filename> finds |
| 10565 | and includes the licenses in the recipe's |
| 10566 | <ulink url='&YOCTO_DOCS_REF_URL;#var-LIC_FILES_CHKSUM'><filename>LIC_FILES_CHKSUM</filename></ulink> |
| 10567 | variables. |
| 10568 | You need to examine the variables and look for those |
| 10569 | with "unknown" in the |
| 10570 | <ulink url='&YOCTO_DOCS_REF_URL;#var-LICENSE'><filename>LICENSE</filename></ulink> |
| 10571 | field. |
| 10572 | You need to track down the license information for |
| 10573 | "unknown" modules and manually add the information to the |
| 10574 | recipe. |
| 10575 | </para> |
| 10576 | |
| 10577 | <para> |
| 10578 | <filename>recipetool</filename> creates "shrinkwrap" and |
| 10579 | "lockdown" files for your recipe. |
| 10580 | Shrinkwrap files capture the version of all dependent |
| 10581 | modules. |
| 10582 | Many packages do not provide shrinkwrap files. |
| 10583 | <filename>recipetool</filename> create a shrinkwrap |
| 10584 | file as it runs. |
| 10585 | You can replace the shrinkwrap file with your own file |
| 10586 | by setting the <filename>NPM_SHRINKWRAP</filename> |
| 10587 | variable. |
| 10588 | </para> |
| 10589 | |
| 10590 | <para> |
| 10591 | Lockdown files contain the checksum for each module |
| 10592 | to determine if your users download the same files when |
| 10593 | building with a recipe. |
| 10594 | Lockdown files ensure that dependencies have not been |
| 10595 | changed and that your NPM registry is still providing |
| 10596 | the same file. |
| 10597 | <note> |
| 10598 | A package is created for each sub-module. |
| 10599 | This policy is the only practical way to have the |
| 10600 | licenses for all of the dependencies represented |
| 10601 | in the license manifest of the image. |
| 10602 | </note> |
| 10603 | </para> |
| 10604 | |
| 10605 | <para> |
| 10606 | The <filename>devtool edit-recipe</filename> command |
| 10607 | lets you take a look at the recipe: |
| 10608 | <literallayout class='monospaced'> |
| 10609 | $ devtool edit-recipe cute-files |
| 10610 | SUMMARY = "Turn any folder on your computer into a cute file browser, available on the local network." |
| 10611 | LICENSE = "BSD-3-Clause & Unknown & MIT & ISC" |
| 10612 | LIC_FILES_CHKSUM = "file://LICENSE;md5=71d98c0a1db42956787b1909c74a86ca \ |
| 10613 | file://node_modules/content-disposition/LICENSE;md5=c6e0ce1e688c5ff16db06b7259e9cd20 \ |
| 10614 | file://node_modules/express/LICENSE;md5=5513c00a5c36cd361da863dd9aa8875d \ |
| 10615 | ... |
| 10616 | |
| 10617 | SRC_URI = "npm://registry.npmjs.org;name=cute-files;version=${PV}" |
| 10618 | NPM_SHRINKWRAP := "${THISDIR}/${PN}/npm-shrinkwrap.json" |
| 10619 | NPM_LOCKDOWN := "${THISDIR}/${PN}/lockdown.json" |
| 10620 | inherit npm |
| 10621 | # Must be set after inherit npm since that itself sets S |
| 10622 | S = "${WORKDIR}/npmpkg" |
| 10623 | |
| 10624 | LICENSE_${PN}-content-disposition = "MIT" |
| 10625 | ... |
| 10626 | LICENSE_${PN}-express = "MIT" |
| 10627 | LICENSE_${PN} = "MIT" |
| 10628 | </literallayout> |
| 10629 | Three key points exist in the previous example: |
| 10630 | <itemizedlist> |
| 10631 | <listitem><para> |
| 10632 | <ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'><filename>SRC_URI</filename></ulink> |
| 10633 | uses the NPM scheme so that the NPM fetcher |
| 10634 | is used. |
| 10635 | </para></listitem> |
| 10636 | <listitem><para> |
| 10637 | <filename>recipetool</filename> collects all |
| 10638 | the license information. |
| 10639 | If a sub-module's license is unavailable, |
| 10640 | the sub-module's name appears in the comments. |
| 10641 | </para></listitem> |
| 10642 | <listitem><para> |
| 10643 | The <filename>inherit npm</filename> statement |
| 10644 | causes the |
| 10645 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-npm'><filename>npm</filename></ulink> |
| 10646 | class to package up all the modules. |
| 10647 | </para></listitem> |
| 10648 | </itemizedlist> |
| 10649 | </para> |
| 10650 | |
| 10651 | <para> |
| 10652 | You can run the following command to build the |
| 10653 | <filename>cute-files</filename> package: |
| 10654 | <literallayout class='monospaced'> |
| 10655 | $ devtool build cute-files |
| 10656 | </literallayout> |
| 10657 | Remember that <filename>nodejs</filename> must be |
| 10658 | installed on the target before your package. |
| 10659 | </para> |
| 10660 | |
| 10661 | <para> |
| 10662 | Assuming 192.168.7.2 for the target's IP address, use |
| 10663 | the following command to deploy your package: |
| 10664 | <literallayout class='monospaced'> |
| 10665 | $ devtool deploy-target -s cute-files root@192.168.7.2 |
| 10666 | </literallayout> |
| 10667 | Once the package is installed on the target, you can |
| 10668 | test the application: |
| 10669 | <note> |
| 10670 | Because of a know issue, you cannot simply run |
| 10671 | <filename>cute-files</filename> as you would if you |
| 10672 | had run <filename>npm install</filename>. |
| 10673 | </note> |
| 10674 | <literallayout class='monospaced'> |
| 10675 | $ cd /usr/lib/node_modules/cute-files |
| 10676 | $ node cute-files.js |
| 10677 | </literallayout> |
| 10678 | On a browser, go to |
| 10679 | <filename>http://192.168.7.2:3000</filename> and you |
| 10680 | see the following: |
| 10681 | <imagedata fileref="figures/cute-files-npm-example.png" align="center" width="6in" depth="4in" /> |
| 10682 | </para> |
| 10683 | |
| 10684 | <para> |
| 10685 | You can find the recipe in |
| 10686 | <filename>workspace/recipes/cute-files</filename>. |
| 10687 | You can use the recipe in any layer you choose. |
| 10688 | </para> |
| 10689 | </section> |
| 10690 | |
| 10691 | <section id='npm-using-the-npm-projects-method'> |
| 10692 | <title>Using the NPM Projects Code Method</title> |
| 10693 | |
| 10694 | <para> |
| 10695 | Although it is useful to package modules already in the |
| 10696 | NPM registry, adding <filename>node.js</filename> projects |
| 10697 | under development is a more common developer use case. |
| 10698 | </para> |
| 10699 | |
| 10700 | <para> |
| 10701 | This section covers the NPM projects code method, which is |
| 10702 | very similar to the "registry" approach described in the |
| 10703 | previous section. |
| 10704 | In the NPM projects method, you provide |
| 10705 | <filename>devtool</filename> with an URL that points to the |
| 10706 | source files. |
| 10707 | </para> |
| 10708 | |
| 10709 | <para> |
| 10710 | Replicating the same example, (i.e. |
| 10711 | <filename>cute-files</filename>) use the following command: |
| 10712 | <literallayout class='monospaced'> |
| 10713 | $ devtool add https://github.com/martinaglv/cute-files.git |
| 10714 | </literallayout> |
| 10715 | The recipe this command generates is very similar to the |
| 10716 | recipe created in the previous section. |
| 10717 | However, the <filename>SRC_URI</filename> looks like the |
| 10718 | following: |
| 10719 | <literallayout class='monospaced'> |
| 10720 | SRC_URI = "git://github.com/martinaglv/cute-files.git;protocol=https \ |
| 10721 | npm://registry.npmjs.org;name=commander;version=2.9.0;subdir=node_modules/commander \ |
| 10722 | npm://registry.npmjs.org;name=express;version=4.14.0;subdir=node_modules/express \ |
| 10723 | npm://registry.npmjs.org;name=content-disposition;version=0.3.0;subdir=node_modules/content-disposition \ |
| 10724 | " |
| 10725 | </literallayout> |
| 10726 | In this example, the main module is taken from the Git |
| 10727 | repository and dependents are taken from the NPM registry. |
| 10728 | Other than those differences, the recipe is basically the |
| 10729 | same between the two methods. |
| 10730 | You can build and deploy the package exactly as described |
| 10731 | in the previous section that uses the registry modules |
| 10732 | method. |
| 10733 | </para> |
| 10734 | </section> |
| 10735 | </section> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 10736 | </section> |
| 10737 | |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 10738 | <section id='efficiently-fetching-source-files-during-a-build'> |
| 10739 | <title>Efficiently Fetching Source Files During a Build</title> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 10740 | |
| 10741 | <para> |
| 10742 | The OpenEmbedded build system works with source files located |
| 10743 | through the |
| 10744 | <ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'><filename>SRC_URI</filename></ulink> |
| 10745 | variable. |
| 10746 | When you build something using BitBake, a big part of the operation |
| 10747 | is locating and downloading all the source tarballs. |
| 10748 | For images, downloading all the source for various packages can |
| 10749 | take a significant amount of time. |
| 10750 | </para> |
| 10751 | |
| 10752 | <para> |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 10753 | This section shows you how you can use mirrors to speed up |
| 10754 | fetching source files and how you can pre-fetch files all of which |
| 10755 | leads to more efficient use of resources and time. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 10756 | </para> |
| 10757 | |
| 10758 | <section id='setting-up-effective-mirrors'> |
| 10759 | <title>Setting up Effective Mirrors</title> |
| 10760 | |
| 10761 | <para> |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 10762 | A good deal that goes into a Yocto Project |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 10763 | build is simply downloading all of the source tarballs. |
| 10764 | Maybe you have been working with another build system |
| 10765 | (OpenEmbedded or Angstrom) for which you have built up a |
| 10766 | sizable directory of source tarballs. |
| 10767 | Or, perhaps someone else has such a directory for which you |
| 10768 | have read access. |
| 10769 | If so, you can save time by adding statements to your |
| 10770 | configuration file so that the build process checks local |
| 10771 | directories first for existing tarballs before checking the |
| 10772 | Internet. |
| 10773 | </para> |
| 10774 | |
| 10775 | <para> |
| 10776 | Here is an efficient way to set it up in your |
| 10777 | <filename>local.conf</filename> file: |
| 10778 | <literallayout class='monospaced'> |
| 10779 | SOURCE_MIRROR_URL ?= "file:///home/you/your-download-dir/" |
| 10780 | INHERIT += "own-mirrors" |
| 10781 | BB_GENERATE_MIRROR_TARBALLS = "1" |
| 10782 | # BB_NO_NETWORK = "1" |
| 10783 | </literallayout> |
| 10784 | </para> |
| 10785 | |
| 10786 | <para> |
| 10787 | In the previous example, the |
| 10788 | <ulink url='&YOCTO_DOCS_REF_URL;#var-BB_GENERATE_MIRROR_TARBALLS'><filename>BB_GENERATE_MIRROR_TARBALLS</filename></ulink> |
| 10789 | variable causes the OpenEmbedded build system to generate |
| 10790 | tarballs of the Git repositories and store them in the |
| 10791 | <ulink url='&YOCTO_DOCS_REF_URL;#var-DL_DIR'><filename>DL_DIR</filename></ulink> |
| 10792 | directory. |
| 10793 | Due to performance reasons, generating and storing these |
| 10794 | tarballs is not the build system's default behavior. |
| 10795 | </para> |
| 10796 | |
| 10797 | <para> |
| 10798 | You can also use the |
| 10799 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PREMIRRORS'><filename>PREMIRRORS</filename></ulink> |
| 10800 | variable. |
| 10801 | For an example, see the variable's glossary entry in the |
| 10802 | Yocto Project Reference Manual. |
| 10803 | </para> |
| 10804 | </section> |
| 10805 | |
| 10806 | <section id='getting-source-files-and-suppressing-the-build'> |
| 10807 | <title>Getting Source Files and Suppressing the Build</title> |
| 10808 | |
| 10809 | <para> |
| 10810 | Another technique you can use to ready yourself for a |
| 10811 | successive string of build operations, is to pre-fetch |
| 10812 | all the source files without actually starting a build. |
| 10813 | This technique lets you work through any download issues |
| 10814 | and ultimately gathers all the source files into your |
| 10815 | download directory |
| 10816 | <ulink url='&YOCTO_DOCS_REF_URL;#structure-build-downloads'><filename>build/downloads</filename></ulink>, |
| 10817 | which is located with |
| 10818 | <ulink url='&YOCTO_DOCS_REF_URL;#var-DL_DIR'><filename>DL_DIR</filename></ulink>. |
| 10819 | </para> |
| 10820 | |
| 10821 | <para> |
| 10822 | Use the following BitBake command form to fetch all the |
| 10823 | necessary sources without starting the build: |
| 10824 | <literallayout class='monospaced'> |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 10825 | $ bitbake -c <replaceable>target</replaceable> runall="fetch" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 10826 | </literallayout> |
| 10827 | This variation of the BitBake command guarantees that you |
| 10828 | have all the sources for that BitBake target should you |
| 10829 | disconnect from the Internet and want to do the build |
| 10830 | later offline. |
| 10831 | </para> |
| 10832 | </section> |
| 10833 | </section> |
| 10834 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 10835 | <section id="selecting-an-initialization-manager"> |
| 10836 | <title>Selecting an Initialization Manager</title> |
| 10837 | |
| 10838 | <para> |
| 10839 | By default, the Yocto Project uses SysVinit as the initialization |
| 10840 | manager. |
| 10841 | However, support also exists for systemd, |
| 10842 | which is a full replacement for init with |
| 10843 | parallel starting of services, reduced shell overhead and other |
| 10844 | features that are used by many distributions. |
| 10845 | </para> |
| 10846 | |
| 10847 | <para> |
Brad Bishop | 64c979e | 2019-11-04 13:55:29 -0500 | [diff] [blame] | 10848 | By default, the Yocto Project uses SysVinit as the initialization |
| 10849 | manager. |
| 10850 | However, support also exists for systemd, |
| 10851 | which is a full replacement for init with |
| 10852 | parallel starting of services, reduced shell overhead and other |
| 10853 | features that are used by many distributions. |
| 10854 | </para> |
| 10855 | |
| 10856 | <para> |
| 10857 | Within the system, SysVinit treats system components as services. |
| 10858 | These services are maintained as shell scripts stored in the |
| 10859 | <filename>/etc/init.d/</filename> directory. |
| 10860 | Services organize into different run levels. |
| 10861 | This organization is maintained by putting links to the services |
| 10862 | in the <filename>/etc/rcN.d/</filename> directories, where |
| 10863 | <replaceable>N/</replaceable> is one of the following options: |
| 10864 | "S", "0", "1", "2", "3", "4", "5", or "6". |
| 10865 | <note> |
| 10866 | Each runlevel has a dependency on the previous runlevel. |
| 10867 | This dependency allows the services to work properly. |
| 10868 | </note> |
| 10869 | </para> |
| 10870 | |
| 10871 | <para> |
| 10872 | In comparison, systemd treats components as units. |
| 10873 | Using units is a broader concept as compared to using a service. |
| 10874 | A unit includes several different types of entities. |
| 10875 | Service is one of the types of entities. |
| 10876 | The runlevel concept in SysVinit corresponds to the concept of a |
| 10877 | target in systemd, where target is also a type of supported unit. |
| 10878 | </para> |
| 10879 | |
| 10880 | <para> |
| 10881 | In a SysVinit-based system, services load sequentially (i.e. one |
| 10882 | by one) during and parallelization is not supported. |
| 10883 | With systemd, services start in parallel. |
| 10884 | Needless to say, the method can have an impact on system startup |
| 10885 | performance. |
| 10886 | </para> |
| 10887 | |
| 10888 | <para> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 10889 | If you want to use SysVinit, you do |
| 10890 | not have to do anything. |
| 10891 | But, if you want to use systemd, you must |
| 10892 | take some steps as described in the following sections. |
| 10893 | </para> |
| 10894 | |
| 10895 | <section id='using-systemd-exclusively'> |
| 10896 | <title>Using systemd Exclusively</title> |
| 10897 | |
| 10898 | <para> |
Brad Bishop | 15ae250 | 2019-06-18 21:44:24 -0400 | [diff] [blame] | 10899 | Set these variables in your distribution configuration |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 10900 | file as follows: |
| 10901 | <literallayout class='monospaced'> |
| 10902 | DISTRO_FEATURES_append = " systemd" |
| 10903 | VIRTUAL-RUNTIME_init_manager = "systemd" |
| 10904 | </literallayout> |
| 10905 | You can also prevent the SysVinit |
| 10906 | distribution feature from |
| 10907 | being automatically enabled as follows: |
| 10908 | <literallayout class='monospaced'> |
| 10909 | DISTRO_FEATURES_BACKFILL_CONSIDERED = "sysvinit" |
| 10910 | </literallayout> |
| 10911 | Doing so removes any redundant SysVinit scripts. |
| 10912 | </para> |
| 10913 | |
| 10914 | <para> |
| 10915 | To remove initscripts from your image altogether, |
| 10916 | set this variable also: |
| 10917 | <literallayout class='monospaced'> |
| 10918 | VIRTUAL-RUNTIME_initscripts = "" |
| 10919 | </literallayout> |
| 10920 | </para> |
| 10921 | |
| 10922 | <para> |
| 10923 | For information on the backfill variable, see |
| 10924 | <ulink url='&YOCTO_DOCS_REF_URL;#var-DISTRO_FEATURES_BACKFILL_CONSIDERED'><filename>DISTRO_FEATURES_BACKFILL_CONSIDERED</filename></ulink>. |
| 10925 | </para> |
| 10926 | </section> |
| 10927 | |
| 10928 | <section id='using-systemd-for-the-main-image-and-using-sysvinit-for-the-rescue-image'> |
| 10929 | <title>Using systemd for the Main Image and Using SysVinit for the Rescue Image</title> |
| 10930 | |
| 10931 | <para> |
| 10932 | Set these variables in your distribution configuration |
| 10933 | file as follows: |
| 10934 | <literallayout class='monospaced'> |
| 10935 | DISTRO_FEATURES_append = " systemd" |
| 10936 | VIRTUAL-RUNTIME_init_manager = "systemd" |
| 10937 | </literallayout> |
| 10938 | Doing so causes your main image to use the |
| 10939 | <filename>packagegroup-core-boot.bb</filename> recipe and |
| 10940 | systemd. |
| 10941 | The rescue/minimal image cannot use this package group. |
| 10942 | However, it can install SysVinit |
| 10943 | and the appropriate packages will have support for both |
| 10944 | systemd and SysVinit. |
| 10945 | </para> |
| 10946 | </section> |
| 10947 | </section> |
| 10948 | |
| 10949 | <section id="selecting-dev-manager"> |
| 10950 | <title>Selecting a Device Manager</title> |
| 10951 | |
| 10952 | <para> |
| 10953 | The Yocto Project provides multiple ways to manage the device |
| 10954 | manager (<filename>/dev</filename>): |
| 10955 | <itemizedlist> |
| 10956 | <listitem><para><emphasis>Persistent and Pre-Populated<filename>/dev</filename>:</emphasis> |
| 10957 | For this case, the <filename>/dev</filename> directory |
| 10958 | is persistent and the required device nodes are created |
| 10959 | during the build. |
| 10960 | </para></listitem> |
| 10961 | <listitem><para><emphasis>Use <filename>devtmpfs</filename> with a Device Manager:</emphasis> |
| 10962 | For this case, the <filename>/dev</filename> directory |
| 10963 | is provided by the kernel as an in-memory file system and |
| 10964 | is automatically populated by the kernel at runtime. |
| 10965 | Additional configuration of device nodes is done in user |
| 10966 | space by a device manager like |
| 10967 | <filename>udev</filename> or |
| 10968 | <filename>busybox-mdev</filename>. |
| 10969 | </para></listitem> |
| 10970 | </itemizedlist> |
| 10971 | </para> |
| 10972 | |
| 10973 | <section id="static-dev-management"> |
| 10974 | <title>Using Persistent and Pre-Populated<filename>/dev</filename></title> |
| 10975 | |
| 10976 | <para> |
| 10977 | To use the static method for device population, you need to |
| 10978 | set the |
| 10979 | <ulink url='&YOCTO_DOCS_REF_URL;#var-USE_DEVFS'><filename>USE_DEVFS</filename></ulink> |
| 10980 | variable to "0" as follows: |
| 10981 | <literallayout class='monospaced'> |
| 10982 | USE_DEVFS = "0" |
| 10983 | </literallayout> |
| 10984 | </para> |
| 10985 | |
| 10986 | <para> |
| 10987 | The content of the resulting <filename>/dev</filename> |
| 10988 | directory is defined in a Device Table file. |
| 10989 | The |
| 10990 | <ulink url='&YOCTO_DOCS_REF_URL;#var-IMAGE_DEVICE_TABLES'><filename>IMAGE_DEVICE_TABLES</filename></ulink> |
| 10991 | variable defines the Device Table to use and should be set |
| 10992 | in the machine or distro configuration file. |
| 10993 | Alternatively, you can set this variable in your |
| 10994 | <filename>local.conf</filename> configuration file. |
| 10995 | </para> |
| 10996 | |
| 10997 | <para> |
| 10998 | If you do not define the |
| 10999 | <filename>IMAGE_DEVICE_TABLES</filename> variable, the default |
| 11000 | <filename>device_table-minimal.txt</filename> is used: |
| 11001 | <literallayout class='monospaced'> |
| 11002 | IMAGE_DEVICE_TABLES = "device_table-mymachine.txt" |
| 11003 | </literallayout> |
| 11004 | </para> |
| 11005 | |
| 11006 | <para> |
| 11007 | The population is handled by the <filename>makedevs</filename> |
| 11008 | utility during image creation: |
| 11009 | </para> |
| 11010 | </section> |
| 11011 | |
| 11012 | <section id="devtmpfs-dev-management"> |
| 11013 | <title>Using <filename>devtmpfs</filename> and a Device Manager</title> |
| 11014 | |
| 11015 | <para> |
| 11016 | To use the dynamic method for device population, you need to |
| 11017 | use (or be sure to set) the |
| 11018 | <ulink url='&YOCTO_DOCS_REF_URL;#var-USE_DEVFS'><filename>USE_DEVFS</filename></ulink> |
| 11019 | variable to "1", which is the default: |
| 11020 | <literallayout class='monospaced'> |
| 11021 | USE_DEVFS = "1" |
| 11022 | </literallayout> |
| 11023 | With this setting, the resulting <filename>/dev</filename> |
| 11024 | directory is populated by the kernel using |
| 11025 | <filename>devtmpfs</filename>. |
| 11026 | Make sure the corresponding kernel configuration variable |
| 11027 | <filename>CONFIG_DEVTMPFS</filename> is set when building |
| 11028 | you build a Linux kernel. |
| 11029 | </para> |
| 11030 | |
| 11031 | <para> |
| 11032 | All devices created by <filename>devtmpfs</filename> will be |
| 11033 | owned by <filename>root</filename> and have permissions |
| 11034 | <filename>0600</filename>. |
| 11035 | </para> |
| 11036 | |
| 11037 | <para> |
| 11038 | To have more control over the device nodes, you can use a |
| 11039 | device manager like <filename>udev</filename> or |
| 11040 | <filename>busybox-mdev</filename>. |
| 11041 | You choose the device manager by defining the |
| 11042 | <filename>VIRTUAL-RUNTIME_dev_manager</filename> variable |
| 11043 | in your machine or distro configuration file. |
| 11044 | Alternatively, you can set this variable in your |
| 11045 | <filename>local.conf</filename> configuration file: |
| 11046 | <literallayout class='monospaced'> |
| 11047 | VIRTUAL-RUNTIME_dev_manager = "udev" |
| 11048 | |
| 11049 | # Some alternative values |
| 11050 | # VIRTUAL-RUNTIME_dev_manager = "busybox-mdev" |
| 11051 | # VIRTUAL-RUNTIME_dev_manager = "systemd" |
| 11052 | </literallayout> |
| 11053 | </para> |
| 11054 | </section> |
| 11055 | </section> |
| 11056 | |
| 11057 | <section id="platdev-appdev-srcrev"> |
| 11058 | <title>Using an External SCM</title> |
| 11059 | |
| 11060 | <para> |
| 11061 | If you're working on a recipe that pulls from an external Source |
| 11062 | Code Manager (SCM), it is possible to have the OpenEmbedded build |
| 11063 | system notice new recipe changes added to the SCM and then build |
| 11064 | the resulting packages that depend on the new recipes by using |
| 11065 | the latest versions. |
| 11066 | This only works for SCMs from which it is possible to get a |
| 11067 | sensible revision number for changes. |
| 11068 | Currently, you can do this with Apache Subversion (SVN), Git, and |
| 11069 | Bazaar (BZR) repositories. |
| 11070 | </para> |
| 11071 | |
| 11072 | <para> |
| 11073 | To enable this behavior, the |
| 11074 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PV'><filename>PV</filename></ulink> |
| 11075 | of the recipe needs to reference |
| 11076 | <ulink url='&YOCTO_DOCS_REF_URL;#var-SRCPV'><filename>SRCPV</filename></ulink>. |
| 11077 | Here is an example: |
| 11078 | <literallayout class='monospaced'> |
| 11079 | PV = "1.2.3+git${SRCPV}" |
| 11080 | </literallayout> |
| 11081 | Then, you can add the following to your |
| 11082 | <filename>local.conf</filename>: |
| 11083 | <literallayout class='monospaced'> |
| 11084 | SRCREV_pn-<replaceable>PN</replaceable> = "${AUTOREV}" |
| 11085 | </literallayout> |
| 11086 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PN'><filename>PN</filename></ulink> |
| 11087 | is the name of the recipe for which you want to enable automatic source |
| 11088 | revision updating. |
| 11089 | </para> |
| 11090 | |
| 11091 | <para> |
| 11092 | If you do not want to update your local configuration file, you can |
| 11093 | add the following directly to the recipe to finish enabling |
| 11094 | the feature: |
| 11095 | <literallayout class='monospaced'> |
| 11096 | SRCREV = "${AUTOREV}" |
| 11097 | </literallayout> |
| 11098 | </para> |
| 11099 | |
| 11100 | <para> |
| 11101 | The Yocto Project provides a distribution named |
| 11102 | <filename>poky-bleeding</filename>, whose configuration |
| 11103 | file contains the line: |
| 11104 | <literallayout class='monospaced'> |
| 11105 | require conf/distro/include/poky-floating-revisions.inc |
| 11106 | </literallayout> |
| 11107 | This line pulls in the listed include file that contains |
| 11108 | numerous lines of exactly that form: |
| 11109 | <literallayout class='monospaced'> |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 11110 | #SRCREV_pn-opkg-native ?= "${AUTOREV}" |
| 11111 | #SRCREV_pn-opkg-sdk ?= "${AUTOREV}" |
| 11112 | #SRCREV_pn-opkg ?= "${AUTOREV}" |
| 11113 | #SRCREV_pn-opkg-utils-native ?= "${AUTOREV}" |
| 11114 | #SRCREV_pn-opkg-utils ?= "${AUTOREV}" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 11115 | SRCREV_pn-gconf-dbus ?= "${AUTOREV}" |
| 11116 | SRCREV_pn-matchbox-common ?= "${AUTOREV}" |
| 11117 | SRCREV_pn-matchbox-config-gtk ?= "${AUTOREV}" |
| 11118 | SRCREV_pn-matchbox-desktop ?= "${AUTOREV}" |
| 11119 | SRCREV_pn-matchbox-keyboard ?= "${AUTOREV}" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 11120 | SRCREV_pn-matchbox-panel-2 ?= "${AUTOREV}" |
| 11121 | SRCREV_pn-matchbox-themes-extra ?= "${AUTOREV}" |
| 11122 | SRCREV_pn-matchbox-terminal ?= "${AUTOREV}" |
| 11123 | SRCREV_pn-matchbox-wm ?= "${AUTOREV}" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 11124 | SRCREV_pn-settings-daemon ?= "${AUTOREV}" |
| 11125 | SRCREV_pn-screenshot ?= "${AUTOREV}" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 11126 | . |
| 11127 | . |
| 11128 | . |
| 11129 | </literallayout> |
| 11130 | These lines allow you to experiment with building a |
| 11131 | distribution that tracks the latest development source |
| 11132 | for numerous packages. |
| 11133 | <note><title>Caution</title> |
| 11134 | The <filename>poky-bleeding</filename> distribution |
| 11135 | is not tested on a regular basis. |
| 11136 | Keep this in mind if you use it. |
| 11137 | </note> |
| 11138 | </para> |
| 11139 | </section> |
| 11140 | |
| 11141 | <section id='creating-a-read-only-root-filesystem'> |
| 11142 | <title>Creating a Read-Only Root Filesystem</title> |
| 11143 | |
| 11144 | <para> |
| 11145 | Suppose, for security reasons, you need to disable |
| 11146 | your target device's root filesystem's write permissions |
| 11147 | (i.e. you need a read-only root filesystem). |
| 11148 | Or, perhaps you are running the device's operating system |
| 11149 | from a read-only storage device. |
| 11150 | For either case, you can customize your image for |
| 11151 | that behavior. |
| 11152 | </para> |
| 11153 | |
| 11154 | <note> |
| 11155 | Supporting a read-only root filesystem requires that the system and |
| 11156 | applications do not try to write to the root filesystem. |
| 11157 | You must configure all parts of the target system to write |
| 11158 | elsewhere, or to gracefully fail in the event of attempting to |
| 11159 | write to the root filesystem. |
| 11160 | </note> |
| 11161 | |
| 11162 | <section id='creating-the-root-filesystem'> |
| 11163 | <title>Creating the Root Filesystem</title> |
| 11164 | |
| 11165 | <para> |
| 11166 | To create the read-only root filesystem, simply add the |
| 11167 | "read-only-rootfs" feature to your image. |
| 11168 | Using either of the following statements in your |
| 11169 | image recipe or from within the |
| 11170 | <filename>local.conf</filename> file found in the |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 11171 | <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 11172 | causes the build system to create a read-only root filesystem: |
| 11173 | <literallayout class='monospaced'> |
| 11174 | IMAGE_FEATURES = "read-only-rootfs" |
| 11175 | </literallayout> |
| 11176 | or |
| 11177 | <literallayout class='monospaced'> |
| 11178 | EXTRA_IMAGE_FEATURES += "read-only-rootfs" |
| 11179 | </literallayout> |
| 11180 | </para> |
| 11181 | |
| 11182 | <para> |
| 11183 | For more information on how to use these variables, see the |
| 11184 | "<link linkend='usingpoky-extend-customimage-imagefeatures'>Customizing Images Using Custom <filename>IMAGE_FEATURES</filename> and <filename>EXTRA_IMAGE_FEATURES</filename></link>" |
| 11185 | section. |
| 11186 | For information on the variables, see |
| 11187 | <ulink url='&YOCTO_DOCS_REF_URL;#var-IMAGE_FEATURES'><filename>IMAGE_FEATURES</filename></ulink> |
| 11188 | and <ulink url='&YOCTO_DOCS_REF_URL;#var-EXTRA_IMAGE_FEATURES'><filename>EXTRA_IMAGE_FEATURES</filename></ulink>. |
| 11189 | </para> |
| 11190 | </section> |
| 11191 | |
| 11192 | <section id='post-installation-scripts'> |
| 11193 | <title>Post-Installation Scripts</title> |
| 11194 | |
| 11195 | <para> |
| 11196 | It is very important that you make sure all |
| 11197 | post-Installation (<filename>pkg_postinst</filename>) scripts |
| 11198 | for packages that are installed into the image can be run |
| 11199 | at the time when the root filesystem is created during the |
| 11200 | build on the host system. |
| 11201 | These scripts cannot attempt to run during first-boot on the |
| 11202 | target device. |
| 11203 | With the "read-only-rootfs" feature enabled, |
| 11204 | the build system checks during root filesystem creation to make |
| 11205 | sure all post-installation scripts succeed. |
| 11206 | If any of these scripts still need to be run after the root |
| 11207 | filesystem is created, the build immediately fails. |
| 11208 | These build-time checks ensure that the build fails |
| 11209 | rather than the target device fails later during its |
| 11210 | initial boot operation. |
| 11211 | </para> |
| 11212 | |
| 11213 | <para> |
| 11214 | Most of the common post-installation scripts generated by the |
| 11215 | build system for the out-of-the-box Yocto Project are engineered |
| 11216 | so that they can run during root filesystem creation |
| 11217 | (e.g. post-installation scripts for caching fonts). |
| 11218 | However, if you create and add custom scripts, you need |
| 11219 | to be sure they can be run during this file system creation. |
| 11220 | </para> |
| 11221 | |
| 11222 | <para> |
| 11223 | Here are some common problems that prevent |
| 11224 | post-installation scripts from running during root filesystem |
| 11225 | creation: |
| 11226 | <itemizedlist> |
| 11227 | <listitem><para> |
| 11228 | <emphasis>Not using $D in front of absolute |
| 11229 | paths:</emphasis> |
| 11230 | The build system defines |
| 11231 | <filename>$</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-D'><filename>D</filename></ulink> |
| 11232 | when the root filesystem is created. |
| 11233 | Furthermore, <filename>$D</filename> is blank when the |
| 11234 | script is run on the target device. |
| 11235 | This implies two purposes for <filename>$D</filename>: |
| 11236 | ensuring paths are valid in both the host and target |
| 11237 | environments, and checking to determine which |
| 11238 | environment is being used as a method for taking |
| 11239 | appropriate actions. |
| 11240 | </para></listitem> |
| 11241 | <listitem><para> |
| 11242 | <emphasis>Attempting to run processes that are |
| 11243 | specific to or dependent on the target |
| 11244 | architecture:</emphasis> |
| 11245 | You can work around these attempts by using native |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 11246 | tools, which run on the host system, |
| 11247 | to accomplish the same tasks, or |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 11248 | by alternatively running the processes under QEMU, |
| 11249 | which has the <filename>qemu_run_binary</filename> |
| 11250 | function. |
| 11251 | For more information, see the |
| 11252 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-qemu'><filename>qemu</filename></ulink> |
| 11253 | class.</para></listitem> |
| 11254 | </itemizedlist> |
| 11255 | </para> |
| 11256 | </section> |
| 11257 | |
| 11258 | <section id='areas-with-write-access'> |
| 11259 | <title>Areas With Write Access</title> |
| 11260 | |
| 11261 | <para> |
| 11262 | With the "read-only-rootfs" feature enabled, |
| 11263 | any attempt by the target to write to the root filesystem at |
| 11264 | runtime fails. |
| 11265 | Consequently, you must make sure that you configure processes |
| 11266 | and applications that attempt these types of writes do so |
| 11267 | to directories with write access (e.g. |
| 11268 | <filename>/tmp</filename> or <filename>/var/run</filename>). |
| 11269 | </para> |
| 11270 | </section> |
| 11271 | </section> |
| 11272 | |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 11273 | |
| 11274 | |
| 11275 | |
| 11276 | <section id='maintaining-build-output-quality'> |
| 11277 | <title>Maintaining Build Output Quality</title> |
| 11278 | |
| 11279 | <para> |
| 11280 | Many factors can influence the quality of a build. |
| 11281 | For example, if you upgrade a recipe to use a new version of an |
| 11282 | upstream software package or you experiment with some new |
| 11283 | configuration options, subtle changes can occur that you might |
| 11284 | not detect until later. |
| 11285 | Consider the case where your recipe is using a newer version of |
| 11286 | an upstream package. |
| 11287 | In this case, a new version of a piece of software might |
| 11288 | introduce an optional dependency on another library, which is |
| 11289 | auto-detected. |
| 11290 | If that library has already been built when the software is |
| 11291 | building, the software will link to the built library and that |
| 11292 | library will be pulled into your image along with the new |
| 11293 | software even if you did not want the library. |
| 11294 | </para> |
| 11295 | |
| 11296 | <para> |
| 11297 | The |
| 11298 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-buildhistory'><filename>buildhistory</filename></ulink> |
| 11299 | class exists to help you maintain the quality of your build |
| 11300 | output. |
| 11301 | You can use the class to highlight unexpected and possibly |
| 11302 | unwanted changes in the build output. |
| 11303 | When you enable build history, it records information about the |
| 11304 | contents of each package and image and then commits that |
| 11305 | information to a local Git repository where you can examine |
| 11306 | the information. |
| 11307 | </para> |
| 11308 | |
| 11309 | <para> |
| 11310 | The remainder of this section describes the following: |
| 11311 | <itemizedlist> |
| 11312 | <listitem><para> |
| 11313 | How you can enable and disable build history |
| 11314 | </para></listitem> |
| 11315 | <listitem><para> |
| 11316 | How to understand what the build history contains |
| 11317 | </para></listitem> |
| 11318 | <listitem><para> |
| 11319 | How to limit the information used for build history |
| 11320 | </para></listitem> |
| 11321 | <listitem><para> |
| 11322 | How to examine the build history from both a |
| 11323 | command-line and web interface |
| 11324 | </para></listitem> |
| 11325 | </itemizedlist> |
| 11326 | </para> |
| 11327 | |
| 11328 | <section id='enabling-and-disabling-build-history'> |
| 11329 | <title>Enabling and Disabling Build History</title> |
| 11330 | |
| 11331 | <para> |
| 11332 | Build history is disabled by default. |
| 11333 | To enable it, add the following <filename>INHERIT</filename> |
| 11334 | statement and set the |
| 11335 | <ulink url='&YOCTO_DOCS_REF_URL;#var-BUILDHISTORY_COMMIT'><filename>BUILDHISTORY_COMMIT</filename></ulink> |
| 11336 | variable to "1" at the end of your |
| 11337 | <filename>conf/local.conf</filename> file found in the |
| 11338 | <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink>: |
| 11339 | <literallayout class='monospaced'> |
| 11340 | INHERIT += "buildhistory" |
| 11341 | BUILDHISTORY_COMMIT = "1" |
| 11342 | </literallayout> |
| 11343 | Enabling build history as previously described causes the |
| 11344 | OpenEmbedded build system to collect build output information |
| 11345 | and commit it as a single commit to a local |
| 11346 | <ulink url='&YOCTO_DOCS_OM_URL;#git'>Git</ulink> |
| 11347 | repository. |
| 11348 | <note> |
| 11349 | Enabling build history increases your build times slightly, |
| 11350 | particularly for images, and increases the amount of disk |
| 11351 | space used during the build. |
| 11352 | </note> |
| 11353 | </para> |
| 11354 | |
| 11355 | <para> |
| 11356 | You can disable build history by removing the previous |
| 11357 | statements from your <filename>conf/local.conf</filename> |
| 11358 | file. |
| 11359 | </para> |
| 11360 | </section> |
| 11361 | |
| 11362 | <section id='understanding-what-the-build-history-contains'> |
| 11363 | <title>Understanding What the Build History Contains</title> |
| 11364 | |
| 11365 | <para> |
| 11366 | Build history information is kept in |
| 11367 | <filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-TOPDIR'><filename>TOPDIR</filename></ulink><filename>}/buildhistory</filename> |
| 11368 | in the Build Directory as defined by the |
| 11369 | <ulink url='&YOCTO_DOCS_REF_URL;#var-BUILDHISTORY_DIR'><filename>BUILDHISTORY_DIR</filename></ulink> |
| 11370 | variable. |
| 11371 | The following is an example abbreviated listing: |
| 11372 | <imagedata fileref="figures/buildhistory.png" align="center" width="6in" depth="4in" /> |
| 11373 | </para> |
| 11374 | |
| 11375 | <para> |
| 11376 | At the top level, a <filename>metadata-revs</filename> |
| 11377 | file exists that lists the revisions of the repositories for |
| 11378 | the enabled layers when the build was produced. |
| 11379 | The rest of the data splits into separate |
| 11380 | <filename>packages</filename>, <filename>images</filename> |
| 11381 | and <filename>sdk</filename> directories, the contents of |
| 11382 | which are described as follows. |
| 11383 | </para> |
| 11384 | |
| 11385 | <section id='build-history-package-information'> |
| 11386 | <title>Build History Package Information</title> |
| 11387 | |
| 11388 | <para> |
| 11389 | The history for each package contains a text file that has |
| 11390 | name-value pairs with information about the package. |
| 11391 | For example, |
| 11392 | <filename>buildhistory/packages/i586-poky-linux/busybox/busybox/latest</filename> |
| 11393 | contains the following: |
| 11394 | <literallayout class='monospaced'> |
| 11395 | PV = 1.22.1 |
| 11396 | PR = r32 |
| 11397 | RPROVIDES = |
| 11398 | RDEPENDS = glibc (>= 2.20) update-alternatives-opkg |
| 11399 | RRECOMMENDS = busybox-syslog busybox-udhcpc update-rc.d |
| 11400 | PKGSIZE = 540168 |
| 11401 | FILES = /usr/bin/* /usr/sbin/* /usr/lib/busybox/* /usr/lib/lib*.so.* \ |
| 11402 | /etc /com /var /bin/* /sbin/* /lib/*.so.* /lib/udev/rules.d \ |
| 11403 | /usr/lib/udev/rules.d /usr/share/busybox /usr/lib/busybox/* \ |
| 11404 | /usr/share/pixmaps /usr/share/applications /usr/share/idl \ |
| 11405 | /usr/share/omf /usr/share/sounds /usr/lib/bonobo/servers |
| 11406 | FILELIST = /bin/busybox /bin/busybox.nosuid /bin/busybox.suid /bin/sh \ |
| 11407 | /etc/busybox.links.nosuid /etc/busybox.links.suid |
| 11408 | </literallayout> |
| 11409 | Most of these name-value pairs correspond to variables |
| 11410 | used to produce the package. |
| 11411 | The exceptions are <filename>FILELIST</filename>, which |
| 11412 | is the actual list of files in the package, and |
| 11413 | <filename>PKGSIZE</filename>, which is the total size of |
| 11414 | files in the package in bytes. |
| 11415 | </para> |
| 11416 | |
| 11417 | <para> |
| 11418 | A file also exists that corresponds to the recipe from |
| 11419 | which the package came (e.g. |
| 11420 | <filename>buildhistory/packages/i586-poky-linux/busybox/latest</filename>): |
| 11421 | <literallayout class='monospaced'> |
| 11422 | PV = 1.22.1 |
| 11423 | PR = r32 |
| 11424 | DEPENDS = initscripts kern-tools-native update-rc.d-native \ |
| 11425 | virtual/i586-poky-linux-compilerlibs virtual/i586-poky-linux-gcc \ |
| 11426 | virtual/libc virtual/update-alternatives |
| 11427 | PACKAGES = busybox-ptest busybox-httpd busybox-udhcpd busybox-udhcpc \ |
| 11428 | busybox-syslog busybox-mdev busybox-hwclock busybox-dbg \ |
| 11429 | busybox-staticdev busybox-dev busybox-doc busybox-locale busybox |
| 11430 | </literallayout> |
| 11431 | </para> |
| 11432 | |
| 11433 | <para> |
| 11434 | Finally, for those recipes fetched from a version control |
| 11435 | system (e.g., Git), a file exists that lists source |
| 11436 | revisions that are specified in the recipe and lists |
| 11437 | the actual revisions used during the build. |
| 11438 | Listed and actual revisions might differ when |
| 11439 | <ulink url='&YOCTO_DOCS_REF_URL;#var-SRCREV'><filename>SRCREV</filename></ulink> |
| 11440 | is set to |
| 11441 | ${<ulink url='&YOCTO_DOCS_REF_URL;#var-AUTOREV'><filename>AUTOREV</filename></ulink>}. |
| 11442 | Here is an example assuming |
| 11443 | <filename>buildhistory/packages/qemux86-poky-linux/linux-yocto/latest_srcrev</filename>): |
| 11444 | <literallayout class='monospaced'> |
| 11445 | # SRCREV_machine = "38cd560d5022ed2dbd1ab0dca9642e47c98a0aa1" |
| 11446 | SRCREV_machine = "38cd560d5022ed2dbd1ab0dca9642e47c98a0aa1" |
| 11447 | # SRCREV_meta = "a227f20eff056e511d504b2e490f3774ab260d6f" |
| 11448 | SRCREV_meta = "a227f20eff056e511d504b2e490f3774ab260d6f" |
| 11449 | </literallayout> |
| 11450 | You can use the |
| 11451 | <filename>buildhistory-collect-srcrevs</filename> |
| 11452 | command with the <filename>-a</filename> option to |
| 11453 | collect the stored <filename>SRCREV</filename> values |
| 11454 | from build history and report them in a format suitable for |
| 11455 | use in global configuration (e.g., |
| 11456 | <filename>local.conf</filename> or a distro include file) |
| 11457 | to override floating <filename>AUTOREV</filename> values |
| 11458 | to a fixed set of revisions. |
| 11459 | Here is some example output from this command: |
| 11460 | <literallayout class='monospaced'> |
| 11461 | $ buildhistory-collect-srcrevs -a |
| 11462 | # i586-poky-linux |
| 11463 | SRCREV_pn-glibc = "b8079dd0d360648e4e8de48656c5c38972621072" |
| 11464 | SRCREV_pn-glibc-initial = "b8079dd0d360648e4e8de48656c5c38972621072" |
| 11465 | SRCREV_pn-opkg-utils = "53274f087565fd45d8452c5367997ba6a682a37a" |
| 11466 | SRCREV_pn-kmod = "fd56638aed3fe147015bfa10ed4a5f7491303cb4" |
| 11467 | # x86_64-linux |
| 11468 | SRCREV_pn-gtk-doc-stub-native = "1dea266593edb766d6d898c79451ef193eb17cfa" |
| 11469 | SRCREV_pn-dtc-native = "65cc4d2748a2c2e6f27f1cf39e07a5dbabd80ebf" |
| 11470 | SRCREV_pn-update-rc.d-native = "eca680ddf28d024954895f59a241a622dd575c11" |
| 11471 | SRCREV_glibc_pn-cross-localedef-native = "b8079dd0d360648e4e8de48656c5c38972621072" |
| 11472 | SRCREV_localedef_pn-cross-localedef-native = "c833367348d39dad7ba018990bfdaffaec8e9ed3" |
| 11473 | SRCREV_pn-prelink-native = "faa069deec99bf61418d0bab831c83d7c1b797ca" |
| 11474 | SRCREV_pn-opkg-utils-native = "53274f087565fd45d8452c5367997ba6a682a37a" |
| 11475 | SRCREV_pn-kern-tools-native = "23345b8846fe4bd167efdf1bd8a1224b2ba9a5ff" |
| 11476 | SRCREV_pn-kmod-native = "fd56638aed3fe147015bfa10ed4a5f7491303cb4" |
| 11477 | # qemux86-poky-linux |
| 11478 | SRCREV_machine_pn-linux-yocto = "38cd560d5022ed2dbd1ab0dca9642e47c98a0aa1" |
| 11479 | SRCREV_meta_pn-linux-yocto = "a227f20eff056e511d504b2e490f3774ab260d6f" |
| 11480 | # all-poky-linux |
| 11481 | SRCREV_pn-update-rc.d = "eca680ddf28d024954895f59a241a622dd575c11" |
| 11482 | </literallayout> |
| 11483 | <note> |
| 11484 | Here are some notes on using the |
| 11485 | <filename>buildhistory-collect-srcrevs</filename> |
| 11486 | command: |
| 11487 | <itemizedlist> |
| 11488 | <listitem><para> |
| 11489 | By default, only values where the |
| 11490 | <filename>SRCREV</filename> was not hardcoded |
| 11491 | (usually when <filename>AUTOREV</filename> |
| 11492 | is used) are reported. |
| 11493 | Use the <filename>-a</filename> option to |
| 11494 | see all <filename>SRCREV</filename> values. |
| 11495 | </para></listitem> |
| 11496 | <listitem><para> |
| 11497 | The output statements might not have any effect |
| 11498 | if overrides are applied elsewhere in the |
| 11499 | build system configuration. |
| 11500 | Use the <filename>-f</filename> option to add |
| 11501 | the <filename>forcevariable</filename> override |
| 11502 | to each output line if you need to work around |
| 11503 | this restriction. |
| 11504 | </para></listitem> |
| 11505 | <listitem><para> |
| 11506 | The script does apply special handling when |
| 11507 | building for multiple machines. |
| 11508 | However, the script does place a comment before |
| 11509 | each set of values that specifies which |
| 11510 | triplet to which they belong as previously |
| 11511 | shown (e.g., |
| 11512 | <filename>i586-poky-linux</filename>). |
| 11513 | </para></listitem> |
| 11514 | </itemizedlist> |
| 11515 | </note> |
| 11516 | </para> |
| 11517 | </section> |
| 11518 | |
| 11519 | <section id='build-history-image-information'> |
| 11520 | <title>Build History Image Information</title> |
| 11521 | |
| 11522 | <para> |
| 11523 | The files produced for each image are as follows: |
| 11524 | <itemizedlist> |
| 11525 | <listitem><para> |
| 11526 | <filename>image-files:</filename> |
| 11527 | A directory containing selected files from the root |
| 11528 | filesystem. |
| 11529 | The files are defined by |
| 11530 | <ulink url='&YOCTO_DOCS_REF_URL;#var-BUILDHISTORY_IMAGE_FILES'><filename>BUILDHISTORY_IMAGE_FILES</filename></ulink>. |
| 11531 | </para></listitem> |
| 11532 | <listitem><para> |
| 11533 | <filename>build-id.txt:</filename> |
| 11534 | Human-readable information about the build |
| 11535 | configuration and metadata source revisions. |
| 11536 | This file contains the full build header as printed |
| 11537 | by BitBake. |
| 11538 | </para></listitem> |
| 11539 | <listitem><para> |
| 11540 | <filename>*.dot:</filename> |
| 11541 | Dependency graphs for the image that are |
| 11542 | compatible with <filename>graphviz</filename>. |
| 11543 | </para></listitem> |
| 11544 | <listitem><para> |
| 11545 | <filename>files-in-image.txt:</filename> |
| 11546 | A list of files in the image with permissions, |
| 11547 | owner, group, size, and symlink information. |
| 11548 | </para></listitem> |
| 11549 | <listitem><para> |
| 11550 | <filename>image-info.txt:</filename> |
| 11551 | A text file containing name-value pairs with |
| 11552 | information about the image. |
| 11553 | See the following listing example for more |
| 11554 | information. |
| 11555 | </para></listitem> |
| 11556 | <listitem><para> |
| 11557 | <filename>installed-package-names.txt:</filename> |
| 11558 | A list of installed packages by name only. |
| 11559 | </para></listitem> |
| 11560 | <listitem><para> |
| 11561 | <filename>installed-package-sizes.txt:</filename> |
| 11562 | A list of installed packages ordered by size. |
| 11563 | </para></listitem> |
| 11564 | <listitem><para> |
| 11565 | <filename>installed-packages.txt:</filename> |
| 11566 | A list of installed packages with full package |
| 11567 | filenames. |
| 11568 | </para></listitem> |
| 11569 | </itemizedlist> |
| 11570 | <note> |
| 11571 | Installed package information is able to be gathered |
| 11572 | and produced even if package management is disabled |
| 11573 | for the final image. |
| 11574 | </note> |
| 11575 | </para> |
| 11576 | |
| 11577 | <para> |
| 11578 | Here is an example of <filename>image-info.txt</filename>: |
| 11579 | <literallayout class='monospaced'> |
| 11580 | DISTRO = poky |
| 11581 | DISTRO_VERSION = 1.7 |
| 11582 | USER_CLASSES = buildstats image-mklibs image-prelink |
| 11583 | IMAGE_CLASSES = image_types |
| 11584 | IMAGE_FEATURES = debug-tweaks |
| 11585 | IMAGE_LINGUAS = |
| 11586 | IMAGE_INSTALL = packagegroup-core-boot run-postinsts |
| 11587 | BAD_RECOMMENDATIONS = |
| 11588 | NO_RECOMMENDATIONS = |
| 11589 | PACKAGE_EXCLUDE = |
| 11590 | ROOTFS_POSTPROCESS_COMMAND = write_package_manifest; license_create_manifest; \ |
| 11591 | write_image_manifest ; buildhistory_list_installed_image ; \ |
| 11592 | buildhistory_get_image_installed ; ssh_allow_empty_password; \ |
| 11593 | postinst_enable_logging; rootfs_update_timestamp ; ssh_disable_dns_lookup ; |
| 11594 | IMAGE_POSTPROCESS_COMMAND = buildhistory_get_imageinfo ; |
| 11595 | IMAGESIZE = 6900 |
| 11596 | </literallayout> |
| 11597 | Other than <filename>IMAGESIZE</filename>, which is the |
| 11598 | total size of the files in the image in Kbytes, the |
| 11599 | name-value pairs are variables that may have influenced the |
| 11600 | content of the image. |
| 11601 | This information is often useful when you are trying to |
| 11602 | determine why a change in the package or file |
| 11603 | listings has occurred. |
| 11604 | </para> |
| 11605 | </section> |
| 11606 | |
| 11607 | <section id='using-build-history-to-gather-image-information-only'> |
| 11608 | <title>Using Build History to Gather Image Information Only</title> |
| 11609 | |
| 11610 | <para> |
| 11611 | As you can see, build history produces image information, |
| 11612 | including dependency graphs, so you can see why something |
| 11613 | was pulled into the image. |
| 11614 | If you are just interested in this information and not |
| 11615 | interested in collecting specific package or SDK |
| 11616 | information, you can enable writing only image information |
| 11617 | without any history by adding the following to your |
| 11618 | <filename>conf/local.conf</filename> file found in the |
| 11619 | <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink>: |
| 11620 | <literallayout class='monospaced'> |
| 11621 | INHERIT += "buildhistory" |
| 11622 | BUILDHISTORY_COMMIT = "0" |
| 11623 | BUILDHISTORY_FEATURES = "image" |
| 11624 | </literallayout> |
| 11625 | Here, you set the |
| 11626 | <ulink url='&YOCTO_DOCS_REF_URL;#var-BUILDHISTORY_FEATURES'><filename>BUILDHISTORY_FEATURES</filename></ulink> |
| 11627 | variable to use the image feature only. |
| 11628 | </para> |
| 11629 | </section> |
| 11630 | |
| 11631 | <section id='build-history-sdk-information'> |
| 11632 | <title>Build History SDK Information</title> |
| 11633 | |
| 11634 | <para> |
| 11635 | Build history collects similar information on the contents |
| 11636 | of SDKs |
| 11637 | (e.g. <filename>bitbake -c populate_sdk imagename</filename>) |
| 11638 | as compared to information it collects for images. |
| 11639 | Furthermore, this information differs depending on whether |
| 11640 | an extensible or standard SDK is being produced. |
| 11641 | </para> |
| 11642 | |
| 11643 | <para> |
| 11644 | The following list shows the files produced for SDKs: |
| 11645 | <itemizedlist> |
| 11646 | <listitem><para> |
| 11647 | <filename>files-in-sdk.txt:</filename> |
| 11648 | A list of files in the SDK with permissions, |
| 11649 | owner, group, size, and symlink information. |
| 11650 | This list includes both the host and target parts |
| 11651 | of the SDK. |
| 11652 | </para></listitem> |
| 11653 | <listitem><para> |
| 11654 | <filename>sdk-info.txt:</filename> |
| 11655 | A text file containing name-value pairs with |
| 11656 | information about the SDK. |
| 11657 | See the following listing example for more |
| 11658 | information. |
| 11659 | </para></listitem> |
| 11660 | <listitem><para> |
| 11661 | <filename>sstate-task-sizes.txt:</filename> |
| 11662 | A text file containing name-value pairs with |
| 11663 | information about task group sizes |
| 11664 | (e.g. <filename>do_populate_sysroot</filename> |
| 11665 | tasks have a total size). |
| 11666 | The <filename>sstate-task-sizes.txt</filename> file |
| 11667 | exists only when an extensible SDK is created. |
| 11668 | </para></listitem> |
| 11669 | <listitem><para> |
| 11670 | <filename>sstate-package-sizes.txt:</filename> |
| 11671 | A text file containing name-value pairs with |
| 11672 | information for the shared-state packages and |
| 11673 | sizes in the SDK. |
| 11674 | The <filename>sstate-package-sizes.txt</filename> |
| 11675 | file exists only when an extensible SDK is created. |
| 11676 | </para></listitem> |
| 11677 | <listitem><para> |
| 11678 | <filename>sdk-files:</filename> |
| 11679 | A folder that contains copies of the files |
| 11680 | mentioned in |
| 11681 | <filename>BUILDHISTORY_SDK_FILES</filename> if the |
| 11682 | files are present in the output. |
| 11683 | Additionally, the default value of |
| 11684 | <filename>BUILDHISTORY_SDK_FILES</filename> is |
| 11685 | specific to the extensible SDK although you can |
| 11686 | set it differently if you would like to pull in |
| 11687 | specific files from the standard SDK.</para> |
| 11688 | |
| 11689 | <para>The default files are |
| 11690 | <filename>conf/local.conf</filename>, |
| 11691 | <filename>conf/bblayers.conf</filename>, |
| 11692 | <filename>conf/auto.conf</filename>, |
| 11693 | <filename>conf/locked-sigs.inc</filename>, and |
| 11694 | <filename>conf/devtool.conf</filename>. |
| 11695 | Thus, for an extensible SDK, these files get |
| 11696 | copied into the <filename>sdk-files</filename> |
| 11697 | directory. |
| 11698 | </para></listitem> |
| 11699 | <listitem><para> |
| 11700 | The following information appears under |
| 11701 | each of the <filename>host</filename> |
| 11702 | and <filename>target</filename> directories |
| 11703 | for the portions of the SDK that run on the host |
| 11704 | and on the target, respectively: |
| 11705 | <note> |
| 11706 | The following files for the most part are empty |
| 11707 | when producing an extensible SDK because this |
| 11708 | type of SDK is not constructed from packages |
| 11709 | as is the standard SDK. |
| 11710 | </note> |
| 11711 | <itemizedlist> |
| 11712 | <listitem><para> |
| 11713 | <filename>depends.dot:</filename> |
| 11714 | Dependency graph for the SDK that is |
| 11715 | compatible with |
| 11716 | <filename>graphviz</filename>. |
| 11717 | </para></listitem> |
| 11718 | <listitem><para> |
| 11719 | <filename>installed-package-names.txt:</filename> |
| 11720 | A list of installed packages by name only. |
| 11721 | </para></listitem> |
| 11722 | <listitem><para> |
| 11723 | <filename>installed-package-sizes.txt:</filename> |
| 11724 | A list of installed packages ordered by size. |
| 11725 | </para></listitem> |
| 11726 | <listitem><para> |
| 11727 | <filename>installed-packages.txt:</filename> |
| 11728 | A list of installed packages with full |
| 11729 | package filenames. |
| 11730 | </para></listitem> |
| 11731 | </itemizedlist> |
| 11732 | </para></listitem> |
| 11733 | </itemizedlist> |
| 11734 | </para> |
| 11735 | |
| 11736 | <para> |
| 11737 | Here is an example of <filename>sdk-info.txt</filename>: |
| 11738 | <literallayout class='monospaced'> |
| 11739 | DISTRO = poky |
| 11740 | DISTRO_VERSION = 1.3+snapshot-20130327 |
| 11741 | SDK_NAME = poky-glibc-i686-arm |
| 11742 | SDK_VERSION = 1.3+snapshot |
| 11743 | SDKMACHINE = |
| 11744 | SDKIMAGE_FEATURES = dev-pkgs dbg-pkgs |
| 11745 | BAD_RECOMMENDATIONS = |
| 11746 | SDKSIZE = 352712 |
| 11747 | </literallayout> |
| 11748 | Other than <filename>SDKSIZE</filename>, which is the |
| 11749 | total size of the files in the SDK in Kbytes, the |
| 11750 | name-value pairs are variables that might have influenced |
| 11751 | the content of the SDK. |
| 11752 | This information is often useful when you are trying to |
| 11753 | determine why a change in the package or file listings |
| 11754 | has occurred. |
| 11755 | </para> |
| 11756 | </section> |
| 11757 | |
| 11758 | <section id='examining-build-history-information'> |
| 11759 | <title>Examining Build History Information</title> |
| 11760 | |
| 11761 | <para> |
| 11762 | You can examine build history output from the command |
| 11763 | line or from a web interface. |
| 11764 | </para> |
| 11765 | |
| 11766 | <para> |
| 11767 | To see any changes that have occurred (assuming you have |
| 11768 | <ulink url='&YOCTO_DOCS_REF_URL;#var-BUILDHISTORY_COMMIT'><filename>BUILDHISTORY_COMMIT</filename></ulink><filename> = "1"</filename>), |
| 11769 | you can simply use any Git command that allows you to |
| 11770 | view the history of a repository. |
| 11771 | Here is one method: |
| 11772 | <literallayout class='monospaced'> |
| 11773 | $ git log -p |
| 11774 | </literallayout> |
| 11775 | You need to realize, however, that this method does show |
| 11776 | changes that are not significant (e.g. a package's size |
| 11777 | changing by a few bytes). |
| 11778 | </para> |
| 11779 | |
| 11780 | <para> |
| 11781 | A command-line tool called |
| 11782 | <filename>buildhistory-diff</filename> does exist, though, |
| 11783 | that queries the Git repository and prints just the |
| 11784 | differences that might be significant in human-readable |
| 11785 | form. |
| 11786 | Here is an example: |
| 11787 | <literallayout class='monospaced'> |
| 11788 | $ ~/poky/poky/scripts/buildhistory-diff . HEAD^ |
| 11789 | Changes to images/qemux86_64/glibc/core-image-minimal (files-in-image.txt): |
| 11790 | /etc/anotherpkg.conf was added |
| 11791 | /sbin/anotherpkg was added |
| 11792 | * (installed-package-names.txt): |
| 11793 | * anotherpkg was added |
| 11794 | Changes to images/qemux86_64/glibc/core-image-minimal (installed-package-names.txt): |
| 11795 | anotherpkg was added |
| 11796 | packages/qemux86_64-poky-linux/v86d: PACKAGES: added "v86d-extras" |
| 11797 | * PR changed from "r0" to "r1" |
| 11798 | * PV changed from "0.1.10" to "0.1.12" |
| 11799 | packages/qemux86_64-poky-linux/v86d/v86d: PKGSIZE changed from 110579 to 144381 (+30%) |
| 11800 | * PR changed from "r0" to "r1" |
| 11801 | * PV changed from "0.1.10" to "0.1.12" |
| 11802 | </literallayout> |
| 11803 | <note> |
| 11804 | The <filename>buildhistory-diff</filename> tool |
| 11805 | requires the <filename>GitPython</filename> package. |
| 11806 | Be sure to install it using Pip3 as follows: |
| 11807 | <literallayout class='monospaced'> |
| 11808 | $ pip3 install GitPython --user |
| 11809 | </literallayout> |
| 11810 | Alternatively, you can install |
| 11811 | <filename>python3-git</filename> using the appropriate |
| 11812 | distribution package manager (e.g. |
| 11813 | <filename>apt-get</filename>, <filename>dnf</filename>, |
| 11814 | or <filename>zipper</filename>). |
| 11815 | </note> |
| 11816 | </para> |
| 11817 | |
| 11818 | <para> |
| 11819 | To see changes to the build history using a web interface, |
| 11820 | follow the instruction in the <filename>README</filename> |
| 11821 | file here. |
| 11822 | <ulink url='http://git.yoctoproject.org/cgit/cgit.cgi/buildhistory-web/'></ulink>. |
| 11823 | </para> |
| 11824 | |
| 11825 | <para> |
| 11826 | Here is a sample screenshot of the interface: |
| 11827 | <imagedata fileref="figures/buildhistory-web.png" align="center" scalefit="1" width="130%" contentdepth="130%" /> |
| 11828 | </para> |
| 11829 | </section> |
| 11830 | </section> |
| 11831 | </section> |
| 11832 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 11833 | <section id="performing-automated-runtime-testing"> |
| 11834 | <title>Performing Automated Runtime Testing</title> |
| 11835 | |
| 11836 | <para> |
| 11837 | The OpenEmbedded build system makes available a series of automated |
| 11838 | tests for images to verify runtime functionality. |
| 11839 | You can run these tests on either QEMU or actual target hardware. |
| 11840 | Tests are written in Python making use of the |
| 11841 | <filename>unittest</filename> module, and the majority of them |
| 11842 | run commands on the target system over SSH. |
| 11843 | This section describes how you set up the environment to use these |
| 11844 | tests, run available tests, and write and add your own tests. |
| 11845 | </para> |
| 11846 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 11847 | <para> |
| 11848 | For information on the test and QA infrastructure available |
| 11849 | within the Yocto Project, see the |
| 11850 | "<ulink url='&YOCTO_DOCS_REF_URL;#testing-and-quality-assurance'>Testing and Quality Assurance</ulink>" |
| 11851 | section in the Yocto Project Reference Manual. |
| 11852 | </para> |
| 11853 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 11854 | <section id='enabling-tests'> |
| 11855 | <title>Enabling Tests</title> |
| 11856 | |
| 11857 | <para> |
| 11858 | Depending on whether you are planning to run tests using |
| 11859 | QEMU or on the hardware, you have to take |
| 11860 | different steps to enable the tests. |
| 11861 | See the following subsections for information on how to |
| 11862 | enable both types of tests. |
| 11863 | </para> |
| 11864 | |
| 11865 | <section id='qemu-image-enabling-tests'> |
| 11866 | <title>Enabling Runtime Tests on QEMU</title> |
| 11867 | |
| 11868 | <para> |
| 11869 | In order to run tests, you need to do the following: |
| 11870 | <itemizedlist> |
| 11871 | <listitem><para><emphasis>Set up to avoid interaction |
| 11872 | with <filename>sudo</filename> for networking:</emphasis> |
| 11873 | To accomplish this, you must do one of the |
| 11874 | following: |
| 11875 | <itemizedlist> |
| 11876 | <listitem><para>Add |
| 11877 | <filename>NOPASSWD</filename> for your user |
| 11878 | in <filename>/etc/sudoers</filename> either for |
| 11879 | all commands or just for |
| 11880 | <filename>runqemu-ifup</filename>. |
| 11881 | You must provide the full path as that can |
| 11882 | change if you are using multiple clones of the |
| 11883 | source repository. |
| 11884 | <note> |
| 11885 | On some distributions, you also need to |
| 11886 | comment out "Defaults requiretty" in |
| 11887 | <filename>/etc/sudoers</filename>. |
| 11888 | </note></para></listitem> |
| 11889 | <listitem><para>Manually configure a tap interface |
| 11890 | for your system.</para></listitem> |
| 11891 | <listitem><para>Run as root the script in |
| 11892 | <filename>scripts/runqemu-gen-tapdevs</filename>, |
| 11893 | which should generate a list of tap devices. |
| 11894 | This is the option typically chosen for |
| 11895 | Autobuilder-type environments. |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 11896 | <note><title>Notes</title> |
| 11897 | <itemizedlist> |
| 11898 | <listitem><para> |
| 11899 | Be sure to use an absolute path |
| 11900 | when calling this script |
| 11901 | with sudo. |
| 11902 | </para></listitem> |
| 11903 | <listitem><para> |
| 11904 | The package recipe |
| 11905 | <filename>qemu-helper-native</filename> |
| 11906 | is required to run this script. |
| 11907 | Build the package using the |
| 11908 | following command: |
| 11909 | <literallayout class='monospaced'> |
| 11910 | $ bitbake qemu-helper-native |
| 11911 | </literallayout> |
| 11912 | </para></listitem> |
| 11913 | </itemizedlist> |
| 11914 | </note> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 11915 | </para></listitem> |
| 11916 | </itemizedlist></para></listitem> |
| 11917 | <listitem><para><emphasis>Set the |
| 11918 | <filename>DISPLAY</filename> variable:</emphasis> |
| 11919 | You need to set this variable so that you have an X |
| 11920 | server available (e.g. start |
| 11921 | <filename>vncserver</filename> for a headless machine). |
| 11922 | </para></listitem> |
| 11923 | <listitem><para><emphasis>Be sure your host's firewall |
| 11924 | accepts incoming connections from |
| 11925 | 192.168.7.0/24:</emphasis> |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 11926 | Some of the tests (in particular DNF tests) start |
| 11927 | an HTTP server on a random high number port, |
| 11928 | which is used to serve files to the target. |
| 11929 | The DNF module serves |
| 11930 | <filename>${WORKDIR}/oe-rootfs-repo</filename> |
| 11931 | so it can run DNF channel commands. |
| 11932 | That means your host's firewall |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 11933 | must accept incoming connections from 192.168.7.0/24, |
| 11934 | which is the default IP range used for tap devices |
| 11935 | by <filename>runqemu</filename>.</para></listitem> |
Patrick Williams | f1e5d69 | 2016-03-30 15:21:19 -0500 | [diff] [blame] | 11936 | <listitem><para><emphasis>Be sure your host has the |
| 11937 | correct packages installed:</emphasis> |
| 11938 | Depending your host's distribution, you need |
| 11939 | to have the following packages installed: |
| 11940 | <itemizedlist> |
| 11941 | <listitem><para>Ubuntu and Debian: |
| 11942 | <filename>sysstat</filename> and |
| 11943 | <filename>iproute2</filename> |
| 11944 | </para></listitem> |
| 11945 | <listitem><para>OpenSUSE: |
| 11946 | <filename>sysstat</filename> and |
| 11947 | <filename>iproute2</filename> |
| 11948 | </para></listitem> |
| 11949 | <listitem><para>Fedora: |
| 11950 | <filename>sysstat</filename> and |
| 11951 | <filename>iproute</filename> |
| 11952 | </para></listitem> |
| 11953 | <listitem><para>CentOS: |
| 11954 | <filename>sysstat</filename> and |
| 11955 | <filename>iproute</filename> |
| 11956 | </para></listitem> |
| 11957 | </itemizedlist> |
| 11958 | </para></listitem> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 11959 | </itemizedlist> |
| 11960 | </para> |
| 11961 | |
| 11962 | <para> |
| 11963 | Once you start running the tests, the following happens: |
| 11964 | <orderedlist> |
| 11965 | <listitem><para>A copy of the root filesystem is written |
| 11966 | to <filename>${WORKDIR}/testimage</filename>. |
| 11967 | </para></listitem> |
| 11968 | <listitem><para>The image is booted under QEMU using the |
| 11969 | standard <filename>runqemu</filename> script. |
| 11970 | </para></listitem> |
| 11971 | <listitem><para>A default timeout of 500 seconds occurs |
| 11972 | to allow for the boot process to reach the login prompt. |
| 11973 | You can change the timeout period by setting |
| 11974 | <ulink url='&YOCTO_DOCS_REF_URL;#var-TEST_QEMUBOOT_TIMEOUT'><filename>TEST_QEMUBOOT_TIMEOUT</filename></ulink> |
| 11975 | in the <filename>local.conf</filename> file. |
| 11976 | </para></listitem> |
| 11977 | <listitem><para>Once the boot process is reached and the |
| 11978 | login prompt appears, the tests run. |
| 11979 | The full boot log is written to |
| 11980 | <filename>${WORKDIR}/testimage/qemu_boot_log</filename>. |
| 11981 | </para></listitem> |
| 11982 | <listitem><para>Each test module loads in the order found |
| 11983 | in <filename>TEST_SUITES</filename>. |
| 11984 | You can find the full output of the commands run over |
| 11985 | SSH in |
| 11986 | <filename>${WORKDIR}/testimgage/ssh_target_log</filename>. |
| 11987 | </para></listitem> |
| 11988 | <listitem><para>If no failures occur, the task running the |
| 11989 | tests ends successfully. |
| 11990 | You can find the output from the |
| 11991 | <filename>unittest</filename> in the task log at |
| 11992 | <filename>${WORKDIR}/temp/log.do_testimage</filename>. |
| 11993 | </para></listitem> |
| 11994 | </orderedlist> |
| 11995 | </para> |
| 11996 | </section> |
| 11997 | |
| 11998 | <section id='hardware-image-enabling-tests'> |
| 11999 | <title>Enabling Runtime Tests on Hardware</title> |
| 12000 | |
| 12001 | <para> |
| 12002 | The OpenEmbedded build system can run tests on real |
| 12003 | hardware, and for certain devices it can also deploy |
| 12004 | the image to be tested onto the device beforehand. |
| 12005 | </para> |
| 12006 | |
| 12007 | <para> |
| 12008 | For automated deployment, a "master image" is installed |
| 12009 | onto the hardware once as part of setup. |
| 12010 | Then, each time tests are to be run, the following |
| 12011 | occurs: |
| 12012 | <orderedlist> |
| 12013 | <listitem><para>The master image is booted into and |
| 12014 | used to write the image to be tested to |
| 12015 | a second partition. |
| 12016 | </para></listitem> |
| 12017 | <listitem><para>The device is then rebooted using an |
| 12018 | external script that you need to provide. |
| 12019 | </para></listitem> |
| 12020 | <listitem><para>The device boots into the image to be |
| 12021 | tested. |
| 12022 | </para></listitem> |
| 12023 | </orderedlist> |
| 12024 | </para> |
| 12025 | |
| 12026 | <para> |
| 12027 | When running tests (independent of whether the image |
| 12028 | has been deployed automatically or not), the device is |
| 12029 | expected to be connected to a network on a |
| 12030 | pre-determined IP address. |
| 12031 | You can either use static IP addresses written into |
| 12032 | the image, or set the image to use DHCP and have your |
| 12033 | DHCP server on the test network assign a known IP address |
| 12034 | based on the MAC address of the device. |
| 12035 | </para> |
| 12036 | |
| 12037 | <para> |
| 12038 | In order to run tests on hardware, you need to set |
| 12039 | <filename>TEST_TARGET</filename> to an appropriate value. |
| 12040 | For QEMU, you do not have to change anything, the default |
| 12041 | value is "QemuTarget". |
| 12042 | For running tests on hardware, the following options exist: |
| 12043 | <itemizedlist> |
| 12044 | <listitem><para><emphasis>"SimpleRemoteTarget":</emphasis> |
| 12045 | Choose "SimpleRemoteTarget" if you are going to |
| 12046 | run tests on a target system that is already |
| 12047 | running the image to be tested and is available |
| 12048 | on the network. |
| 12049 | You can use "SimpleRemoteTarget" in conjunction |
| 12050 | with either real hardware or an image running |
| 12051 | within a separately started QEMU or any |
| 12052 | other virtual machine manager. |
| 12053 | </para></listitem> |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 12054 | <listitem><para><emphasis>"SystemdbootTarget":</emphasis> |
| 12055 | Choose "SystemdbootTarget" if your hardware is |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 12056 | an EFI-based machine with |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 12057 | <filename>systemd-boot</filename> as bootloader and |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 12058 | <filename>core-image-testmaster</filename> |
| 12059 | (or something similar) is installed. |
| 12060 | Also, your hardware under test must be in a |
| 12061 | DHCP-enabled network that gives it the same IP |
| 12062 | address for each reboot.</para> |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 12063 | <para>If you choose "SystemdbootTarget", there are |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 12064 | additional requirements and considerations. |
| 12065 | See the |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 12066 | "<link linkend='selecting-systemdboottarget'>Selecting SystemdbootTarget</link>" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 12067 | section, which follows, for more information. |
| 12068 | </para></listitem> |
| 12069 | <listitem><para><emphasis>"BeagleBoneTarget":</emphasis> |
| 12070 | Choose "BeagleBoneTarget" if you are deploying |
| 12071 | images and running tests on the BeagleBone |
| 12072 | "Black" or original "White" hardware. |
| 12073 | For information on how to use these tests, see the |
| 12074 | comments at the top of the BeagleBoneTarget |
| 12075 | <filename>meta-yocto-bsp/lib/oeqa/controllers/beaglebonetarget.py</filename> |
| 12076 | file. |
| 12077 | </para></listitem> |
| 12078 | <listitem><para><emphasis>"EdgeRouterTarget":</emphasis> |
| 12079 | Choose "EdgeRouterTarget" is you are deploying |
| 12080 | images and running tests on the Ubiquiti Networks |
| 12081 | EdgeRouter Lite. |
| 12082 | For information on how to use these tests, see the |
| 12083 | comments at the top of the EdgeRouterTarget |
| 12084 | <filename>meta-yocto-bsp/lib/oeqa/controllers/edgeroutertarget.py</filename> |
| 12085 | file. |
| 12086 | </para></listitem> |
| 12087 | <listitem><para><emphasis>"GrubTarget":</emphasis> |
| 12088 | Choose the "supports deploying images and running |
| 12089 | tests on any generic PC that boots using GRUB. |
| 12090 | For information on how to use these tests, see the |
| 12091 | comments at the top of the GrubTarget |
| 12092 | <filename>meta-yocto-bsp/lib/oeqa/controllers/grubtarget.py</filename> |
| 12093 | file. |
| 12094 | </para></listitem> |
| 12095 | <listitem><para><emphasis>"<replaceable>your-target</replaceable>":</emphasis> |
| 12096 | Create your own custom target if you want to run |
| 12097 | tests when you are deploying images and running |
| 12098 | tests on a custom machine within your BSP layer. |
| 12099 | To do this, you need to add a Python unit that |
| 12100 | defines the target class under |
| 12101 | <filename>lib/oeqa/controllers/</filename> within |
| 12102 | your layer. |
| 12103 | You must also provide an empty |
| 12104 | <filename>__init__.py</filename>. |
| 12105 | For examples, see files in |
| 12106 | <filename>meta-yocto-bsp/lib/oeqa/controllers/</filename>. |
| 12107 | </para></listitem> |
| 12108 | </itemizedlist> |
| 12109 | </para> |
| 12110 | </section> |
| 12111 | |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 12112 | <section id='selecting-systemdboottarget'> |
| 12113 | <title>Selecting SystemdbootTarget</title> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 12114 | |
| 12115 | <para> |
| 12116 | If you did not set <filename>TEST_TARGET</filename> to |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 12117 | "SystemdbootTarget", then you do not need any information |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 12118 | in this section. |
| 12119 | You can skip down to the |
| 12120 | "<link linkend='qemu-image-running-tests'>Running Tests</link>" |
| 12121 | section. |
| 12122 | </para> |
| 12123 | |
| 12124 | <para> |
| 12125 | If you did set <filename>TEST_TARGET</filename> to |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 12126 | "SystemdbootTarget", you also need to perform a one-time |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 12127 | setup of your master image by doing the following: |
| 12128 | <orderedlist> |
| 12129 | <listitem><para><emphasis>Set <filename>EFI_PROVIDER</filename>:</emphasis> |
| 12130 | Be sure that <filename>EFI_PROVIDER</filename> |
| 12131 | is as follows: |
| 12132 | <literallayout class='monospaced'> |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 12133 | EFI_PROVIDER = "systemd-boot" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 12134 | </literallayout> |
| 12135 | </para></listitem> |
| 12136 | <listitem><para><emphasis>Build the master image:</emphasis> |
| 12137 | Build the <filename>core-image-testmaster</filename> |
| 12138 | image. |
| 12139 | The <filename>core-image-testmaster</filename> |
| 12140 | recipe is provided as an example for a |
| 12141 | "master" image and you can customize the image |
| 12142 | recipe as you would any other recipe. |
| 12143 | </para> |
| 12144 | <para>Here are the image recipe requirements: |
| 12145 | <itemizedlist> |
| 12146 | <listitem><para>Inherits |
| 12147 | <filename>core-image</filename> |
| 12148 | so that kernel modules are installed. |
| 12149 | </para></listitem> |
| 12150 | <listitem><para>Installs normal linux utilities |
| 12151 | not busybox ones (e.g. |
| 12152 | <filename>bash</filename>, |
| 12153 | <filename>coreutils</filename>, |
| 12154 | <filename>tar</filename>, |
| 12155 | <filename>gzip</filename>, and |
| 12156 | <filename>kmod</filename>). |
| 12157 | </para></listitem> |
| 12158 | <listitem><para>Uses a custom |
| 12159 | Initial RAM Disk (initramfs) image with a |
| 12160 | custom installer. |
| 12161 | A normal image that you can install usually |
| 12162 | creates a single rootfs partition. |
| 12163 | This image uses another installer that |
| 12164 | creates a specific partition layout. |
| 12165 | Not all Board Support Packages (BSPs) |
| 12166 | can use an installer. |
| 12167 | For such cases, you need to manually create |
| 12168 | the following partition layout on the |
| 12169 | target: |
| 12170 | <itemizedlist> |
| 12171 | <listitem><para>First partition mounted |
| 12172 | under <filename>/boot</filename>, |
| 12173 | labeled "boot". |
| 12174 | </para></listitem> |
| 12175 | <listitem><para>The main rootfs |
| 12176 | partition where this image gets |
| 12177 | installed, which is mounted under |
| 12178 | <filename>/</filename>. |
| 12179 | </para></listitem> |
| 12180 | <listitem><para>Another partition |
| 12181 | labeled "testrootfs" where test |
| 12182 | images get deployed. |
| 12183 | </para></listitem> |
| 12184 | </itemizedlist> |
| 12185 | </para></listitem> |
| 12186 | </itemizedlist> |
| 12187 | </para></listitem> |
| 12188 | <listitem><para><emphasis>Install image:</emphasis> |
| 12189 | Install the image that you just built on the target |
| 12190 | system. |
| 12191 | </para></listitem> |
| 12192 | </orderedlist> |
| 12193 | </para> |
| 12194 | |
| 12195 | <para> |
| 12196 | The final thing you need to do when setting |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 12197 | <filename>TEST_TARGET</filename> to "SystemdbootTarget" is |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 12198 | to set up the test image: |
| 12199 | <orderedlist> |
| 12200 | <listitem><para><emphasis>Set up your <filename>local.conf</filename> file:</emphasis> |
| 12201 | Make sure you have the following statements in |
| 12202 | your <filename>local.conf</filename> file: |
| 12203 | <literallayout class='monospaced'> |
| 12204 | IMAGE_FSTYPES += "tar.gz" |
| 12205 | INHERIT += "testimage" |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 12206 | TEST_TARGET = "SystemdbootTarget" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 12207 | TEST_TARGET_IP = "192.168.2.3" |
| 12208 | </literallayout> |
| 12209 | </para></listitem> |
| 12210 | <listitem><para><emphasis>Build your test image:</emphasis> |
| 12211 | Use BitBake to build the image: |
| 12212 | <literallayout class='monospaced'> |
| 12213 | $ bitbake core-image-sato |
| 12214 | </literallayout> |
| 12215 | </para></listitem> |
| 12216 | </orderedlist> |
| 12217 | </para> |
| 12218 | </section> |
| 12219 | |
| 12220 | <section id='power-control'> |
| 12221 | <title>Power Control</title> |
| 12222 | |
| 12223 | <para> |
| 12224 | For most hardware targets other than SimpleRemoteTarget, |
| 12225 | you can control power: |
| 12226 | <itemizedlist> |
| 12227 | <listitem><para> |
| 12228 | You can use |
| 12229 | <filename>TEST_POWERCONTROL_CMD</filename> |
| 12230 | together with |
| 12231 | <filename>TEST_POWERCONTROL_EXTRA_ARGS</filename> |
| 12232 | as a command that runs on the host and does power |
| 12233 | cycling. |
| 12234 | The test code passes one argument to that command: |
| 12235 | off, on or cycle (off then on). |
| 12236 | Here is an example that could appear in your |
| 12237 | <filename>local.conf</filename> file: |
| 12238 | <literallayout class='monospaced'> |
| 12239 | TEST_POWERCONTROL_CMD = "powercontrol.exp test 10.11.12.1 nuc1" |
| 12240 | </literallayout> |
| 12241 | In this example, the expect script does the |
| 12242 | following: |
| 12243 | <literallayout class='monospaced'> |
| 12244 | ssh test@10.11.12.1 "pyctl nuc1 <replaceable>arg</replaceable>" |
| 12245 | </literallayout> |
| 12246 | It then runs a Python script that controls power |
| 12247 | for a label called <filename>nuc1</filename>. |
| 12248 | <note> |
| 12249 | You need to customize |
| 12250 | <filename>TEST_POWERCONTROL_CMD</filename> |
| 12251 | and |
| 12252 | <filename>TEST_POWERCONTROL_EXTRA_ARGS</filename> |
| 12253 | for your own setup. |
| 12254 | The one requirement is that it accepts |
| 12255 | "on", "off", and "cycle" as the last argument. |
| 12256 | </note> |
| 12257 | </para></listitem> |
| 12258 | <listitem><para> |
| 12259 | When no command is defined, it connects to the |
| 12260 | device over SSH and uses the classic reboot command |
| 12261 | to reboot the device. |
| 12262 | Classic reboot is fine as long as the machine |
| 12263 | actually reboots (i.e. the SSH test has not |
| 12264 | failed). |
| 12265 | It is useful for scenarios where you have a simple |
| 12266 | setup, typically with a single board, and where |
| 12267 | some manual interaction is okay from time to time. |
| 12268 | </para></listitem> |
| 12269 | </itemizedlist> |
| 12270 | If you have no hardware to automatically perform power |
| 12271 | control but still wish to experiment with automated |
| 12272 | hardware testing, you can use the dialog-power-control |
| 12273 | script that shows a dialog prompting you to perform the |
| 12274 | required power action. |
| 12275 | This script requires either KDialog or Zenity to be |
| 12276 | installed. |
| 12277 | To use this script, set the |
| 12278 | <ulink url='&YOCTO_DOCS_REF_URL;#var-TEST_POWERCONTROL_CMD'><filename>TEST_POWERCONTROL_CMD</filename></ulink> |
| 12279 | variable as follows: |
| 12280 | <literallayout class='monospaced'> |
| 12281 | TEST_POWERCONTROL_CMD = "${COREBASE}/scripts/contrib/dialog-power-control" |
| 12282 | </literallayout> |
| 12283 | </para> |
| 12284 | </section> |
| 12285 | |
| 12286 | <section id='serial-console-connection'> |
| 12287 | <title>Serial Console Connection</title> |
| 12288 | |
| 12289 | <para> |
| 12290 | For test target classes requiring a serial console |
| 12291 | to interact with the bootloader (e.g. BeagleBoneTarget, |
| 12292 | EdgeRouterTarget, and GrubTarget), you need to |
| 12293 | specify a command to use to connect to the serial console |
| 12294 | of the target machine by using the |
| 12295 | <ulink url='&YOCTO_DOCS_REF_URL;#var-TEST_SERIALCONTROL_CMD'><filename>TEST_SERIALCONTROL_CMD</filename></ulink> |
| 12296 | variable and optionally the |
| 12297 | <ulink url='&YOCTO_DOCS_REF_URL;#var-TEST_SERIALCONTROL_EXTRA_ARGS'><filename>TEST_SERIALCONTROL_EXTRA_ARGS</filename></ulink> |
| 12298 | variable. |
| 12299 | </para> |
| 12300 | |
| 12301 | <para> |
| 12302 | These cases could be a serial terminal program if the |
| 12303 | machine is connected to a local serial port, or a |
| 12304 | <filename>telnet</filename> or |
| 12305 | <filename>ssh</filename> command connecting to a remote |
| 12306 | console server. |
| 12307 | Regardless of the case, the command simply needs to |
| 12308 | connect to the serial console and forward that connection |
| 12309 | to standard input and output as any normal terminal |
| 12310 | program does. |
| 12311 | For example, to use the picocom terminal program on |
| 12312 | serial device <filename>/dev/ttyUSB0</filename> |
| 12313 | at 115200bps, you would set the variable as follows: |
| 12314 | <literallayout class='monospaced'> |
| 12315 | TEST_SERIALCONTROL_CMD = "picocom /dev/ttyUSB0 -b 115200" |
| 12316 | </literallayout> |
| 12317 | For local devices where the serial port device disappears |
| 12318 | when the device reboots, an additional "serdevtry" wrapper |
| 12319 | script is provided. |
| 12320 | To use this wrapper, simply prefix the terminal command |
| 12321 | with |
| 12322 | <filename>${COREBASE}/scripts/contrib/serdevtry</filename>: |
| 12323 | <literallayout class='monospaced'> |
| 12324 | TEST_SERIALCONTROL_CMD = "${COREBASE}/scripts/contrib/serdevtry picocom -b |
| 12325 | 115200 /dev/ttyUSB0" |
| 12326 | </literallayout> |
| 12327 | </para> |
| 12328 | </section> |
| 12329 | </section> |
| 12330 | |
| 12331 | <section id="qemu-image-running-tests"> |
| 12332 | <title>Running Tests</title> |
| 12333 | |
| 12334 | <para> |
| 12335 | You can start the tests automatically or manually: |
| 12336 | <itemizedlist> |
| 12337 | <listitem><para><emphasis>Automatically running tests:</emphasis> |
| 12338 | To run the tests automatically after the |
| 12339 | OpenEmbedded build system successfully creates an image, |
| 12340 | first set the |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 12341 | <ulink url='&YOCTO_DOCS_REF_URL;#var-TESTIMAGE_AUTO'><filename>TESTIMAGE_AUTO</filename></ulink> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 12342 | variable to "1" in your <filename>local.conf</filename> |
| 12343 | file in the |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 12344 | <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink>: |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 12345 | <literallayout class='monospaced'> |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 12346 | TESTIMAGE_AUTO = "1" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 12347 | </literallayout> |
| 12348 | Next, build your image. |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 12349 | If the image successfully builds, the tests run: |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 12350 | <literallayout class='monospaced'> |
| 12351 | bitbake core-image-sato |
| 12352 | </literallayout></para></listitem> |
| 12353 | <listitem><para><emphasis>Manually running tests:</emphasis> |
| 12354 | To manually run the tests, first globally inherit the |
Patrick Williams | f1e5d69 | 2016-03-30 15:21:19 -0500 | [diff] [blame] | 12355 | <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] | 12356 | class by editing your <filename>local.conf</filename> |
| 12357 | file: |
| 12358 | <literallayout class='monospaced'> |
| 12359 | INHERIT += "testimage" |
| 12360 | </literallayout> |
| 12361 | Next, use BitBake to run the tests: |
| 12362 | <literallayout class='monospaced'> |
| 12363 | bitbake -c testimage <replaceable>image</replaceable> |
| 12364 | </literallayout></para></listitem> |
| 12365 | </itemizedlist> |
| 12366 | </para> |
| 12367 | |
| 12368 | <para> |
| 12369 | All test files reside in |
| 12370 | <filename>meta/lib/oeqa/runtime</filename> in the |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 12371 | <ulink url='&YOCTO_DOCS_REF_URL;#source-directory'>Source Directory</ulink>. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 12372 | A test name maps directly to a Python module. |
| 12373 | Each test module may contain a number of individual tests. |
| 12374 | Tests are usually grouped together by the area |
| 12375 | tested (e.g tests for systemd reside in |
| 12376 | <filename>meta/lib/oeqa/runtime/systemd.py</filename>). |
| 12377 | </para> |
| 12378 | |
| 12379 | <para> |
| 12380 | You can add tests to any layer provided you place them in the |
| 12381 | proper area and you extend |
| 12382 | <ulink url='&YOCTO_DOCS_REF_URL;#var-BBPATH'><filename>BBPATH</filename></ulink> |
| 12383 | in the <filename>local.conf</filename> file as normal. |
| 12384 | Be sure that tests reside in |
| 12385 | <filename><replaceable>layer</replaceable>/lib/oeqa/runtime</filename>. |
| 12386 | <note> |
| 12387 | Be sure that module names do not collide with module names |
| 12388 | used in the default set of test modules in |
| 12389 | <filename>meta/lib/oeqa/runtime</filename>. |
| 12390 | </note> |
| 12391 | </para> |
| 12392 | |
| 12393 | <para> |
| 12394 | You can change the set of tests run by appending or overriding |
| 12395 | <ulink url='&YOCTO_DOCS_REF_URL;#var-TEST_SUITES'><filename>TEST_SUITES</filename></ulink> |
| 12396 | variable in <filename>local.conf</filename>. |
| 12397 | Each name in <filename>TEST_SUITES</filename> represents a |
| 12398 | required test for the image. |
| 12399 | Test modules named within <filename>TEST_SUITES</filename> |
| 12400 | cannot be skipped even if a test is not suitable for an image |
| 12401 | (e.g. running the RPM tests on an image without |
| 12402 | <filename>rpm</filename>). |
| 12403 | Appending "auto" to <filename>TEST_SUITES</filename> causes the |
| 12404 | build system to try to run all tests that are suitable for the |
| 12405 | image (i.e. each test module may elect to skip itself). |
| 12406 | </para> |
| 12407 | |
| 12408 | <para> |
| 12409 | The order you list tests in <filename>TEST_SUITES</filename> |
| 12410 | is important and influences test dependencies. |
| 12411 | Consequently, tests that depend on other tests should be added |
| 12412 | after the test on which they depend. |
| 12413 | For example, since the <filename>ssh</filename> test |
| 12414 | depends on the |
| 12415 | <filename>ping</filename> test, "ssh" needs to come after |
| 12416 | "ping" in the list. |
| 12417 | The test class provides no re-ordering or dependency handling. |
| 12418 | <note> |
| 12419 | Each module can have multiple classes with multiple test |
| 12420 | methods. |
| 12421 | And, Python <filename>unittest</filename> rules apply. |
| 12422 | </note> |
| 12423 | </para> |
| 12424 | |
| 12425 | <para> |
| 12426 | Here are some things to keep in mind when running tests: |
| 12427 | <itemizedlist> |
| 12428 | <listitem><para>The default tests for the image are defined |
| 12429 | as: |
| 12430 | <literallayout class='monospaced'> |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 12431 | DEFAULT_TEST_SUITES_pn-<replaceable>image</replaceable> = "ping ssh df connman syslog xorg scp vnc date rpm dnf dmesg" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 12432 | </literallayout></para></listitem> |
| 12433 | <listitem><para>Add your own test to the list of the |
| 12434 | by using the following: |
| 12435 | <literallayout class='monospaced'> |
| 12436 | TEST_SUITES_append = " mytest" |
| 12437 | </literallayout></para></listitem> |
| 12438 | <listitem><para>Run a specific list of tests as follows: |
| 12439 | <literallayout class='monospaced'> |
| 12440 | TEST_SUITES = "test1 test2 test3" |
| 12441 | </literallayout> |
| 12442 | Remember, order is important. |
| 12443 | Be sure to place a test that is dependent on another test |
| 12444 | later in the order.</para></listitem> |
| 12445 | </itemizedlist> |
| 12446 | </para> |
| 12447 | </section> |
| 12448 | |
| 12449 | <section id="exporting-tests"> |
| 12450 | <title>Exporting Tests</title> |
| 12451 | |
| 12452 | <para> |
| 12453 | You can export tests so that they can run independently of |
| 12454 | the build system. |
| 12455 | Exporting tests is required if you want to be able to hand |
| 12456 | the test execution off to a scheduler. |
| 12457 | You can only export tests that are defined in |
| 12458 | <ulink url='&YOCTO_DOCS_REF_URL;#var-TEST_SUITES'><filename>TEST_SUITES</filename></ulink>. |
| 12459 | </para> |
| 12460 | |
| 12461 | <para> |
| 12462 | If your image is already built, make sure the following are set |
Brad Bishop | 37a0e4d | 2017-12-04 01:01:44 -0500 | [diff] [blame] | 12463 | in your <filename>local.conf</filename> file: |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 12464 | <literallayout class='monospaced'> |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 12465 | INHERIT +="testexport" |
Brad Bishop | 37a0e4d | 2017-12-04 01:01:44 -0500 | [diff] [blame] | 12466 | TEST_TARGET_IP = "<replaceable>IP-address-for-the-test-target</replaceable>" |
| 12467 | TEST_SERVER_IP = "<replaceable>IP-address-for-the-test-server</replaceable>" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 12468 | </literallayout> |
Brad Bishop | 37a0e4d | 2017-12-04 01:01:44 -0500 | [diff] [blame] | 12469 | You can then export the tests with the following BitBake |
| 12470 | command form: |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 12471 | <literallayout class='monospaced'> |
Brad Bishop | 37a0e4d | 2017-12-04 01:01:44 -0500 | [diff] [blame] | 12472 | $ bitbake <replaceable>image</replaceable> -c testexport |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 12473 | </literallayout> |
| 12474 | Exporting the tests places them in the |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 12475 | <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink> |
| 12476 | in |
Brad Bishop | 37a0e4d | 2017-12-04 01:01:44 -0500 | [diff] [blame] | 12477 | <filename>tmp/testexport/</filename><replaceable>image</replaceable>, |
| 12478 | which is controlled by the |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 12479 | <filename>TEST_EXPORT_DIR</filename> variable. |
| 12480 | </para> |
| 12481 | |
| 12482 | <para> |
| 12483 | You can now run the tests outside of the build environment: |
| 12484 | <literallayout class='monospaced'> |
Brad Bishop | 37a0e4d | 2017-12-04 01:01:44 -0500 | [diff] [blame] | 12485 | $ cd tmp/testexport/<replaceable>image</replaceable> |
| 12486 | $ ./runexported.py testdata.json |
| 12487 | </literallayout> |
| 12488 | </para> |
| 12489 | |
| 12490 | <para> |
| 12491 | Here is a complete example that shows IP addresses and uses |
| 12492 | the <filename>core-image-sato</filename> image: |
| 12493 | <literallayout class='monospaced'> |
| 12494 | INHERIT +="testexport" |
| 12495 | TEST_TARGET_IP = "192.168.7.2" |
| 12496 | TEST_SERVER_IP = "192.168.7.1" |
| 12497 | </literallayout> |
| 12498 | Use BitBake to export the tests: |
| 12499 | <literallayout class='monospaced'> |
| 12500 | $ bitbake core-image-sato -c testexport |
| 12501 | </literallayout> |
| 12502 | Run the tests outside of the build environment using the |
| 12503 | following: |
| 12504 | <literallayout class='monospaced'> |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 12505 | $ cd tmp/testexport/core-image-sato |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 12506 | $ ./runexported.py testdata.json |
| 12507 | </literallayout> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 12508 | </para> |
| 12509 | </section> |
| 12510 | |
| 12511 | <section id="qemu-image-writing-new-tests"> |
| 12512 | <title>Writing New Tests</title> |
| 12513 | |
| 12514 | <para> |
| 12515 | As mentioned previously, all new test files need to be in the |
| 12516 | proper place for the build system to find them. |
| 12517 | New tests for additional functionality outside of the core |
| 12518 | should be added to the layer that adds the functionality, in |
| 12519 | <filename><replaceable>layer</replaceable>/lib/oeqa/runtime</filename> |
| 12520 | (as long as |
| 12521 | <ulink url='&YOCTO_DOCS_REF_URL;#var-BBPATH'><filename>BBPATH</filename></ulink> |
| 12522 | is extended in the layer's |
| 12523 | <filename>layer.conf</filename> file as normal). |
| 12524 | Just remember the following: |
| 12525 | <itemizedlist> |
| 12526 | <listitem><para>Filenames need to map directly to test |
| 12527 | (module) names. |
| 12528 | </para></listitem> |
| 12529 | <listitem><para>Do not use module names that |
| 12530 | collide with existing core tests. |
| 12531 | </para></listitem> |
| 12532 | <listitem><para>Minimally, an empty |
| 12533 | <filename>__init__.py</filename> file must exist |
| 12534 | in the runtime directory. |
| 12535 | </para></listitem> |
| 12536 | </itemizedlist> |
| 12537 | </para> |
| 12538 | |
| 12539 | <para> |
| 12540 | To create a new test, start by copying an existing module |
| 12541 | (e.g. <filename>syslog.py</filename> or |
| 12542 | <filename>gcc.py</filename> are good ones to use). |
| 12543 | Test modules can use code from |
| 12544 | <filename>meta/lib/oeqa/utils</filename>, which are helper |
| 12545 | classes. |
| 12546 | </para> |
| 12547 | |
| 12548 | <note> |
| 12549 | Structure shell commands such that you rely on them and they |
| 12550 | return a single code for success. |
| 12551 | Be aware that sometimes you will need to parse the output. |
| 12552 | See the <filename>df.py</filename> and |
| 12553 | <filename>date.py</filename> modules for examples. |
| 12554 | </note> |
| 12555 | |
| 12556 | <para> |
| 12557 | You will notice that all test classes inherit |
| 12558 | <filename>oeRuntimeTest</filename>, which is found in |
| 12559 | <filename>meta/lib/oetest.py</filename>. |
| 12560 | This base class offers some helper attributes, which are |
| 12561 | described in the following sections: |
| 12562 | </para> |
| 12563 | |
| 12564 | <section id='qemu-image-writing-tests-class-methods'> |
| 12565 | <title>Class Methods</title> |
| 12566 | |
| 12567 | <para> |
| 12568 | Class methods are as follows: |
| 12569 | <itemizedlist> |
| 12570 | <listitem><para><emphasis><filename>hasPackage(pkg)</filename>:</emphasis> |
| 12571 | Returns "True" if <filename>pkg</filename> is in the |
| 12572 | installed package list of the image, which is based |
| 12573 | on the manifest file that is generated during the |
| 12574 | <filename>do_rootfs</filename> task. |
| 12575 | </para></listitem> |
| 12576 | <listitem><para><emphasis><filename>hasFeature(feature)</filename>:</emphasis> |
| 12577 | Returns "True" if the feature is in |
| 12578 | <ulink url='&YOCTO_DOCS_REF_URL;#var-IMAGE_FEATURES'><filename>IMAGE_FEATURES</filename></ulink> |
| 12579 | or |
| 12580 | <ulink url='&YOCTO_DOCS_REF_URL;#var-DISTRO_FEATURES'><filename>DISTRO_FEATURES</filename></ulink>. |
| 12581 | </para></listitem> |
| 12582 | </itemizedlist> |
| 12583 | </para> |
| 12584 | </section> |
| 12585 | |
| 12586 | <section id='qemu-image-writing-tests-class-attributes'> |
| 12587 | <title>Class Attributes</title> |
| 12588 | |
| 12589 | <para> |
| 12590 | Class attributes are as follows: |
| 12591 | <itemizedlist> |
| 12592 | <listitem><para><emphasis><filename>pscmd</filename>:</emphasis> |
| 12593 | Equals "ps -ef" if <filename>procps</filename> is |
| 12594 | installed in the image. |
| 12595 | Otherwise, <filename>pscmd</filename> equals |
| 12596 | "ps" (busybox). |
| 12597 | </para></listitem> |
| 12598 | <listitem><para><emphasis><filename>tc</filename>:</emphasis> |
| 12599 | The called test context, which gives access to the |
| 12600 | following attributes: |
| 12601 | <itemizedlist> |
| 12602 | <listitem><para><emphasis><filename>d</filename>:</emphasis> |
| 12603 | The BitBake datastore, which allows you to |
| 12604 | use stuff such as |
| 12605 | <filename>oeRuntimeTest.tc.d.getVar("VIRTUAL-RUNTIME_init_manager")</filename>. |
| 12606 | </para></listitem> |
| 12607 | <listitem><para><emphasis><filename>testslist</filename> and <filename>testsrequired</filename>:</emphasis> |
| 12608 | Used internally. |
| 12609 | The tests do not need these. |
| 12610 | </para></listitem> |
| 12611 | <listitem><para><emphasis><filename>filesdir</filename>:</emphasis> |
| 12612 | The absolute path to |
| 12613 | <filename>meta/lib/oeqa/runtime/files</filename>, |
| 12614 | which contains helper files for tests meant |
| 12615 | for copying on the target such as small |
| 12616 | files written in C for compilation. |
| 12617 | </para></listitem> |
| 12618 | <listitem><para><emphasis><filename>target</filename>:</emphasis> |
| 12619 | The target controller object used to deploy |
| 12620 | and start an image on a particular target |
| 12621 | (e.g. QemuTarget, SimpleRemote, and |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 12622 | SystemdbootTarget). |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 12623 | Tests usually use the following: |
| 12624 | <itemizedlist> |
| 12625 | <listitem><para><emphasis><filename>ip</filename>:</emphasis> |
| 12626 | The target's IP address. |
| 12627 | </para></listitem> |
| 12628 | <listitem><para><emphasis><filename>server_ip</filename>:</emphasis> |
| 12629 | The host's IP address, which is |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 12630 | usually used by the DNF test |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 12631 | suite. |
| 12632 | </para></listitem> |
| 12633 | <listitem><para><emphasis><filename>run(cmd, timeout=None)</filename>:</emphasis> |
| 12634 | The single, most used method. |
| 12635 | This command is a wrapper for: |
| 12636 | <filename>ssh root@host "cmd"</filename>. |
| 12637 | The command returns a tuple: |
| 12638 | (status, output), which are what |
| 12639 | their names imply - the return code |
| 12640 | of "cmd" and whatever output |
| 12641 | it produces. |
| 12642 | The optional timeout argument |
| 12643 | represents the number of seconds the |
| 12644 | test should wait for "cmd" to |
| 12645 | return. |
| 12646 | If the argument is "None", the |
| 12647 | test uses the default instance's |
| 12648 | timeout period, which is 300 |
| 12649 | seconds. |
| 12650 | If the argument is "0", the test |
| 12651 | runs until the command returns. |
| 12652 | </para></listitem> |
| 12653 | <listitem><para><emphasis><filename>copy_to(localpath, remotepath)</filename>:</emphasis> |
| 12654 | <filename>scp localpath root@ip:remotepath</filename>. |
| 12655 | </para></listitem> |
| 12656 | <listitem><para><emphasis><filename>copy_from(remotepath, localpath)</filename>:</emphasis> |
| 12657 | <filename>scp root@host:remotepath localpath</filename>. |
| 12658 | </para></listitem> |
| 12659 | </itemizedlist></para></listitem> |
| 12660 | </itemizedlist></para></listitem> |
| 12661 | </itemizedlist> |
| 12662 | </para> |
| 12663 | </section> |
| 12664 | |
| 12665 | <section id='qemu-image-writing-tests-instance-attributes'> |
| 12666 | <title>Instance Attributes</title> |
| 12667 | |
| 12668 | <para> |
| 12669 | A single instance attribute exists, which is |
| 12670 | <filename>target</filename>. |
| 12671 | The <filename>target</filename> instance attribute is |
| 12672 | identical to the class attribute of the same name, which |
| 12673 | is described in the previous section. |
| 12674 | This attribute exists as both an instance and class |
| 12675 | attribute so tests can use |
| 12676 | <filename>self.target.run(cmd)</filename> in instance |
| 12677 | methods instead of |
| 12678 | <filename>oeRuntimeTest.tc.target.run(cmd)</filename>. |
| 12679 | </para> |
| 12680 | </section> |
| 12681 | </section> |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 12682 | |
| 12683 | <section id='installing-packages-in-the-dut-without-the-package-manager'> |
| 12684 | <title>Installing Packages in the DUT Without the Package Manager</title> |
| 12685 | |
| 12686 | <para> |
| 12687 | When a test requires a package built by BitBake, it is possible |
| 12688 | to install that package. |
| 12689 | Installing the package does not require a package manager be |
| 12690 | installed in the device under test (DUT). |
| 12691 | It does, however, require an SSH connection and the target must |
| 12692 | be using the <filename>sshcontrol</filename> class. |
| 12693 | <note> |
| 12694 | This method uses <filename>scp</filename> to copy files |
| 12695 | from the host to the target, which causes permissions and |
| 12696 | special attributes to be lost. |
| 12697 | </note> |
| 12698 | </para> |
| 12699 | |
| 12700 | <para> |
| 12701 | A JSON file is used to define the packages needed by a test. |
| 12702 | This file must be in the same path as the file used to define |
| 12703 | the tests. |
| 12704 | Furthermore, the filename must map directly to the test |
| 12705 | module name with a <filename>.json</filename> extension. |
| 12706 | </para> |
| 12707 | |
| 12708 | <para> |
| 12709 | The JSON file must include an object with the test name as |
| 12710 | keys of an object or an array. |
| 12711 | This object (or array of objects) uses the following data: |
| 12712 | <itemizedlist> |
| 12713 | <listitem><para>"pkg" - A mandatory string that is the |
| 12714 | name of the package to be installed. |
| 12715 | </para></listitem> |
| 12716 | <listitem><para>"rm" - An optional boolean, which defaults |
| 12717 | to "false", that specifies to remove the package after |
| 12718 | the test. |
| 12719 | </para></listitem> |
| 12720 | <listitem><para>"extract" - An optional boolean, which |
| 12721 | defaults to "false", that specifies if the package must |
| 12722 | be extracted from the package format. |
| 12723 | When set to "true", the package is not automatically |
| 12724 | installed into the DUT. |
| 12725 | </para></listitem> |
| 12726 | </itemizedlist> |
| 12727 | </para> |
| 12728 | |
| 12729 | <para> |
| 12730 | Following is an example JSON file that handles test "foo" |
| 12731 | installing package "bar" and test "foobar" installing |
| 12732 | packages "foo" and "bar". |
| 12733 | Once the test is complete, the packages are removed from the |
| 12734 | DUT. |
| 12735 | <literallayout class='monospaced'> |
| 12736 | { |
| 12737 | "foo": { |
| 12738 | "pkg": "bar" |
| 12739 | }, |
| 12740 | "foobar": [ |
| 12741 | { |
| 12742 | "pkg": "foo", |
| 12743 | "rm": true |
| 12744 | }, |
| 12745 | { |
| 12746 | "pkg": "bar", |
| 12747 | "rm": true |
| 12748 | } |
| 12749 | ] |
| 12750 | } |
| 12751 | </literallayout> |
| 12752 | </para> |
| 12753 | </section> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 12754 | </section> |
| 12755 | |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 12756 | <section id='usingpoky-debugging-tools-and-techniques'> |
| 12757 | <title>Debugging Tools and Techniques</title> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 12758 | |
| 12759 | <para> |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 12760 | The exact method for debugging build failures depends on the nature |
| 12761 | of the problem and on the system's area from which the bug |
| 12762 | originates. |
| 12763 | Standard debugging practices such as comparison against the last |
| 12764 | known working version with examination of the changes and the |
| 12765 | re-application of steps to identify the one causing the problem are |
| 12766 | valid for the Yocto Project just as they are for any other system. |
| 12767 | Even though it is impossible to detail every possible potential |
| 12768 | failure, this section provides some general tips to aid in |
| 12769 | debugging given a variety of situations. |
| 12770 | <note><title>Tip</title> |
| 12771 | A useful feature for debugging is the error reporting tool. |
| 12772 | Configuring the Yocto Project to use this tool causes the |
| 12773 | OpenEmbedded build system to produce error reporting commands as |
| 12774 | part of the console output. |
| 12775 | You can enter the commands after the build completes to log |
| 12776 | error information into a common database, that can help you |
| 12777 | figure out what might be going wrong. |
| 12778 | For information on how to enable and use this feature, see the |
| 12779 | "<link linkend='using-the-error-reporting-tool'>Using the Error Reporting Tool</link>" |
| 12780 | section. |
| 12781 | </note> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 12782 | </para> |
| 12783 | |
| 12784 | <para> |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 12785 | The following list shows the debugging topics in the remainder of |
| 12786 | this section: |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 12787 | <itemizedlist> |
| 12788 | <listitem><para> |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 12789 | "<link linkend='dev-debugging-viewing-logs-from-failed-tasks'>Viewing Logs from Failed Tasks</link>" |
| 12790 | describes how to find and view logs from tasks that |
| 12791 | failed during the build process. |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 12792 | </para></listitem> |
| 12793 | <listitem><para> |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 12794 | "<link linkend='dev-debugging-viewing-variable-values'>Viewing Variable Values</link>" |
| 12795 | describes how to use the BitBake <filename>-e</filename> |
| 12796 | option to examine variable values after a recipe has been |
| 12797 | parsed. |
| 12798 | </para></listitem> |
| 12799 | <listitem><para> |
| 12800 | "<link linkend='viewing-package-information-with-oe-pkgdata-util'>Viewing Package Information with <filename>oe-pkgdata-util</filename></link>" |
| 12801 | describes how to use the |
| 12802 | <filename>oe-pkgdata-util</filename> utility to query |
| 12803 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PKGDATA_DIR'><filename>PKGDATA_DIR</filename></ulink> |
| 12804 | and display package-related information for built |
| 12805 | packages. |
| 12806 | </para></listitem> |
| 12807 | <listitem><para> |
| 12808 | "<link linkend='dev-viewing-dependencies-between-recipes-and-tasks'>Viewing Dependencies Between Recipes and Tasks</link>" |
| 12809 | describes how to use the BitBake <filename>-g</filename> |
| 12810 | option to display recipe dependency information used |
| 12811 | during the build. |
| 12812 | </para></listitem> |
| 12813 | <listitem><para> |
| 12814 | "<link linkend='dev-viewing-task-variable-dependencies'>Viewing Task Variable Dependencies</link>" |
| 12815 | describes how to use the |
| 12816 | <filename>bitbake-dumpsig</filename> command in |
| 12817 | conjunction with key subdirectories in the |
| 12818 | <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink> |
| 12819 | to determine variable dependencies. |
| 12820 | </para></listitem> |
| 12821 | <listitem><para> |
| 12822 | "<link linkend='dev-debugging-taskrunning'>Running Specific Tasks</link>" |
| 12823 | describes how to use several BitBake options (e.g. |
| 12824 | <filename>-c</filename>, <filename>-C</filename>, and |
| 12825 | <filename>-f</filename>) to run specific tasks in the |
| 12826 | build chain. |
| 12827 | It can be useful to run tasks "out-of-order" when trying |
| 12828 | isolate build issues. |
| 12829 | </para></listitem> |
| 12830 | <listitem><para> |
| 12831 | "<link linkend='dev-debugging-bitbake'>General BitBake Problems</link>" |
| 12832 | describes how to use BitBake's <filename>-D</filename> |
| 12833 | debug output option to reveal more about what BitBake is |
| 12834 | doing during the build. |
| 12835 | </para></listitem> |
| 12836 | <listitem><para> |
| 12837 | "<link linkend='dev-debugging-buildfile'>Building with No Dependencies</link>" |
| 12838 | describes how to use the BitBake <filename>-b</filename> |
| 12839 | option to build a recipe while ignoring dependencies. |
| 12840 | </para></listitem> |
| 12841 | <listitem><para> |
| 12842 | "<link linkend='recipe-logging-mechanisms'>Recipe Logging Mechanisms</link>" |
| 12843 | describes how to use the many recipe logging functions |
| 12844 | to produce debugging output and report errors and warnings. |
| 12845 | </para></listitem> |
| 12846 | <listitem><para> |
| 12847 | "<link linkend='debugging-parallel-make-races'>Debugging Parallel Make Races</link>" |
| 12848 | describes how to debug situations where the build consists |
| 12849 | of several parts that are run simultaneously and when the |
| 12850 | output or result of one part is not ready for use with a |
| 12851 | different part of the build that depends on that output. |
| 12852 | </para></listitem> |
| 12853 | <listitem><para> |
| 12854 | "<link linkend='platdev-gdb-remotedebug'>Debugging With the GNU Project Debugger (GDB) Remotely</link>" |
| 12855 | describes how to use GDB to allow you to examine running |
| 12856 | programs, which can help you fix problems. |
| 12857 | </para></listitem> |
| 12858 | <listitem><para> |
| 12859 | "<link linkend='debugging-with-the-gnu-project-debugger-gdb-on-the-target'>Debugging with the GNU Project Debugger (GDB) on the Target</link>" |
| 12860 | describes how to use GDB directly on target hardware for |
| 12861 | debugging. |
| 12862 | </para></listitem> |
| 12863 | <listitem><para> |
| 12864 | "<link linkend='dev-other-debugging-others'>Other Debugging Tips</link>" |
| 12865 | describes miscellaneous debugging tips that can be useful. |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 12866 | </para></listitem> |
| 12867 | </itemizedlist> |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 12868 | </para> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 12869 | |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 12870 | <section id='dev-debugging-viewing-logs-from-failed-tasks'> |
| 12871 | <title>Viewing Logs from Failed Tasks</title> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 12872 | |
| 12873 | <para> |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 12874 | You can find the log for a task in the file |
| 12875 | <filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-WORKDIR'><filename>WORKDIR</filename></ulink><filename>}/temp/log.do_</filename><replaceable>taskname</replaceable>. |
| 12876 | For example, the log for the |
| 12877 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-compile'><filename>do_compile</filename></ulink> |
| 12878 | task of the QEMU minimal image for the x86 machine |
| 12879 | (<filename>qemux86</filename>) might be in |
| 12880 | <filename>tmp/work/qemux86-poky-linux/core-image-minimal/1.0-r0/temp/log.do_compile</filename>. |
| 12881 | To see the commands |
| 12882 | <ulink url='&YOCTO_DOCS_REF_URL;#bitbake-term'>BitBake</ulink> |
| 12883 | ran to generate a log, look at the corresponding |
| 12884 | <filename>run.do_</filename><replaceable>taskname</replaceable> |
| 12885 | file in the same directory. |
| 12886 | </para> |
| 12887 | |
| 12888 | <para> |
| 12889 | <filename>log.do_</filename><replaceable>taskname</replaceable> |
| 12890 | and |
| 12891 | <filename>run.do_</filename><replaceable>taskname</replaceable> |
| 12892 | are actually symbolic links to |
| 12893 | <filename>log.do_</filename><replaceable>taskname</replaceable><filename>.</filename><replaceable>pid</replaceable> |
| 12894 | and |
| 12895 | <filename>log.run_</filename><replaceable>taskname</replaceable><filename>.</filename><replaceable>pid</replaceable>, |
| 12896 | where <replaceable>pid</replaceable> is the PID the task had |
| 12897 | when it ran. |
| 12898 | The symlinks always point to the files corresponding to the most |
| 12899 | recent run. |
| 12900 | </para> |
| 12901 | </section> |
| 12902 | |
| 12903 | <section id='dev-debugging-viewing-variable-values'> |
| 12904 | <title>Viewing Variable Values</title> |
| 12905 | |
| 12906 | <para> |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 12907 | Sometimes you need to know the value of a variable as a |
| 12908 | result of BitBake's parsing step. |
| 12909 | This could be because some unexpected behavior occurred |
| 12910 | in your project. |
| 12911 | Perhaps an attempt to |
| 12912 | <ulink url='&YOCTO_DOCS_BB_URL;#modifying-existing-variables'>modify a variable</ulink> |
| 12913 | did not work out as expected. |
| 12914 | </para> |
| 12915 | |
| 12916 | <para> |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 12917 | BitBake's <filename>-e</filename> option is used to display |
| 12918 | variable values after parsing. |
| 12919 | The following command displays the variable values after the |
| 12920 | configuration files (i.e. <filename>local.conf</filename>, |
| 12921 | <filename>bblayers.conf</filename>, |
| 12922 | <filename>bitbake.conf</filename> and so forth) have been |
| 12923 | parsed: |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 12924 | <literallayout class='monospaced'> |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 12925 | $ bitbake -e |
| 12926 | </literallayout> |
| 12927 | The following command displays variable values after a specific |
| 12928 | recipe has been parsed. |
| 12929 | The variables include those from the configuration as well: |
| 12930 | <literallayout class='monospaced'> |
| 12931 | $ bitbake -e recipename |
| 12932 | </literallayout> |
| 12933 | <note><para> |
| 12934 | Each recipe has its own private set of variables |
| 12935 | (datastore). |
| 12936 | Internally, after parsing the configuration, a copy of the |
| 12937 | resulting datastore is made prior to parsing each recipe. |
| 12938 | This copying implies that variables set in one recipe will |
| 12939 | not be visible to other recipes.</para> |
| 12940 | |
| 12941 | <para>Likewise, each task within a recipe gets a private |
| 12942 | datastore based on the recipe datastore, which means that |
| 12943 | variables set within one task will not be visible to |
| 12944 | other tasks.</para> |
| 12945 | </note> |
| 12946 | </para> |
| 12947 | |
| 12948 | <para> |
| 12949 | In the output of <filename>bitbake -e</filename>, each |
| 12950 | variable is preceded by a description of how the variable |
| 12951 | got its value, including temporary values that were later |
| 12952 | overriden. |
| 12953 | This description also includes variable flags (varflags) set on |
| 12954 | the variable. |
| 12955 | The output can be very helpful during debugging. |
| 12956 | </para> |
| 12957 | |
| 12958 | <para> |
| 12959 | Variables that are exported to the environment are preceded by |
| 12960 | <filename>export</filename> in the output of |
| 12961 | <filename>bitbake -e</filename>. |
| 12962 | See the following example: |
| 12963 | <literallayout class='monospaced'> |
| 12964 | export CC="i586-poky-linux-gcc -m32 -march=i586 --sysroot=/home/ulf/poky/build/tmp/sysroots/qemux86" |
| 12965 | </literallayout> |
| 12966 | </para> |
| 12967 | |
| 12968 | <para> |
| 12969 | In addition to variable values, the output of the |
| 12970 | <filename>bitbake -e</filename> and |
| 12971 | <filename>bitbake -e</filename> <replaceable>recipe</replaceable> |
| 12972 | commands includes the following information: |
| 12973 | <itemizedlist> |
| 12974 | <listitem><para> |
| 12975 | The output starts with a tree listing all configuration |
| 12976 | files and classes included globally, recursively listing |
| 12977 | the files they include or inherit in turn. |
| 12978 | Much of the behavior of the OpenEmbedded build system |
| 12979 | (including the behavior of the |
| 12980 | <ulink url='&YOCTO_DOCS_REF_URL;#normal-recipe-build-tasks'>normal recipe build tasks</ulink>) |
| 12981 | is implemented in the |
| 12982 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-base'><filename>base</filename></ulink> |
| 12983 | class and the classes it inherits, rather than being |
| 12984 | built into BitBake itself. |
| 12985 | </para></listitem> |
| 12986 | <listitem><para> |
| 12987 | After the variable values, all functions appear in the |
| 12988 | output. |
| 12989 | For shell functions, variables referenced within the |
| 12990 | function body are expanded. |
| 12991 | If a function has been modified using overrides or |
| 12992 | using override-style operators like |
| 12993 | <filename>_append</filename> and |
| 12994 | <filename>_prepend</filename>, then the final assembled |
| 12995 | function body appears in the output. |
| 12996 | </para></listitem> |
| 12997 | </itemizedlist> |
| 12998 | </para> |
| 12999 | </section> |
| 13000 | |
| 13001 | <section id='viewing-package-information-with-oe-pkgdata-util'> |
| 13002 | <title>Viewing Package Information with <filename>oe-pkgdata-util</filename></title> |
| 13003 | |
| 13004 | <para> |
| 13005 | You can use the <filename>oe-pkgdata-util</filename> |
| 13006 | command-line utility to query |
| 13007 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PKGDATA_DIR'><filename>PKGDATA_DIR</filename></ulink> |
| 13008 | and display various package-related information. |
| 13009 | When you use the utility, you must use it to view information |
| 13010 | on packages that have already been built. |
| 13011 | </para> |
| 13012 | |
| 13013 | <para> |
| 13014 | Following are a few of the available |
| 13015 | <filename>oe-pkgdata-util</filename> subcommands. |
| 13016 | <note> |
| 13017 | You can use the standard * and ? globbing wildcards as part |
| 13018 | of package names and paths. |
| 13019 | </note> |
| 13020 | <itemizedlist> |
| 13021 | <listitem><para> |
| 13022 | <filename>oe-pkgdata-util list-pkgs [</filename><replaceable>pattern</replaceable><filename>]</filename>: |
| 13023 | Lists all packages that have been built, optionally |
| 13024 | limiting the match to packages that match |
| 13025 | <replaceable>pattern</replaceable>. |
| 13026 | </para></listitem> |
| 13027 | <listitem><para> |
| 13028 | <filename>oe-pkgdata-util list-pkg-files </filename><replaceable>package</replaceable><filename> ...</filename>: |
| 13029 | Lists the files and directories contained in the given |
| 13030 | packages. |
| 13031 | <note> |
| 13032 | <para> |
| 13033 | A different way to view the contents of a package is |
| 13034 | to look at the |
| 13035 | <filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-WORKDIR'><filename>WORKDIR</filename></ulink><filename>}/packages-split</filename> |
| 13036 | directory of the recipe that generates the |
| 13037 | package. |
| 13038 | This directory is created by the |
| 13039 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-package'><filename>do_package</filename></ulink> |
| 13040 | task and has one subdirectory for each package the |
| 13041 | recipe generates, which contains the files stored in |
| 13042 | that package.</para> |
| 13043 | <para> |
| 13044 | If you want to inspect the |
| 13045 | <filename>${WORKDIR}/packages-split</filename> |
| 13046 | directory, make sure that |
| 13047 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-rm-work'><filename>rm_work</filename></ulink> |
| 13048 | is not enabled when you build the recipe. |
| 13049 | </para> |
| 13050 | </note> |
| 13051 | </para></listitem> |
| 13052 | <listitem><para> |
| 13053 | <filename>oe-pkgdata-util find-path </filename><replaceable>path</replaceable><filename> ...</filename>: |
| 13054 | Lists the names of the packages that contain the given |
| 13055 | paths. |
| 13056 | For example, the following tells us that |
| 13057 | <filename>/usr/share/man/man1/make.1</filename> |
| 13058 | is contained in the <filename>make-doc</filename> |
| 13059 | package: |
| 13060 | <literallayout class='monospaced'> |
| 13061 | $ oe-pkgdata-util find-path /usr/share/man/man1/make.1 |
| 13062 | make-doc: /usr/share/man/man1/make.1 |
| 13063 | </literallayout> |
| 13064 | </para></listitem> |
| 13065 | <listitem><para> |
| 13066 | <filename>oe-pkgdata-util lookup-recipe </filename><replaceable>package</replaceable><filename> ...</filename>: |
| 13067 | Lists the name of the recipes that |
| 13068 | produce the given packages. |
| 13069 | </para></listitem> |
| 13070 | </itemizedlist> |
| 13071 | </para> |
| 13072 | |
| 13073 | <para> |
| 13074 | For more information on the <filename>oe-pkgdata-util</filename> |
| 13075 | command, use the help facility: |
| 13076 | <literallayout class='monospaced'> |
| 13077 | $ oe-pkgdata-util ‐‐help |
| 13078 | $ oe-pkgdata-util <replaceable>subcommand</replaceable> --help |
| 13079 | </literallayout> |
| 13080 | </para> |
| 13081 | </section> |
| 13082 | |
| 13083 | <section id='dev-viewing-dependencies-between-recipes-and-tasks'> |
| 13084 | <title>Viewing Dependencies Between Recipes and Tasks</title> |
| 13085 | |
| 13086 | <para> |
| 13087 | Sometimes it can be hard to see why BitBake wants to build other |
| 13088 | recipes before the one you have specified. |
| 13089 | Dependency information can help you understand why a recipe is |
| 13090 | built. |
| 13091 | </para> |
| 13092 | |
| 13093 | <para> |
| 13094 | To generate dependency information for a recipe, run the |
| 13095 | following command: |
| 13096 | <literallayout class='monospaced'> |
| 13097 | $ bitbake -g <replaceable>recipename</replaceable> |
| 13098 | </literallayout> |
| 13099 | This command writes the following files in the current |
| 13100 | directory: |
| 13101 | <itemizedlist> |
| 13102 | <listitem><para> |
| 13103 | <filename>pn-buildlist</filename>: A list of |
| 13104 | recipes/targets involved in building |
| 13105 | <replaceable>recipename</replaceable>. |
| 13106 | "Involved" here means that at least one task from the |
| 13107 | recipe needs to run when building |
| 13108 | <replaceable>recipename</replaceable> from scratch. |
| 13109 | Targets that are in |
| 13110 | <ulink url='&YOCTO_DOCS_REF_URL;#var-ASSUME_PROVIDED'><filename>ASSUME_PROVIDED</filename></ulink> |
| 13111 | are not listed. |
| 13112 | </para></listitem> |
| 13113 | <listitem><para> |
| 13114 | <filename>task-depends.dot</filename>: A graph showing |
| 13115 | dependencies between tasks. |
| 13116 | </para></listitem> |
| 13117 | </itemizedlist> |
| 13118 | </para> |
| 13119 | |
| 13120 | <para> |
| 13121 | The graphs are in |
| 13122 | <ulink url='https://en.wikipedia.org/wiki/DOT_%28graph_description_language%29'>DOT</ulink> |
| 13123 | format and can be converted to images (e.g. using the |
| 13124 | <filename>dot</filename> tool from |
| 13125 | <ulink url='http://www.graphviz.org/'>Graphviz</ulink>). |
| 13126 | <note><title>Notes</title> |
| 13127 | <itemizedlist> |
| 13128 | <listitem><para> |
| 13129 | DOT files use a plain text format. |
| 13130 | The graphs generated using the |
| 13131 | <filename>bitbake -g</filename> command are often so |
| 13132 | large as to be difficult to read without special |
| 13133 | pruning (e.g. with Bitbake's |
| 13134 | <filename>-I</filename> option) and processing. |
| 13135 | Despite the form and size of the graphs, the |
| 13136 | corresponding <filename>.dot</filename> files can |
| 13137 | still be possible to read and provide useful |
| 13138 | information. |
| 13139 | </para> |
| 13140 | |
| 13141 | <para>As an example, the |
| 13142 | <filename>task-depends.dot</filename> file contains |
| 13143 | lines such as the following: |
| 13144 | <literallayout class='monospaced'> |
| 13145 | "libxslt.do_configure" -> "libxml2.do_populate_sysroot" |
| 13146 | </literallayout> |
| 13147 | The above example line reveals that the |
| 13148 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-configure'><filename>do_configure</filename></ulink> |
| 13149 | task in <filename>libxslt</filename> depends on the |
| 13150 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-populate_sysroot'><filename>do_populate_sysroot</filename></ulink> |
| 13151 | task in <filename>libxml2</filename>, which is a |
| 13152 | normal |
| 13153 | <ulink url='&YOCTO_DOCS_REF_URL;#var-DEPENDS'><filename>DEPENDS</filename></ulink> |
| 13154 | dependency between the two recipes. |
| 13155 | </para></listitem> |
| 13156 | <listitem><para> |
| 13157 | For an example of how <filename>.dot</filename> |
| 13158 | files can be processed, see the |
| 13159 | <filename>scripts/contrib/graph-tool</filename> |
| 13160 | Python script, which finds and displays paths |
| 13161 | between graph nodes. |
| 13162 | </para></listitem> |
| 13163 | </itemizedlist> |
| 13164 | </note> |
| 13165 | </para> |
| 13166 | |
| 13167 | <para> |
| 13168 | You can use a different method to view dependency information |
| 13169 | by using the following command: |
| 13170 | <literallayout class='monospaced'> |
| 13171 | $ bitbake -g -u taskexp <replaceable>recipename</replaceable> |
| 13172 | </literallayout> |
| 13173 | This command displays a GUI window from which you can view |
| 13174 | build-time and runtime dependencies for the recipes involved in |
| 13175 | building <replaceable>recipename</replaceable>. |
| 13176 | </para> |
| 13177 | </section> |
| 13178 | |
| 13179 | <section id='dev-viewing-task-variable-dependencies'> |
| 13180 | <title>Viewing Task Variable Dependencies</title> |
| 13181 | |
| 13182 | <para> |
| 13183 | As mentioned in the |
| 13184 | "<ulink url='&YOCTO_DOCS_BB_URL;#checksums'>Checksums (Signatures)</ulink>" |
| 13185 | section of the BitBake User Manual, BitBake tries to |
| 13186 | automatically determine what variables a task depends on so |
| 13187 | that it can rerun the task if any values of the variables |
| 13188 | change. |
| 13189 | This determination is usually reliable. |
| 13190 | However, if you do things like construct variable names at |
| 13191 | runtime, then you might have to manually declare dependencies |
| 13192 | on those variables using <filename>vardeps</filename> as |
| 13193 | described in the |
| 13194 | "<ulink url='&YOCTO_DOCS_BB_URL;#variable-flags'>Variable Flags</ulink>" |
| 13195 | section of the BitBake User Manual. |
| 13196 | </para> |
| 13197 | |
| 13198 | <para> |
| 13199 | If you are unsure whether a variable dependency is being |
| 13200 | picked up automatically for a given task, you can list the |
| 13201 | variable dependencies BitBake has determined by doing the |
| 13202 | following: |
| 13203 | <orderedlist> |
| 13204 | <listitem><para> |
| 13205 | Build the recipe containing the task: |
| 13206 | <literallayout class='monospaced'> |
| 13207 | $ bitbake <replaceable>recipename</replaceable> |
| 13208 | </literallayout> |
| 13209 | </para></listitem> |
| 13210 | <listitem><para> |
| 13211 | Inside the |
| 13212 | <ulink url='&YOCTO_DOCS_REF_URL;#var-STAMPS_DIR'><filename>STAMPS_DIR</filename></ulink> |
| 13213 | directory, find the signature data |
| 13214 | (<filename>sigdata</filename>) file that corresponds |
| 13215 | to the task. |
| 13216 | The <filename>sigdata</filename> files contain a pickled |
| 13217 | Python database of all the metadata that went into |
| 13218 | creating the input checksum for the task. |
| 13219 | As an example, for the |
| 13220 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-fetch'><filename>do_fetch</filename></ulink> |
| 13221 | task of the <filename>db</filename> recipe, the |
| 13222 | <filename>sigdata</filename> file might be found in the |
| 13223 | following location: |
| 13224 | <literallayout class='monospaced'> |
| 13225 | ${BUILDDIR}/tmp/stamps/i586-poky-linux/db/6.0.30-r1.do_fetch.sigdata.7c048c18222b16ff0bcee2000ef648b1 |
| 13226 | </literallayout> |
| 13227 | For tasks that are accelerated through the shared state |
| 13228 | (<ulink url='&YOCTO_DOCS_OM_URL;#shared-state-cache'>sstate</ulink>) |
| 13229 | cache, an additional <filename>siginfo</filename> file |
| 13230 | is written into |
| 13231 | <ulink url='&YOCTO_DOCS_REF_URL;#var-SSTATE_DIR'><filename>SSTATE_DIR</filename></ulink> |
| 13232 | along with the cached task output. |
| 13233 | The <filename>siginfo</filename> files contain exactly |
| 13234 | the same information as <filename>sigdata</filename> |
| 13235 | files. |
| 13236 | </para></listitem> |
| 13237 | <listitem><para> |
| 13238 | Run <filename>bitbake-dumpsig</filename> on the |
| 13239 | <filename>sigdata</filename> or |
| 13240 | <filename>siginfo</filename> file. |
| 13241 | Here is an example: |
| 13242 | <literallayout class='monospaced'> |
| 13243 | $ bitbake-dumpsig ${BUILDDIR}/tmp/stamps/i586-poky-linux/db/6.0.30-r1.do_fetch.sigdata.7c048c18222b16ff0bcee2000ef648b1 |
| 13244 | </literallayout> |
| 13245 | In the output of the above command, you will find a |
| 13246 | line like the following, which lists all the (inferred) |
| 13247 | variable dependencies for the task. |
| 13248 | This list also includes indirect dependencies from |
| 13249 | variables depending on other variables, recursively. |
| 13250 | <literallayout class='monospaced'> |
| 13251 | Task dependencies: ['PV', 'SRCREV', 'SRC_URI', 'SRC_URI[md5sum]', 'SRC_URI[sha256sum]', 'base_do_fetch'] |
| 13252 | </literallayout> |
| 13253 | <note> |
| 13254 | Functions (e.g. <filename>base_do_fetch</filename>) |
| 13255 | also count as variable dependencies. |
| 13256 | These functions in turn depend on the variables they |
| 13257 | reference. |
| 13258 | </note> |
| 13259 | The output of <filename>bitbake-dumpsig</filename> also |
| 13260 | includes the value each variable had, a list of |
| 13261 | dependencies for each variable, and |
| 13262 | <ulink url='&YOCTO_DOCS_BB_URL;#var-BB_HASHBASE_WHITELIST'><filename>BB_HASHBASE_WHITELIST</filename></ulink> |
| 13263 | information. |
| 13264 | </para></listitem> |
| 13265 | </orderedlist> |
| 13266 | </para> |
| 13267 | |
| 13268 | <para> |
| 13269 | There is also a <filename>bitbake-diffsigs</filename> command |
| 13270 | for comparing two <filename>siginfo</filename> or |
| 13271 | <filename>sigdata</filename> files. |
| 13272 | This command can be helpful when trying to figure out what |
| 13273 | changed between two versions of a task. |
| 13274 | If you call <filename>bitbake-diffsigs</filename> with just one |
| 13275 | file, the command behaves like |
| 13276 | <filename>bitbake-dumpsig</filename>. |
| 13277 | </para> |
| 13278 | |
| 13279 | <para> |
| 13280 | You can also use BitBake to dump out the signature construction |
| 13281 | information without executing tasks by using either of the |
| 13282 | following BitBake command-line options: |
| 13283 | <literallayout class='monospaced'> |
| 13284 | ‐‐dump-signatures=<replaceable>SIGNATURE_HANDLER</replaceable> |
| 13285 | -S <replaceable>SIGNATURE_HANDLER</replaceable> |
| 13286 | </literallayout> |
| 13287 | <note> |
| 13288 | Two common values for |
| 13289 | <replaceable>SIGNATURE_HANDLER</replaceable> are "none" and |
| 13290 | "printdiff", which dump only the signature or compare the |
| 13291 | dumped signature with the cached one, respectively. |
| 13292 | </note> |
| 13293 | Using BitBake with either of these options causes BitBake to |
| 13294 | dump out <filename>sigdata</filename> files in the |
| 13295 | <filename>stamps</filename> directory for every task it would |
| 13296 | have executed instead of building the specified target package. |
| 13297 | </para> |
| 13298 | </section> |
| 13299 | |
| 13300 | <section id='dev-viewing-metadata-used-to-create-the-input-signature-of-a-shared-state-task'> |
| 13301 | <title>Viewing Metadata Used to Create the Input Signature of a Shared State Task</title> |
| 13302 | |
| 13303 | <para> |
| 13304 | Seeing what metadata went into creating the input signature |
| 13305 | of a shared state (sstate) task can be a useful debugging |
| 13306 | aid. |
| 13307 | This information is available in signature information |
| 13308 | (<filename>siginfo</filename>) files in |
| 13309 | <ulink url='&YOCTO_DOCS_REF_URL;#var-SSTATE_DIR'><filename>SSTATE_DIR</filename></ulink>. |
| 13310 | For information on how to view and interpret information in |
| 13311 | <filename>siginfo</filename> files, see the |
| 13312 | "<link linkend='dev-viewing-task-variable-dependencies'>Viewing Task Variable Dependencies</link>" |
| 13313 | section. |
| 13314 | </para> |
| 13315 | |
| 13316 | <para> |
| 13317 | For conceptual information on shared state, see the |
| 13318 | "<ulink url='&YOCTO_DOCS_OM_URL;#shared-state'>Shared State</ulink>" |
| 13319 | section in the Yocto Project Overview and Concepts Manual. |
| 13320 | </para> |
| 13321 | </section> |
| 13322 | |
| 13323 | <section id='dev-invalidating-shared-state-to-force-a-task-to-run'> |
| 13324 | <title>Invalidating Shared State to Force a Task to Run</title> |
| 13325 | |
| 13326 | <para> |
| 13327 | The OpenEmbedded build system uses |
| 13328 | <ulink url='&YOCTO_DOCS_OM_URL;#overview-checksums'>checksums</ulink> |
| 13329 | and |
| 13330 | <ulink url='&YOCTO_DOCS_OM_URL;#shared-state'>shared state</ulink> |
| 13331 | cache to avoid unnecessarily rebuilding tasks. |
| 13332 | Collectively, this scheme is known as "shared state code." |
| 13333 | </para> |
| 13334 | |
| 13335 | <para> |
| 13336 | As with all schemes, this one has some drawbacks. |
| 13337 | It is possible that you could make implicit changes to your |
| 13338 | code that the checksum calculations do not take into |
| 13339 | account. |
| 13340 | These implicit changes affect a task's output but do not |
| 13341 | trigger the shared state code into rebuilding a recipe. |
| 13342 | Consider an example during which a tool changes its output. |
| 13343 | Assume that the output of <filename>rpmdeps</filename> |
| 13344 | changes. |
| 13345 | The result of the change should be that all the |
| 13346 | <filename>package</filename> and |
| 13347 | <filename>package_write_rpm</filename> shared state cache |
| 13348 | items become invalid. |
| 13349 | However, because the change to the output is |
| 13350 | external to the code and therefore implicit, |
| 13351 | the associated shared state cache items do not become |
| 13352 | invalidated. |
| 13353 | In this case, the build process uses the cached items |
| 13354 | rather than running the task again. |
| 13355 | Obviously, these types of implicit changes can cause |
| 13356 | problems. |
| 13357 | </para> |
| 13358 | |
| 13359 | <para> |
| 13360 | To avoid these problems during the build, you need to |
| 13361 | understand the effects of any changes you make. |
| 13362 | Realize that changes you make directly to a function |
| 13363 | are automatically factored into the checksum calculation. |
| 13364 | Thus, these explicit changes invalidate the associated |
| 13365 | area of shared state cache. |
| 13366 | However, you need to be aware of any implicit changes that |
| 13367 | are not obvious changes to the code and could affect |
| 13368 | the output of a given task. |
| 13369 | </para> |
| 13370 | |
| 13371 | <para> |
| 13372 | When you identify an implicit change, you can easily |
| 13373 | take steps to invalidate the cache and force the tasks |
| 13374 | to run. |
| 13375 | The steps you can take are as simple as changing a |
| 13376 | function's comments in the source code. |
| 13377 | For example, to invalidate package shared state files, |
| 13378 | change the comment statements of |
| 13379 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-package'><filename>do_package</filename></ulink> |
| 13380 | or the comments of one of the functions it calls. |
| 13381 | Even though the change is purely cosmetic, it causes the |
| 13382 | checksum to be recalculated and forces the build system to |
| 13383 | run the task again. |
| 13384 | <note> |
| 13385 | For an example of a commit that makes a cosmetic |
| 13386 | change to invalidate shared state, see this |
| 13387 | <ulink url='&YOCTO_GIT_URL;/cgit.cgi/poky/commit/meta/classes/package.bbclass?id=737f8bbb4f27b4837047cb9b4fbfe01dfde36d54'>commit</ulink>. |
| 13388 | </note> |
| 13389 | </para> |
| 13390 | </section> |
| 13391 | |
| 13392 | <section id='dev-debugging-taskrunning'> |
| 13393 | <title>Running Specific Tasks</title> |
| 13394 | |
| 13395 | <para> |
| 13396 | Any given recipe consists of a set of tasks. |
| 13397 | The standard BitBake behavior in most cases is: |
| 13398 | <filename>do_fetch</filename>, |
| 13399 | <filename>do_unpack</filename>, |
| 13400 | <filename>do_patch</filename>, |
| 13401 | <filename>do_configure</filename>, |
| 13402 | <filename>do_compile</filename>, |
| 13403 | <filename>do_install</filename>, |
| 13404 | <filename>do_package</filename>, |
| 13405 | <filename>do_package_write_*</filename>, and |
| 13406 | <filename>do_build</filename>. |
| 13407 | The default task is <filename>do_build</filename> and any tasks |
| 13408 | on which it depends build first. |
| 13409 | Some tasks, such as <filename>do_devshell</filename>, are not |
| 13410 | part of the default build chain. |
| 13411 | If you wish to run a task that is not part of the default build |
| 13412 | chain, you can use the <filename>-c</filename> option in |
| 13413 | BitBake. |
| 13414 | Here is an example: |
| 13415 | <literallayout class='monospaced'> |
| 13416 | $ bitbake matchbox-desktop -c devshell |
| 13417 | </literallayout> |
| 13418 | </para> |
| 13419 | |
| 13420 | <para> |
| 13421 | The <filename>-c</filename> option respects task dependencies, |
| 13422 | which means that all other tasks (including tasks from other |
| 13423 | recipes) that the specified task depends on will be run before |
| 13424 | the task. |
| 13425 | Even when you manually specify a task to run with |
| 13426 | <filename>-c</filename>, BitBake will only run the task if it |
| 13427 | considers it "out of date". |
| 13428 | See the |
| 13429 | "<ulink url='&YOCTO_DOCS_OM_URL;#stamp-files-and-the-rerunning-of-tasks'>Stamp Files and the Rerunning of Tasks</ulink>" |
| 13430 | section in the Yocto Project Overview and Concepts Manual for |
| 13431 | how BitBake determines whether a task is "out of date". |
| 13432 | </para> |
| 13433 | |
| 13434 | <para> |
| 13435 | If you want to force an up-to-date task to be rerun (e.g. |
| 13436 | because you made manual modifications to the recipe's |
| 13437 | <ulink url='&YOCTO_DOCS_REF_URL;#var-WORKDIR'><filename>WORKDIR</filename></ulink> |
| 13438 | that you want to try out), then you can use the |
| 13439 | <filename>-f</filename> option. |
| 13440 | <note> |
| 13441 | The reason <filename>-f</filename> is never required when |
| 13442 | running the |
| 13443 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-devshell'><filename>do_devshell</filename></ulink> |
| 13444 | task is because the |
| 13445 | <filename>[</filename><ulink url='&YOCTO_DOCS_BB_URL;#variable-flags'><filename>nostamp</filename></ulink><filename>]</filename> |
| 13446 | variable flag is already set for the task. |
| 13447 | </note> |
| 13448 | The following example shows one way you can use the |
| 13449 | <filename>-f</filename> option: |
| 13450 | <literallayout class='monospaced'> |
| 13451 | $ bitbake matchbox-desktop |
| 13452 | . |
| 13453 | . |
| 13454 | make some changes to the source code in the work directory |
| 13455 | . |
| 13456 | . |
| 13457 | $ bitbake matchbox-desktop -c compile -f |
| 13458 | $ bitbake matchbox-desktop |
| 13459 | </literallayout> |
| 13460 | </para> |
| 13461 | |
| 13462 | <para> |
| 13463 | This sequence first builds and then recompiles |
| 13464 | <filename>matchbox-desktop</filename>. |
| 13465 | The last command reruns all tasks (basically the packaging |
| 13466 | tasks) after the compile. |
| 13467 | BitBake recognizes that the <filename>do_compile</filename> |
| 13468 | task was rerun and therefore understands that the other tasks |
| 13469 | also need to be run again. |
| 13470 | </para> |
| 13471 | |
| 13472 | <para> |
| 13473 | Another, shorter way to rerun a task and all |
| 13474 | <ulink url='&YOCTO_DOCS_REF_URL;#normal-recipe-build-tasks'>normal recipe build tasks</ulink> |
| 13475 | that depend on it is to use the <filename>-C</filename> |
| 13476 | option. |
| 13477 | <note> |
| 13478 | This option is upper-cased and is separate from the |
| 13479 | <filename>-c</filename> option, which is lower-cased. |
| 13480 | </note> |
| 13481 | Using this option invalidates the given task and then runs the |
| 13482 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-build'><filename>do_build</filename></ulink> |
| 13483 | task, which is the default task if no task is given, and the |
| 13484 | tasks on which it depends. |
| 13485 | You could replace the final two commands in the previous example |
| 13486 | with the following single command: |
| 13487 | <literallayout class='monospaced'> |
| 13488 | $ bitbake matchbox-desktop -C compile |
| 13489 | </literallayout> |
| 13490 | Internally, the <filename>-f</filename> and |
| 13491 | <filename>-C</filename> options work by tainting (modifying) the |
| 13492 | input checksum of the specified task. |
| 13493 | This tainting indirectly causes the task and its |
| 13494 | dependent tasks to be rerun through the normal task dependency |
| 13495 | mechanisms. |
| 13496 | <note> |
| 13497 | BitBake explicitly keeps track of which tasks have been |
| 13498 | tainted in this fashion, and will print warnings such as the |
| 13499 | following for builds involving such tasks: |
| 13500 | <literallayout class='monospaced'> |
| 13501 | WARNING: /home/ulf/poky/meta/recipes-sato/matchbox-desktop/matchbox-desktop_2.1.bb.do_compile is tainted from a forced run |
| 13502 | </literallayout> |
| 13503 | The purpose of the warning is to let you know that the work |
| 13504 | directory and build output might not be in the clean state |
| 13505 | they would be in for a "normal" build, depending on what |
| 13506 | actions you took. |
| 13507 | To get rid of such warnings, you can remove the work |
| 13508 | directory and rebuild the recipe, as follows: |
| 13509 | <literallayout class='monospaced'> |
| 13510 | $ bitbake matchbox-desktop -c clean |
| 13511 | $ bitbake matchbox-desktop |
| 13512 | </literallayout> |
| 13513 | </note> |
| 13514 | </para> |
| 13515 | |
| 13516 | <para> |
| 13517 | You can view a list of tasks in a given package by running the |
| 13518 | <filename>do_listtasks</filename> task as follows: |
| 13519 | <literallayout class='monospaced'> |
| 13520 | $ bitbake matchbox-desktop -c listtasks |
| 13521 | </literallayout> |
| 13522 | The results appear as output to the console and are also in the |
| 13523 | file <filename>${WORKDIR}/temp/log.do_listtasks</filename>. |
| 13524 | </para> |
| 13525 | </section> |
| 13526 | |
| 13527 | <section id='dev-debugging-bitbake'> |
| 13528 | <title>General BitBake Problems</title> |
| 13529 | |
| 13530 | <para> |
| 13531 | You can see debug output from BitBake by using the |
| 13532 | <filename>-D</filename> option. |
| 13533 | The debug output gives more information about what BitBake |
| 13534 | is doing and the reason behind it. |
| 13535 | Each <filename>-D</filename> option you use increases the |
| 13536 | logging level. |
| 13537 | The most common usage is <filename>-DDD</filename>. |
| 13538 | </para> |
| 13539 | |
| 13540 | <para> |
| 13541 | The output from |
| 13542 | <filename>bitbake -DDD -v</filename> <replaceable>targetname</replaceable> |
| 13543 | can reveal why BitBake chose a certain version of a package or |
| 13544 | why BitBake picked a certain provider. |
| 13545 | This command could also help you in a situation where you think |
| 13546 | BitBake did something unexpected. |
| 13547 | </para> |
| 13548 | </section> |
| 13549 | |
| 13550 | <section id='dev-debugging-buildfile'> |
| 13551 | <title>Building with No Dependencies</title> |
| 13552 | |
| 13553 | <para> |
| 13554 | To build a specific recipe (<filename>.bb</filename> file), |
| 13555 | you can use the following command form: |
| 13556 | <literallayout class='monospaced'> |
| 13557 | $ bitbake -b <replaceable>somepath</replaceable>/<replaceable>somerecipe</replaceable>.bb |
| 13558 | </literallayout> |
| 13559 | This command form does not check for dependencies. |
| 13560 | Consequently, you should use it only when you know existing |
| 13561 | dependencies have been met. |
| 13562 | <note> |
| 13563 | You can also specify fragments of the filename. |
| 13564 | In this case, BitBake checks for a unique match. |
| 13565 | </note> |
| 13566 | </para> |
| 13567 | </section> |
| 13568 | |
| 13569 | <section id='recipe-logging-mechanisms'> |
| 13570 | <title>Recipe Logging Mechanisms</title> |
| 13571 | |
| 13572 | <para> |
| 13573 | The Yocto Project provides several logging functions for |
| 13574 | producing debugging output and reporting errors and warnings. |
| 13575 | For Python functions, the following logging functions exist. |
| 13576 | All of these functions log to |
| 13577 | <filename>${T}/log.do_</filename><replaceable>task</replaceable>, |
| 13578 | and can also log to standard output (stdout) with the right |
| 13579 | settings: |
| 13580 | <itemizedlist> |
| 13581 | <listitem><para> |
| 13582 | <filename>bb.plain(</filename><replaceable>msg</replaceable><filename>)</filename>: |
| 13583 | Writes <replaceable>msg</replaceable> as is to the |
| 13584 | log while also logging to stdout. |
| 13585 | </para></listitem> |
| 13586 | <listitem><para> |
| 13587 | <filename>bb.note(</filename><replaceable>msg</replaceable><filename>)</filename>: |
| 13588 | Writes "NOTE: <replaceable>msg</replaceable>" to the |
| 13589 | log. |
| 13590 | Also logs to stdout if BitBake is called with "-v". |
| 13591 | </para></listitem> |
| 13592 | <listitem><para> |
| 13593 | <filename>bb.debug(</filename><replaceable>level</replaceable><filename>, </filename><replaceable>msg</replaceable><filename>)</filename>: |
| 13594 | Writes "DEBUG: <replaceable>msg</replaceable>" to the |
| 13595 | log. |
| 13596 | Also logs to stdout if the log level is greater than or |
| 13597 | equal to <replaceable>level</replaceable>. |
| 13598 | See the |
| 13599 | "<ulink url='&YOCTO_DOCS_BB_URL;#usage-and-syntax'>-D</ulink>" |
| 13600 | option in the BitBake User Manual for more information. |
| 13601 | </para></listitem> |
| 13602 | <listitem><para> |
| 13603 | <filename>bb.warn(</filename><replaceable>msg</replaceable><filename>)</filename>: |
| 13604 | Writes "WARNING: <replaceable>msg</replaceable>" to the |
| 13605 | log while also logging to stdout. |
| 13606 | </para></listitem> |
| 13607 | <listitem><para> |
| 13608 | <filename>bb.error(</filename><replaceable>msg</replaceable><filename>)</filename>: |
| 13609 | Writes "ERROR: <replaceable>msg</replaceable>" to the |
| 13610 | log while also logging to standard out (stdout). |
| 13611 | <note> |
| 13612 | Calling this function does not cause the task to fail. |
| 13613 | </note> |
| 13614 | </para></listitem> |
| 13615 | <listitem><para> |
| 13616 | <filename>bb.fatal(</filename><replaceable>msg</replaceable><filename>)</filename>: |
| 13617 | This logging function is similar to |
| 13618 | <filename>bb.error(</filename><replaceable>msg</replaceable><filename>)</filename> |
| 13619 | but also causes the calling task to fail. |
| 13620 | <note> |
| 13621 | <filename>bb.fatal()</filename> raises an exception, |
| 13622 | which means you do not need to put a "return" |
| 13623 | statement after the function. |
| 13624 | </note> |
| 13625 | </para></listitem> |
| 13626 | </itemizedlist> |
| 13627 | </para> |
| 13628 | |
| 13629 | <para> |
| 13630 | The same logging functions are also available in shell |
| 13631 | functions, under the names |
| 13632 | <filename>bbplain</filename>, <filename>bbnote</filename>, |
| 13633 | <filename>bbdebug</filename>, <filename>bbwarn</filename>, |
| 13634 | <filename>bberror</filename>, and <filename>bbfatal</filename>. |
| 13635 | The |
| 13636 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-logging'><filename>logging</filename></ulink> |
| 13637 | class implements these functions. |
| 13638 | See that class in the |
| 13639 | <filename>meta/classes</filename> folder of the |
| 13640 | <ulink url='&YOCTO_DOCS_REF_URL;#source-directory'>Source Directory</ulink> |
| 13641 | for information. |
| 13642 | </para> |
| 13643 | |
| 13644 | <section id='logging-with-python'> |
| 13645 | <title>Logging With Python</title> |
| 13646 | |
| 13647 | <para> |
| 13648 | When creating recipes using Python and inserting code that |
| 13649 | handles build logs, keep in mind the goal is to have |
| 13650 | informative logs while keeping the console as "silent" as |
| 13651 | possible. |
| 13652 | Also, if you want status messages in the log, use the |
| 13653 | "debug" loglevel. |
| 13654 | </para> |
| 13655 | |
| 13656 | <para> |
| 13657 | Following is an example written in Python. |
| 13658 | The code handles logging for a function that determines the |
| 13659 | number of tasks needed to be run. |
| 13660 | See the |
| 13661 | "<ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-listtasks'><filename>do_listtasks</filename></ulink>" |
| 13662 | section for additional information: |
| 13663 | <literallayout class='monospaced'> |
| 13664 | python do_listtasks() { |
| 13665 | bb.debug(2, "Starting to figure out the task list") |
| 13666 | if noteworthy_condition: |
| 13667 | bb.note("There are 47 tasks to run") |
| 13668 | bb.debug(2, "Got to point xyz") |
| 13669 | if warning_trigger: |
| 13670 | bb.warn("Detected warning_trigger, this might be a problem later.") |
| 13671 | if recoverable_error: |
| 13672 | bb.error("Hit recoverable_error, you really need to fix this!") |
| 13673 | if fatal_error: |
| 13674 | bb.fatal("fatal_error detected, unable to print the task list") |
| 13675 | bb.plain("The tasks present are abc") |
| 13676 | bb.debug(2, "Finished figuring out the tasklist") |
| 13677 | } |
| 13678 | </literallayout> |
| 13679 | </para> |
| 13680 | </section> |
| 13681 | |
| 13682 | <section id='logging-with-bash'> |
| 13683 | <title>Logging With Bash</title> |
| 13684 | |
| 13685 | <para> |
| 13686 | When creating recipes using Bash and inserting code that |
| 13687 | handles build logs, you have the same goals - informative |
| 13688 | with minimal console output. |
| 13689 | The syntax you use for recipes written in Bash is similar |
| 13690 | to that of recipes written in Python described in the |
| 13691 | previous section. |
| 13692 | </para> |
| 13693 | |
| 13694 | <para> |
| 13695 | Following is an example written in Bash. |
| 13696 | The code logs the progress of the <filename>do_my_function</filename> function. |
| 13697 | <literallayout class='monospaced'> |
| 13698 | do_my_function() { |
| 13699 | bbdebug 2 "Running do_my_function" |
| 13700 | if [ exceptional_condition ]; then |
| 13701 | bbnote "Hit exceptional_condition" |
| 13702 | fi |
| 13703 | bbdebug 2 "Got to point xyz" |
| 13704 | if [ warning_trigger ]; then |
| 13705 | bbwarn "Detected warning_trigger, this might cause a problem later." |
| 13706 | fi |
| 13707 | if [ recoverable_error ]; then |
| 13708 | bberror "Hit recoverable_error, correcting" |
| 13709 | fi |
| 13710 | if [ fatal_error ]; then |
| 13711 | bbfatal "fatal_error detected" |
| 13712 | fi |
| 13713 | bbdebug 2 "Completed do_my_function" |
| 13714 | } |
| 13715 | </literallayout> |
| 13716 | </para> |
| 13717 | </section> |
| 13718 | </section> |
| 13719 | |
| 13720 | <section id='debugging-parallel-make-races'> |
| 13721 | <title>Debugging Parallel Make Races</title> |
| 13722 | |
| 13723 | <para> |
| 13724 | A parallel <filename>make</filename> race occurs when the build |
| 13725 | consists of several parts that are run simultaneously and |
| 13726 | a situation occurs when the output or result of one |
| 13727 | part is not ready for use with a different part of the build |
| 13728 | that depends on that output. |
| 13729 | Parallel make races are annoying and can sometimes be difficult |
| 13730 | to reproduce and fix. |
| 13731 | However, some simple tips and tricks exist that can help |
| 13732 | you debug and fix them. |
| 13733 | This section presents a real-world example of an error |
| 13734 | encountered on the Yocto Project autobuilder and the process |
| 13735 | used to fix it. |
| 13736 | <note> |
| 13737 | If you cannot properly fix a <filename>make</filename> race |
| 13738 | condition, you can work around it by clearing either the |
| 13739 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PARALLEL_MAKE'><filename>PARALLEL_MAKE</filename></ulink> |
| 13740 | or |
| 13741 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PARALLEL_MAKEINST'><filename>PARALLEL_MAKEINST</filename></ulink> |
| 13742 | variables. |
| 13743 | </note> |
| 13744 | </para> |
| 13745 | |
| 13746 | <section id='the-failure'> |
| 13747 | <title>The Failure</title> |
| 13748 | |
| 13749 | <para> |
| 13750 | For this example, assume that you are building an image that |
| 13751 | depends on the "neard" package. |
| 13752 | And, during the build, BitBake runs into problems and |
| 13753 | creates the following output. |
| 13754 | <note> |
| 13755 | This example log file has longer lines artificially |
| 13756 | broken to make the listing easier to read. |
| 13757 | </note> |
| 13758 | If you examine the output or the log file, you see the |
| 13759 | failure during <filename>make</filename>: |
| 13760 | <literallayout class='monospaced'> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 13761 | | DEBUG: SITE files ['endian-little', 'bit-32', 'ix86-common', 'common-linux', 'common-glibc', 'i586-linux', 'common'] |
| 13762 | | DEBUG: Executing shell function do_compile |
| 13763 | | NOTE: make -j 16 |
| 13764 | | make --no-print-directory all-am |
| 13765 | | /bin/mkdir -p include/near |
| 13766 | | /bin/mkdir -p include/near |
| 13767 | | /bin/mkdir -p include/near |
| 13768 | | ln -s /home/pokybuild/yocto-autobuilder/yocto-slave/nightly-x86/build/build/tmp/work/i586-poky-linux/neard/ |
| 13769 | 0.14-r0/neard-0.14/include/types.h include/near/types.h |
| 13770 | | ln -s /home/pokybuild/yocto-autobuilder/yocto-slave/nightly-x86/build/build/tmp/work/i586-poky-linux/neard/ |
| 13771 | 0.14-r0/neard-0.14/include/log.h include/near/log.h |
| 13772 | | ln -s /home/pokybuild/yocto-autobuilder/yocto-slave/nightly-x86/build/build/tmp/work/i586-poky-linux/neard/ |
| 13773 | 0.14-r0/neard-0.14/include/plugin.h include/near/plugin.h |
| 13774 | | /bin/mkdir -p include/near |
| 13775 | | /bin/mkdir -p include/near |
| 13776 | | /bin/mkdir -p include/near |
| 13777 | | ln -s /home/pokybuild/yocto-autobuilder/yocto-slave/nightly-x86/build/build/tmp/work/i586-poky-linux/neard/ |
| 13778 | 0.14-r0/neard-0.14/include/tag.h include/near/tag.h |
| 13779 | | /bin/mkdir -p include/near |
| 13780 | | ln -s /home/pokybuild/yocto-autobuilder/yocto-slave/nightly-x86/build/build/tmp/work/i586-poky-linux/neard/ |
| 13781 | 0.14-r0/neard-0.14/include/adapter.h include/near/adapter.h |
| 13782 | | /bin/mkdir -p include/near |
| 13783 | | ln -s /home/pokybuild/yocto-autobuilder/yocto-slave/nightly-x86/build/build/tmp/work/i586-poky-linux/neard/ |
| 13784 | 0.14-r0/neard-0.14/include/ndef.h include/near/ndef.h |
| 13785 | | ln -s /home/pokybuild/yocto-autobuilder/yocto-slave/nightly-x86/build/build/tmp/work/i586-poky-linux/neard/ |
| 13786 | 0.14-r0/neard-0.14/include/tlv.h include/near/tlv.h |
| 13787 | | /bin/mkdir -p include/near |
| 13788 | | /bin/mkdir -p include/near |
| 13789 | | ln -s /home/pokybuild/yocto-autobuilder/yocto-slave/nightly-x86/build/build/tmp/work/i586-poky-linux/neard/ |
| 13790 | 0.14-r0/neard-0.14/include/setting.h include/near/setting.h |
| 13791 | | /bin/mkdir -p include/near |
| 13792 | | /bin/mkdir -p include/near |
| 13793 | | /bin/mkdir -p include/near |
| 13794 | | ln -s /home/pokybuild/yocto-autobuilder/yocto-slave/nightly-x86/build/build/tmp/work/i586-poky-linux/neard/ |
| 13795 | 0.14-r0/neard-0.14/include/device.h include/near/device.h |
| 13796 | | ln -s /home/pokybuild/yocto-autobuilder/yocto-slave/nightly-x86/build/build/tmp/work/i586-poky-linux/neard/ |
| 13797 | 0.14-r0/neard-0.14/include/nfc_copy.h include/near/nfc_copy.h |
| 13798 | | ln -s /home/pokybuild/yocto-autobuilder/yocto-slave/nightly-x86/build/build/tmp/work/i586-poky-linux/neard/ |
| 13799 | 0.14-r0/neard-0.14/include/snep.h include/near/snep.h |
| 13800 | | ln -s /home/pokybuild/yocto-autobuilder/yocto-slave/nightly-x86/build/build/tmp/work/i586-poky-linux/neard/ |
| 13801 | 0.14-r0/neard-0.14/include/version.h include/near/version.h |
| 13802 | | ln -s /home/pokybuild/yocto-autobuilder/yocto-slave/nightly-x86/build/build/tmp/work/i586-poky-linux/neard/ |
| 13803 | 0.14-r0/neard-0.14/include/dbus.h include/near/dbus.h |
| 13804 | | ./src/genbuiltin nfctype1 nfctype2 nfctype3 nfctype4 p2p > src/builtin.h |
| 13805 | | i586-poky-linux-gcc -m32 -march=i586 --sysroot=/home/pokybuild/yocto-autobuilder/yocto-slave/nightly-x86/ |
| 13806 | build/build/tmp/sysroots/qemux86 -DHAVE_CONFIG_H -I. -I./include -I./src -I./gdbus -I/home/pokybuild/ |
| 13807 | yocto-autobuilder/yocto-slave/nightly-x86/build/build/tmp/sysroots/qemux86/usr/include/glib-2.0 |
| 13808 | -I/home/pokybuild/yocto-autobuilder/yocto-slave/nightly-x86/build/build/tmp/sysroots/qemux86/usr/ |
| 13809 | lib/glib-2.0/include -I/home/pokybuild/yocto-autobuilder/yocto-slave/nightly-x86/build/build/ |
| 13810 | tmp/sysroots/qemux86/usr/include/dbus-1.0 -I/home/pokybuild/yocto-autobuilder/yocto-slave/ |
| 13811 | nightly-x86/build/build/tmp/sysroots/qemux86/usr/lib/dbus-1.0/include -I/home/pokybuild/yocto-autobuilder/ |
| 13812 | yocto-slave/nightly-x86/build/build/tmp/sysroots/qemux86/usr/include/libnl3 |
| 13813 | -DNEAR_PLUGIN_BUILTIN -DPLUGINDIR=\""/usr/lib/near/plugins"\" |
| 13814 | -DCONFIGDIR=\""/etc/neard\"" -O2 -pipe -g -feliminate-unused-debug-types -c |
| 13815 | -o tools/snep-send.o tools/snep-send.c |
| 13816 | | In file included from tools/snep-send.c:16:0: |
| 13817 | | tools/../src/near.h:41:23: fatal error: near/dbus.h: No such file or directory |
| 13818 | | #include <near/dbus.h> |
| 13819 | | ^ |
| 13820 | | compilation terminated. |
| 13821 | | make[1]: *** [tools/snep-send.o] Error 1 |
| 13822 | | make[1]: *** Waiting for unfinished jobs.... |
| 13823 | | make: *** [all] Error 2 |
| 13824 | | ERROR: oe_runmake failed |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 13825 | </literallayout> |
| 13826 | </para> |
| 13827 | </section> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 13828 | |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 13829 | <section id='reproducing-the-error'> |
| 13830 | <title>Reproducing the Error</title> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 13831 | |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 13832 | <para> |
| 13833 | Because race conditions are intermittent, they do not |
| 13834 | manifest themselves every time you do the build. |
| 13835 | In fact, most times the build will complete without problems |
| 13836 | even though the potential race condition exists. |
| 13837 | Thus, once the error surfaces, you need a way to reproduce |
| 13838 | it. |
| 13839 | </para> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 13840 | |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 13841 | <para> |
| 13842 | In this example, compiling the "neard" package is causing |
| 13843 | the problem. |
| 13844 | So the first thing to do is build "neard" locally. |
| 13845 | Before you start the build, set the |
| 13846 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PARALLEL_MAKE'><filename>PARALLEL_MAKE</filename></ulink> |
| 13847 | variable in your <filename>local.conf</filename> file to |
| 13848 | a high number (e.g. "-j 20"). |
| 13849 | Using a high value for <filename>PARALLEL_MAKE</filename> |
| 13850 | increases the chances of the race condition showing up: |
| 13851 | <literallayout class='monospaced'> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 13852 | $ bitbake neard |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 13853 | </literallayout> |
| 13854 | </para> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 13855 | |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 13856 | <para> |
| 13857 | Once the local build for "neard" completes, start a |
| 13858 | <filename>devshell</filename> build: |
| 13859 | <literallayout class='monospaced'> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 13860 | $ bitbake neard -c devshell |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 13861 | </literallayout> |
| 13862 | For information on how to use a |
| 13863 | <filename>devshell</filename>, see the |
| 13864 | "<link linkend='platdev-appdev-devshell'>Using a Development Shell</link>" |
| 13865 | section. |
| 13866 | </para> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 13867 | |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 13868 | <para> |
| 13869 | In the <filename>devshell</filename>, do the following: |
| 13870 | <literallayout class='monospaced'> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 13871 | $ make clean |
| 13872 | $ make tools/snep-send.o |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 13873 | </literallayout> |
| 13874 | The <filename>devshell</filename> commands cause the failure |
| 13875 | to clearly be visible. |
| 13876 | In this case, a missing dependency exists for the "neard" |
| 13877 | Makefile target. |
| 13878 | Here is some abbreviated, sample output with the |
| 13879 | missing dependency clearly visible at the end: |
| 13880 | <literallayout class='monospaced'> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 13881 | i586-poky-linux-gcc -m32 -march=i586 --sysroot=/home/scott-lenovo/...... |
| 13882 | . |
| 13883 | . |
| 13884 | . |
| 13885 | tools/snep-send.c |
| 13886 | In file included from tools/snep-send.c:16:0: |
| 13887 | tools/../src/near.h:41:23: fatal error: near/dbus.h: No such file or directory |
| 13888 | #include <near/dbus.h> |
| 13889 | ^ |
| 13890 | compilation terminated. |
| 13891 | make: *** [tools/snep-send.o] Error 1 |
| 13892 | $ |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 13893 | </literallayout> |
| 13894 | </para> |
| 13895 | </section> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 13896 | |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 13897 | <section id='creating-a-patch-for-the-fix'> |
| 13898 | <title>Creating a Patch for the Fix</title> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 13899 | |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 13900 | <para> |
| 13901 | Because there is a missing dependency for the Makefile |
| 13902 | target, you need to patch the |
| 13903 | <filename>Makefile.am</filename> file, which is generated |
| 13904 | from <filename>Makefile.in</filename>. |
| 13905 | You can use Quilt to create the patch: |
| 13906 | <literallayout class='monospaced'> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 13907 | $ quilt new parallelmake.patch |
| 13908 | Patch patches/parallelmake.patch is now on top |
| 13909 | $ quilt add Makefile.am |
| 13910 | File Makefile.am added to patch patches/parallelmake.patch |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 13911 | </literallayout> |
| 13912 | For more information on using Quilt, see the |
| 13913 | "<link linkend='using-a-quilt-workflow'>Using Quilt in Your Workflow</link>" |
| 13914 | section. |
| 13915 | </para> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 13916 | |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 13917 | <para> |
| 13918 | At this point you need to make the edits to |
| 13919 | <filename>Makefile.am</filename> to add the missing |
| 13920 | dependency. |
| 13921 | For our example, you have to add the following line |
| 13922 | to the file: |
| 13923 | <literallayout class='monospaced'> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 13924 | tools/snep-send.$(OBJEXT): include/near/dbus.h |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 13925 | </literallayout> |
| 13926 | </para> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 13927 | |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 13928 | <para> |
| 13929 | Once you have edited the file, use the |
| 13930 | <filename>refresh</filename> command to create the patch: |
| 13931 | <literallayout class='monospaced'> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 13932 | $ quilt refresh |
| 13933 | Refreshed patch patches/parallelmake.patch |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 13934 | </literallayout> |
| 13935 | Once the patch file exists, you need to add it back to the |
| 13936 | originating recipe folder. |
| 13937 | Here is an example assuming a top-level |
| 13938 | <ulink url='&YOCTO_DOCS_REF_URL;#source-directory'>Source Directory</ulink> |
| 13939 | named <filename>poky</filename>: |
| 13940 | <literallayout class='monospaced'> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 13941 | $ cp patches/parallelmake.patch poky/meta/recipes-connectivity/neard/neard |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 13942 | </literallayout> |
| 13943 | The final thing you need to do to implement the fix in the |
| 13944 | build is to update the "neard" recipe (i.e. |
| 13945 | <filename>neard-0.14.bb</filename>) so that the |
| 13946 | <ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'><filename>SRC_URI</filename></ulink> |
| 13947 | statement includes the patch file. |
| 13948 | The recipe file is in the folder above the patch. |
| 13949 | Here is what the edited <filename>SRC_URI</filename> |
| 13950 | statement would look like: |
| 13951 | <literallayout class='monospaced'> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 13952 | SRC_URI = "${KERNELORG_MIRROR}/linux/network/nfc/${BPN}-${PV}.tar.xz \ |
| 13953 | file://neard.in \ |
| 13954 | file://neard.service.in \ |
| 13955 | file://parallelmake.patch \ |
| 13956 | " |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 13957 | </literallayout> |
| 13958 | </para> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 13959 | |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 13960 | <para> |
| 13961 | With the patch complete and moved to the correct folder and |
| 13962 | the <filename>SRC_URI</filename> statement updated, you can |
| 13963 | exit the <filename>devshell</filename>: |
| 13964 | <literallayout class='monospaced'> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 13965 | $ exit |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 13966 | </literallayout> |
| 13967 | </para> |
| 13968 | </section> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 13969 | |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 13970 | <section id='testing-the-build'> |
| 13971 | <title>Testing the Build</title> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 13972 | |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 13973 | <para> |
| 13974 | With everything in place, you can get back to trying the |
| 13975 | build again locally: |
| 13976 | <literallayout class='monospaced'> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 13977 | $ bitbake neard |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 13978 | </literallayout> |
| 13979 | This build should succeed. |
| 13980 | </para> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 13981 | |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 13982 | <para> |
| 13983 | Now you can open up a <filename>devshell</filename> again |
| 13984 | and repeat the clean and make operations as follows: |
| 13985 | <literallayout class='monospaced'> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 13986 | $ bitbake neard -c devshell |
| 13987 | $ make clean |
| 13988 | $ make tools/snep-send.o |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 13989 | </literallayout> |
| 13990 | The build should work without issue. |
| 13991 | </para> |
| 13992 | |
| 13993 | <para> |
| 13994 | As with all solved problems, if they originated upstream, |
| 13995 | you need to submit the fix for the recipe in OE-Core and |
| 13996 | upstream so that the problem is taken care of at its |
| 13997 | source. |
| 13998 | See the |
| 13999 | "<link linkend='how-to-submit-a-change'>Submitting a Change to the Yocto Project</link>" |
| 14000 | section for more information. |
| 14001 | </para> |
| 14002 | </section> |
| 14003 | </section> |
| 14004 | |
| 14005 | <section id="platdev-gdb-remotedebug"> |
| 14006 | <title>Debugging With the GNU Project Debugger (GDB) Remotely</title> |
| 14007 | |
| 14008 | <para> |
| 14009 | GDB allows you to examine running programs, which in turn helps |
| 14010 | you to understand and fix problems. |
| 14011 | It also allows you to perform post-mortem style analysis of |
| 14012 | program crashes. |
| 14013 | GDB is available as a package within the Yocto Project and is |
| 14014 | installed in SDK images by default. |
| 14015 | See the |
| 14016 | "<ulink url='&YOCTO_DOCS_REF_URL;#ref-images'>Images</ulink>" |
| 14017 | chapter in the Yocto Project Reference Manual for a description of |
| 14018 | these images. |
| 14019 | You can find information on GDB at |
| 14020 | <ulink url="http://sourceware.org/gdb/"/>. |
| 14021 | <note><title>Tip</title> |
| 14022 | For best results, install debug (<filename>-dbg</filename>) |
| 14023 | packages for the applications you are going to debug. |
| 14024 | Doing so makes extra debug symbols available that give you |
| 14025 | more meaningful output. |
| 14026 | </note> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 14027 | </para> |
| 14028 | |
| 14029 | <para> |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 14030 | Sometimes, due to memory or disk space constraints, it is not |
| 14031 | possible to use GDB directly on the remote target to debug |
| 14032 | applications. |
| 14033 | These constraints arise because GDB needs to load the debugging |
| 14034 | information and the binaries of the process being debugged. |
| 14035 | Additionally, GDB needs to perform many computations to locate |
| 14036 | information such as function names, variable names and values, |
| 14037 | stack traces and so forth - even before starting the debugging |
| 14038 | process. |
| 14039 | These extra computations place more load on the target system |
| 14040 | and can alter the characteristics of the program being debugged. |
| 14041 | </para> |
| 14042 | |
| 14043 | <para> |
| 14044 | To help get past the previously mentioned constraints, you can |
| 14045 | use gdbserver, which runs on the remote target and does not |
| 14046 | load any debugging information from the debugged process. |
| 14047 | Instead, a GDB instance processes the debugging information that |
| 14048 | is run on a remote computer - the host GDB. |
| 14049 | The host GDB then sends control commands to gdbserver to make |
| 14050 | it stop or start the debugged program, as well as read or write |
| 14051 | memory regions of that debugged program. |
| 14052 | All the debugging information loaded and processed as well |
| 14053 | as all the heavy debugging is done by the host GDB. |
| 14054 | Offloading these processes gives the gdbserver running on the |
| 14055 | target a chance to remain small and fast. |
| 14056 | </para> |
| 14057 | |
| 14058 | <para> |
| 14059 | Because the host GDB is responsible for loading the debugging |
| 14060 | information and for doing the necessary processing to make |
| 14061 | actual debugging happen, you have to make sure the host can |
| 14062 | access the unstripped binaries complete with their debugging |
| 14063 | information and also be sure the target is compiled with no |
| 14064 | optimizations. |
| 14065 | The host GDB must also have local access to all the libraries |
| 14066 | used by the debugged program. |
| 14067 | Because gdbserver does not need any local debugging information, |
| 14068 | the binaries on the remote target can remain stripped. |
| 14069 | However, the binaries must also be compiled without optimization |
| 14070 | so they match the host's binaries. |
| 14071 | </para> |
| 14072 | |
| 14073 | <para> |
| 14074 | To remain consistent with GDB documentation and terminology, |
| 14075 | the binary being debugged on the remote target machine is |
| 14076 | referred to as the "inferior" binary. |
| 14077 | For documentation on GDB see the |
| 14078 | <ulink url="http://sourceware.org/gdb/documentation/">GDB site</ulink>. |
| 14079 | </para> |
| 14080 | |
| 14081 | <para> |
| 14082 | The following steps show you how to debug using the GNU project |
| 14083 | debugger. |
| 14084 | <orderedlist> |
| 14085 | <listitem><para> |
| 14086 | <emphasis>Configure your build system to construct the |
| 14087 | companion debug filesystem:</emphasis></para> |
| 14088 | |
| 14089 | <para>In your <filename>local.conf</filename> file, set |
| 14090 | the following: |
| 14091 | <literallayout class='monospaced'> |
| 14092 | IMAGE_GEN_DEBUGFS = "1" |
| 14093 | IMAGE_FSTYPES_DEBUGFS = "tar.bz2" |
| 14094 | </literallayout> |
| 14095 | These options cause the OpenEmbedded build system |
| 14096 | to generate a special companion filesystem fragment, |
| 14097 | which contains the matching source and debug symbols to |
| 14098 | your deployable filesystem. |
| 14099 | The build system does this by looking at what is in the |
| 14100 | deployed filesystem, and pulling the corresponding |
| 14101 | <filename>-dbg</filename> packages.</para> |
| 14102 | |
| 14103 | <para>The companion debug filesystem is not a complete |
| 14104 | filesystem, but only contains the debug fragments. |
| 14105 | This filesystem must be combined with the full filesystem |
| 14106 | for debugging. |
| 14107 | Subsequent steps in this procedure show how to combine |
| 14108 | the partial filesystem with the full filesystem. |
| 14109 | </para></listitem> |
| 14110 | <listitem><para> |
| 14111 | <emphasis>Configure the system to include gdbserver in |
| 14112 | the target filesystem:</emphasis></para> |
| 14113 | |
| 14114 | <para>Make the following addition in either your |
| 14115 | <filename>local.conf</filename> file or in an image |
| 14116 | recipe: |
| 14117 | <literallayout class='monospaced'> |
| 14118 | IMAGE_INSTALL_append = “ gdbserver" |
| 14119 | </literallayout> |
| 14120 | The change makes sure the <filename>gdbserver</filename> |
| 14121 | package is included. |
| 14122 | </para></listitem> |
| 14123 | <listitem><para> |
| 14124 | <emphasis>Build the environment:</emphasis></para> |
| 14125 | |
| 14126 | <para>Use the following command to construct the image |
| 14127 | and the companion Debug Filesystem: |
| 14128 | <literallayout class='monospaced'> |
| 14129 | $ bitbake <replaceable>image</replaceable> |
| 14130 | </literallayout> |
| 14131 | Build the cross GDB component and make it available |
| 14132 | for debugging. |
| 14133 | Build the SDK that matches the image. |
| 14134 | Building the SDK is best for a production build |
| 14135 | that can be used later for debugging, especially |
| 14136 | during long term maintenance: |
| 14137 | <literallayout class='monospaced'> |
| 14138 | $ bitbake -c populate_sdk <replaceable>image</replaceable> |
| 14139 | </literallayout></para> |
| 14140 | |
| 14141 | <para>Alternatively, you can build the minimal |
| 14142 | toolchain components that match the target. |
| 14143 | Doing so creates a smaller than typical SDK and only |
| 14144 | contains a minimal set of components with which to |
| 14145 | build simple test applications, as well as run the |
| 14146 | debugger: |
| 14147 | <literallayout class='monospaced'> |
| 14148 | $ bitbake meta-toolchain |
| 14149 | </literallayout></para> |
| 14150 | |
| 14151 | <para>A final method is to build Gdb itself within |
| 14152 | the build system: |
| 14153 | <literallayout class='monospaced'> |
| 14154 | $ bitbake gdb-cross-<replaceable>architecture</replaceable> |
| 14155 | </literallayout> |
| 14156 | Doing so produces a temporary copy of |
| 14157 | <filename>cross-gdb</filename> you can use for |
| 14158 | debugging during development. |
| 14159 | While this is the quickest approach, the two previous |
| 14160 | methods in this step are better when considering |
| 14161 | long-term maintenance strategies. |
| 14162 | <note> |
| 14163 | If you run |
| 14164 | <filename>bitbake gdb-cross</filename>, the |
| 14165 | OpenEmbedded build system suggests the actual |
| 14166 | image (e.g. <filename>gdb-cross-i586</filename>). |
| 14167 | The suggestion is usually the actual name you want |
| 14168 | to use. |
| 14169 | </note> |
| 14170 | </para></listitem> |
| 14171 | <listitem><para> |
| 14172 | <emphasis>Set up the</emphasis> <filename>debugfs</filename></para> |
| 14173 | |
| 14174 | <para>Run the following commands to set up the |
| 14175 | <filename>debugfs</filename>: |
| 14176 | <literallayout class='monospaced'> |
| 14177 | $ mkdir debugfs |
| 14178 | $ cd debugfs |
| 14179 | $ tar xvfj <replaceable>build-dir</replaceable>/tmp-glibc/deploy/images/<replaceable>machine</replaceable>/<replaceable>image</replaceable>.rootfs.tar.bz2 |
| 14180 | $ tar xvfj <replaceable>build-dir</replaceable>/tmp-glibc/deploy/images/<replaceable>machine</replaceable>/<replaceable>image</replaceable>-dbg.rootfs.tar.bz2 |
| 14181 | </literallayout> |
| 14182 | </para></listitem> |
| 14183 | <listitem><para> |
| 14184 | <emphasis>Set up GDB</emphasis></para> |
| 14185 | |
| 14186 | <para>Install the SDK (if you built one) and then |
| 14187 | source the correct environment file. |
| 14188 | Sourcing the environment file puts the SDK in your |
| 14189 | <filename>PATH</filename> environment variable.</para> |
| 14190 | |
| 14191 | <para>If you are using the build system, Gdb is |
| 14192 | located in |
| 14193 | <replaceable>build-dir</replaceable>/tmp/sysroots/<replaceable>host</replaceable>/usr/bin/<replaceable>architecture</replaceable>/<replaceable>architecture</replaceable>-gdb |
| 14194 | </para></listitem> |
| 14195 | <listitem><para> |
| 14196 | <emphasis>Boot the target:</emphasis></para> |
| 14197 | |
| 14198 | <para>For information on how to run QEMU, see the |
| 14199 | <ulink url='http://wiki.qemu.org/Documentation/GettingStartedDevelopers'>QEMU Documentation</ulink>. |
| 14200 | <note> |
| 14201 | Be sure to verify that your host can access the |
| 14202 | target via TCP. |
| 14203 | </note> |
| 14204 | </para></listitem> |
| 14205 | <listitem><para> |
| 14206 | <emphasis>Debug a program:</emphasis></para> |
| 14207 | |
| 14208 | <para>Debugging a program involves running gdbserver |
| 14209 | on the target and then running Gdb on the host. |
| 14210 | The example in this step debugs |
| 14211 | <filename>gzip</filename>: |
| 14212 | <literallayout class='monospaced'> |
| 14213 | root@qemux86:~# gdbserver localhost:1234 /bin/gzip —help |
| 14214 | </literallayout> |
| 14215 | For additional gdbserver options, see the |
| 14216 | <ulink url='https://www.gnu.org/software/gdb/documentation/'>GDB Server Documentation</ulink>. |
| 14217 | </para> |
| 14218 | |
| 14219 | <para>After running gdbserver on the target, you need |
| 14220 | to run Gdb on the host and configure it and connect to |
| 14221 | the target. |
| 14222 | Use these commands: |
| 14223 | <literallayout class='monospaced'> |
| 14224 | $ cd <replaceable>directory-holding-the-debugfs-directory</replaceable> |
| 14225 | $ <replaceable>arch</replaceable>-gdb |
| 14226 | |
| 14227 | (gdb) set sysroot debugfs |
| 14228 | (gdb) set substitute-path /usr/src/debug debugfs/usr/src/debug |
| 14229 | (gdb) target remote <replaceable>IP-of-target</replaceable>:1234 |
| 14230 | </literallayout> |
| 14231 | At this point, everything should automatically load |
| 14232 | (i.e. matching binaries, symbols and headers). |
| 14233 | <note> |
| 14234 | The Gdb <filename>set</filename> commands in the |
| 14235 | previous example can be placed into the users |
| 14236 | <filename>~/.gdbinit</filename> file. |
| 14237 | Upon starting, Gdb automatically runs whatever |
| 14238 | commands are in that file. |
| 14239 | </note> |
| 14240 | </para></listitem> |
| 14241 | <listitem><para> |
| 14242 | <emphasis>Deploying without a full image |
| 14243 | rebuild:</emphasis></para> |
| 14244 | |
| 14245 | <para>In many cases, during development you want a |
| 14246 | quick method to deploy a new binary to the target and |
| 14247 | debug it, without waiting for a full image build. |
| 14248 | </para> |
| 14249 | |
| 14250 | <para>One approach to solving this situation is to |
| 14251 | just build the component you want to debug. |
| 14252 | Once you have built the component, copy the |
| 14253 | executable directly to both the target and the |
| 14254 | host <filename>debugfs</filename>.</para> |
| 14255 | |
| 14256 | <para>If the binary is processed through the debug |
| 14257 | splitting in OpenEmbedded, you should also |
| 14258 | copy the debug items (i.e. <filename>.debug</filename> |
| 14259 | contents and corresponding |
| 14260 | <filename>/usr/src/debug</filename> files) |
| 14261 | from the work directory. |
| 14262 | Here is an example: |
| 14263 | <literallayout class='monospaced'> |
| 14264 | $ bitbake bash |
| 14265 | $ bitbake -c devshell bash |
| 14266 | $ cd .. |
| 14267 | $ scp packages-split/bash/bin/bash <replaceable>target</replaceable>:/bin/bash |
| 14268 | $ cp -a packages-split/bash-dbg/* <replaceable>path</replaceable>/debugfs |
| 14269 | </literallayout> |
| 14270 | </para></listitem> |
| 14271 | </orderedlist> |
| 14272 | </para> |
| 14273 | </section> |
| 14274 | |
| 14275 | <section id='debugging-with-the-gnu-project-debugger-gdb-on-the-target'> |
| 14276 | <title>Debugging with the GNU Project Debugger (GDB) on the Target</title> |
| 14277 | |
| 14278 | <para> |
| 14279 | The previous section addressed using GDB remotely for debugging |
| 14280 | purposes, which is the most usual case due to the inherent |
| 14281 | hardware limitations on many embedded devices. |
| 14282 | However, debugging in the target hardware itself is also |
| 14283 | possible with more powerful devices. |
| 14284 | This section describes what you need to do in order to support |
| 14285 | using GDB to debug on the target hardware. |
| 14286 | </para> |
| 14287 | |
| 14288 | <para> |
| 14289 | To support this kind of debugging, you need do the following: |
| 14290 | <itemizedlist> |
| 14291 | <listitem><para> |
| 14292 | Ensure that GDB is on the target. |
| 14293 | You can do this by adding "gdb" to |
| 14294 | <ulink url='&YOCTO_DOCS_REF_URL;#var-IMAGE_INSTALL'><filename>IMAGE_INSTALL</filename></ulink>: |
| 14295 | <literallayout class='monospaced'> |
| 14296 | IMAGE_INSTALL_append = " gdb" |
| 14297 | </literallayout> |
| 14298 | Alternatively, you can add "tools-debug" to |
| 14299 | <ulink url='&YOCTO_DOCS_REF_URL;#var-IMAGE_FEATURES'><filename>IMAGE_FEATURES</filename></ulink>: |
| 14300 | <literallayout class='monospaced'> |
| 14301 | IMAGE_FEATURES_append = " tools-debug" |
| 14302 | </literallayout> |
| 14303 | </para></listitem> |
| 14304 | <listitem><para> |
| 14305 | Ensure that debug symbols are present. |
| 14306 | You can make sure these symbols are present by |
| 14307 | installing <filename>-dbg</filename>: |
| 14308 | <literallayout class='monospaced'> |
| 14309 | IMAGE_INSTALL_append = " <replaceable>packagename</replaceable>-dbg" |
| 14310 | </literallayout> |
| 14311 | Alternatively, you can do the following to include all |
| 14312 | the debug symbols: |
| 14313 | <literallayout class='monospaced'> |
| 14314 | IMAGE_FEATURES_append = " dbg-pkgs" |
| 14315 | </literallayout> |
| 14316 | </para></listitem> |
| 14317 | </itemizedlist> |
| 14318 | <note> |
| 14319 | To improve the debug information accuracy, you can reduce |
| 14320 | the level of optimization used by the compiler. |
| 14321 | For example, when adding the following line to your |
| 14322 | <filename>local.conf</filename> file, you will reduce |
| 14323 | optimization from |
| 14324 | <ulink url='&YOCTO_DOCS_REF_URL;#var-FULL_OPTIMIZATION'><filename>FULL_OPTIMIZATION</filename></ulink> |
| 14325 | of "-O2" to |
| 14326 | <ulink url='&YOCTO_DOCS_REF_URL;#var-DEBUG_OPTIMIZATION'><filename>DEBUG_OPTIMIZATION</filename></ulink> |
| 14327 | of "-O -fno-omit-frame-pointer": |
| 14328 | <literallayout class='monospaced'> |
| 14329 | DEBUG_BUILD = "1" |
| 14330 | </literallayout> |
| 14331 | Consider that this will reduce the application's performance |
| 14332 | and is recommended only for debugging purposes. |
| 14333 | </note> |
| 14334 | </para> |
| 14335 | </section> |
| 14336 | |
| 14337 | <section id='dev-other-debugging-others'> |
| 14338 | <title>Other Debugging Tips</title> |
| 14339 | |
| 14340 | <para> |
| 14341 | Here are some other tips that you might find useful: |
| 14342 | <itemizedlist> |
| 14343 | <listitem><para> |
| 14344 | When adding new packages, it is worth watching for |
| 14345 | undesirable items making their way into compiler command |
| 14346 | lines. |
| 14347 | For example, you do not want references to local system |
| 14348 | files like |
| 14349 | <filename>/usr/lib/</filename> or |
| 14350 | <filename>/usr/include/</filename>. |
| 14351 | </para></listitem> |
| 14352 | <listitem><para> |
| 14353 | If you want to remove the <filename>psplash</filename> |
| 14354 | boot splashscreen, |
| 14355 | add <filename>psplash=false</filename> to the kernel |
| 14356 | command line. |
| 14357 | Doing so prevents <filename>psplash</filename> from |
| 14358 | loading and thus allows you to see the console. |
| 14359 | It is also possible to switch out of the splashscreen by |
| 14360 | switching the virtual console (e.g. Fn+Left or Fn+Right |
| 14361 | on a Zaurus). |
| 14362 | </para></listitem> |
| 14363 | <listitem><para> |
| 14364 | Removing |
| 14365 | <ulink url='&YOCTO_DOCS_REF_URL;#var-TMPDIR'><filename>TMPDIR</filename></ulink> |
| 14366 | (usually <filename>tmp/</filename>, within the |
| 14367 | <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink>) |
| 14368 | can often fix temporary build issues. |
| 14369 | Removing <filename>TMPDIR</filename> is usually a |
| 14370 | relatively cheap operation, because task output will be |
| 14371 | cached in |
| 14372 | <ulink url='&YOCTO_DOCS_REF_URL;#var-SSTATE_DIR'><filename>SSTATE_DIR</filename></ulink> |
| 14373 | (usually <filename>sstate-cache/</filename>, which is |
| 14374 | also in the Build Directory). |
| 14375 | <note> |
| 14376 | Removing <filename>TMPDIR</filename> might be a |
| 14377 | workaround rather than a fix. |
| 14378 | Consequently, trying to determine the underlying |
| 14379 | cause of an issue before removing the directory is |
| 14380 | a good idea. |
| 14381 | </note> |
| 14382 | </para></listitem> |
| 14383 | <listitem><para> |
| 14384 | Understanding how a feature is used in practice within |
| 14385 | existing recipes can be very helpful. |
| 14386 | It is recommended that you configure some method that |
| 14387 | allows you to quickly search through files.</para> |
| 14388 | |
| 14389 | <para>Using GNU Grep, you can use the following shell |
| 14390 | function to recursively search through common |
| 14391 | recipe-related files, skipping binary files, |
| 14392 | <filename>.git</filename> directories, and the |
| 14393 | Build Directory (assuming its name starts with |
| 14394 | "build"): |
| 14395 | <literallayout class='monospaced'> |
| 14396 | g() { |
| 14397 | grep -Ir \ |
| 14398 | --exclude-dir=.git \ |
| 14399 | --exclude-dir='build*' \ |
| 14400 | --include='*.bb*' \ |
| 14401 | --include='*.inc*' \ |
| 14402 | --include='*.conf*' \ |
| 14403 | --include='*.py*' \ |
| 14404 | "$@" |
| 14405 | } |
| 14406 | </literallayout> |
| 14407 | Following are some usage examples: |
| 14408 | <literallayout class='monospaced'> |
| 14409 | $ g FOO # Search recursively for "FOO" |
| 14410 | $ g -i foo # Search recursively for "foo", ignoring case |
| 14411 | $ g -w FOO # Search recursively for "FOO" as a word, ignoring e.g. "FOOBAR" |
| 14412 | </literallayout> |
| 14413 | If figuring out how some feature works requires a lot of |
| 14414 | searching, it might indicate that the documentation |
| 14415 | should be extended or improved. |
| 14416 | In such cases, consider filing a documentation bug using |
| 14417 | the Yocto Project implementation of |
| 14418 | <ulink url='https://bugzilla.yoctoproject.org/'>Bugzilla</ulink>. |
| 14419 | For information on how to submit a bug against |
| 14420 | the Yocto Project, see the Yocto Project Bugzilla |
| 14421 | <ulink url='&YOCTO_WIKI_URL;/wiki/Bugzilla_Configuration_and_Bug_Tracking'>wiki page</ulink> |
| 14422 | and the |
| 14423 | "<link linkend='submitting-a-defect-against-the-yocto-project'>Submitting a Defect Against the Yocto Project</link>" |
| 14424 | section. |
| 14425 | <note> |
| 14426 | The manuals might not be the right place to document |
| 14427 | variables that are purely internal and have a |
| 14428 | limited scope (e.g. internal variables used to |
| 14429 | implement a single <filename>.bbclass</filename> |
| 14430 | file). |
| 14431 | </note> |
| 14432 | </para></listitem> |
| 14433 | </itemizedlist> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 14434 | </para> |
| 14435 | </section> |
| 14436 | </section> |
| 14437 | |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 14438 | <section id='making-changes-to-the-yocto-project'> |
| 14439 | <title>Making Changes to the Yocto Project</title> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 14440 | |
| 14441 | <para> |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 14442 | Because the Yocto Project is an open-source, community-based |
| 14443 | project, you can effect changes to the project. |
| 14444 | This section presents procedures that show you how to submit |
| 14445 | a defect against the project and how to submit a change. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 14446 | </para> |
| 14447 | |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 14448 | <section id='submitting-a-defect-against-the-yocto-project'> |
| 14449 | <title>Submitting a Defect Against the Yocto Project</title> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 14450 | |
| 14451 | <para> |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 14452 | Use the Yocto Project implementation of |
| 14453 | <ulink url='http://www.bugzilla.org/about/'>Bugzilla</ulink> |
| 14454 | to submit a defect (bug) against the Yocto Project. |
| 14455 | For additional information on this implementation of Bugzilla see the |
| 14456 | "<ulink url='&YOCTO_DOCS_REF_URL;#resources-bugtracker'>Yocto Project Bugzilla</ulink>" |
| 14457 | section in the Yocto Project Reference Manual. |
| 14458 | For more detail on any of the following steps, see the Yocto Project |
| 14459 | <ulink url='&YOCTO_WIKI_URL;/wiki/Bugzilla_Configuration_and_Bug_Tracking'>Bugzilla wiki page</ulink>. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 14460 | </para> |
| 14461 | |
| 14462 | <para> |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 14463 | Use the following general steps to submit a bug" |
| 14464 | |
| 14465 | <orderedlist> |
| 14466 | <listitem><para> |
| 14467 | Open the Yocto Project implementation of |
| 14468 | <ulink url='&YOCTO_BUGZILLA_URL;'>Bugzilla</ulink>. |
| 14469 | </para></listitem> |
| 14470 | <listitem><para> |
| 14471 | Click "File a Bug" to enter a new bug. |
| 14472 | </para></listitem> |
| 14473 | <listitem><para> |
| 14474 | Choose the appropriate "Classification", "Product", and |
| 14475 | "Component" for which the bug was found. |
| 14476 | Bugs for the Yocto Project fall into one of several |
| 14477 | classifications, which in turn break down into several |
| 14478 | products and components. |
| 14479 | For example, for a bug against the |
| 14480 | <filename>meta-intel</filename> layer, you would choose |
| 14481 | "Build System, Metadata & Runtime", "BSPs", and |
| 14482 | "bsps-meta-intel", respectively. |
| 14483 | </para></listitem> |
| 14484 | <listitem><para> |
| 14485 | Choose the "Version" of the Yocto Project for which you found |
| 14486 | the bug (e.g. &DISTRO;). |
| 14487 | </para></listitem> |
| 14488 | <listitem><para> |
| 14489 | Determine and select the "Severity" of the bug. |
| 14490 | The severity indicates how the bug impacted your work. |
| 14491 | </para></listitem> |
| 14492 | <listitem><para> |
| 14493 | Choose the "Hardware" that the bug impacts. |
| 14494 | </para></listitem> |
| 14495 | <listitem><para> |
| 14496 | Choose the "Architecture" that the bug impacts. |
| 14497 | </para></listitem> |
| 14498 | <listitem><para> |
| 14499 | Choose a "Documentation change" item for the bug. |
| 14500 | Fixing a bug might or might not affect the Yocto Project |
| 14501 | documentation. |
| 14502 | If you are unsure of the impact to the documentation, select |
| 14503 | "Don't Know". |
| 14504 | </para></listitem> |
| 14505 | <listitem><para> |
| 14506 | Provide a brief "Summary" of the bug. |
| 14507 | Try to limit your summary to just a line or two and be sure |
| 14508 | to capture the essence of the bug. |
| 14509 | </para></listitem> |
| 14510 | <listitem><para> |
| 14511 | Provide a detailed "Description" of the bug. |
| 14512 | You should provide as much detail as you can about the context, |
| 14513 | behavior, output, and so forth that surrounds the bug. |
| 14514 | You can even attach supporting files for output from logs by |
| 14515 | using the "Add an attachment" button. |
| 14516 | </para></listitem> |
| 14517 | <listitem><para> |
| 14518 | Click the "Submit Bug" button submit the bug. |
| 14519 | A new Bugzilla number is assigned to the bug and the defect |
| 14520 | is logged in the bug tracking system. |
| 14521 | </para></listitem> |
| 14522 | </orderedlist> |
| 14523 | Once you file a bug, the bug is processed by the Yocto Project Bug |
| 14524 | Triage Team and further details concerning the bug are assigned |
| 14525 | (e.g. priority and owner). |
| 14526 | You are the "Submitter" of the bug and any further categorization, |
| 14527 | progress, or comments on the bug result in Bugzilla sending you an |
| 14528 | automated email concerning the particular change or progress to the |
| 14529 | bug. |
| 14530 | </para> |
| 14531 | </section> |
| 14532 | |
| 14533 | <section id='how-to-submit-a-change'> |
| 14534 | <title>Submitting a Change to the Yocto Project</title> |
| 14535 | |
| 14536 | <para> |
| 14537 | Contributions to the Yocto Project and OpenEmbedded are very welcome. |
| 14538 | Because the system is extremely configurable and flexible, we recognize |
| 14539 | that developers will want to extend, configure or optimize it for |
| 14540 | their specific uses. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 14541 | </para> |
| 14542 | |
| 14543 | <para> |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 14544 | The Yocto Project uses a mailing list and a patch-based workflow |
| 14545 | that is similar to the Linux kernel but contains important |
| 14546 | differences. |
| 14547 | In general, a mailing list exists through which you can submit |
| 14548 | patches. |
| 14549 | You should send patches to the appropriate mailing list so that they |
| 14550 | can be reviewed and merged by the appropriate maintainer. |
| 14551 | The specific mailing list you need to use depends on the |
| 14552 | location of the code you are changing. |
| 14553 | Each component (e.g. layer) should have a |
| 14554 | <filename>README</filename> file that indicates where to send |
| 14555 | the changes and which process to follow. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 14556 | </para> |
| 14557 | |
| 14558 | <para> |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 14559 | You can send the patch to the mailing list using whichever approach |
| 14560 | you feel comfortable with to generate the patch. |
| 14561 | Once sent, the patch is usually reviewed by the community at large. |
| 14562 | If somebody has concerns with the patch, they will usually voice |
| 14563 | their concern over the mailing list. |
| 14564 | If a patch does not receive any negative reviews, the maintainer of |
| 14565 | the affected layer typically takes the patch, tests it, and then |
| 14566 | based on successful testing, merges the patch. |
| 14567 | </para> |
| 14568 | |
| 14569 | <para id='figuring-out-the-mailing-list-to-use'> |
| 14570 | The "poky" repository, which is the Yocto Project's reference build |
| 14571 | environment, is a hybrid repository that contains several |
| 14572 | individual pieces (e.g. BitBake, Metadata, documentation, |
| 14573 | and so forth) built using the combo-layer tool. |
| 14574 | The upstream location used for submitting changes varies by |
| 14575 | component: |
| 14576 | <itemizedlist> |
| 14577 | <listitem><para> |
| 14578 | <emphasis>Core Metadata:</emphasis> |
| 14579 | Send your patch to the |
| 14580 | <ulink url='http://lists.openembedded.org/mailman/listinfo/openembedded-core'>openembedded-core</ulink> |
| 14581 | mailing list. For example, a change to anything under |
| 14582 | the <filename>meta</filename> or |
| 14583 | <filename>scripts</filename> directories should be sent |
| 14584 | to this mailing list. |
| 14585 | </para></listitem> |
| 14586 | <listitem><para> |
| 14587 | <emphasis>BitBake:</emphasis> |
| 14588 | For changes to BitBake (i.e. anything under the |
| 14589 | <filename>bitbake</filename> directory), send your patch |
| 14590 | to the |
| 14591 | <ulink url='http://lists.openembedded.org/mailman/listinfo/bitbake-devel'>bitbake-devel</ulink> |
| 14592 | mailing list. |
| 14593 | </para></listitem> |
| 14594 | <listitem><para> |
| 14595 | <emphasis>"meta-*" trees:</emphasis> |
| 14596 | These trees contain Metadata. |
| 14597 | Use the |
| 14598 | <ulink url='https://lists.yoctoproject.org/listinfo/poky'>poky</ulink> |
| 14599 | mailing list. |
| 14600 | </para></listitem> |
| 14601 | </itemizedlist> |
| 14602 | </para> |
| 14603 | |
| 14604 | <para> |
| 14605 | For changes to other layers hosted in the Yocto Project source |
| 14606 | repositories (i.e. <filename>yoctoproject.org</filename>), tools, |
| 14607 | and the Yocto Project documentation, use the |
| 14608 | <ulink url='https://lists.yoctoproject.org/listinfo/yocto'>Yocto Project</ulink> |
| 14609 | general mailing list. |
| 14610 | <note> |
| 14611 | Sometimes a layer's documentation specifies to use a |
| 14612 | particular mailing list. |
| 14613 | If so, use that list. |
| 14614 | </note> |
| 14615 | For additional recipes that do not fit into the core Metadata, you |
| 14616 | should determine which layer the recipe should go into and submit |
| 14617 | the change in the manner recommended by the documentation (e.g. |
| 14618 | the <filename>README</filename> file) supplied with the layer. |
| 14619 | If in doubt, please ask on the Yocto general mailing list or on |
| 14620 | the openembedded-devel mailing list. |
| 14621 | </para> |
| 14622 | |
| 14623 | <para> |
| 14624 | You can also push a change upstream and request a maintainer to |
| 14625 | pull the change into the component's upstream repository. |
| 14626 | You do this by pushing to a contribution repository that is upstream. |
| 14627 | See the |
| 14628 | "<ulink url='&YOCTO_DOCS_OM_URL;#gs-git-workflows-and-the-yocto-project'>Git Workflows and the Yocto Project</ulink>" |
| 14629 | section in the Yocto Project Overview and Concepts Manual for additional |
| 14630 | concepts on working in the Yocto Project development environment. |
| 14631 | </para> |
| 14632 | |
| 14633 | <para> |
| 14634 | Two commonly used testing repositories exist for |
| 14635 | OpenEmbedded-Core: |
| 14636 | <itemizedlist> |
| 14637 | <listitem><para> |
| 14638 | <emphasis>"ross/mut" branch:</emphasis> |
| 14639 | The "mut" (master-under-test) tree |
| 14640 | exists in the <filename>poky-contrib</filename> repository |
| 14641 | in the |
| 14642 | <ulink url='&YOCTO_GIT_URL;'>Yocto Project source repositories</ulink>. |
| 14643 | </para></listitem> |
| 14644 | <listitem><para> |
| 14645 | <emphasis>"master-next" branch:</emphasis> |
| 14646 | This branch is part of the main |
| 14647 | "poky" repository in the Yocto Project source repositories. |
| 14648 | </para></listitem> |
| 14649 | </itemizedlist> |
| 14650 | Maintainers use these branches to test submissions prior to merging |
| 14651 | patches. |
| 14652 | Thus, you can get an idea of the status of a patch based on |
| 14653 | whether the patch has been merged into one of these branches. |
| 14654 | <note> |
| 14655 | This system is imperfect and changes can sometimes get lost in the |
| 14656 | flow. |
| 14657 | Asking about the status of a patch or change is reasonable if the |
| 14658 | change has been idle for a while with no feedback. |
| 14659 | The Yocto Project does have plans to use |
| 14660 | <ulink url='https://en.wikipedia.org/wiki/Patchwork_(software)'>Patchwork</ulink> |
| 14661 | to track the status of patches and also to automatically preview |
| 14662 | patches. |
| 14663 | </note> |
| 14664 | </para> |
| 14665 | |
| 14666 | <para> |
| 14667 | The following sections provide procedures for submitting a change. |
| 14668 | </para> |
| 14669 | |
| 14670 | <section id='pushing-a-change-upstream'> |
| 14671 | <title>Using Scripts to Push a Change Upstream and Request a Pull</title> |
| 14672 | |
| 14673 | <para> |
| 14674 | Follow this procedure to push a change to an upstream "contrib" |
| 14675 | Git repository: |
| 14676 | <note> |
| 14677 | You can find general Git information on how to push a change |
| 14678 | upstream in the |
| 14679 | <ulink url='http://git-scm.com/book/en/v2/Distributed-Git-Distributed-Workflows'>Git Community Book</ulink>. |
| 14680 | </note> |
| 14681 | <orderedlist> |
| 14682 | <listitem><para> |
| 14683 | <emphasis>Make Your Changes Locally:</emphasis> |
| 14684 | Make your changes in your local Git repository. |
| 14685 | You should make small, controlled, isolated changes. |
| 14686 | Keeping changes small and isolated aids review, |
| 14687 | makes merging/rebasing easier and keeps the change |
| 14688 | history clean should anyone need to refer to it in |
| 14689 | future. |
| 14690 | </para></listitem> |
| 14691 | <listitem><para> |
| 14692 | <emphasis>Stage Your Changes:</emphasis> |
| 14693 | Stage your changes by using the <filename>git add</filename> |
| 14694 | command on each file you changed. |
| 14695 | </para></listitem> |
| 14696 | <listitem><para id='making-sure-you-have-correct-commit-information'> |
| 14697 | <emphasis>Commit Your Changes:</emphasis> |
| 14698 | Commit the change by using the |
| 14699 | <filename>git commit</filename> command. |
| 14700 | Make sure your commit information follows standards by |
| 14701 | following these accepted conventions: |
| 14702 | <itemizedlist> |
| 14703 | <listitem><para> |
| 14704 | Be sure to include a "Signed-off-by:" line in the |
| 14705 | same style as required by the Linux kernel. |
| 14706 | Adding this line signifies that you, the submitter, |
| 14707 | have agreed to the Developer's Certificate of |
| 14708 | Origin 1.1 as follows: |
| 14709 | <literallayout class='monospaced'> |
| 14710 | Developer's Certificate of Origin 1.1 |
| 14711 | |
| 14712 | By making a contribution to this project, I certify that: |
| 14713 | |
| 14714 | (a) The contribution was created in whole or in part by me and I |
| 14715 | have the right to submit it under the open source license |
| 14716 | indicated in the file; or |
| 14717 | |
| 14718 | (b) The contribution is based upon previous work that, to the best |
| 14719 | of my knowledge, is covered under an appropriate open source |
| 14720 | license and I have the right under that license to submit that |
| 14721 | work with modifications, whether created in whole or in part |
| 14722 | by me, under the same open source license (unless I am |
| 14723 | permitted to submit under a different license), as indicated |
| 14724 | in the file; or |
| 14725 | |
| 14726 | (c) The contribution was provided directly to me by some other |
| 14727 | person who certified (a), (b) or (c) and I have not modified |
| 14728 | it. |
| 14729 | |
| 14730 | (d) I understand and agree that this project and the contribution |
| 14731 | are public and that a record of the contribution (including all |
| 14732 | personal information I submit with it, including my sign-off) is |
| 14733 | maintained indefinitely and may be redistributed consistent with |
| 14734 | this project or the open source license(s) involved. |
| 14735 | </literallayout> |
| 14736 | </para></listitem> |
| 14737 | <listitem><para> |
| 14738 | Provide a single-line summary of the change. |
| 14739 | and, |
| 14740 | if more explanation is needed, provide more |
| 14741 | detail in the body of the commit. |
| 14742 | This summary is typically viewable in the |
| 14743 | "shortlist" of changes. |
| 14744 | Thus, providing something short and descriptive |
| 14745 | that gives the reader a summary of the change is |
| 14746 | useful when viewing a list of many commits. |
| 14747 | You should prefix this short description with the |
| 14748 | recipe name (if changing a recipe), or else with |
| 14749 | the short form path to the file being changed. |
| 14750 | </para></listitem> |
| 14751 | <listitem><para> |
| 14752 | For the body of the commit message, provide |
| 14753 | detailed information that describes what you |
| 14754 | changed, why you made the change, and the approach |
| 14755 | you used. |
| 14756 | It might also be helpful if you mention how you |
| 14757 | tested the change. |
| 14758 | Provide as much detail as you can in the body of |
| 14759 | the commit message. |
| 14760 | <note> |
| 14761 | You do not need to provide a more detailed |
| 14762 | explanation of a change if the change is |
| 14763 | minor to the point of the single line |
| 14764 | summary providing all the information. |
| 14765 | </note> |
| 14766 | </para></listitem> |
| 14767 | <listitem><para> |
| 14768 | If the change addresses a specific bug or issue |
| 14769 | that is associated with a bug-tracking ID, |
| 14770 | include a reference to that ID in your detailed |
| 14771 | description. |
| 14772 | For example, the Yocto Project uses a specific |
| 14773 | convention for bug references - any commit that |
| 14774 | addresses a specific bug should use the following |
| 14775 | form for the detailed description. |
| 14776 | Be sure to use the actual bug-tracking ID from |
| 14777 | Bugzilla for |
| 14778 | <replaceable>bug-id</replaceable>: |
| 14779 | <literallayout class='monospaced'> |
| 14780 | Fixes [YOCTO #<replaceable>bug-id</replaceable>] |
| 14781 | |
| 14782 | <replaceable>detailed description of change</replaceable> |
| 14783 | </literallayout> |
| 14784 | </para></listitem> |
| 14785 | </itemizedlist> |
| 14786 | </para></listitem> |
| 14787 | <listitem><para> |
| 14788 | <emphasis>Push Your Commits to a "Contrib" Upstream:</emphasis> |
| 14789 | If you have arranged for permissions to push to an |
| 14790 | upstream contrib repository, push the change to that |
| 14791 | repository: |
| 14792 | <literallayout class='monospaced'> |
| 14793 | $ git push <replaceable>upstream_remote_repo</replaceable> <replaceable>local_branch_name</replaceable> |
| 14794 | </literallayout> |
| 14795 | For example, suppose you have permissions to push into the |
| 14796 | upstream <filename>meta-intel-contrib</filename> |
| 14797 | repository and you are working in a local branch named |
| 14798 | <replaceable>your_name</replaceable><filename>/README</filename>. |
| 14799 | The following command pushes your local commits to the |
| 14800 | <filename>meta-intel-contrib</filename> upstream |
| 14801 | repository and puts the commit in a branch named |
| 14802 | <replaceable>your_name</replaceable><filename>/README</filename>: |
| 14803 | <literallayout class='monospaced'> |
| 14804 | $ git push meta-intel-contrib <replaceable>your_name</replaceable>/README |
| 14805 | </literallayout> |
| 14806 | </para></listitem> |
| 14807 | <listitem><para id='push-determine-who-to-notify'> |
| 14808 | <emphasis>Determine Who to Notify:</emphasis> |
| 14809 | Determine the maintainer or the mailing list |
| 14810 | that you need to notify for the change.</para> |
| 14811 | |
| 14812 | <para>Before submitting any change, you need to be sure |
| 14813 | who the maintainer is or what mailing list that you need |
| 14814 | to notify. |
| 14815 | Use either these methods to find out: |
| 14816 | <itemizedlist> |
| 14817 | <listitem><para> |
| 14818 | <emphasis>Maintenance File:</emphasis> |
| 14819 | Examine the <filename>maintainers.inc</filename> |
| 14820 | file, which is located in the |
| 14821 | <ulink url='&YOCTO_DOCS_REF_URL;#source-directory'>Source Directory</ulink> |
| 14822 | at |
| 14823 | <filename>meta/conf/distro/include</filename>, |
| 14824 | to see who is responsible for code. |
| 14825 | </para></listitem> |
| 14826 | <listitem><para> |
| 14827 | <emphasis>Search by File:</emphasis> |
| 14828 | Using <ulink url='&YOCTO_DOCS_OM_URL;#git'>Git</ulink>, |
| 14829 | you can enter the following command to bring up a |
| 14830 | short list of all commits against a specific file: |
| 14831 | <literallayout class='monospaced'> |
| 14832 | git shortlog -- <replaceable>filename</replaceable> |
| 14833 | </literallayout> |
| 14834 | Just provide the name of the file for which you |
| 14835 | are interested. |
| 14836 | The information returned is not ordered by history |
| 14837 | but does include a list of everyone who has |
| 14838 | committed grouped by name. |
| 14839 | From the list, you can see who is responsible for |
| 14840 | the bulk of the changes against the file. |
| 14841 | </para></listitem> |
| 14842 | <listitem><para> |
| 14843 | <emphasis>Examine the List of Mailing Lists:</emphasis> |
| 14844 | For a list of the Yocto Project and related mailing |
| 14845 | lists, see the |
| 14846 | "<ulink url='&YOCTO_DOCS_REF_URL;#resources-mailinglist'>Mailing lists</ulink>" |
| 14847 | section in the Yocto Project Reference Manual. |
| 14848 | </para></listitem> |
| 14849 | </itemizedlist> |
| 14850 | </para></listitem> |
| 14851 | <listitem><para> |
| 14852 | <emphasis>Make a Pull Request:</emphasis> |
| 14853 | Notify the maintainer or the mailing list that you have |
| 14854 | pushed a change by making a pull request.</para> |
| 14855 | |
| 14856 | <para>The Yocto Project provides two scripts that |
| 14857 | conveniently let you generate and send pull requests to the |
| 14858 | Yocto Project. |
| 14859 | These scripts are <filename>create-pull-request</filename> |
| 14860 | and <filename>send-pull-request</filename>. |
| 14861 | You can find these scripts in the |
| 14862 | <filename>scripts</filename> directory within the |
| 14863 | <ulink url='&YOCTO_DOCS_REF_URL;#source-directory'>Source Directory</ulink> |
| 14864 | (e.g. <filename>~/poky/scripts</filename>). |
| 14865 | </para> |
| 14866 | |
| 14867 | <para>Using these scripts correctly formats the requests |
| 14868 | without introducing any whitespace or HTML formatting. |
| 14869 | The maintainer that receives your patches either directly |
| 14870 | or through the mailing list needs to be able to save and |
| 14871 | apply them directly from your emails. |
| 14872 | Using these scripts is the preferred method for sending |
| 14873 | patches.</para> |
| 14874 | |
| 14875 | <para>First, create the pull request. |
| 14876 | For example, the following command runs the script, |
| 14877 | specifies the upstream repository in the contrib directory |
| 14878 | into which you pushed the change, and provides a subject |
| 14879 | line in the created patch files: |
| 14880 | <literallayout class='monospaced'> |
| 14881 | $ ~/poky/scripts/create-pull-request -u meta-intel-contrib -s "Updated Manual Section Reference in README" |
| 14882 | </literallayout> |
| 14883 | Running this script forms |
| 14884 | <filename>*.patch</filename> files in a folder named |
| 14885 | <filename>pull-</filename><replaceable>PID</replaceable> |
| 14886 | in the current directory. |
| 14887 | One of the patch files is a cover letter.</para> |
| 14888 | |
| 14889 | <para>Before running the |
| 14890 | <filename>send-pull-request</filename> script, you must |
| 14891 | edit the cover letter patch to insert information about |
| 14892 | your change. |
| 14893 | After editing the cover letter, send the pull request. |
| 14894 | For example, the following command runs the script and |
| 14895 | specifies the patch directory and email address. |
| 14896 | In this example, the email address is a mailing list: |
| 14897 | <literallayout class='monospaced'> |
| 14898 | $ ~/poky/scripts/send-pull-request -p ~/meta-intel/pull-10565 -t meta-intel@yoctoproject.org |
| 14899 | </literallayout> |
| 14900 | You need to follow the prompts as the script is |
| 14901 | interactive. |
| 14902 | <note> |
| 14903 | For help on using these scripts, simply provide the |
| 14904 | <filename>-h</filename> argument as follows: |
| 14905 | <literallayout class='monospaced'> |
| 14906 | $ poky/scripts/create-pull-request -h |
| 14907 | $ poky/scripts/send-pull-request -h |
| 14908 | </literallayout> |
| 14909 | </note> |
| 14910 | </para></listitem> |
| 14911 | </orderedlist> |
| 14912 | </para> |
| 14913 | </section> |
| 14914 | |
| 14915 | <section id='submitting-a-patch'> |
| 14916 | <title>Using Email to Submit a Patch</title> |
| 14917 | |
| 14918 | <para> |
| 14919 | You can submit patches without using the |
| 14920 | <filename>create-pull-request</filename> and |
| 14921 | <filename>send-pull-request</filename> scripts described in the |
| 14922 | previous section. |
| 14923 | However, keep in mind, the preferred method is to use the scripts. |
| 14924 | </para> |
| 14925 | |
| 14926 | <para> |
| 14927 | Depending on the components changed, you need to submit the email |
| 14928 | to a specific mailing list. |
| 14929 | For some guidance on which mailing list to use, see the |
| 14930 | <link linkend='figuring-out-the-mailing-list-to-use'>list</link> |
| 14931 | at the beginning of this section. |
| 14932 | For a description of all the available mailing lists, see the |
| 14933 | "<ulink url='&YOCTO_DOCS_REF_URL;#resources-mailinglist'>Mailing Lists</ulink>" |
| 14934 | section in the Yocto Project Reference Manual. |
| 14935 | </para> |
| 14936 | |
| 14937 | <para> |
| 14938 | Here is the general procedure on how to submit a patch through |
| 14939 | email without using the scripts: |
| 14940 | <orderedlist> |
| 14941 | <listitem><para> |
| 14942 | <emphasis>Make Your Changes Locally:</emphasis> |
| 14943 | Make your changes in your local Git repository. |
| 14944 | You should make small, controlled, isolated changes. |
| 14945 | Keeping changes small and isolated aids review, |
| 14946 | makes merging/rebasing easier and keeps the change |
| 14947 | history clean should anyone need to refer to it in |
| 14948 | future. |
| 14949 | </para></listitem> |
| 14950 | <listitem><para> |
| 14951 | <emphasis>Stage Your Changes:</emphasis> |
| 14952 | Stage your changes by using the <filename>git add</filename> |
| 14953 | command on each file you changed. |
| 14954 | </para></listitem> |
| 14955 | <listitem><para> |
| 14956 | <emphasis>Commit Your Changes:</emphasis> |
| 14957 | Commit the change by using the |
| 14958 | <filename>git commit --signoff</filename> command. |
| 14959 | Using the <filename>--signoff</filename> option identifies |
| 14960 | you as the person making the change and also satisfies |
| 14961 | the Developer's Certificate of Origin (DCO) shown earlier. |
| 14962 | </para> |
| 14963 | |
| 14964 | <para>When you form a commit, you must follow certain |
| 14965 | standards established by the Yocto Project development |
| 14966 | team. |
| 14967 | See |
| 14968 | <link linkend='making-sure-you-have-correct-commit-information'>Step 3</link> |
| 14969 | in the previous section for information on how to |
| 14970 | provide commit information that meets Yocto Project |
| 14971 | commit message standards. |
| 14972 | </para></listitem> |
| 14973 | <listitem><para> |
| 14974 | <emphasis>Format the Commit:</emphasis> |
| 14975 | Format the commit into an email message. |
| 14976 | To format commits, use the |
| 14977 | <filename>git format-patch</filename> command. |
| 14978 | When you provide the command, you must include a revision |
| 14979 | list or a number of patches as part of the command. |
| 14980 | For example, either of these two commands takes your most |
| 14981 | recent single commit and formats it as an email message in |
| 14982 | the current directory: |
| 14983 | <literallayout class='monospaced'> |
| 14984 | $ git format-patch -1 |
| 14985 | </literallayout> |
| 14986 | or |
| 14987 | <literallayout class='monospaced'> |
| 14988 | $ git format-patch HEAD~ |
| 14989 | </literallayout></para> |
| 14990 | |
| 14991 | <para>After the command is run, the current directory |
| 14992 | contains a numbered <filename>.patch</filename> file for |
| 14993 | the commit.</para> |
| 14994 | |
| 14995 | <para>If you provide several commits as part of the |
| 14996 | command, the <filename>git format-patch</filename> command |
| 14997 | produces a series of numbered files in the current |
| 14998 | directory – one for each commit. |
| 14999 | If you have more than one patch, you should also use the |
| 15000 | <filename>--cover</filename> option with the command, |
| 15001 | which generates a cover letter as the first "patch" in |
| 15002 | the series. |
| 15003 | You can then edit the cover letter to provide a |
| 15004 | description for the series of patches. |
| 15005 | For information on the |
| 15006 | <filename>git format-patch</filename> command, |
| 15007 | see <filename>GIT_FORMAT_PATCH(1)</filename> displayed |
| 15008 | using the <filename>man git-format-patch</filename> |
| 15009 | command. |
| 15010 | <note> |
| 15011 | If you are or will be a frequent contributor to the |
| 15012 | Yocto Project or to OpenEmbedded, you might consider |
| 15013 | requesting a contrib area and the necessary associated |
| 15014 | rights. |
| 15015 | </note> |
| 15016 | </para></listitem> |
| 15017 | <listitem><para> |
| 15018 | <emphasis>Import the Files Into Your Mail Client:</emphasis> |
| 15019 | Import the files into your mail client by using the |
| 15020 | <filename>git send-email</filename> command. |
| 15021 | <note> |
| 15022 | In order to use <filename>git send-email</filename>, |
| 15023 | you must have the proper Git packages installed on |
| 15024 | your host. |
| 15025 | For Ubuntu, Debian, and Fedora the package is |
| 15026 | <filename>git-email</filename>. |
| 15027 | </note></para> |
| 15028 | |
| 15029 | <para>The <filename>git send-email</filename> command |
| 15030 | sends email by using a local or remote Mail Transport Agent |
| 15031 | (MTA) such as <filename>msmtp</filename>, |
| 15032 | <filename>sendmail</filename>, or through a direct |
| 15033 | <filename>smtp</filename> configuration in your Git |
| 15034 | <filename>~/.gitconfig</filename> file. |
| 15035 | If you are submitting patches through email only, it is |
| 15036 | very important that you submit them without any whitespace |
| 15037 | or HTML formatting that either you or your mailer |
| 15038 | introduces. |
| 15039 | The maintainer that receives your patches needs to be able |
| 15040 | to save and apply them directly from your emails. |
| 15041 | A good way to verify that what you are sending will be |
| 15042 | applicable by the maintainer is to do a dry run and send |
| 15043 | them to yourself and then save and apply them as the |
| 15044 | maintainer would.</para> |
| 15045 | |
| 15046 | <para>The <filename>git send-email</filename> command is |
| 15047 | the preferred method for sending your patches using |
| 15048 | email since there is no risk of compromising whitespace |
| 15049 | in the body of the message, which can occur when you use |
| 15050 | your own mail client. |
| 15051 | The command also has several options that let you |
| 15052 | specify recipients and perform further editing of the |
| 15053 | email message. |
| 15054 | For information on how to use the |
| 15055 | <filename>git send-email</filename> command, |
| 15056 | see <filename>GIT-SEND-EMAIL(1)</filename> displayed using |
| 15057 | the <filename>man git-send-email</filename> command. |
| 15058 | </para></listitem> |
| 15059 | </orderedlist> |
| 15060 | </para> |
| 15061 | </section> |
| 15062 | </section> |
| 15063 | </section> |
| 15064 | |
| 15065 | <section id='working-with-licenses'> |
| 15066 | <title>Working With Licenses</title> |
| 15067 | |
| 15068 | <para> |
| 15069 | As mentioned in the |
| 15070 | "<ulink url='&YOCTO_DOCS_OM_URL;#licensing'>Licensing</ulink>" |
| 15071 | section in the Yocto Project Overview and Concepts Manual, |
| 15072 | open source projects are open to the public and they |
| 15073 | consequently have different licensing structures in place. |
| 15074 | This section describes the mechanism by which the |
| 15075 | <ulink url='&YOCTO_DOCS_REF_URL;#build-system-term'>OpenEmbedded build system</ulink> |
| 15076 | tracks changes to licensing text and covers how to maintain open |
| 15077 | source license compliance during your project's lifecycle. |
| 15078 | The section also describes how to enable commercially licensed |
| 15079 | recipes, which by default are disabled. |
| 15080 | </para> |
| 15081 | |
| 15082 | <section id="usingpoky-configuring-LIC_FILES_CHKSUM"> |
| 15083 | <title>Tracking License Changes</title> |
| 15084 | |
| 15085 | <para> |
| 15086 | The license of an upstream project might change in the future. |
| 15087 | In order to prevent these changes going unnoticed, the |
| 15088 | <ulink url='&YOCTO_DOCS_REF_URL;#var-LIC_FILES_CHKSUM'><filename>LIC_FILES_CHKSUM</filename></ulink> |
| 15089 | variable tracks changes to the license text. The checksums are |
| 15090 | validated at the end of the configure step, and if the |
| 15091 | checksums do not match, the build will fail. |
| 15092 | </para> |
| 15093 | |
| 15094 | <section id="usingpoky-specifying-LIC_FILES_CHKSUM"> |
| 15095 | <title>Specifying the <filename>LIC_FILES_CHKSUM</filename> Variable</title> |
| 15096 | |
| 15097 | <para> |
| 15098 | The <filename>LIC_FILES_CHKSUM</filename> |
| 15099 | variable contains checksums of the license text in the |
| 15100 | source code for the recipe. |
| 15101 | Following is an example of how to specify |
| 15102 | <filename>LIC_FILES_CHKSUM</filename>: |
| 15103 | <literallayout class='monospaced'> |
| 15104 | LIC_FILES_CHKSUM = "file://COPYING;md5=xxxx \ |
| 15105 | file://licfile1.txt;beginline=5;endline=29;md5=yyyy \ |
| 15106 | file://licfile2.txt;endline=50;md5=zzzz \ |
| 15107 | ..." |
| 15108 | </literallayout> |
| 15109 | <note><title>Notes</title> |
| 15110 | <itemizedlist> |
| 15111 | <listitem><para> |
| 15112 | When using "beginline" and "endline", realize |
| 15113 | that line numbering begins with one and not |
| 15114 | zero. |
| 15115 | Also, the included lines are inclusive (i.e. |
| 15116 | lines five through and including 29 in the |
| 15117 | previous example for |
| 15118 | <filename>licfile1.txt</filename>). |
| 15119 | </para></listitem> |
| 15120 | <listitem><para> |
| 15121 | When a license check fails, the selected license |
| 15122 | text is included as part of the QA message. |
| 15123 | Using this output, you can determine the exact |
| 15124 | start and finish for the needed license text. |
| 15125 | </para></listitem> |
| 15126 | </itemizedlist> |
| 15127 | </note> |
| 15128 | </para> |
| 15129 | |
| 15130 | <para> |
| 15131 | The build system uses the |
| 15132 | <ulink url='&YOCTO_DOCS_REF_URL;#var-S'><filename>S</filename></ulink> |
| 15133 | variable as the default directory when searching files |
| 15134 | listed in <filename>LIC_FILES_CHKSUM</filename>. |
| 15135 | The previous example employs the default directory. |
| 15136 | </para> |
| 15137 | |
| 15138 | <para> |
| 15139 | Consider this next example: |
| 15140 | <literallayout class='monospaced'> |
| 15141 | LIC_FILES_CHKSUM = "file://src/ls.c;beginline=5;endline=16;\ |
| 15142 | md5=bb14ed3c4cda583abc85401304b5cd4e" |
| 15143 | LIC_FILES_CHKSUM = "file://${WORKDIR}/license.html;md5=5c94767cedb5d6987c902ac850ded2c6" |
| 15144 | </literallayout> |
| 15145 | </para> |
| 15146 | |
| 15147 | <para> |
| 15148 | The first line locates a file in |
| 15149 | <filename>${S}/src/ls.c</filename> and isolates lines five |
| 15150 | through 16 as license text. |
| 15151 | The second line refers to a file in |
| 15152 | <ulink url='&YOCTO_DOCS_REF_URL;#var-WORKDIR'><filename>WORKDIR</filename></ulink>. |
| 15153 | </para> |
| 15154 | |
| 15155 | <para> |
| 15156 | Note that <filename>LIC_FILES_CHKSUM</filename> variable is |
| 15157 | mandatory for all recipes, unless the |
| 15158 | <filename>LICENSE</filename> variable is set to "CLOSED". |
| 15159 | </para> |
| 15160 | </section> |
| 15161 | |
| 15162 | <section id="usingpoky-LIC_FILES_CHKSUM-explanation-of-syntax"> |
| 15163 | <title>Explanation of Syntax</title> |
| 15164 | |
| 15165 | <para> |
| 15166 | As mentioned in the previous section, the |
| 15167 | <filename>LIC_FILES_CHKSUM</filename> variable lists all |
| 15168 | the important files that contain the license text for the |
| 15169 | source code. |
| 15170 | It is possible to specify a checksum for an entire file, |
| 15171 | or a specific section of a file (specified by beginning and |
| 15172 | ending line numbers with the "beginline" and "endline" |
| 15173 | parameters, respectively). |
| 15174 | The latter is useful for source files with a license |
| 15175 | notice header, README documents, and so forth. |
| 15176 | If you do not use the "beginline" parameter, then it is |
| 15177 | assumed that the text begins on the first line of the file. |
| 15178 | Similarly, if you do not use the "endline" parameter, |
| 15179 | it is assumed that the license text ends with the last |
| 15180 | line of the file. |
| 15181 | </para> |
| 15182 | |
| 15183 | <para> |
| 15184 | The "md5" parameter stores the md5 checksum of the license |
| 15185 | text. |
| 15186 | If the license text changes in any way as compared to |
| 15187 | this parameter then a mismatch occurs. |
| 15188 | This mismatch triggers a build failure and notifies |
| 15189 | the developer. |
| 15190 | Notification allows the developer to review and address |
| 15191 | the license text changes. |
| 15192 | Also note that if a mismatch occurs during the build, |
| 15193 | the correct md5 checksum is placed in the build log and |
| 15194 | can be easily copied to the recipe. |
| 15195 | </para> |
| 15196 | |
| 15197 | <para> |
| 15198 | There is no limit to how many files you can specify using |
| 15199 | the <filename>LIC_FILES_CHKSUM</filename> variable. |
| 15200 | Generally, however, every project requires a few |
| 15201 | specifications for license tracking. |
| 15202 | Many projects have a "COPYING" file that stores the |
| 15203 | license information for all the source code files. |
| 15204 | This practice allows you to just track the "COPYING" |
| 15205 | file as long as it is kept up to date. |
| 15206 | <note><title>Tips</title> |
| 15207 | <itemizedlist> |
| 15208 | <listitem><para> |
| 15209 | If you specify an empty or invalid "md5" |
| 15210 | parameter, |
| 15211 | <ulink url='&YOCTO_DOCS_REF_URL;#bitbake-term'>BitBake</ulink> |
| 15212 | returns an md5 mis-match |
| 15213 | error and displays the correct "md5" parameter |
| 15214 | value during the build. |
| 15215 | The correct parameter is also captured in |
| 15216 | the build log. |
| 15217 | </para></listitem> |
| 15218 | <listitem><para> |
| 15219 | If the whole file contains only license text, |
| 15220 | you do not need to use the "beginline" and |
| 15221 | "endline" parameters. |
| 15222 | </para></listitem> |
| 15223 | </itemizedlist> |
| 15224 | </note> |
| 15225 | </para> |
| 15226 | </section> |
| 15227 | </section> |
| 15228 | |
| 15229 | <section id="enabling-commercially-licensed-recipes"> |
| 15230 | <title>Enabling Commercially Licensed Recipes</title> |
| 15231 | |
| 15232 | <para> |
| 15233 | By default, the OpenEmbedded build system disables |
| 15234 | components that have commercial or other special licensing |
| 15235 | requirements. |
| 15236 | Such requirements are defined on a |
| 15237 | recipe-by-recipe basis through the |
| 15238 | <ulink url='&YOCTO_DOCS_REF_URL;#var-LICENSE_FLAGS'><filename>LICENSE_FLAGS</filename></ulink> |
| 15239 | variable definition in the affected recipe. |
| 15240 | For instance, the |
| 15241 | <filename>poky/meta/recipes-multimedia/gstreamer/gst-plugins-ugly</filename> |
| 15242 | recipe contains the following statement: |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 15243 | <literallayout class='monospaced'> |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 15244 | LICENSE_FLAGS = "commercial" |
| 15245 | </literallayout> |
| 15246 | Here is a slightly more complicated example that contains both |
| 15247 | an explicit recipe name and version (after variable expansion): |
| 15248 | <literallayout class='monospaced'> |
| 15249 | LICENSE_FLAGS = "license_${PN}_${PV}" |
| 15250 | </literallayout> |
| 15251 | In order for a component restricted by a |
| 15252 | <filename>LICENSE_FLAGS</filename> definition to be enabled and |
| 15253 | included in an image, it needs to have a matching entry in the |
| 15254 | global |
| 15255 | <ulink url='&YOCTO_DOCS_REF_URL;#var-LICENSE_FLAGS_WHITELIST'><filename>LICENSE_FLAGS_WHITELIST</filename></ulink> |
| 15256 | variable, which is a variable typically defined in your |
| 15257 | <filename>local.conf</filename> file. |
| 15258 | For example, to enable the |
| 15259 | <filename>poky/meta/recipes-multimedia/gstreamer/gst-plugins-ugly</filename> |
| 15260 | package, you could add either the string |
| 15261 | "commercial_gst-plugins-ugly" or the more general string |
| 15262 | "commercial" to <filename>LICENSE_FLAGS_WHITELIST</filename>. |
| 15263 | See the |
| 15264 | "<link linkend='license-flag-matching'>License Flag Matching</link>" |
| 15265 | section for a full |
| 15266 | explanation of how <filename>LICENSE_FLAGS</filename> matching |
| 15267 | works. |
| 15268 | Here is the example: |
| 15269 | <literallayout class='monospaced'> |
| 15270 | LICENSE_FLAGS_WHITELIST = "commercial_gst-plugins-ugly" |
| 15271 | </literallayout> |
| 15272 | Likewise, to additionally enable the package built from the |
| 15273 | recipe containing |
| 15274 | <filename>LICENSE_FLAGS = "license_${PN}_${PV}"</filename>, |
| 15275 | and assuming that the actual recipe name was |
| 15276 | <filename>emgd_1.10.bb</filename>, the following string would |
| 15277 | enable that package as well as the original |
| 15278 | <filename>gst-plugins-ugly</filename> package: |
| 15279 | <literallayout class='monospaced'> |
| 15280 | LICENSE_FLAGS_WHITELIST = "commercial_gst-plugins-ugly license_emgd_1.10" |
| 15281 | </literallayout> |
| 15282 | As a convenience, you do not need to specify the complete |
| 15283 | license string in the whitelist for every package. |
| 15284 | You can use an abbreviated form, which consists |
| 15285 | of just the first portion or portions of the license |
| 15286 | string before the initial underscore character or characters. |
| 15287 | A partial string will match any license that contains the |
| 15288 | given string as the first portion of its license. |
| 15289 | For example, the following whitelist string will also match |
| 15290 | both of the packages previously mentioned as well as any other |
| 15291 | packages that have licenses starting with "commercial" or |
| 15292 | "license". |
| 15293 | <literallayout class='monospaced'> |
| 15294 | LICENSE_FLAGS_WHITELIST = "commercial license" |
| 15295 | </literallayout> |
| 15296 | </para> |
| 15297 | |
| 15298 | <section id="license-flag-matching"> |
| 15299 | <title>License Flag Matching</title> |
| 15300 | |
| 15301 | <para> |
| 15302 | License flag matching allows you to control what recipes |
| 15303 | the OpenEmbedded build system includes in the build. |
| 15304 | Fundamentally, the build system attempts to match |
| 15305 | <filename>LICENSE_FLAGS</filename> strings found in recipes |
| 15306 | against <filename>LICENSE_FLAGS_WHITELIST</filename> |
| 15307 | strings found in the whitelist. |
| 15308 | A match causes the build system to include a recipe in the |
| 15309 | build, while failure to find a match causes the build |
| 15310 | system to exclude a recipe. |
| 15311 | </para> |
| 15312 | |
| 15313 | <para> |
| 15314 | In general, license flag matching is simple. |
| 15315 | However, understanding some concepts will help you |
| 15316 | correctly and effectively use matching. |
| 15317 | </para> |
| 15318 | |
| 15319 | <para> |
| 15320 | Before a flag |
| 15321 | defined by a particular recipe is tested against the |
| 15322 | contents of the whitelist, the expanded string |
| 15323 | <filename>_${PN}</filename> is appended to the flag. |
| 15324 | This expansion makes each |
| 15325 | <filename>LICENSE_FLAGS</filename> value recipe-specific. |
| 15326 | After expansion, the string is then matched against the |
| 15327 | whitelist. |
| 15328 | Thus, specifying |
| 15329 | <filename>LICENSE_FLAGS = "commercial"</filename> |
| 15330 | in recipe "foo", for example, results in the string |
| 15331 | <filename>"commercial_foo"</filename>. |
| 15332 | And, to create a match, that string must appear in the |
| 15333 | whitelist. |
| 15334 | </para> |
| 15335 | |
| 15336 | <para> |
| 15337 | Judicious use of the <filename>LICENSE_FLAGS</filename> |
| 15338 | strings and the contents of the |
| 15339 | <filename>LICENSE_FLAGS_WHITELIST</filename> variable |
| 15340 | allows you a lot of flexibility for including or excluding |
| 15341 | recipes based on licensing. |
| 15342 | For example, you can broaden the matching capabilities by |
| 15343 | using license flags string subsets in the whitelist. |
| 15344 | <note> |
| 15345 | When using a string subset, be sure to use the part of |
| 15346 | the expanded string that precedes the appended |
| 15347 | underscore character (e.g. |
| 15348 | <filename>usethispart_1.3</filename>, |
| 15349 | <filename>usethispart_1.4</filename>, and so forth). |
| 15350 | </note> |
| 15351 | For example, simply specifying the string "commercial" in |
| 15352 | the whitelist matches any expanded |
| 15353 | <filename>LICENSE_FLAGS</filename> definition that starts |
| 15354 | with the string "commercial" such as "commercial_foo" and |
| 15355 | "commercial_bar", which are the strings the build system |
| 15356 | automatically generates for hypothetical recipes named |
| 15357 | "foo" and "bar" assuming those recipes simply specify the |
| 15358 | following: |
| 15359 | <literallayout class='monospaced'> |
| 15360 | LICENSE_FLAGS = "commercial" |
| 15361 | </literallayout> |
| 15362 | Thus, you can choose to exhaustively |
| 15363 | enumerate each license flag in the whitelist and |
| 15364 | allow only specific recipes into the image, or |
| 15365 | you can use a string subset that causes a broader range of |
| 15366 | matches to allow a range of recipes into the image. |
| 15367 | </para> |
| 15368 | |
| 15369 | <para> |
| 15370 | This scheme works even if the |
| 15371 | <filename>LICENSE_FLAGS</filename> string already |
| 15372 | has <filename>_${PN}</filename> appended. |
| 15373 | For example, the build system turns the license flag |
| 15374 | "commercial_1.2_foo" into "commercial_1.2_foo_foo" and |
| 15375 | would match both the general "commercial" and the specific |
| 15376 | "commercial_1.2_foo" strings found in the whitelist, as |
| 15377 | expected. |
| 15378 | </para> |
| 15379 | |
| 15380 | <para> |
| 15381 | Here are some other scenarios: |
| 15382 | <itemizedlist> |
| 15383 | <listitem><para> |
| 15384 | You can specify a versioned string in the recipe |
| 15385 | such as "commercial_foo_1.2" in a "foo" recipe. |
| 15386 | The build system expands this string to |
| 15387 | "commercial_foo_1.2_foo". |
| 15388 | Combine this license flag with a whitelist that has |
| 15389 | the string "commercial" and you match the flag |
| 15390 | along with any other flag that starts with the |
| 15391 | string "commercial". |
| 15392 | </para></listitem> |
| 15393 | <listitem><para> |
| 15394 | Under the same circumstances, you can use |
| 15395 | "commercial_foo" in the whitelist and the build |
| 15396 | system not only matches "commercial_foo_1.2" but |
| 15397 | also matches any license flag with the string |
| 15398 | "commercial_foo", regardless of the version. |
| 15399 | </para></listitem> |
| 15400 | <listitem><para> |
| 15401 | You can be very specific and use both the |
| 15402 | package and version parts in the whitelist (e.g. |
| 15403 | "commercial_foo_1.2") to specifically match a |
| 15404 | versioned recipe. |
| 15405 | </para></listitem> |
| 15406 | </itemizedlist> |
| 15407 | </para> |
| 15408 | </section> |
| 15409 | |
| 15410 | <section id="other-variables-related-to-commercial-licenses"> |
| 15411 | <title>Other Variables Related to Commercial Licenses</title> |
| 15412 | |
| 15413 | <para> |
| 15414 | Other helpful variables related to commercial |
| 15415 | license handling exist and are defined in the |
| 15416 | <filename>poky/meta/conf/distro/include/default-distrovars.inc</filename> file: |
| 15417 | <literallayout class='monospaced'> |
| 15418 | COMMERCIAL_AUDIO_PLUGINS ?= "" |
| 15419 | COMMERCIAL_VIDEO_PLUGINS ?= "" |
| 15420 | </literallayout> |
| 15421 | If you want to enable these components, you can do so by |
| 15422 | making sure you have statements similar to the following |
| 15423 | in your <filename>local.conf</filename> configuration file: |
| 15424 | <literallayout class='monospaced'> |
| 15425 | COMMERCIAL_AUDIO_PLUGINS = "gst-plugins-ugly-mad \ |
| 15426 | gst-plugins-ugly-mpegaudioparse" |
| 15427 | COMMERCIAL_VIDEO_PLUGINS = "gst-plugins-ugly-mpeg2dec \ |
| 15428 | gst-plugins-ugly-mpegstream gst-plugins-bad-mpegvideoparse" |
| 15429 | LICENSE_FLAGS_WHITELIST = "commercial_gst-plugins-ugly commercial_gst-plugins-bad commercial_qmmp" |
| 15430 | </literallayout> |
| 15431 | Of course, you could also create a matching whitelist |
| 15432 | for those components using the more general "commercial" |
| 15433 | in the whitelist, but that would also enable all the |
| 15434 | other packages with <filename>LICENSE_FLAGS</filename> |
| 15435 | containing "commercial", which you may or may not want: |
| 15436 | <literallayout class='monospaced'> |
| 15437 | LICENSE_FLAGS_WHITELIST = "commercial" |
| 15438 | </literallayout> |
| 15439 | </para> |
| 15440 | |
| 15441 | <para> |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 15442 | Specifying audio and video plugins as part of the |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 15443 | <filename>COMMERCIAL_AUDIO_PLUGINS</filename> and |
| 15444 | <filename>COMMERCIAL_VIDEO_PLUGINS</filename> statements |
| 15445 | (along with the enabling |
| 15446 | <filename>LICENSE_FLAGS_WHITELIST</filename>) includes the |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 15447 | plugins or components into built images, thus adding |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 15448 | support for media formats or components. |
| 15449 | </para> |
| 15450 | </section> |
| 15451 | </section> |
| 15452 | |
| 15453 | <section id='maintaining-open-source-license-compliance-during-your-products-lifecycle'> |
| 15454 | <title>Maintaining Open Source License Compliance During Your Product's Lifecycle</title> |
| 15455 | |
| 15456 | <para> |
| 15457 | One of the concerns for a development organization using open source |
| 15458 | software is how to maintain compliance with various open source |
| 15459 | licensing during the lifecycle of the product. |
| 15460 | While this section does not provide legal advice or |
| 15461 | comprehensively cover all scenarios, it does |
| 15462 | present methods that you can use to |
| 15463 | assist you in meeting the compliance requirements during a software |
| 15464 | release. |
| 15465 | </para> |
| 15466 | |
| 15467 | <para> |
| 15468 | With hundreds of different open source licenses that the Yocto |
| 15469 | Project tracks, it is difficult to know the requirements of each |
| 15470 | and every license. |
| 15471 | However, the requirements of the major FLOSS licenses can begin |
| 15472 | to be covered by |
| 15473 | assuming that three main areas of concern exist: |
| 15474 | <itemizedlist> |
| 15475 | <listitem><para>Source code must be provided.</para></listitem> |
| 15476 | <listitem><para>License text for the software must be |
| 15477 | provided.</para></listitem> |
| 15478 | <listitem><para>Compilation scripts and modifications to the |
| 15479 | source code must be provided. |
| 15480 | </para></listitem> |
| 15481 | </itemizedlist> |
| 15482 | There are other requirements beyond the scope of these |
| 15483 | three and the methods described in this section |
| 15484 | (e.g. the mechanism through which source code is distributed). |
| 15485 | </para> |
| 15486 | |
| 15487 | <para> |
| 15488 | As different organizations have different methods of complying with |
| 15489 | open source licensing, this section is not meant to imply that |
| 15490 | there is only one single way to meet your compliance obligations, |
| 15491 | but rather to describe one method of achieving compliance. |
| 15492 | The remainder of this section describes methods supported to meet the |
| 15493 | previously mentioned three requirements. |
| 15494 | Once you take steps to meet these requirements, |
| 15495 | and prior to releasing images, sources, and the build system, |
| 15496 | you should audit all artifacts to ensure completeness. |
| 15497 | <note> |
| 15498 | The Yocto Project generates a license manifest during |
| 15499 | image creation that is located |
| 15500 | in <filename>${DEPLOY_DIR}/licenses/<replaceable>image_name-datestamp</replaceable></filename> |
| 15501 | to assist with any audits. |
| 15502 | </note> |
| 15503 | </para> |
| 15504 | |
| 15505 | <section id='providing-the-source-code'> |
| 15506 | <title>Providing the Source Code</title> |
| 15507 | |
| 15508 | <para> |
| 15509 | Compliance activities should begin before you generate the |
| 15510 | final image. |
| 15511 | The first thing you should look at is the requirement that |
| 15512 | tops the list for most compliance groups - providing |
| 15513 | the source. |
| 15514 | The Yocto Project has a few ways of meeting this |
| 15515 | requirement. |
| 15516 | </para> |
| 15517 | |
| 15518 | <para> |
| 15519 | One of the easiest ways to meet this requirement is |
| 15520 | to provide the entire |
| 15521 | <ulink url='&YOCTO_DOCS_REF_URL;#var-DL_DIR'><filename>DL_DIR</filename></ulink> |
| 15522 | used by the build. |
| 15523 | This method, however, has a few issues. |
| 15524 | The most obvious is the size of the directory since it includes |
| 15525 | all sources used in the build and not just the source used in |
| 15526 | the released image. |
| 15527 | It will include toolchain source, and other artifacts, which |
| 15528 | you would not generally release. |
| 15529 | However, the more serious issue for most companies is accidental |
| 15530 | release of proprietary software. |
| 15531 | The Yocto Project provides an |
| 15532 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-archiver'><filename>archiver</filename></ulink> |
| 15533 | class to help avoid some of these concerns. |
| 15534 | </para> |
| 15535 | |
| 15536 | <para> |
| 15537 | Before you employ <filename>DL_DIR</filename> or the |
| 15538 | <filename>archiver</filename> class, you need to decide how |
| 15539 | you choose to provide source. |
| 15540 | The source <filename>archiver</filename> class can generate |
| 15541 | tarballs and SRPMs and can create them with various levels of |
| 15542 | compliance in mind. |
| 15543 | </para> |
| 15544 | |
| 15545 | <para> |
| 15546 | One way of doing this (but certainly not the only way) is to |
| 15547 | release just the source as a tarball. |
| 15548 | You can do this by adding the following to the |
| 15549 | <filename>local.conf</filename> file found in the |
| 15550 | <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink>: |
| 15551 | <literallayout class='monospaced'> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 15552 | INHERIT += "archiver" |
| 15553 | ARCHIVER_MODE[src] = "original" |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 15554 | </literallayout> |
| 15555 | During the creation of your image, the source from all |
| 15556 | recipes that deploy packages to the image is placed within |
| 15557 | subdirectories of |
| 15558 | <filename>DEPLOY_DIR/sources</filename> based on the |
| 15559 | <ulink url='&YOCTO_DOCS_REF_URL;#var-LICENSE'><filename>LICENSE</filename></ulink> |
| 15560 | for each recipe. |
| 15561 | Releasing the entire directory enables you to comply with |
| 15562 | requirements concerning providing the unmodified source. |
| 15563 | It is important to note that the size of the directory can |
| 15564 | get large. |
| 15565 | </para> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 15566 | |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 15567 | <para> |
| 15568 | A way to help mitigate the size issue is to only release |
| 15569 | tarballs for licenses that require the release of |
| 15570 | source. |
| 15571 | Let us assume you are only concerned with GPL code as |
| 15572 | identified by running the following script: |
| 15573 | <literallayout class='monospaced'> |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 15574 | # Script to archive a subset of packages matching specific license(s) |
| 15575 | # Source and license files are copied into sub folders of package folder |
| 15576 | # Must be run from build folder |
| 15577 | #!/bin/bash |
| 15578 | src_release_dir="source-release" |
| 15579 | mkdir -p $src_release_dir |
| 15580 | for a in tmp/deploy/sources/*; do |
| 15581 | for d in $a/*; do |
| 15582 | # Get package name from path |
| 15583 | p=`basename $d` |
| 15584 | p=${p%-*} |
| 15585 | p=${p%-*} |
| 15586 | # Only archive GPL packages (update *GPL* regex for your license check) |
| 15587 | numfiles=`ls tmp/deploy/licenses/$p/*GPL* 2> /dev/null | wc -l` |
| 15588 | if [ $numfiles -gt 1 ]; then |
| 15589 | echo Archiving $p |
| 15590 | mkdir -p $src_release_dir/$p/source |
| 15591 | cp $d/* $src_release_dir/$p/source 2> /dev/null |
| 15592 | mkdir -p $src_release_dir/$p/license |
| 15593 | cp tmp/deploy/licenses/$p/* $src_release_dir/$p/license 2> /dev/null |
| 15594 | fi |
| 15595 | done |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 15596 | done |
| 15597 | </literallayout> |
| 15598 | At this point, you could create a tarball from the |
| 15599 | <filename>gpl_source_release</filename> directory and |
| 15600 | provide that to the end user. |
| 15601 | This method would be a step toward achieving compliance |
| 15602 | with section 3a of GPLv2 and with section 6 of GPLv3. |
| 15603 | </para> |
| 15604 | </section> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 15605 | |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 15606 | <section id='providing-license-text'> |
| 15607 | <title>Providing License Text</title> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 15608 | |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 15609 | <para> |
| 15610 | One requirement that is often overlooked is inclusion |
| 15611 | of license text. |
| 15612 | This requirement also needs to be dealt with prior to |
| 15613 | generating the final image. |
| 15614 | Some licenses require the license text to accompany |
| 15615 | the binary. |
| 15616 | You can achieve this by adding the following to your |
| 15617 | <filename>local.conf</filename> file: |
| 15618 | <literallayout class='monospaced'> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 15619 | COPY_LIC_MANIFEST = "1" |
| 15620 | COPY_LIC_DIRS = "1" |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 15621 | LICENSE_CREATE_PACKAGE = "1" |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 15622 | </literallayout> |
| 15623 | Adding these statements to the configuration file ensures |
| 15624 | that the licenses collected during package generation |
| 15625 | are included on your image. |
| 15626 | <note> |
| 15627 | <para>Setting all three variables to "1" results in the |
| 15628 | image having two copies of the same license file. |
| 15629 | One copy resides in |
| 15630 | <filename>/usr/share/common-licenses</filename> and |
| 15631 | the other resides in |
| 15632 | <filename>/usr/share/license</filename>.</para> |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 15633 | |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 15634 | <para>The reason for this behavior is because |
| 15635 | <ulink url='&YOCTO_DOCS_REF_URL;#var-COPY_LIC_DIRS'><filename>COPY_LIC_DIRS</filename></ulink> |
| 15636 | and |
| 15637 | <ulink url='&YOCTO_DOCS_REF_URL;#var-COPY_LIC_MANIFEST'><filename>COPY_LIC_MANIFEST</filename></ulink> |
| 15638 | add a copy of the license when the image is built but do |
| 15639 | not offer a path for adding licenses for newly installed |
| 15640 | packages to an image. |
| 15641 | <ulink url='&YOCTO_DOCS_REF_URL;#var-LICENSE_CREATE_PACKAGE'><filename>LICENSE_CREATE_PACKAGE</filename></ulink> |
| 15642 | adds a separate package and an upgrade path for adding |
| 15643 | licenses to an image.</para> |
| 15644 | </note> |
| 15645 | </para> |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 15646 | |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 15647 | <para> |
| 15648 | As the source <filename>archiver</filename> class has already |
| 15649 | archived the original |
| 15650 | unmodified source that contains the license files, |
| 15651 | you would have already met the requirements for inclusion |
| 15652 | of the license information with source as defined by the GPL |
| 15653 | and other open source licenses. |
| 15654 | </para> |
| 15655 | </section> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 15656 | |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 15657 | <section id='providing-compilation-scripts-and-source-code-modifications'> |
| 15658 | <title>Providing Compilation Scripts and Source Code Modifications</title> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 15659 | |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 15660 | <para> |
| 15661 | At this point, we have addressed all we need to |
| 15662 | prior to generating the image. |
| 15663 | The next two requirements are addressed during the final |
| 15664 | packaging of the release. |
| 15665 | </para> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 15666 | |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 15667 | <para> |
| 15668 | By releasing the version of the OpenEmbedded build system |
| 15669 | and the layers used during the build, you will be providing both |
| 15670 | compilation scripts and the source code modifications in one |
| 15671 | step. |
| 15672 | </para> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 15673 | |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 15674 | <para> |
| 15675 | If the deployment team has a |
| 15676 | <ulink url='&YOCTO_DOCS_BSP_URL;#bsp-layers'>BSP layer</ulink> |
| 15677 | and a distro layer, and those those layers are used to patch, |
| 15678 | compile, package, or modify (in any way) any open source |
| 15679 | software included in your released images, you |
| 15680 | might be required to release those layers under section 3 of |
| 15681 | GPLv2 or section 1 of GPLv3. |
| 15682 | One way of doing that is with a clean |
| 15683 | checkout of the version of the Yocto Project and layers used |
| 15684 | during your build. |
| 15685 | Here is an example: |
| 15686 | <literallayout class='monospaced'> |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 15687 | # We built using the &DISTRO_NAME_NO_CAP; branch of the poky repo |
| 15688 | $ git clone -b &DISTRO_NAME_NO_CAP; git://git.yoctoproject.org/poky |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 15689 | $ cd poky |
| 15690 | # We built using the release_branch for our layers |
| 15691 | $ git clone -b release_branch git://git.mycompany.com/meta-my-bsp-layer |
| 15692 | $ git clone -b release_branch git://git.mycompany.com/meta-my-software-layer |
| 15693 | # clean up the .git repos |
| 15694 | $ find . -name ".git" -type d -exec rm -rf {} \; |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 15695 | </literallayout> |
| 15696 | One thing a development organization might want to consider |
| 15697 | for end-user convenience is to modify |
| 15698 | <filename>meta-poky/conf/bblayers.conf.sample</filename> to |
| 15699 | ensure that when the end user utilizes the released build |
| 15700 | system to build an image, the development organization's |
| 15701 | layers are included in the <filename>bblayers.conf</filename> |
| 15702 | file automatically: |
| 15703 | <literallayout class='monospaced'> |
| 15704 | # POKY_BBLAYERS_CONF_VERSION is increased each time build/conf/bblayers.conf |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 15705 | # changes incompatibly |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 15706 | POKY_BBLAYERS_CONF_VERSION = "2" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 15707 | |
| 15708 | BBPATH = "${TOPDIR}" |
| 15709 | BBFILES ?= "" |
| 15710 | |
| 15711 | BBLAYERS ?= " \ |
| 15712 | ##OEROOT##/meta \ |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 15713 | ##OEROOT##/meta-poky \ |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 15714 | ##OEROOT##/meta-yocto-bsp \ |
| 15715 | ##OEROOT##/meta-mylayer \ |
| 15716 | " |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 15717 | </literallayout> |
| 15718 | Creating and providing an archive of the |
| 15719 | <ulink url='&YOCTO_DOCS_REF_URL;#metadata'>Metadata</ulink> |
| 15720 | layers (recipes, configuration files, and so forth) |
| 15721 | enables you to meet your |
| 15722 | requirements to include the scripts to control compilation |
| 15723 | as well as any modifications to the original source. |
| 15724 | </para> |
| 15725 | </section> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 15726 | </section> |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 15727 | |
| 15728 | <section id='copying-licenses-that-do-not-exist'> |
| 15729 | <title>Copying Licenses that Do Not Exist</title> |
| 15730 | |
| 15731 | <para> |
| 15732 | Some packages, such as the linux-firmware package, have many |
| 15733 | licenses that are not in any way common. |
| 15734 | You can avoid adding a lot of these types of common license |
| 15735 | files, which are only applicable to a specific package, by using |
| 15736 | the |
| 15737 | <ulink url='&YOCTO_DOCS_REF_URL;#var-NO_GENERIC_LICENSE'><filename>NO_GENERIC_LICENSE</filename></ulink> |
| 15738 | variable. |
| 15739 | Using this variable also avoids QA errors when you use a |
| 15740 | non-common, non-CLOSED license in a recipe. |
| 15741 | </para> |
| 15742 | |
| 15743 | <para> |
| 15744 | The following is an example that uses the |
| 15745 | <filename>LICENSE.Abilis.txt</filename> |
| 15746 | file as the license from the fetched source: |
| 15747 | <literallayout class='monospaced'> |
| 15748 | NO_GENERIC_LICENSE[Firmware-Abilis] = "LICENSE.Abilis.txt" |
| 15749 | </literallayout> |
| 15750 | </para> |
| 15751 | </section> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 15752 | </section> |
| 15753 | |
| 15754 | <section id='using-the-error-reporting-tool'> |
| 15755 | <title>Using the Error Reporting Tool</title> |
| 15756 | |
| 15757 | <para> |
| 15758 | The error reporting tool allows you to |
| 15759 | submit errors encountered during builds to a central database. |
| 15760 | Outside of the build environment, you can use a web interface to |
| 15761 | browse errors, view statistics, and query for errors. |
| 15762 | The tool works using a client-server system where the client |
| 15763 | portion is integrated with the installed Yocto Project |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 15764 | <ulink url='&YOCTO_DOCS_REF_URL;#source-directory'>Source Directory</ulink> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 15765 | (e.g. <filename>poky</filename>). |
| 15766 | The server receives the information collected and saves it in a |
| 15767 | database. |
| 15768 | </para> |
| 15769 | |
| 15770 | <para> |
| 15771 | A live instance of the error reporting server exists at |
| 15772 | <ulink url='http://errors.yoctoproject.org'></ulink>. |
| 15773 | This server exists so that when you want to get help with |
| 15774 | build failures, you can submit all of the information on the |
| 15775 | failure easily and then point to the URL in your bug report |
| 15776 | or send an email to the mailing list. |
| 15777 | <note> |
| 15778 | If you send error reports to this server, the reports become |
| 15779 | publicly visible. |
| 15780 | </note> |
| 15781 | </para> |
| 15782 | |
| 15783 | <section id='enabling-and-using-the-tool'> |
| 15784 | <title>Enabling and Using the Tool</title> |
| 15785 | |
| 15786 | <para> |
| 15787 | By default, the error reporting tool is disabled. |
| 15788 | You can enable it by inheriting the |
| 15789 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-report-error'><filename>report-error</filename></ulink> |
| 15790 | class by adding the following statement to the end of |
| 15791 | your <filename>local.conf</filename> file in your |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 15792 | <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink>. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 15793 | <literallayout class='monospaced'> |
| 15794 | INHERIT += "report-error" |
| 15795 | </literallayout> |
| 15796 | </para> |
| 15797 | |
| 15798 | <para> |
| 15799 | By default, the error reporting feature stores information in |
| 15800 | <filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-LOG_DIR'><filename>LOG_DIR</filename></ulink><filename>}/error-report</filename>. |
| 15801 | However, you can specify a directory to use by adding the following |
| 15802 | to your <filename>local.conf</filename> file: |
| 15803 | <literallayout class='monospaced'> |
| 15804 | ERR_REPORT_DIR = "path" |
| 15805 | </literallayout> |
| 15806 | Enabling error reporting causes the build process to collect |
| 15807 | the errors and store them in a file as previously described. |
| 15808 | When the build system encounters an error, it includes a |
| 15809 | command as part of the console output. |
| 15810 | You can run the command to send the error file to the server. |
| 15811 | For example, the following command sends the errors to an |
| 15812 | upstream server: |
| 15813 | <literallayout class='monospaced'> |
| 15814 | $ send-error-report /home/brandusa/project/poky/build/tmp/log/error-report/error_report_201403141617.txt |
| 15815 | </literallayout> |
| 15816 | In the previous example, the errors are sent to a public |
| 15817 | database available at |
| 15818 | <ulink url='http://errors.yoctoproject.org'></ulink>, which is |
| 15819 | used by the entire community. |
| 15820 | If you specify a particular server, you can send the errors |
| 15821 | to a different database. |
| 15822 | Use the following command for more information on available |
| 15823 | options: |
| 15824 | <literallayout class='monospaced'> |
| 15825 | $ send-error-report --help |
| 15826 | </literallayout> |
| 15827 | </para> |
| 15828 | |
| 15829 | <para> |
| 15830 | When sending the error file, you are prompted to review the |
| 15831 | data being sent as well as to provide a name and optional |
| 15832 | email address. |
| 15833 | Once you satisfy these prompts, the command returns a link |
| 15834 | from the server that corresponds to your entry in the database. |
| 15835 | For example, here is a typical link: |
| 15836 | <literallayout class='monospaced'> |
| 15837 | http://errors.yoctoproject.org/Errors/Details/9522/ |
| 15838 | </literallayout> |
| 15839 | Following the link takes you to a web interface where you can |
| 15840 | browse, query the errors, and view statistics. |
| 15841 | </para> |
| 15842 | </section> |
| 15843 | |
| 15844 | <section id='disabling-the-tool'> |
| 15845 | <title>Disabling the Tool</title> |
| 15846 | |
| 15847 | <para> |
| 15848 | To disable the error reporting feature, simply remove or comment |
| 15849 | out the following statement from the end of your |
| 15850 | <filename>local.conf</filename> file in your |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 15851 | <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink>. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 15852 | <literallayout class='monospaced'> |
| 15853 | INHERIT += "report-error" |
| 15854 | </literallayout> |
| 15855 | </para> |
| 15856 | </section> |
| 15857 | |
| 15858 | <section id='setting-up-your-own-error-reporting-server'> |
| 15859 | <title>Setting Up Your Own Error Reporting Server</title> |
| 15860 | |
| 15861 | <para> |
| 15862 | If you want to set up your own error reporting server, you |
| 15863 | can obtain the code from the Git repository at |
| 15864 | <ulink url='http://git.yoctoproject.org/cgit/cgit.cgi/error-report-web/'></ulink>. |
| 15865 | Instructions on how to set it up are in the README document. |
| 15866 | </para> |
| 15867 | </section> |
| 15868 | </section> |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 15869 | |
| 15870 | <section id="dev-using-wayland-and-weston"> |
| 15871 | <title>Using Wayland and Weston</title> |
| 15872 | |
| 15873 | <para> |
| 15874 | <ulink url='http://en.wikipedia.org/wiki/Wayland_(display_server_protocol)'>Wayland</ulink> |
| 15875 | is a computer display server protocol that |
| 15876 | provides a method for compositing window managers to communicate |
| 15877 | directly with applications and video hardware and expects them to |
| 15878 | communicate with input hardware using other libraries. |
| 15879 | Using Wayland with supporting targets can result in better control |
| 15880 | over graphics frame rendering than an application might otherwise |
| 15881 | achieve. |
| 15882 | </para> |
| 15883 | |
| 15884 | <para> |
| 15885 | The Yocto Project provides the Wayland protocol libraries and the |
| 15886 | reference |
| 15887 | <ulink url='http://en.wikipedia.org/wiki/Wayland_(display_server_protocol)#Weston'>Weston</ulink> |
| 15888 | compositor as part of its release. |
| 15889 | You can find the integrated packages in the |
| 15890 | <filename>meta</filename> layer of the |
| 15891 | <ulink url='&YOCTO_DOCS_REF_URL;#source-directory'>Source Directory</ulink>. |
| 15892 | Specifically, you can find the recipes that build both Wayland |
| 15893 | and Weston at <filename>meta/recipes-graphics/wayland</filename>. |
| 15894 | </para> |
| 15895 | |
| 15896 | <para> |
| 15897 | You can build both the Wayland and Weston packages for use only |
| 15898 | with targets that accept the |
| 15899 | <ulink url='https://en.wikipedia.org/wiki/Mesa_(computer_graphics)'>Mesa 3D and Direct Rendering Infrastructure</ulink>, |
| 15900 | which is also known as Mesa DRI. |
| 15901 | This implies that you cannot build and use the packages if your |
| 15902 | target uses, for example, the |
| 15903 | <trademark class='registered'>Intel</trademark> Embedded Media |
| 15904 | and Graphics Driver |
| 15905 | (<trademark class='registered'>Intel</trademark> EMGD) that |
| 15906 | overrides Mesa DRI. |
| 15907 | <note> |
| 15908 | Due to lack of EGL support, Weston 1.0.3 will not run |
| 15909 | directly on the emulated QEMU hardware. |
| 15910 | However, this version of Weston will run under X emulation |
| 15911 | without issues. |
| 15912 | </note> |
| 15913 | </para> |
| 15914 | |
| 15915 | <para> |
| 15916 | This section describes what you need to do to implement Wayland and |
| 15917 | use the Weston compositor when building an image for a supporting |
| 15918 | target. |
| 15919 | </para> |
| 15920 | |
| 15921 | <section id="enabling-wayland-in-an-image"> |
| 15922 | <title>Enabling Wayland in an Image</title> |
| 15923 | |
| 15924 | <para> |
| 15925 | To enable Wayland, you need to enable it to be built and enable |
| 15926 | it to be included (installed) in the image. |
| 15927 | </para> |
| 15928 | |
| 15929 | <section id="enable-building"> |
| 15930 | <title>Building</title> |
| 15931 | |
| 15932 | <para> |
| 15933 | To cause Mesa to build the <filename>wayland-egl</filename> |
| 15934 | platform and Weston to build Wayland with Kernel Mode |
| 15935 | Setting |
| 15936 | (<ulink url='https://wiki.archlinux.org/index.php/Kernel_Mode_Setting'>KMS</ulink>) |
| 15937 | support, include the "wayland" flag in the |
| 15938 | <ulink url="&YOCTO_DOCS_REF_URL;#var-DISTRO_FEATURES"><filename>DISTRO_FEATURES</filename></ulink> |
| 15939 | statement in your <filename>local.conf</filename> file: |
| 15940 | <literallayout class='monospaced'> |
| 15941 | DISTRO_FEATURES_append = " wayland" |
| 15942 | </literallayout> |
| 15943 | <note> |
| 15944 | If X11 has been enabled elsewhere, Weston will build |
| 15945 | Wayland with X11 support |
| 15946 | </note> |
| 15947 | </para> |
| 15948 | </section> |
| 15949 | |
| 15950 | <section id="enable-installation-in-an-image"> |
| 15951 | <title>Installing</title> |
| 15952 | |
| 15953 | <para> |
| 15954 | To install the Wayland feature into an image, you must |
| 15955 | include the following |
| 15956 | <ulink url='&YOCTO_DOCS_REF_URL;#var-CORE_IMAGE_EXTRA_INSTALL'><filename>CORE_IMAGE_EXTRA_INSTALL</filename></ulink> |
| 15957 | statement in your <filename>local.conf</filename> file: |
| 15958 | <literallayout class='monospaced'> |
| 15959 | CORE_IMAGE_EXTRA_INSTALL += "wayland weston" |
| 15960 | </literallayout> |
| 15961 | </para> |
| 15962 | </section> |
| 15963 | </section> |
| 15964 | |
| 15965 | <section id="running-weston"> |
| 15966 | <title>Running Weston</title> |
| 15967 | |
| 15968 | <para> |
| 15969 | To run Weston inside X11, enabling it as described earlier and |
| 15970 | building a Sato image is sufficient. |
| 15971 | If you are running your image under Sato, a Weston Launcher |
| 15972 | appears in the "Utility" category. |
| 15973 | </para> |
| 15974 | |
| 15975 | <para> |
| 15976 | Alternatively, you can run Weston through the command-line |
| 15977 | interpretor (CLI), which is better suited for development work. |
| 15978 | To run Weston under the CLI, you need to do the following after |
| 15979 | your image is built: |
| 15980 | <orderedlist> |
| 15981 | <listitem><para> |
| 15982 | Run these commands to export |
| 15983 | <filename>XDG_RUNTIME_DIR</filename>: |
| 15984 | <literallayout class='monospaced'> |
| 15985 | mkdir -p /tmp/$USER-weston |
| 15986 | chmod 0700 /tmp/$USER-weston |
| 15987 | export XDG_RUNTIME_DIR=/tmp/$USER-weston |
| 15988 | </literallayout> |
| 15989 | </para></listitem> |
| 15990 | <listitem><para> |
| 15991 | Launch Weston in the shell: |
| 15992 | <literallayout class='monospaced'> |
| 15993 | weston |
| 15994 | </literallayout></para></listitem> |
| 15995 | </orderedlist> |
| 15996 | </para> |
| 15997 | </section> |
| 15998 | </section> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 15999 | </chapter> |
| 16000 | |
| 16001 | <!-- |
| 16002 | vim: expandtab tw=80 ts=4 |
| 16003 | --> |