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> |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 187 | <ulink url='&YOCTO_DOCS_REF_URL;#var-LAYERDEPENDS'><filename>LAYERDEPENDS</filename></ulink>: |
| 188 | Lists all layers on which this layer depends (if any). |
| 189 | </para></listitem> |
| 190 | <listitem><para> |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 191 | <ulink url='&YOCTO_DOCS_REF_URL;#var-LAYERSERIES_COMPAT'><filename>LAYERSERIES_COMPAT</filename></ulink>: |
| 192 | Lists the |
| 193 | <ulink url='&YOCTO_WIKI_URL;/wiki/Releases'>Yocto Project</ulink> |
| 194 | releases for which the current version is |
| 195 | compatible. |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 196 | This variable is a good way to indicate if |
| 197 | your particular layer is current. |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 198 | </para></listitem> |
| 199 | </itemizedlist> |
| 200 | </para></listitem> |
| 201 | <listitem><para> |
| 202 | <emphasis>Add Content:</emphasis> |
| 203 | Depending on the type of layer, add the content. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 204 | If the layer adds support for a machine, add the machine |
| 205 | configuration in a <filename>conf/machine/</filename> |
| 206 | file within the layer. |
| 207 | If the layer adds distro policy, add the distro |
| 208 | configuration in a <filename>conf/distro/</filename> |
| 209 | file within the layer. |
| 210 | If the layer introduces new recipes, put the recipes |
| 211 | you need in <filename>recipes-*</filename> |
| 212 | subdirectories within the layer. |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 213 | <note> |
| 214 | For an explanation of layer hierarchy that |
| 215 | is compliant with the Yocto Project, see |
| 216 | the |
| 217 | "<ulink url='&YOCTO_DOCS_BSP_URL;#bsp-filelayout'>Example Filesystem Layout</ulink>" |
| 218 | section in the Yocto Project Board |
| 219 | Support Package (BSP) Developer's Guide. |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 220 | </note> |
| 221 | </para></listitem> |
| 222 | <listitem><para> |
| 223 | <emphasis>Optionally Test for Compatibility:</emphasis> |
| 224 | If you want permission to use the Yocto Project |
| 225 | Compatibility logo with your layer or application that |
| 226 | uses your layer, perform the steps to apply for |
| 227 | compatibility. |
| 228 | See the |
| 229 | "<link linkend='making-sure-your-layer-is-compatible-with-yocto-project'>Making Sure Your Layer is Compatible With Yocto Project</link>" |
| 230 | section for more information. |
| 231 | </para></listitem> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 232 | </orderedlist> |
| 233 | </para> |
| 234 | </section> |
| 235 | |
| 236 | <section id='best-practices-to-follow-when-creating-layers'> |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 237 | <title>Following Best Practices When Creating Layers</title> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 238 | |
| 239 | <para> |
| 240 | To create layers that are easier to maintain and that will |
| 241 | not impact builds for other machines, you should consider the |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 242 | information in the following list: |
| 243 | <itemizedlist> |
| 244 | <listitem><para> |
| 245 | <emphasis>Avoid "Overlaying" Entire Recipes from Other Layers in Your Configuration:</emphasis> |
| 246 | In other words, do not copy an entire recipe into your |
| 247 | layer and then modify it. |
| 248 | Rather, use an append file |
| 249 | (<filename>.bbappend</filename>) to override only those |
| 250 | parts of the original recipe you need to modify. |
| 251 | </para></listitem> |
| 252 | <listitem><para> |
| 253 | <emphasis>Avoid Duplicating Include Files:</emphasis> |
| 254 | Use append files (<filename>.bbappend</filename>) |
| 255 | for each recipe that uses an include file. |
| 256 | Or, if you are introducing a new recipe that requires |
| 257 | the included file, use the path relative to the |
| 258 | original layer directory to refer to the file. |
| 259 | For example, use |
| 260 | <filename>require recipes-core/</filename><replaceable>package</replaceable><filename>/</filename><replaceable>file</replaceable><filename>.inc</filename> |
| 261 | instead of |
| 262 | <filename>require </filename><replaceable>file</replaceable><filename>.inc</filename>. |
| 263 | If you're finding you have to overlay the include file, |
| 264 | it could indicate a deficiency in the include file in |
| 265 | the layer to which it originally belongs. |
| 266 | If this is the case, you should try to address that |
| 267 | deficiency instead of overlaying the include file. |
| 268 | For example, you could address this by getting the |
| 269 | maintainer of the include file to add a variable or |
| 270 | variables to make it easy to override the parts needing |
| 271 | to be overridden. |
| 272 | </para></listitem> |
| 273 | <listitem><para> |
| 274 | <emphasis>Structure Your Layers:</emphasis> |
| 275 | Proper use of overrides within append files and |
| 276 | placement of machine-specific files within your layer |
| 277 | can ensure that a build is not using the wrong Metadata |
| 278 | and negatively impacting a build for a different |
| 279 | machine. |
| 280 | Following are some examples: |
| 281 | <itemizedlist> |
| 282 | <listitem><para> |
| 283 | <emphasis>Modify Variables to Support a |
| 284 | Different Machine:</emphasis> |
| 285 | Suppose you have a layer named |
| 286 | <filename>meta-one</filename> that adds support |
| 287 | for building machine "one". |
| 288 | To do so, you use an append file named |
| 289 | <filename>base-files.bbappend</filename> and |
| 290 | create a dependency on "foo" by altering the |
| 291 | <ulink url='&YOCTO_DOCS_REF_URL;#var-DEPENDS'><filename>DEPENDS</filename></ulink> |
| 292 | variable: |
| 293 | <literallayout class='monospaced'> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 294 | DEPENDS = "foo" |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 295 | </literallayout> |
| 296 | The dependency is created during any build that |
| 297 | includes the layer |
| 298 | <filename>meta-one</filename>. |
| 299 | However, you might not want this dependency |
| 300 | for all machines. |
| 301 | For example, suppose you are building for |
| 302 | machine "two" but your |
| 303 | <filename>bblayers.conf</filename> file has the |
| 304 | <filename>meta-one</filename> layer included. |
| 305 | During the build, the |
| 306 | <filename>base-files</filename> for machine |
| 307 | "two" will also have the dependency on |
| 308 | <filename>foo</filename>.</para> |
| 309 | <para>To make sure your changes apply only when |
| 310 | building machine "one", use a machine override |
| 311 | with the <filename>DEPENDS</filename> statement: |
| 312 | <literallayout class='monospaced'> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 313 | DEPENDS_one = "foo" |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 314 | </literallayout> |
| 315 | You should follow the same strategy when using |
| 316 | <filename>_append</filename> and |
| 317 | <filename>_prepend</filename> operations: |
| 318 | <literallayout class='monospaced'> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 319 | DEPENDS_append_one = " foo" |
| 320 | DEPENDS_prepend_one = "foo " |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 321 | </literallayout> |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 322 | As an actual example, here's a snippet from the |
| 323 | generic kernel include file |
| 324 | <filename>linux-yocto.inc</filename>, |
| 325 | wherein the kernel compile and link options are |
| 326 | adjusted in the case of a subset of the supported |
| 327 | architectures: |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 328 | <literallayout class='monospaced'> |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 329 | DEPENDS_append_aarch64 = " libgcc" |
| 330 | KERNEL_CC_append_aarch64 = " ${TOOLCHAIN_OPTIONS}" |
| 331 | KERNEL_LD_append_aarch64 = " ${TOOLCHAIN_OPTIONS}" |
| 332 | |
| 333 | DEPENDS_append_nios2 = " libgcc" |
| 334 | KERNEL_CC_append_nios2 = " ${TOOLCHAIN_OPTIONS}" |
| 335 | KERNEL_LD_append_nios2 = " ${TOOLCHAIN_OPTIONS}" |
| 336 | |
| 337 | DEPENDS_append_arc = " libgcc" |
| 338 | KERNEL_CC_append_arc = " ${TOOLCHAIN_OPTIONS}" |
| 339 | KERNEL_LD_append_arc = " ${TOOLCHAIN_OPTIONS}" |
| 340 | |
| 341 | KERNEL_FEATURES_append_qemuall=" features/debug/printk.scc" |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 342 | </literallayout> |
| 343 | <note> |
| 344 | Avoiding "+=" and "=+" and using |
| 345 | machine-specific |
| 346 | <filename>_append</filename> |
| 347 | and <filename>_prepend</filename> operations |
| 348 | is recommended as well. |
| 349 | </note> |
| 350 | </para></listitem> |
| 351 | <listitem><para> |
| 352 | <emphasis>Place Machine-Specific Files in |
| 353 | Machine-Specific Locations:</emphasis> |
| 354 | When you have a base recipe, such as |
| 355 | <filename>base-files.bb</filename>, that |
| 356 | contains a |
| 357 | <ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'><filename>SRC_URI</filename></ulink> |
| 358 | statement to a file, you can use an append file |
| 359 | to cause the build to use your own version of |
| 360 | the file. |
| 361 | For example, an append file in your layer at |
| 362 | <filename>meta-one/recipes-core/base-files/base-files.bbappend</filename> |
| 363 | could extend |
| 364 | <ulink url='&YOCTO_DOCS_REF_URL;#var-FILESPATH'><filename>FILESPATH</filename></ulink> |
| 365 | using |
| 366 | <ulink url='&YOCTO_DOCS_REF_URL;#var-FILESEXTRAPATHS'><filename>FILESEXTRAPATHS</filename></ulink> |
| 367 | as follows: |
| 368 | <literallayout class='monospaced'> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 369 | FILESEXTRAPATHS_prepend := "${THISDIR}/${BPN}:" |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 370 | </literallayout> |
| 371 | The build for machine "one" will pick up your |
| 372 | machine-specific file as long as you have the |
| 373 | file in |
| 374 | <filename>meta-one/recipes-core/base-files/base-files/</filename>. |
| 375 | However, if you are building for a different |
| 376 | machine and the |
| 377 | <filename>bblayers.conf</filename> file includes |
| 378 | the <filename>meta-one</filename> layer and |
| 379 | the location of your machine-specific file is |
| 380 | the first location where that file is found |
| 381 | according to <filename>FILESPATH</filename>, |
| 382 | builds for all machines will also use that |
| 383 | machine-specific file.</para> |
| 384 | <para>You can make sure that a machine-specific |
| 385 | file is used for a particular machine by putting |
| 386 | the file in a subdirectory specific to the |
| 387 | machine. |
| 388 | For example, rather than placing the file in |
| 389 | <filename>meta-one/recipes-core/base-files/base-files/</filename> |
| 390 | as shown above, put it in |
| 391 | <filename>meta-one/recipes-core/base-files/base-files/one/</filename>. |
| 392 | Not only does this make sure the file is used |
| 393 | only when building for machine "one", but the |
| 394 | build process locates the file more quickly.</para> |
| 395 | <para>In summary, you need to place all files |
| 396 | referenced from <filename>SRC_URI</filename> |
| 397 | in a machine-specific subdirectory within the |
| 398 | layer in order to restrict those files to |
| 399 | machine-specific builds. |
| 400 | </para></listitem> |
| 401 | </itemizedlist> |
| 402 | </para></listitem> |
| 403 | <listitem><para> |
| 404 | <emphasis>Perform Steps to Apply for Yocto Project Compatibility:</emphasis> |
| 405 | If you want permission to use the |
| 406 | Yocto Project Compatibility logo with your layer |
| 407 | or application that uses your layer, perform the |
| 408 | steps to apply for compatibility. |
| 409 | See the |
| 410 | "<link linkend='making-sure-your-layer-is-compatible-with-yocto-project'>Making Sure Your Layer is Compatible With Yocto Project</link>" |
| 411 | section for more information. |
| 412 | </para></listitem> |
| 413 | <listitem><para> |
| 414 | <emphasis>Follow the Layer Naming Convention:</emphasis> |
| 415 | Store custom layers in a Git repository that use the |
| 416 | <filename>meta-<replaceable>layer_name</replaceable></filename> |
| 417 | format. |
| 418 | </para></listitem> |
| 419 | <listitem><para> |
| 420 | <emphasis>Group Your Layers Locally:</emphasis> |
| 421 | Clone your repository alongside other cloned |
| 422 | <filename>meta</filename> directories from the |
| 423 | <ulink url='&YOCTO_DOCS_REF_URL;#source-directory'>Source Directory</ulink>. |
| 424 | </para></listitem> |
| 425 | </itemizedlist> |
| 426 | </para> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 427 | </section> |
| 428 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 429 | <section id='making-sure-your-layer-is-compatible-with-yocto-project'> |
| 430 | <title>Making Sure Your Layer is Compatible With Yocto Project</title> |
| 431 | |
| 432 | <para> |
| 433 | When you create a layer used with the Yocto Project, it is |
| 434 | advantageous to make sure that the layer interacts well with |
| 435 | existing Yocto Project layers (i.e. the layer is compatible |
| 436 | with the Yocto Project). |
| 437 | Ensuring compatibility makes the layer easy to be consumed |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 438 | by others in the Yocto Project community and could allow you |
| 439 | permission to use the Yocto Project Compatible Logo. |
| 440 | <note> |
| 441 | Only Yocto Project member organizations are permitted to |
| 442 | use the Yocto Project Compatible Logo. |
| 443 | The logo is not available for general use. |
| 444 | For information on how to become a Yocto Project member |
| 445 | organization, see the |
| 446 | <ulink url='&YOCTO_HOME_URL;'>Yocto Project Website</ulink>. |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 447 | </note> |
| 448 | </para> |
| 449 | |
| 450 | <para> |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 451 | The Yocto Project Compatibility Program consists of a layer |
| 452 | application process that requests permission to use the Yocto |
| 453 | Project Compatibility Logo for your layer and application. |
| 454 | The process consists of two parts: |
| 455 | <orderedlist> |
| 456 | <listitem><para> |
| 457 | Successfully passing a script |
| 458 | (<filename>yocto-check-layer</filename>) that |
| 459 | when run against your layer, tests it against |
| 460 | constraints based on experiences of how layers have |
| 461 | worked in the real world and where pitfalls have been |
| 462 | found. |
| 463 | Getting a "PASS" result from the script is required for |
| 464 | successful compatibility registration. |
| 465 | </para></listitem> |
| 466 | <listitem><para> |
| 467 | Completion of an application acceptance form, which |
| 468 | you can find at |
| 469 | <ulink url='https://www.yoctoproject.org/webform/yocto-project-compatible-registration'></ulink>. |
| 470 | </para></listitem> |
| 471 | </orderedlist> |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 472 | </para> |
| 473 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 474 | <para> |
| 475 | To be granted permission to use the logo, you need to satisfy |
| 476 | the following: |
| 477 | <itemizedlist> |
| 478 | <listitem><para> |
| 479 | Be able to check the box indicating that you |
| 480 | got a "PASS" when running the script against your |
| 481 | layer. |
| 482 | </para></listitem> |
| 483 | <listitem><para> |
| 484 | Answer "Yes" to the questions on the form or have an |
| 485 | acceptable explanation for any questions answered "No". |
| 486 | </para></listitem> |
| 487 | <listitem><para> |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 488 | Be a Yocto Project Member Organization. |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 489 | </para></listitem> |
| 490 | </itemizedlist> |
| 491 | </para> |
| 492 | |
| 493 | <para> |
| 494 | The remainder of this section presents information on the |
| 495 | registration form and on the |
| 496 | <filename>yocto-check-layer</filename> script. |
| 497 | </para> |
| 498 | |
| 499 | <section id='yocto-project-compatible-program-application'> |
| 500 | <title>Yocto Project Compatible Program Application</title> |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 501 | |
| 502 | <para> |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 503 | Use the form to apply for your layer's approval. |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 504 | Upon successful application, you can use the Yocto |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 505 | Project Compatibility Logo with your layer and the |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 506 | application that uses your layer. |
| 507 | </para> |
| 508 | |
| 509 | <para> |
| 510 | To access the form, use this link: |
| 511 | <ulink url='https://www.yoctoproject.org/webform/yocto-project-compatible-registration'></ulink>. |
| 512 | Follow the instructions on the form to complete your |
| 513 | application. |
| 514 | </para> |
| 515 | |
| 516 | <para> |
| 517 | The application consists of the following sections: |
| 518 | <itemizedlist> |
| 519 | <listitem><para> |
| 520 | <emphasis>Contact Information:</emphasis> |
| 521 | Provide your contact information as the fields |
| 522 | require. |
| 523 | Along with your information, provide the |
| 524 | released versions of the Yocto Project for which |
| 525 | your layer is compatible. |
| 526 | </para></listitem> |
| 527 | <listitem><para> |
| 528 | <emphasis>Acceptance Criteria:</emphasis> |
| 529 | Provide "Yes" or "No" answers for each of the |
| 530 | items in the checklist. |
| 531 | Space exists at the bottom of the form for any |
| 532 | explanations for items for which you answered "No". |
| 533 | </para></listitem> |
| 534 | <listitem><para> |
| 535 | <emphasis>Recommendations:</emphasis> |
| 536 | Provide answers for the questions regarding Linux |
| 537 | kernel use and build success. |
| 538 | </para></listitem> |
| 539 | </itemizedlist> |
| 540 | </para> |
| 541 | </section> |
| 542 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 543 | <section id='yocto-check-layer-script'> |
| 544 | <title><filename>yocto-check-layer</filename> Script</title> |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 545 | |
| 546 | <para> |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 547 | The <filename>yocto-check-layer</filename> script |
| 548 | provides you a way to assess how compatible your layer is |
| 549 | with the Yocto Project. |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 550 | You should run this script prior to using the form to |
| 551 | apply for compatibility as described in the previous |
| 552 | section. |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 553 | You need to achieve a "PASS" result in order to have |
| 554 | your application form successfully processed. |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 555 | </para> |
| 556 | |
| 557 | <para> |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 558 | The script divides tests into three areas: COMMON, BSP, |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 559 | and DISTRO. |
| 560 | For example, given a distribution layer (DISTRO), the |
| 561 | layer must pass both the COMMON and DISTRO related tests. |
| 562 | Furthermore, if your layer is a BSP layer, the layer must |
| 563 | pass the COMMON and BSP set of tests. |
| 564 | </para> |
| 565 | |
| 566 | <para> |
| 567 | To execute the script, enter the following commands from |
| 568 | your build directory: |
| 569 | <literallayout class='monospaced'> |
| 570 | $ source oe-init-build-env |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 571 | $ yocto-check-layer <replaceable>your_layer_directory</replaceable> |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 572 | </literallayout> |
| 573 | Be sure to provide the actual directory for your layer |
| 574 | as part of the command. |
| 575 | </para> |
| 576 | |
| 577 | <para> |
| 578 | Entering the command causes the script to determine the |
| 579 | type of layer and then to execute a set of specific |
| 580 | tests against the layer. |
| 581 | The following list overviews the test: |
| 582 | <itemizedlist> |
| 583 | <listitem><para> |
| 584 | <filename>common.test_readme</filename>: |
| 585 | Tests if a <filename>README</filename> file |
| 586 | exists in the layer and the file is not empty. |
| 587 | </para></listitem> |
| 588 | <listitem><para> |
| 589 | <filename>common.test_parse</filename>: |
| 590 | Tests to make sure that BitBake can parse the |
| 591 | files without error (i.e. |
| 592 | <filename>bitbake -p</filename>). |
| 593 | </para></listitem> |
| 594 | <listitem><para> |
| 595 | <filename>common.test_show_environment</filename>: |
| 596 | Tests that the global or per-recipe environment |
| 597 | is in order without errors (i.e. |
| 598 | <filename>bitbake -e</filename>). |
| 599 | </para></listitem> |
| 600 | <listitem><para> |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 601 | <filename>common.test_world</filename>: |
| 602 | Verifies that <filename>bitbake world</filename> works. |
| 603 | </para></listitem> |
| 604 | <listitem><para> |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 605 | <filename>common.test_signatures</filename>: |
| 606 | Tests to be sure that BSP and DISTRO layers do not |
| 607 | come with recipes that change signatures. |
| 608 | </para></listitem> |
| 609 | <listitem><para> |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 610 | <filename>common.test_layerseries_compat</filename>: |
| 611 | Verifies layer compatibility is set properly. |
| 612 | </para></listitem> |
| 613 | <listitem><para> |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 614 | <filename>bsp.test_bsp_defines_machines</filename>: |
| 615 | Tests if a BSP layer has machine configurations. |
| 616 | </para></listitem> |
| 617 | <listitem><para> |
| 618 | <filename>bsp.test_bsp_no_set_machine</filename>: |
| 619 | Tests to ensure a BSP layer does not set the |
| 620 | machine when the layer is added. |
| 621 | </para></listitem> |
| 622 | <listitem><para> |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 623 | <filename>bsp.test_machine_world</filename>: |
| 624 | Verifies that <filename>bitbake world</filename> |
| 625 | works regardless of which machine is selected. |
| 626 | </para></listitem> |
| 627 | <listitem><para> |
| 628 | <filename>bsp.test_machine_signatures</filename>: |
| 629 | Verifies that building for a particular machine |
| 630 | affects only the signature of tasks specific to that |
| 631 | machine. |
| 632 | </para></listitem> |
| 633 | <listitem><para> |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 634 | <filename>distro.test_distro_defines_distros</filename>: |
| 635 | Tests if a DISTRO layer has distro configurations. |
| 636 | </para></listitem> |
| 637 | <listitem><para> |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 638 | <filename>distro.test_distro_no_set_distros</filename>: |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 639 | Tests to ensure a DISTRO layer does not set the |
| 640 | distribution when the layer is added. |
| 641 | </para></listitem> |
| 642 | </itemizedlist> |
| 643 | </para> |
| 644 | </section> |
| 645 | </section> |
| 646 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 647 | <section id='enabling-your-layer'> |
| 648 | <title>Enabling Your Layer</title> |
| 649 | |
| 650 | <para> |
| 651 | Before the OpenEmbedded build system can use your new layer, |
| 652 | you need to enable it. |
| 653 | To enable your layer, simply add your layer's path to the |
| 654 | <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-BBLAYERS'>BBLAYERS</ulink></filename> |
| 655 | variable in your <filename>conf/bblayers.conf</filename> file, |
| 656 | which is found in the |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 657 | <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink>. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 658 | The following example shows how to enable a layer named |
| 659 | <filename>meta-mylayer</filename>: |
| 660 | <literallayout class='monospaced'> |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 661 | # POKY_BBLAYERS_CONF_VERSION is increased each time build/conf/bblayers.conf |
| 662 | # changes incompatibly |
| 663 | POKY_BBLAYERS_CONF_VERSION = "2" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 664 | |
| 665 | BBPATH = "${TOPDIR}" |
| 666 | BBFILES ?= "" |
| 667 | |
| 668 | BBLAYERS ?= " \ |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 669 | /home/<replaceable>user</replaceable>/poky/meta \ |
| 670 | /home/<replaceable>user</replaceable>/poky/meta-poky \ |
| 671 | /home/<replaceable>user</replaceable>/poky/meta-yocto-bsp \ |
| 672 | /home/<replaceable>user</replaceable>/poky/meta-mylayer \ |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 673 | " |
| 674 | </literallayout> |
| 675 | </para> |
| 676 | |
| 677 | <para> |
| 678 | BitBake parses each <filename>conf/layer.conf</filename> file |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 679 | from the top down as specified in the |
| 680 | <filename>BBLAYERS</filename> variable |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 681 | within the <filename>conf/bblayers.conf</filename> file. |
| 682 | During the processing of each |
| 683 | <filename>conf/layer.conf</filename> file, BitBake adds the |
| 684 | recipes, classes and configurations contained within the |
| 685 | particular layer to the source directory. |
| 686 | </para> |
| 687 | </section> |
| 688 | |
| 689 | <section id='using-bbappend-files'> |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 690 | <title>Using .bbappend Files in Your Layer</title> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 691 | |
| 692 | <para> |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 693 | A recipe that appends Metadata to another recipe is called a |
| 694 | BitBake append file. |
| 695 | A BitBake append file uses the <filename>.bbappend</filename> |
| 696 | file type suffix, while the corresponding recipe to which |
| 697 | Metadata is being appended uses the <filename>.bb</filename> |
| 698 | file type suffix. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 699 | </para> |
| 700 | |
| 701 | <para> |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 702 | You can use a <filename>.bbappend</filename> file in your |
| 703 | layer to make additions or changes to the content of another |
| 704 | layer's recipe without having to copy the other layer's |
| 705 | recipe into your layer. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 706 | Your <filename>.bbappend</filename> file resides in your layer, |
| 707 | while the main <filename>.bb</filename> recipe file to |
| 708 | which you are appending Metadata resides in a different layer. |
| 709 | </para> |
| 710 | |
| 711 | <para> |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 712 | Being able to append information to an existing recipe not only |
| 713 | avoids duplication, but also automatically applies recipe |
| 714 | changes from a different layer into your layer. |
| 715 | If you were copying recipes, you would have to manually merge |
| 716 | changes as they occur. |
| 717 | </para> |
| 718 | |
| 719 | <para> |
| 720 | When you create an append file, you must use the same root |
| 721 | name as the corresponding recipe file. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 722 | For example, the append file |
| 723 | <filename>someapp_&DISTRO;.bbappend</filename> must apply to |
| 724 | <filename>someapp_&DISTRO;.bb</filename>. |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 725 | This means the original recipe and append file names are |
| 726 | version number-specific. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 727 | If the corresponding recipe is renamed to update to a newer |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 728 | version, you must also rename and possibly update |
| 729 | the corresponding <filename>.bbappend</filename> as well. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 730 | During the build process, BitBake displays an error on starting |
| 731 | if it detects a <filename>.bbappend</filename> file that does |
| 732 | not have a corresponding recipe with a matching name. |
| 733 | See the |
| 734 | <ulink url='&YOCTO_DOCS_REF_URL;#var-BB_DANGLINGAPPENDS_WARNONLY'><filename>BB_DANGLINGAPPENDS_WARNONLY</filename></ulink> |
| 735 | variable for information on how to handle this error. |
| 736 | </para> |
| 737 | |
| 738 | <para> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 739 | As an example, consider the main formfactor recipe and a |
| 740 | corresponding formfactor append file both from the |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 741 | <ulink url='&YOCTO_DOCS_REF_URL;#source-directory'>Source Directory</ulink>. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 742 | Here is the main formfactor recipe, which is named |
| 743 | <filename>formfactor_0.0.bb</filename> and located in the |
| 744 | "meta" layer at |
| 745 | <filename>meta/recipes-bsp/formfactor</filename>: |
| 746 | <literallayout class='monospaced'> |
| 747 | SUMMARY = "Device formfactor information" |
| 748 | SECTION = "base" |
| 749 | LICENSE = "MIT" |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 750 | LIC_FILES_CHKSUM = "file://${COREBASE}/meta/COPYING.MIT;md5=3da9cfbcb788c80a0384361b4de20420" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 751 | PR = "r45" |
| 752 | |
| 753 | SRC_URI = "file://config file://machconfig" |
| 754 | S = "${WORKDIR}" |
| 755 | |
| 756 | PACKAGE_ARCH = "${MACHINE_ARCH}" |
| 757 | INHIBIT_DEFAULT_DEPS = "1" |
| 758 | |
| 759 | do_install() { |
| 760 | # Install file only if it has contents |
| 761 | install -d ${D}${sysconfdir}/formfactor/ |
| 762 | install -m 0644 ${S}/config ${D}${sysconfdir}/formfactor/ |
| 763 | if [ -s "${S}/machconfig" ]; then |
| 764 | install -m 0644 ${S}/machconfig ${D}${sysconfdir}/formfactor/ |
| 765 | fi |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 766 | } </literallayout> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 767 | In the main recipe, note the |
| 768 | <ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'><filename>SRC_URI</filename></ulink> |
| 769 | variable, which tells the OpenEmbedded build system where to |
| 770 | find files during the build. |
| 771 | </para> |
| 772 | |
| 773 | <para> |
| 774 | Following is the append file, which is named |
| 775 | <filename>formfactor_0.0.bbappend</filename> and is from the |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 776 | Raspberry Pi BSP Layer named |
| 777 | <filename>meta-raspberrypi</filename>. |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 778 | The file is in the layer at |
| 779 | <filename>recipes-bsp/formfactor</filename>: |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 780 | <literallayout class='monospaced'> |
| 781 | FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:" |
| 782 | </literallayout> |
| 783 | </para> |
| 784 | |
| 785 | <para> |
| 786 | By default, the build system uses the |
| 787 | <ulink url='&YOCTO_DOCS_REF_URL;#var-FILESPATH'><filename>FILESPATH</filename></ulink> |
| 788 | variable to locate files. |
| 789 | This append file extends the locations by setting the |
| 790 | <ulink url='&YOCTO_DOCS_REF_URL;#var-FILESEXTRAPATHS'><filename>FILESEXTRAPATHS</filename></ulink> |
| 791 | variable. |
| 792 | Setting this variable in the <filename>.bbappend</filename> |
| 793 | file is the most reliable and recommended method for adding |
| 794 | directories to the search path used by the build system |
| 795 | to find files. |
| 796 | </para> |
| 797 | |
| 798 | <para> |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 799 | The statement in this example extends the directories to |
| 800 | include |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 801 | <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>, |
| 802 | which resolves to a directory named |
| 803 | <filename>formfactor</filename> in the same directory |
| 804 | in which the append file resides (i.e. |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 805 | <filename>meta-raspberrypi/recipes-bsp/formfactor</filename>. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 806 | This implies that you must have the supporting directory |
| 807 | structure set up that will contain any files or patches you |
| 808 | will be including from the layer. |
| 809 | </para> |
| 810 | |
| 811 | <para> |
| 812 | Using the immediate expansion assignment operator |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 813 | <filename>:=</filename> is important because of the reference |
| 814 | to <filename>THISDIR</filename>. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 815 | The trailing colon character is important as it ensures that |
| 816 | items in the list remain colon-separated. |
| 817 | <note> |
| 818 | <para> |
| 819 | BitBake automatically defines the |
| 820 | <filename>THISDIR</filename> variable. |
| 821 | You should never set this variable yourself. |
| 822 | Using "_prepend" as part of the |
| 823 | <filename>FILESEXTRAPATHS</filename> ensures your path |
| 824 | will be searched prior to other paths in the final |
| 825 | list. |
| 826 | </para> |
| 827 | |
| 828 | <para> |
| 829 | Also, not all append files add extra files. |
| 830 | Many append files simply exist to add build options |
| 831 | (e.g. <filename>systemd</filename>). |
| 832 | For these cases, your append file would not even |
| 833 | use the <filename>FILESEXTRAPATHS</filename> statement. |
| 834 | </para> |
| 835 | </note> |
| 836 | </para> |
| 837 | </section> |
| 838 | |
| 839 | <section id='prioritizing-your-layer'> |
| 840 | <title>Prioritizing Your Layer</title> |
| 841 | |
| 842 | <para> |
| 843 | Each layer is assigned a priority value. |
| 844 | Priority values control which layer takes precedence if there |
| 845 | are recipe files with the same name in multiple layers. |
| 846 | For these cases, the recipe file from the layer with a higher |
| 847 | priority number takes precedence. |
| 848 | Priority values also affect the order in which multiple |
| 849 | <filename>.bbappend</filename> files for the same recipe are |
| 850 | applied. |
| 851 | You can either specify the priority manually, or allow the |
| 852 | build system to calculate it based on the layer's dependencies. |
| 853 | </para> |
| 854 | |
| 855 | <para> |
| 856 | To specify the layer's priority manually, use the |
| 857 | <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] | 858 | variable and append the layer's root name: |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 859 | <literallayout class='monospaced'> |
| 860 | BBFILE_PRIORITY_mylayer = "1" |
| 861 | </literallayout> |
| 862 | </para> |
| 863 | |
| 864 | <note> |
| 865 | <para>It is possible for a recipe with a lower version number |
| 866 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PV'><filename>PV</filename></ulink> |
| 867 | in a layer that has a higher priority to take precedence.</para> |
| 868 | <para>Also, the layer priority does not currently affect the |
| 869 | precedence order of <filename>.conf</filename> |
| 870 | or <filename>.bbclass</filename> files. |
| 871 | Future versions of BitBake might address this.</para> |
| 872 | </note> |
| 873 | </section> |
| 874 | |
| 875 | <section id='managing-layers'> |
| 876 | <title>Managing Layers</title> |
| 877 | |
| 878 | <para> |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 879 | You can use the BitBake layer management tool |
| 880 | <filename>bitbake-layers</filename> to provide a view |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 881 | into the structure of recipes across a multi-layer project. |
| 882 | Being able to generate output that reports on configured layers |
| 883 | with their paths and priorities and on |
| 884 | <filename>.bbappend</filename> files and their applicable |
| 885 | recipes can help to reveal potential problems. |
| 886 | </para> |
| 887 | |
| 888 | <para> |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 889 | For help on the BitBake layer management tool, use the |
| 890 | following command: |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 891 | <literallayout class='monospaced'> |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 892 | $ bitbake-layers --help |
| 893 | NOTE: Starting bitbake server... |
| 894 | usage: bitbake-layers [-d] [-q] [-F] [--color COLOR] [-h] <subcommand> ... |
| 895 | |
| 896 | BitBake layers utility |
| 897 | |
| 898 | optional arguments: |
| 899 | -d, --debug Enable debug output |
| 900 | -q, --quiet Print only errors |
| 901 | -F, --force Force add without recipe parse verification |
| 902 | --color COLOR Colorize output (where COLOR is auto, always, never) |
| 903 | -h, --help show this help message and exit |
| 904 | |
| 905 | subcommands: |
| 906 | <subcommand> |
| 907 | show-layers show current configured layers. |
| 908 | show-overlayed list overlayed recipes (where the same recipe exists |
| 909 | in another layer) |
| 910 | show-recipes list available recipes, showing the layer they are |
| 911 | provided by |
| 912 | show-appends list bbappend files and recipe files they apply to |
| 913 | show-cross-depends Show dependencies between recipes that cross layer |
| 914 | boundaries. |
| 915 | add-layer Add one or more layers to bblayers.conf. |
| 916 | remove-layer Remove one or more layers from bblayers.conf. |
| 917 | flatten flatten layer configuration into a separate output |
| 918 | directory. |
| 919 | layerindex-fetch Fetches a layer from a layer index along with its |
| 920 | dependent layers, and adds them to conf/bblayers.conf. |
| 921 | layerindex-show-depends |
| 922 | Find layer dependencies from layer index. |
| 923 | create-layer Create a basic layer |
| 924 | |
| 925 | Use bitbake-layers <subcommand> --help to get help on a specific command |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 926 | </literallayout> |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 927 | </para> |
| 928 | |
| 929 | <para> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 930 | The following list describes the available commands: |
| 931 | <itemizedlist> |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 932 | <listitem><para> |
| 933 | <emphasis><filename>help:</filename></emphasis> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 934 | Displays general help or help on a specified command. |
| 935 | </para></listitem> |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 936 | <listitem><para> |
| 937 | <emphasis><filename>show-layers:</filename></emphasis> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 938 | Shows the current configured layers. |
| 939 | </para></listitem> |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 940 | <listitem><para> |
| 941 | <emphasis><filename>show-overlayed:</filename></emphasis> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 942 | Lists overlayed recipes. |
| 943 | A recipe is overlayed when a recipe with the same name |
| 944 | exists in another layer that has a higher layer |
| 945 | priority. |
| 946 | </para></listitem> |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 947 | <listitem><para> |
| 948 | <emphasis><filename>show-recipes:</filename></emphasis> |
| 949 | Lists available recipes and the layers that provide them. |
| 950 | </para></listitem> |
| 951 | <listitem><para> |
| 952 | <emphasis><filename>show-appends:</filename></emphasis> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 953 | Lists <filename>.bbappend</filename> files and the |
| 954 | recipe files to which they apply. |
| 955 | </para></listitem> |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 956 | <listitem><para> |
| 957 | <emphasis><filename>show-cross-depends:</filename></emphasis> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 958 | Lists dependency relationships between recipes that |
| 959 | cross layer boundaries. |
| 960 | </para></listitem> |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 961 | <listitem><para> |
| 962 | <emphasis><filename>add-layer:</filename></emphasis> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 963 | Adds a layer to <filename>bblayers.conf</filename>. |
| 964 | </para></listitem> |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 965 | <listitem><para> |
| 966 | <emphasis><filename>remove-layer:</filename></emphasis> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 967 | Removes a layer from <filename>bblayers.conf</filename> |
| 968 | </para></listitem> |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 969 | <listitem><para> |
| 970 | <emphasis><filename>flatten:</filename></emphasis> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 971 | Flattens the layer configuration into a separate output |
| 972 | directory. |
| 973 | Flattening your layer configuration builds a "flattened" |
| 974 | directory that contains the contents of all layers, |
| 975 | with any overlayed recipes removed and any |
| 976 | <filename>.bbappend</filename> files appended to the |
| 977 | corresponding recipes. |
| 978 | You might have to perform some manual cleanup of the |
| 979 | flattened layer as follows: |
| 980 | <itemizedlist> |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 981 | <listitem><para> |
| 982 | Non-recipe files (such as patches) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 983 | are overwritten. |
| 984 | The flatten command shows a warning for these |
| 985 | files. |
| 986 | </para></listitem> |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 987 | <listitem><para> |
| 988 | Anything beyond the normal layer |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 989 | setup has been added to the |
| 990 | <filename>layer.conf</filename> file. |
| 991 | Only the lowest priority layer's |
| 992 | <filename>layer.conf</filename> is used. |
| 993 | </para></listitem> |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 994 | <listitem><para> |
| 995 | Overridden and appended items from |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 996 | <filename>.bbappend</filename> files need to be |
| 997 | cleaned up. |
| 998 | The contents of each |
| 999 | <filename>.bbappend</filename> end up in the |
| 1000 | flattened recipe. |
| 1001 | However, if there are appended or changed |
| 1002 | variable values, you need to tidy these up |
| 1003 | yourself. |
| 1004 | Consider the following example. |
| 1005 | Here, the <filename>bitbake-layers</filename> |
| 1006 | command adds the line |
| 1007 | <filename>#### bbappended ...</filename> so that |
| 1008 | you know where the following lines originate: |
| 1009 | <literallayout class='monospaced'> |
| 1010 | ... |
| 1011 | DESCRIPTION = "A useful utility" |
| 1012 | ... |
| 1013 | EXTRA_OECONF = "--enable-something" |
| 1014 | ... |
| 1015 | |
| 1016 | #### bbappended from meta-anotherlayer #### |
| 1017 | |
| 1018 | DESCRIPTION = "Customized utility" |
| 1019 | EXTRA_OECONF += "--enable-somethingelse" |
| 1020 | </literallayout> |
| 1021 | Ideally, you would tidy up these utilities as |
| 1022 | follows: |
| 1023 | <literallayout class='monospaced'> |
| 1024 | ... |
| 1025 | DESCRIPTION = "Customized utility" |
| 1026 | ... |
| 1027 | EXTRA_OECONF = "--enable-something --enable-somethingelse" |
| 1028 | ... |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 1029 | </literallayout> |
| 1030 | </para></listitem> |
| 1031 | </itemizedlist> |
| 1032 | </para></listitem> |
| 1033 | <listitem><para> |
| 1034 | <emphasis><filename>layerindex-fetch</filename>:</emphasis> |
| 1035 | Fetches a layer from a layer index, along with its |
| 1036 | dependent layers, and adds the layers to the |
| 1037 | <filename>conf/bblayers.conf</filename> file. |
| 1038 | </para></listitem> |
| 1039 | <listitem><para> |
| 1040 | <emphasis><filename>layerindex-show-depends</filename>:</emphasis> |
| 1041 | Finds layer dependencies from the layer index. |
| 1042 | </para></listitem> |
| 1043 | <listitem><para> |
| 1044 | <emphasis><filename>create-layer</filename>:</emphasis> |
| 1045 | Creates a basic layer. |
| 1046 | </para></listitem> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1047 | </itemizedlist> |
| 1048 | </para> |
| 1049 | </section> |
| 1050 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 1051 | <section id='creating-a-general-layer-using-the-bitbake-layers-script'> |
| 1052 | <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] | 1053 | |
| 1054 | <para> |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 1055 | The <filename>bitbake-layers</filename> script with the |
| 1056 | <filename>create-layer</filename> subcommand simplifies |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1057 | creating a new general layer. |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 1058 | <note><title>Notes</title> |
| 1059 | <itemizedlist> |
| 1060 | <listitem><para> |
| 1061 | For information on BSP layers, see the |
| 1062 | "<ulink url='&YOCTO_DOCS_BSP_URL;#bsp-layers'>BSP Layers</ulink>" |
| 1063 | section in the Yocto Project Board Specific (BSP) |
| 1064 | Developer's Guide. |
| 1065 | </para></listitem> |
| 1066 | <listitem><para> |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 1067 | In order to use a layer with the OpenEmbedded |
| 1068 | build system, you need to add the layer to your |
| 1069 | <filename>bblayers.conf</filename> configuration |
| 1070 | file. |
| 1071 | See the |
| 1072 | "<link linkend='adding-a-layer-using-the-bitbake-layers-script'>Adding a Layer Using the <filename>bitbake-layers</filename> Script</link>" |
| 1073 | section for more information. |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 1074 | </para></listitem> |
| 1075 | </itemizedlist> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1076 | </note> |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 1077 | The default mode of the script's operation with this |
| 1078 | subcommand is to create a layer with the following: |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1079 | <itemizedlist> |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 1080 | <listitem><para>A layer priority of 6. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1081 | </para></listitem> |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 1082 | <listitem><para>A <filename>conf</filename> |
| 1083 | subdirectory that contains a |
| 1084 | <filename>layer.conf</filename> file. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1085 | </para></listitem> |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 1086 | <listitem><para> |
| 1087 | A <filename>recipes-example</filename> subdirectory |
| 1088 | that contains a further subdirectory named |
| 1089 | <filename>example</filename>, which contains |
| 1090 | an <filename>example.bb</filename> recipe file. |
| 1091 | </para></listitem> |
| 1092 | <listitem><para>A <filename >COPYING.MIT</filename>, |
| 1093 | which is the license statement for the layer. |
| 1094 | The script assumes you want to use the MIT license, |
| 1095 | which is typical for most layers, for the contents of |
| 1096 | the layer itself. |
| 1097 | </para></listitem> |
| 1098 | <listitem><para> |
| 1099 | A <filename>README</filename> file, which is a file |
| 1100 | describing the contents of your new layer. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1101 | </para></listitem> |
| 1102 | </itemizedlist> |
| 1103 | </para> |
| 1104 | |
| 1105 | <para> |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 1106 | In its simplest form, you can use the following command form |
| 1107 | to create a layer. |
| 1108 | The command creates a layer whose name corresponds to |
| 1109 | <replaceable>your_layer_name</replaceable> in the current |
| 1110 | directory: |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1111 | <literallayout class='monospaced'> |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 1112 | $ bitbake-layers create-layer <replaceable>your_layer_name</replaceable> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1113 | </literallayout> |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 1114 | As an example, the following command creates a layer named |
| 1115 | <filename>meta-scottrif</filename> in your home directory: |
| 1116 | <literallayout class='monospaced'> |
| 1117 | $ cd /usr/home |
| 1118 | $ bitbake-layers create-layer meta-scottrif |
| 1119 | NOTE: Starting bitbake server... |
| 1120 | Add your new layer with 'bitbake-layers add-layer meta-scottrif' |
| 1121 | </literallayout> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1122 | </para> |
| 1123 | |
| 1124 | <para> |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 1125 | If you want to set the priority of the layer to other than the |
| 1126 | default value of "6", you can either use the |
| 1127 | <filename>‐‐priority</filename> option or you can |
| 1128 | edit the |
| 1129 | <ulink url='&YOCTO_DOCS_REF_URL;#var-BBFILE_PRIORITY'><filename>BBFILE_PRIORITY</filename></ulink> |
| 1130 | value in the <filename>conf/layer.conf</filename> after the |
| 1131 | script creates it. |
| 1132 | Furthermore, if you want to give the example recipe file |
| 1133 | some name other than the default, you can |
| 1134 | use the |
| 1135 | <filename>‐‐example-recipe-name</filename> option. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1136 | </para> |
| 1137 | |
| 1138 | <para> |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 1139 | The easiest way to see how the |
| 1140 | <filename>bitbake-layers create-layer</filename> command |
| 1141 | works is to experiment with the script. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1142 | You can also read the usage information by entering the |
| 1143 | following: |
| 1144 | <literallayout class='monospaced'> |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 1145 | $ bitbake-layers create-layer --help |
| 1146 | NOTE: Starting bitbake server... |
| 1147 | usage: bitbake-layers create-layer [-h] [--priority PRIORITY] |
| 1148 | [--example-recipe-name EXAMPLERECIPE] |
| 1149 | layerdir |
| 1150 | |
| 1151 | Create a basic layer |
| 1152 | |
| 1153 | positional arguments: |
| 1154 | layerdir Layer directory to create |
| 1155 | |
| 1156 | optional arguments: |
| 1157 | -h, --help show this help message and exit |
| 1158 | --priority PRIORITY, -p PRIORITY |
| 1159 | Layer directory to create |
| 1160 | --example-recipe-name EXAMPLERECIPE, -e EXAMPLERECIPE |
| 1161 | Filename of the example recipe |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1162 | </literallayout> |
| 1163 | </para> |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 1164 | </section> |
| 1165 | |
| 1166 | <section id='adding-a-layer-using-the-bitbake-layers-script'> |
| 1167 | <title>Adding a Layer Using the <filename>bitbake-layers</filename> Script</title> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1168 | |
| 1169 | <para> |
| 1170 | Once you create your general layer, you must add it to your |
| 1171 | <filename>bblayers.conf</filename> file. |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 1172 | Adding the layer to this configuration file makes the |
| 1173 | OpenEmbedded build system aware of your layer so that it can |
| 1174 | search it for metadata. |
| 1175 | </para> |
| 1176 | |
| 1177 | <para> |
| 1178 | Add your layer by using the |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 1179 | <filename>bitbake-layers add-layer</filename> command: |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1180 | <literallayout class='monospaced'> |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 1181 | $ bitbake-layers add-layer <replaceable>your_layer_name</replaceable> |
| 1182 | </literallayout> |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 1183 | Here is an example that adds a layer named |
| 1184 | <filename>meta-scottrif</filename> to the configuration file. |
| 1185 | Following the command that adds the layer is another |
| 1186 | <filename>bitbake-layers</filename> command that shows the |
| 1187 | layers that are in your <filename>bblayers.conf</filename> |
| 1188 | file: |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 1189 | <literallayout class='monospaced'> |
| 1190 | $ bitbake-layers add-layer meta-scottrif |
| 1191 | NOTE: Starting bitbake server... |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 1192 | Parsing recipes: 100% |##########################################################| Time: 0:00:49 |
| 1193 | 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] | 1194 | $ bitbake-layers show-layers |
| 1195 | NOTE: Starting bitbake server... |
| 1196 | layer path priority |
| 1197 | ========================================================================== |
| 1198 | meta /home/scottrif/poky/meta 5 |
| 1199 | meta-poky /home/scottrif/poky/meta-poky 5 |
| 1200 | meta-yocto-bsp /home/scottrif/poky/meta-yocto-bsp 5 |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 1201 | workspace /home/scottrif/poky/build/workspace 99 |
| 1202 | meta-scottrif /home/scottrif/poky/build/meta-scottrif 6 |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1203 | </literallayout> |
| 1204 | Adding the layer to this file enables the build system to |
| 1205 | locate the layer during the build. |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 1206 | <note> |
| 1207 | During a build, the OpenEmbedded build system looks in |
| 1208 | the layers from the top of the list down to the bottom |
| 1209 | in that order. |
| 1210 | </note> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1211 | </para> |
| 1212 | </section> |
| 1213 | </section> |
| 1214 | |
| 1215 | <section id='usingpoky-extend-customimage'> |
| 1216 | <title>Customizing Images</title> |
| 1217 | |
| 1218 | <para> |
| 1219 | You can customize images to satisfy particular requirements. |
| 1220 | This section describes several methods and provides guidelines for each. |
| 1221 | </para> |
| 1222 | |
| 1223 | <section id='usingpoky-extend-customimage-localconf'> |
| 1224 | <title>Customizing Images Using <filename>local.conf</filename></title> |
| 1225 | |
| 1226 | <para> |
| 1227 | Probably the easiest way to customize an image is to add a |
| 1228 | package by way of the <filename>local.conf</filename> |
| 1229 | configuration file. |
| 1230 | Because it is limited to local use, this method generally only |
| 1231 | allows you to add packages and is not as flexible as creating |
| 1232 | your own customized image. |
| 1233 | When you add packages using local variables this way, you need |
| 1234 | to realize that these variable changes are in effect for every |
| 1235 | build and consequently affect all images, which might not |
| 1236 | be what you require. |
| 1237 | </para> |
| 1238 | |
| 1239 | <para> |
| 1240 | To add a package to your image using the local configuration |
| 1241 | file, use the |
| 1242 | <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-IMAGE_INSTALL'>IMAGE_INSTALL</ulink></filename> |
| 1243 | variable with the <filename>_append</filename> operator: |
| 1244 | <literallayout class='monospaced'> |
| 1245 | IMAGE_INSTALL_append = " strace" |
| 1246 | </literallayout> |
| 1247 | Use of the syntax is important - specifically, the space between |
| 1248 | the quote and the package name, which is |
| 1249 | <filename>strace</filename> in this example. |
| 1250 | This space is required since the <filename>_append</filename> |
| 1251 | operator does not add the space. |
| 1252 | </para> |
| 1253 | |
| 1254 | <para> |
| 1255 | Furthermore, you must use <filename>_append</filename> instead |
| 1256 | of the <filename>+=</filename> operator if you want to avoid |
| 1257 | ordering issues. |
| 1258 | The reason for this is because doing so unconditionally appends |
| 1259 | to the variable and avoids ordering problems due to the |
| 1260 | variable being set in image recipes and |
| 1261 | <filename>.bbclass</filename> files with operators like |
| 1262 | <filename>?=</filename>. |
| 1263 | Using <filename>_append</filename> ensures the operation takes |
| 1264 | affect. |
| 1265 | </para> |
| 1266 | |
| 1267 | <para> |
| 1268 | As shown in its simplest use, |
| 1269 | <filename>IMAGE_INSTALL_append</filename> affects all images. |
| 1270 | It is possible to extend the syntax so that the variable |
| 1271 | applies to a specific image only. |
| 1272 | Here is an example: |
| 1273 | <literallayout class='monospaced'> |
| 1274 | IMAGE_INSTALL_append_pn-core-image-minimal = " strace" |
| 1275 | </literallayout> |
| 1276 | This example adds <filename>strace</filename> to the |
| 1277 | <filename>core-image-minimal</filename> image only. |
| 1278 | </para> |
| 1279 | |
| 1280 | <para> |
| 1281 | You can add packages using a similar approach through the |
| 1282 | <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-CORE_IMAGE_EXTRA_INSTALL'>CORE_IMAGE_EXTRA_INSTALL</ulink></filename> |
| 1283 | variable. |
| 1284 | If you use this variable, only |
| 1285 | <filename>core-image-*</filename> images are affected. |
| 1286 | </para> |
| 1287 | </section> |
| 1288 | |
| 1289 | <section id='usingpoky-extend-customimage-imagefeatures'> |
| 1290 | <title>Customizing Images Using Custom <filename>IMAGE_FEATURES</filename> and |
| 1291 | <filename>EXTRA_IMAGE_FEATURES</filename></title> |
| 1292 | |
| 1293 | <para> |
| 1294 | Another method for customizing your image is to enable or |
| 1295 | disable high-level image features by using the |
| 1296 | <ulink url='&YOCTO_DOCS_REF_URL;#var-IMAGE_FEATURES'><filename>IMAGE_FEATURES</filename></ulink> |
| 1297 | and <ulink url='&YOCTO_DOCS_REF_URL;#var-EXTRA_IMAGE_FEATURES'><filename>EXTRA_IMAGE_FEATURES</filename></ulink> |
| 1298 | variables. |
| 1299 | Although the functions for both variables are nearly equivalent, |
| 1300 | best practices dictate using <filename>IMAGE_FEATURES</filename> |
| 1301 | from within a recipe and using |
| 1302 | <filename>EXTRA_IMAGE_FEATURES</filename> from within |
| 1303 | your <filename>local.conf</filename> file, which is found in the |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 1304 | <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink>. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1305 | </para> |
| 1306 | |
| 1307 | <para> |
| 1308 | To understand how these features work, the best reference is |
| 1309 | <filename>meta/classes/core-image.bbclass</filename>. |
| 1310 | This class lists out the available |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 1311 | <filename>IMAGE_FEATURES</filename> of which most map to |
| 1312 | package groups while some, such as |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1313 | <filename>debug-tweaks</filename> and |
| 1314 | <filename>read-only-rootfs</filename>, resolve as general |
| 1315 | configuration settings. |
| 1316 | </para> |
| 1317 | |
| 1318 | <para> |
| 1319 | In summary, the file looks at the contents of the |
| 1320 | <filename>IMAGE_FEATURES</filename> variable and then maps |
| 1321 | or configures the feature accordingly. |
| 1322 | Based on this information, the build system automatically |
| 1323 | adds the appropriate packages or configurations to the |
| 1324 | <ulink url='&YOCTO_DOCS_REF_URL;#var-IMAGE_INSTALL'><filename>IMAGE_INSTALL</filename></ulink> |
| 1325 | variable. |
| 1326 | Effectively, you are enabling extra features by extending the |
| 1327 | class or creating a custom class for use with specialized image |
| 1328 | <filename>.bb</filename> files. |
| 1329 | </para> |
| 1330 | |
| 1331 | <para> |
| 1332 | Use the <filename>EXTRA_IMAGE_FEATURES</filename> variable |
| 1333 | from within your local configuration file. |
| 1334 | Using a separate area from which to enable features with |
| 1335 | this variable helps you avoid overwriting the features in the |
| 1336 | image recipe that are enabled with |
| 1337 | <filename>IMAGE_FEATURES</filename>. |
| 1338 | The value of <filename>EXTRA_IMAGE_FEATURES</filename> is added |
| 1339 | to <filename>IMAGE_FEATURES</filename> within |
| 1340 | <filename>meta/conf/bitbake.conf</filename>. |
| 1341 | </para> |
| 1342 | |
| 1343 | <para> |
| 1344 | To illustrate how you can use these variables to modify your |
| 1345 | image, consider an example that selects the SSH server. |
| 1346 | The Yocto Project ships with two SSH servers you can use |
| 1347 | with your images: Dropbear and OpenSSH. |
| 1348 | Dropbear is a minimal SSH server appropriate for |
| 1349 | resource-constrained environments, while OpenSSH is a |
| 1350 | well-known standard SSH server implementation. |
| 1351 | By default, the <filename>core-image-sato</filename> image |
| 1352 | is configured to use Dropbear. |
| 1353 | The <filename>core-image-full-cmdline</filename> and |
| 1354 | <filename>core-image-lsb</filename> images both |
| 1355 | include OpenSSH. |
| 1356 | The <filename>core-image-minimal</filename> image does not |
| 1357 | contain an SSH server. |
| 1358 | </para> |
| 1359 | |
| 1360 | <para> |
| 1361 | You can customize your image and change these defaults. |
| 1362 | Edit the <filename>IMAGE_FEATURES</filename> variable |
| 1363 | in your recipe or use the |
| 1364 | <filename>EXTRA_IMAGE_FEATURES</filename> in your |
| 1365 | <filename>local.conf</filename> file so that it configures the |
| 1366 | image you are working with to include |
| 1367 | <filename>ssh-server-dropbear</filename> or |
| 1368 | <filename>ssh-server-openssh</filename>. |
| 1369 | </para> |
| 1370 | |
| 1371 | <note> |
| 1372 | See the |
| 1373 | "<ulink url='&YOCTO_DOCS_REF_URL;#ref-images'>Images</ulink>" |
| 1374 | section in the Yocto Project Reference Manual for a complete |
| 1375 | list of image features that ship with the Yocto Project. |
| 1376 | </note> |
| 1377 | </section> |
| 1378 | |
| 1379 | <section id='usingpoky-extend-customimage-custombb'> |
| 1380 | <title>Customizing Images Using Custom .bb Files</title> |
| 1381 | |
| 1382 | <para> |
| 1383 | You can also customize an image by creating a custom recipe |
| 1384 | that defines additional software as part of the image. |
| 1385 | The following example shows the form for the two lines you need: |
| 1386 | <literallayout class='monospaced'> |
| 1387 | IMAGE_INSTALL = "packagegroup-core-x11-base package1 package2" |
| 1388 | |
| 1389 | inherit core-image |
| 1390 | </literallayout> |
| 1391 | </para> |
| 1392 | |
| 1393 | <para> |
| 1394 | Defining the software using a custom recipe gives you total |
| 1395 | control over the contents of the image. |
| 1396 | It is important to use the correct names of packages in the |
| 1397 | <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-IMAGE_INSTALL'>IMAGE_INSTALL</ulink></filename> |
| 1398 | variable. |
| 1399 | You must use the OpenEmbedded notation and not the Debian notation for the names |
| 1400 | (e.g. <filename>glibc-dev</filename> instead of <filename>libc6-dev</filename>). |
| 1401 | </para> |
| 1402 | |
| 1403 | <para> |
| 1404 | The other method for creating a custom image is to base it on an existing image. |
| 1405 | For example, if you want to create an image based on <filename>core-image-sato</filename> |
| 1406 | but add the additional package <filename>strace</filename> to the image, |
| 1407 | copy the <filename>meta/recipes-sato/images/core-image-sato.bb</filename> to a |
| 1408 | new <filename>.bb</filename> and add the following line to the end of the copy: |
| 1409 | <literallayout class='monospaced'> |
| 1410 | IMAGE_INSTALL += "strace" |
| 1411 | </literallayout> |
| 1412 | </para> |
| 1413 | </section> |
| 1414 | |
| 1415 | <section id='usingpoky-extend-customimage-customtasks'> |
| 1416 | <title>Customizing Images Using Custom Package Groups</title> |
| 1417 | |
| 1418 | <para> |
| 1419 | For complex custom images, the best approach for customizing |
| 1420 | an image is to create a custom package group recipe that is |
| 1421 | used to build the image or images. |
| 1422 | A good example of a package group recipe is |
| 1423 | <filename>meta/recipes-core/packagegroups/packagegroup-base.bb</filename>. |
| 1424 | </para> |
| 1425 | |
| 1426 | <para> |
| 1427 | If you examine that recipe, you see that the |
| 1428 | <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGES'>PACKAGES</ulink></filename> |
| 1429 | variable lists the package group packages to produce. |
| 1430 | The <filename>inherit packagegroup</filename> statement |
| 1431 | sets appropriate default values and automatically adds |
| 1432 | <filename>-dev</filename>, <filename>-dbg</filename>, and |
| 1433 | <filename>-ptest</filename> complementary packages for each |
| 1434 | package specified in the <filename>PACKAGES</filename> |
| 1435 | statement. |
| 1436 | <note> |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 1437 | The <filename>inherit packagegroup</filename> line should be |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1438 | located near the top of the recipe, certainly before |
| 1439 | the <filename>PACKAGES</filename> statement. |
| 1440 | </note> |
| 1441 | </para> |
| 1442 | |
| 1443 | <para> |
| 1444 | For each package you specify in <filename>PACKAGES</filename>, |
| 1445 | you can use |
| 1446 | <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-RDEPENDS'>RDEPENDS</ulink></filename> |
| 1447 | and |
| 1448 | <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-RRECOMMENDS'>RRECOMMENDS</ulink></filename> |
| 1449 | entries to provide a list of packages the parent task package |
| 1450 | should contain. |
| 1451 | You can see examples of these further down in the |
| 1452 | <filename>packagegroup-base.bb</filename> recipe. |
| 1453 | </para> |
| 1454 | |
| 1455 | <para> |
| 1456 | Here is a short, fabricated example showing the same basic |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 1457 | pieces for a hypothetical packagegroup defined in |
| 1458 | <filename>packagegroup-custom.bb</filename>, where the |
| 1459 | variable <filename>PN</filename> is the standard way to |
| 1460 | abbreviate the reference to the full packagegroup name |
| 1461 | <filename>packagegroup-custom</filename>: |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1462 | <literallayout class='monospaced'> |
| 1463 | DESCRIPTION = "My Custom Package Groups" |
| 1464 | |
| 1465 | inherit packagegroup |
| 1466 | |
| 1467 | PACKAGES = "\ |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 1468 | ${PN}-apps \ |
| 1469 | ${PN}-tools \ |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1470 | " |
| 1471 | |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 1472 | RDEPENDS_${PN}-apps = "\ |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1473 | dropbear \ |
| 1474 | portmap \ |
| 1475 | psplash" |
| 1476 | |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 1477 | RDEPENDS_${PN}-tools = "\ |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1478 | oprofile \ |
| 1479 | oprofileui-server \ |
| 1480 | lttng-tools" |
| 1481 | |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 1482 | RRECOMMENDS_${PN}-tools = "\ |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1483 | kernel-module-oprofile" |
| 1484 | </literallayout> |
| 1485 | </para> |
| 1486 | |
| 1487 | <para> |
| 1488 | In the previous example, two package group packages are created with their dependencies and their |
| 1489 | recommended package dependencies listed: <filename>packagegroup-custom-apps</filename>, and |
| 1490 | <filename>packagegroup-custom-tools</filename>. |
| 1491 | To build an image using these package group packages, you need to add |
| 1492 | <filename>packagegroup-custom-apps</filename> and/or |
| 1493 | <filename>packagegroup-custom-tools</filename> to |
| 1494 | <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-IMAGE_INSTALL'>IMAGE_INSTALL</ulink></filename>. |
| 1495 | For other forms of image dependencies see the other areas of this section. |
| 1496 | </para> |
| 1497 | </section> |
| 1498 | |
| 1499 | <section id='usingpoky-extend-customimage-image-name'> |
| 1500 | <title>Customizing an Image Hostname</title> |
| 1501 | |
| 1502 | <para> |
| 1503 | By default, the configured hostname (i.e. |
| 1504 | <filename>/etc/hostname</filename>) in an image is the |
| 1505 | same as the machine name. |
| 1506 | For example, if |
| 1507 | <ulink url='&YOCTO_DOCS_REF_URL;#var-MACHINE'><filename>MACHINE</filename></ulink> |
| 1508 | equals "qemux86", the configured hostname written to |
| 1509 | <filename>/etc/hostname</filename> is "qemux86". |
| 1510 | </para> |
| 1511 | |
| 1512 | <para> |
| 1513 | You can customize this name by altering the value of the |
| 1514 | "hostname" variable in the |
| 1515 | <filename>base-files</filename> recipe using either |
| 1516 | an append file or a configuration file. |
| 1517 | Use the following in an append file: |
| 1518 | <literallayout class='monospaced'> |
| 1519 | hostname="myhostname" |
| 1520 | </literallayout> |
| 1521 | Use the following in a configuration file: |
| 1522 | <literallayout class='monospaced'> |
| 1523 | hostname_pn-base-files = "myhostname" |
| 1524 | </literallayout> |
| 1525 | </para> |
| 1526 | |
| 1527 | <para> |
| 1528 | Changing the default value of the variable "hostname" can be |
| 1529 | useful in certain situations. |
| 1530 | For example, suppose you need to do extensive testing on an |
| 1531 | image and you would like to easily identify the image |
| 1532 | under test from existing images with typical default |
| 1533 | hostnames. |
| 1534 | In this situation, you could change the default hostname to |
| 1535 | "testme", which results in all the images using the name |
| 1536 | "testme". |
| 1537 | Once testing is complete and you do not need to rebuild the |
| 1538 | image for test any longer, you can easily reset the default |
| 1539 | hostname. |
| 1540 | </para> |
| 1541 | |
| 1542 | <para> |
| 1543 | Another point of interest is that if you unset the variable, |
| 1544 | the image will have no default hostname in the filesystem. |
| 1545 | Here is an example that unsets the variable in a |
| 1546 | configuration file: |
| 1547 | <literallayout class='monospaced'> |
| 1548 | hostname_pn-base-files = "" |
| 1549 | </literallayout> |
| 1550 | Having no default hostname in the filesystem is suitable for |
| 1551 | environments that use dynamic hostnames such as virtual |
| 1552 | machines. |
| 1553 | </para> |
| 1554 | </section> |
| 1555 | </section> |
| 1556 | |
| 1557 | <section id='new-recipe-writing-a-new-recipe'> |
| 1558 | <title>Writing a New Recipe</title> |
| 1559 | |
| 1560 | <para> |
| 1561 | Recipes (<filename>.bb</filename> files) are fundamental components |
| 1562 | in the Yocto Project environment. |
| 1563 | Each software component built by the OpenEmbedded build system |
| 1564 | requires a recipe to define the component. |
| 1565 | This section describes how to create, write, and test a new |
| 1566 | recipe. |
| 1567 | <note> |
| 1568 | For information on variables that are useful for recipes and |
| 1569 | for information about recipe naming issues, see the |
| 1570 | "<ulink url='&YOCTO_DOCS_REF_URL;#ref-varlocality-recipe-required'>Required</ulink>" |
| 1571 | section of the Yocto Project Reference Manual. |
| 1572 | </note> |
| 1573 | </para> |
| 1574 | |
| 1575 | <section id='new-recipe-overview'> |
| 1576 | <title>Overview</title> |
| 1577 | |
| 1578 | <para> |
| 1579 | The following figure shows the basic process for creating a |
| 1580 | new recipe. |
| 1581 | The remainder of the section provides details for the steps. |
| 1582 | <imagedata fileref="figures/recipe-workflow.png" width="6in" depth="7in" align="center" scalefit="1" /> |
| 1583 | </para> |
| 1584 | </section> |
| 1585 | |
| 1586 | <section id='new-recipe-locate-or-automatically-create-a-base-recipe'> |
| 1587 | <title>Locate or Automatically Create a Base Recipe</title> |
| 1588 | |
| 1589 | <para> |
| 1590 | You can always write a recipe from scratch. |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 1591 | However, three choices exist that can help you quickly get a |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1592 | start on a new recipe: |
| 1593 | <itemizedlist> |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 1594 | <listitem><para> |
| 1595 | <emphasis><filename>devtool add</filename>:</emphasis> |
| 1596 | A command that assists in creating a recipe and |
| 1597 | an environment conducive to development. |
| 1598 | </para></listitem> |
| 1599 | <listitem><para> |
| 1600 | <emphasis><filename>recipetool create</filename>:</emphasis> |
| 1601 | A command provided by the Yocto Project that automates |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1602 | creation of a base recipe based on the source |
| 1603 | files. |
| 1604 | </para></listitem> |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 1605 | <listitem><para> |
| 1606 | <emphasis>Existing Recipes:</emphasis> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1607 | Location and modification of an existing recipe that is |
| 1608 | similar in function to the recipe you need. |
| 1609 | </para></listitem> |
| 1610 | </itemizedlist> |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 1611 | <note> |
| 1612 | For information on recipe syntax, see the |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 1613 | "<link linkend='recipe-syntax'>Recipe Syntax</link>" |
| 1614 | section. |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 1615 | </note> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1616 | </para> |
| 1617 | |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 1618 | <section id='new-recipe-creating-the-base-recipe-using-devtool'> |
| 1619 | <title>Creating the Base Recipe Using <filename>devtool add</filename></title> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1620 | |
| 1621 | <para> |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 1622 | The <filename>devtool add</filename> command uses the same |
| 1623 | logic for auto-creating the recipe as |
| 1624 | <filename>recipetool create</filename>, which is listed |
| 1625 | below. |
| 1626 | Additionally, however, <filename>devtool add</filename> |
| 1627 | sets up an environment that makes it easy for you to |
| 1628 | patch the source and to make changes to the recipe as |
| 1629 | is often necessary when adding a recipe to build a new |
| 1630 | piece of software to be included in a build. |
| 1631 | </para> |
| 1632 | |
| 1633 | <para> |
| 1634 | You can find a complete description of the |
| 1635 | <filename>devtool add</filename> command in the |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 1636 | "<ulink url='&YOCTO_DOCS_SDK_URL;#sdk-a-closer-look-at-devtool-add'>A Closer Look at <filename>devtool</filename> add</ulink>" |
| 1637 | section in the Yocto Project Application Development |
| 1638 | and the Extensible Software Development Kit (eSDK) manual. |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 1639 | </para> |
| 1640 | </section> |
| 1641 | |
| 1642 | <section id='new-recipe-creating-the-base-recipe-using-recipetool'> |
| 1643 | <title>Creating the Base Recipe Using <filename>recipetool create</filename></title> |
| 1644 | |
| 1645 | <para> |
| 1646 | <filename>recipetool create</filename> automates creation |
| 1647 | of a base recipe given a set of source code files. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1648 | As long as you can extract or point to the source files, |
| 1649 | the tool will construct a recipe and automatically |
| 1650 | configure all pre-build information into the recipe. |
| 1651 | For example, suppose you have an application that builds |
| 1652 | using Autotools. |
| 1653 | Creating the base recipe using |
| 1654 | <filename>recipetool</filename> results in a recipe |
| 1655 | that has the pre-build dependencies, license requirements, |
| 1656 | and checksums configured. |
| 1657 | </para> |
| 1658 | |
| 1659 | <para> |
| 1660 | To run the tool, you just need to be in your |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 1661 | <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1662 | and have sourced the build environment setup script |
| 1663 | (i.e. |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 1664 | <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] | 1665 | To get help on the tool, use the following command: |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1666 | <literallayout class='monospaced'> |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 1667 | $ recipetool -h |
| 1668 | NOTE: Starting bitbake server... |
| 1669 | usage: recipetool [-d] [-q] [--color COLOR] [-h] <subcommand> ... |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1670 | |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 1671 | OpenEmbedded recipe tool |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1672 | |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 1673 | options: |
| 1674 | -d, --debug Enable debug output |
| 1675 | -q, --quiet Print only errors |
| 1676 | --color COLOR Colorize output (where COLOR is auto, always, never) |
| 1677 | -h, --help show this help message and exit |
| 1678 | |
| 1679 | subcommands: |
| 1680 | create Create a new recipe |
| 1681 | newappend Create a bbappend for the specified target in the specified |
| 1682 | layer |
| 1683 | setvar Set a variable within a recipe |
| 1684 | appendfile Create/update a bbappend to replace a target file |
| 1685 | appendsrcfiles Create/update a bbappend to add or replace source files |
| 1686 | appendsrcfile Create/update a bbappend to add or replace a source file |
| 1687 | Use recipetool <subcommand> --help to get help on a specific command |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1688 | </literallayout> |
| 1689 | </para> |
| 1690 | |
| 1691 | <para> |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 1692 | Running |
| 1693 | <filename>recipetool create -o</filename> <replaceable>OUTFILE</replaceable> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1694 | creates the base recipe and locates it properly in the |
| 1695 | layer that contains your source files. |
| 1696 | Following are some syntax examples: |
| 1697 | </para> |
| 1698 | |
| 1699 | <para> |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 1700 | Use this syntax to generate a recipe based on |
| 1701 | <replaceable>source</replaceable>. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1702 | Once generated, the recipe resides in the existing source |
| 1703 | code layer: |
| 1704 | <literallayout class='monospaced'> |
| 1705 | recipetool create -o <replaceable>OUTFILE</replaceable> <replaceable>source</replaceable> |
| 1706 | </literallayout> |
| 1707 | Use this syntax to generate a recipe using code that you |
| 1708 | extract from <replaceable>source</replaceable>. |
| 1709 | The extracted code is placed in its own layer defined |
| 1710 | by <replaceable>EXTERNALSRC</replaceable>. |
| 1711 | <literallayout class='monospaced'> |
| 1712 | recipetool create -o <replaceable>OUTFILE</replaceable> -x <replaceable>EXTERNALSRC</replaceable> <replaceable>source</replaceable> |
| 1713 | </literallayout> |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 1714 | Use this syntax to generate a recipe based on |
| 1715 | <replaceable>source</replaceable>. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1716 | The options direct <filename>recipetool</filename> to |
Brad Bishop | 37a0e4d | 2017-12-04 01:01:44 -0500 | [diff] [blame] | 1717 | generate debugging information. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1718 | Once generated, the recipe resides in the existing source |
| 1719 | code layer: |
| 1720 | <literallayout class='monospaced'> |
Brad Bishop | 37a0e4d | 2017-12-04 01:01:44 -0500 | [diff] [blame] | 1721 | recipetool create -d -o <replaceable>OUTFILE</replaceable> <replaceable>source</replaceable> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1722 | </literallayout> |
| 1723 | </para> |
| 1724 | </section> |
| 1725 | |
| 1726 | <section id='new-recipe-locating-and-using-a-similar-recipe'> |
| 1727 | <title>Locating and Using a Similar Recipe</title> |
| 1728 | |
| 1729 | <para> |
| 1730 | Before writing a recipe from scratch, it is often useful to |
| 1731 | discover whether someone else has already written one that |
| 1732 | meets (or comes close to meeting) your needs. |
| 1733 | The Yocto Project and OpenEmbedded communities maintain many |
| 1734 | recipes that might be candidates for what you are doing. |
| 1735 | You can find a good central index of these recipes in the |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 1736 | <ulink url='http://layers.openembedded.org'>OpenEmbedded Layer Index</ulink>. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1737 | </para> |
| 1738 | |
| 1739 | <para> |
| 1740 | Working from an existing recipe or a skeleton recipe is the |
| 1741 | best way to get started. |
| 1742 | Here are some points on both methods: |
| 1743 | <itemizedlist> |
| 1744 | <listitem><para><emphasis>Locate and modify a recipe that |
| 1745 | is close to what you want to do:</emphasis> |
| 1746 | This method works when you are familiar with the |
| 1747 | current recipe space. |
| 1748 | The method does not work so well for those new to |
| 1749 | the Yocto Project or writing recipes.</para> |
| 1750 | <para>Some risks associated with this method are |
| 1751 | using a recipe that has areas totally unrelated to |
| 1752 | what you are trying to accomplish with your recipe, |
| 1753 | not recognizing areas of the recipe that you might |
| 1754 | have to add from scratch, and so forth. |
| 1755 | All these risks stem from unfamiliarity with the |
| 1756 | existing recipe space.</para></listitem> |
| 1757 | <listitem><para><emphasis>Use and modify the following |
| 1758 | skeleton recipe:</emphasis> |
| 1759 | If for some reason you do not want to use |
| 1760 | <filename>recipetool</filename> and you cannot |
| 1761 | find an existing recipe that is close to meeting |
| 1762 | your needs, you can use the following structure to |
| 1763 | provide the fundamental areas of a new recipe. |
| 1764 | <literallayout class='monospaced'> |
| 1765 | DESCRIPTION = "" |
| 1766 | HOMEPAGE = "" |
| 1767 | LICENSE = "" |
| 1768 | SECTION = "" |
| 1769 | DEPENDS = "" |
| 1770 | LIC_FILES_CHKSUM = "" |
| 1771 | |
| 1772 | SRC_URI = "" |
| 1773 | </literallayout> |
| 1774 | </para></listitem> |
| 1775 | </itemizedlist> |
| 1776 | </para> |
| 1777 | </section> |
| 1778 | </section> |
| 1779 | |
| 1780 | <section id='new-recipe-storing-and-naming-the-recipe'> |
| 1781 | <title>Storing and Naming the Recipe</title> |
| 1782 | |
| 1783 | <para> |
| 1784 | Once you have your base recipe, you should put it in your |
| 1785 | own layer and name it appropriately. |
| 1786 | Locating it correctly ensures that the OpenEmbedded build |
| 1787 | system can find it when you use BitBake to process the |
| 1788 | recipe. |
| 1789 | </para> |
| 1790 | |
| 1791 | <itemizedlist> |
| 1792 | <listitem><para><emphasis>Storing Your Recipe:</emphasis> |
| 1793 | The OpenEmbedded build system locates your recipe |
| 1794 | through the layer's <filename>conf/layer.conf</filename> |
| 1795 | file and the |
| 1796 | <ulink url='&YOCTO_DOCS_REF_URL;#var-BBFILES'><filename>BBFILES</filename></ulink> |
| 1797 | variable. |
| 1798 | This variable sets up a path from which the build system can |
| 1799 | locate recipes. |
| 1800 | Here is the typical use: |
| 1801 | <literallayout class='monospaced'> |
| 1802 | BBFILES += "${LAYERDIR}/recipes-*/*/*.bb \ |
| 1803 | ${LAYERDIR}/recipes-*/*/*.bbappend" |
| 1804 | </literallayout> |
| 1805 | Consequently, you need to be sure you locate your new recipe |
| 1806 | inside your layer such that it can be found.</para> |
| 1807 | <para>You can find more information on how layers are |
| 1808 | structured in the |
| 1809 | "<link linkend='understanding-and-creating-layers'>Understanding and Creating Layers</link>" |
| 1810 | section.</para></listitem> |
| 1811 | <listitem><para><emphasis>Naming Your Recipe:</emphasis> |
| 1812 | When you name your recipe, you need to follow this naming |
| 1813 | convention: |
| 1814 | <literallayout class='monospaced'> |
| 1815 | <replaceable>basename</replaceable>_<replaceable>version</replaceable>.bb |
| 1816 | </literallayout> |
| 1817 | Use lower-cased characters and do not include the reserved |
| 1818 | suffixes <filename>-native</filename>, |
| 1819 | <filename>-cross</filename>, <filename>-initial</filename>, |
| 1820 | or <filename>-dev</filename> casually (i.e. do not use them |
| 1821 | as part of your recipe name unless the string applies). |
| 1822 | Here are some examples: |
| 1823 | <literallayout class='monospaced'> |
| 1824 | cups_1.7.0.bb |
| 1825 | gawk_4.0.2.bb |
| 1826 | irssi_0.8.16-rc1.bb |
| 1827 | </literallayout></para></listitem> |
| 1828 | </itemizedlist> |
| 1829 | </section> |
| 1830 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1831 | <section id='new-recipe-running-a-build-on-the-recipe'> |
| 1832 | <title>Running a Build on the Recipe</title> |
| 1833 | |
| 1834 | <para> |
| 1835 | Creating a new recipe is usually an iterative process that |
| 1836 | requires using BitBake to process the recipe multiple times in |
| 1837 | order to progressively discover and add information to the |
| 1838 | recipe file. |
| 1839 | </para> |
| 1840 | |
| 1841 | <para> |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 1842 | Assuming you have sourced the build environment setup script (i.e. |
| 1843 | <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] | 1844 | and you are in the |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 1845 | <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink>, |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1846 | use BitBake to process your recipe. |
| 1847 | All you need to provide is the |
| 1848 | <filename><replaceable>basename</replaceable></filename> of the recipe as described |
| 1849 | in the previous section: |
| 1850 | <literallayout class='monospaced'> |
| 1851 | $ bitbake <replaceable>basename</replaceable> |
| 1852 | </literallayout> |
| 1853 | |
| 1854 | </para> |
| 1855 | |
| 1856 | <para> |
| 1857 | During the build, the OpenEmbedded build system creates a |
| 1858 | temporary work directory for each recipe |
| 1859 | (<filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-WORKDIR'><filename>WORKDIR</filename></ulink><filename>}</filename>) |
| 1860 | where it keeps extracted source files, log files, intermediate |
| 1861 | compilation and packaging files, and so forth. |
| 1862 | </para> |
| 1863 | |
| 1864 | <para> |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 1865 | The path to the per-recipe temporary work directory depends |
| 1866 | on the context in which it is being built. |
| 1867 | The quickest way to find this path is to have BitBake return it |
| 1868 | by running the following: |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1869 | <literallayout class='monospaced'> |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 1870 | $ bitbake -e <replaceable>basename</replaceable> | grep ^WORKDIR= |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1871 | </literallayout> |
| 1872 | As an example, assume a Source Directory top-level folder named |
| 1873 | <filename>poky</filename>, a default Build Directory at |
| 1874 | <filename>poky/build</filename>, and a |
| 1875 | <filename>qemux86-poky-linux</filename> machine target system. |
| 1876 | Furthermore, suppose your recipe is named |
| 1877 | <filename>foo_1.3.0.bb</filename>. |
| 1878 | In this case, the work directory the build system uses to |
| 1879 | build the package would be as follows: |
| 1880 | <literallayout class='monospaced'> |
| 1881 | poky/build/tmp/work/qemux86-poky-linux/foo/1.3.0-r0 |
| 1882 | </literallayout> |
| 1883 | Inside this directory you can find sub-directories such as |
| 1884 | <filename>image</filename>, <filename>packages-split</filename>, |
| 1885 | and <filename>temp</filename>. |
| 1886 | After the build, you can examine these to determine how well |
| 1887 | the build went. |
| 1888 | <note> |
| 1889 | You can find log files for each task in the recipe's |
| 1890 | <filename>temp</filename> directory (e.g. |
| 1891 | <filename>poky/build/tmp/work/qemux86-poky-linux/foo/1.3.0-r0/temp</filename>). |
| 1892 | Log files are named <filename>log.<replaceable>taskname</replaceable></filename> |
| 1893 | (e.g. <filename>log.do_configure</filename>, |
| 1894 | <filename>log.do_fetch</filename>, and |
| 1895 | <filename>log.do_compile</filename>). |
| 1896 | </note> |
| 1897 | </para> |
| 1898 | |
| 1899 | <para> |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 1900 | You can find more information about the build process in |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 1901 | "<ulink url='&YOCTO_DOCS_OM_URL;#overview-development-environment'>The Yocto Project Development Environment</ulink>" |
| 1902 | chapter of the Yocto Project Overview and Concepts Manual. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1903 | </para> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1904 | </section> |
| 1905 | |
| 1906 | <section id='new-recipe-fetching-code'> |
| 1907 | <title>Fetching Code</title> |
| 1908 | |
| 1909 | <para> |
| 1910 | The first thing your recipe must do is specify how to fetch |
| 1911 | the source files. |
| 1912 | Fetching is controlled mainly through the |
| 1913 | <ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'><filename>SRC_URI</filename></ulink> |
| 1914 | variable. |
| 1915 | Your recipe must have a <filename>SRC_URI</filename> variable |
| 1916 | that points to where the source is located. |
| 1917 | For a graphical representation of source locations, see the |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 1918 | "<ulink url='&YOCTO_DOCS_OM_URL;#sources-dev-environment'>Sources</ulink>" |
| 1919 | section in the Yocto Project Overview and Concepts Manual. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1920 | </para> |
| 1921 | |
| 1922 | <para> |
| 1923 | The |
| 1924 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-fetch'><filename>do_fetch</filename></ulink> |
| 1925 | task uses the prefix of each entry in the |
| 1926 | <filename>SRC_URI</filename> variable value to determine which |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 1927 | <ulink url='&YOCTO_DOCS_BB_URL;#bb-fetchers'>fetcher</ulink> |
| 1928 | to use to get your source files. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1929 | It is the <filename>SRC_URI</filename> variable that triggers |
| 1930 | the fetcher. |
| 1931 | The |
| 1932 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-patch'><filename>do_patch</filename></ulink> |
| 1933 | task uses the variable after source is fetched to apply |
| 1934 | patches. |
| 1935 | The OpenEmbedded build system uses |
| 1936 | <ulink url='&YOCTO_DOCS_REF_URL;#var-FILESOVERRIDES'><filename>FILESOVERRIDES</filename></ulink> |
| 1937 | for scanning directory locations for local files in |
| 1938 | <filename>SRC_URI</filename>. |
| 1939 | </para> |
| 1940 | |
| 1941 | <para> |
| 1942 | The <filename>SRC_URI</filename> variable in your recipe must |
| 1943 | define each unique location for your source files. |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 1944 | It is good practice to not hard-code version numbers in a URL used |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1945 | in <filename>SRC_URI</filename>. |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 1946 | Rather than hard-code these values, use |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1947 | <filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-PV'><filename>PV</filename></ulink><filename>}</filename>, |
| 1948 | which causes the fetch process to use the version specified in |
| 1949 | the recipe filename. |
| 1950 | Specifying the version in this manner means that upgrading the |
| 1951 | recipe to a future version is as simple as renaming the recipe |
| 1952 | to match the new version. |
| 1953 | </para> |
| 1954 | |
| 1955 | <para> |
| 1956 | Here is a simple example from the |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 1957 | <filename>meta/recipes-devtools/strace/strace_5.5.bb</filename> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1958 | recipe where the source comes from a single tarball. |
| 1959 | Notice the use of the |
| 1960 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PV'><filename>PV</filename></ulink> |
| 1961 | variable: |
| 1962 | <literallayout class='monospaced'> |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 1963 | SRC_URI = "https://strace.io/files/${PV}/strace-${PV}.tar.xz \ |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1964 | </literallayout> |
| 1965 | </para> |
| 1966 | |
| 1967 | <para> |
| 1968 | Files mentioned in <filename>SRC_URI</filename> whose names end |
| 1969 | in a typical archive extension (e.g. <filename>.tar</filename>, |
| 1970 | <filename>.tar.gz</filename>, <filename>.tar.bz2</filename>, |
| 1971 | <filename>.zip</filename>, and so forth), are automatically |
| 1972 | extracted during the |
| 1973 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-unpack'><filename>do_unpack</filename></ulink> |
| 1974 | task. |
| 1975 | For another example that specifies these types of files, see |
| 1976 | the |
| 1977 | "<link linkend='new-recipe-autotooled-package'>Autotooled Package</link>" |
| 1978 | section. |
| 1979 | </para> |
| 1980 | |
| 1981 | <para> |
| 1982 | Another way of specifying source is from an SCM. |
| 1983 | For Git repositories, you must specify |
| 1984 | <ulink url='&YOCTO_DOCS_REF_URL;#var-SRCREV'><filename>SRCREV</filename></ulink> |
| 1985 | and you should specify |
| 1986 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PV'><filename>PV</filename></ulink> |
| 1987 | to include the revision with |
| 1988 | <ulink url='&YOCTO_DOCS_REF_URL;#var-SRCPV'><filename>SRCPV</filename></ulink>. |
| 1989 | Here is an example from the recipe |
| 1990 | <filename>meta/recipes-kernel/blktrace/blktrace_git.bb</filename>: |
| 1991 | <literallayout class='monospaced'> |
| 1992 | SRCREV = "d6918c8832793b4205ed3bfede78c2f915c23385" |
| 1993 | |
| 1994 | PR = "r6" |
| 1995 | PV = "1.0.5+git${SRCPV}" |
| 1996 | |
| 1997 | SRC_URI = "git://git.kernel.dk/blktrace.git \ |
| 1998 | file://ldflags.patch" |
| 1999 | </literallayout> |
| 2000 | </para> |
| 2001 | |
| 2002 | <para> |
| 2003 | If your <filename>SRC_URI</filename> statement includes |
| 2004 | URLs pointing to individual files fetched from a remote server |
| 2005 | other than a version control system, BitBake attempts to |
| 2006 | verify the files against checksums defined in your recipe to |
| 2007 | ensure they have not been tampered with or otherwise modified |
| 2008 | since the recipe was written. |
| 2009 | Two checksums are used: |
| 2010 | <filename>SRC_URI[md5sum]</filename> and |
| 2011 | <filename>SRC_URI[sha256sum]</filename>. |
| 2012 | </para> |
| 2013 | |
| 2014 | <para> |
| 2015 | If your <filename>SRC_URI</filename> variable points to |
| 2016 | more than a single URL (excluding SCM URLs), you need to |
| 2017 | provide the <filename>md5</filename> and |
| 2018 | <filename>sha256</filename> checksums for each URL. |
| 2019 | For these cases, you provide a name for each URL as part of |
| 2020 | the <filename>SRC_URI</filename> and then reference that name |
| 2021 | in the subsequent checksum statements. |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 2022 | Here is an example combining lines from the files |
| 2023 | <filename>git.inc</filename> and |
| 2024 | <filename>git_2.24.1.bb</filename>: |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 2025 | <literallayout class='monospaced'> |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 2026 | SRC_URI = "${KERNELORG_MIRROR}/software/scm/git/git-${PV}.tar.gz;name=tarball \ |
| 2027 | ${KERNELORG_MIRROR}/software/scm/git/git-manpages-${PV}.tar.gz;name=manpages" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 2028 | |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 2029 | SRC_URI[tarball.md5sum] = "166bde96adbbc11c8843d4f8f4f9811b" |
| 2030 | SRC_URI[tarball.sha256sum] = "ad5334956301c86841eb1e5b1bb20884a6bad89a10a6762c958220c7cf64da02" |
| 2031 | SRC_URI[manpages.md5sum] = "31c2272a8979022497ba3d4202df145d" |
| 2032 | SRC_URI[manpages.sha256sum] = "9a7ae3a093bea39770eb96ca3e5b40bff7af0b9f6123f089d7821d0e5b8e1230" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 2033 | </literallayout> |
| 2034 | </para> |
| 2035 | |
| 2036 | <para> |
| 2037 | Proper values for <filename>md5</filename> and |
| 2038 | <filename>sha256</filename> checksums might be available |
| 2039 | with other signatures on the download page for the upstream |
| 2040 | source (e.g. <filename>md5</filename>, |
| 2041 | <filename>sha1</filename>, <filename>sha256</filename>, |
| 2042 | <filename>GPG</filename>, and so forth). |
| 2043 | Because the OpenEmbedded build system only deals with |
| 2044 | <filename>sha256sum</filename> and <filename>md5sum</filename>, |
| 2045 | you should verify all the signatures you find by hand. |
| 2046 | </para> |
| 2047 | |
| 2048 | <para> |
| 2049 | If no <filename>SRC_URI</filename> checksums are specified |
| 2050 | when you attempt to build the recipe, or you provide an |
| 2051 | incorrect checksum, the build will produce an error for each |
| 2052 | missing or incorrect checksum. |
| 2053 | As part of the error message, the build system provides |
| 2054 | the checksum string corresponding to the fetched file. |
| 2055 | Once you have the correct checksums, you can copy and paste |
| 2056 | them into your recipe and then run the build again to continue. |
| 2057 | <note> |
| 2058 | As mentioned, if the upstream source provides signatures |
| 2059 | for verifying the downloaded source code, you should |
| 2060 | verify those manually before setting the checksum values |
| 2061 | in the recipe and continuing with the build. |
| 2062 | </note> |
| 2063 | </para> |
| 2064 | |
| 2065 | <para> |
| 2066 | This final example is a bit more complicated and is from the |
| 2067 | <filename>meta/recipes-sato/rxvt-unicode/rxvt-unicode_9.20.bb</filename> |
| 2068 | recipe. |
| 2069 | The example's <filename>SRC_URI</filename> statement identifies |
| 2070 | multiple files as the source files for the recipe: a tarball, a |
| 2071 | patch file, a desktop file, and an icon. |
| 2072 | <literallayout class='monospaced'> |
| 2073 | SRC_URI = "http://dist.schmorp.de/rxvt-unicode/Attic/rxvt-unicode-${PV}.tar.bz2 \ |
| 2074 | file://xwc.patch \ |
| 2075 | file://rxvt.desktop \ |
| 2076 | file://rxvt.png" |
| 2077 | </literallayout> |
| 2078 | </para> |
| 2079 | |
| 2080 | <para> |
| 2081 | When you specify local files using the |
| 2082 | <filename>file://</filename> URI protocol, the build system |
| 2083 | fetches files from the local machine. |
| 2084 | The path is relative to the |
| 2085 | <ulink url='&YOCTO_DOCS_REF_URL;#var-FILESPATH'><filename>FILESPATH</filename></ulink> |
| 2086 | variable and searches specific directories in a certain order: |
| 2087 | <filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-BP'><filename>BP</filename></ulink><filename>}</filename>, |
| 2088 | <filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-BPN'><filename>BPN</filename></ulink><filename>}</filename>, |
| 2089 | and <filename>files</filename>. |
| 2090 | The directories are assumed to be subdirectories of the |
| 2091 | directory in which the recipe or append file resides. |
| 2092 | For another example that specifies these types of files, see the |
| 2093 | "<link linkend='new-recipe-single-c-file-package-hello-world'>Single .c File Package (Hello World!)</link>" |
| 2094 | section. |
| 2095 | </para> |
| 2096 | |
| 2097 | <para> |
| 2098 | The previous example also specifies a patch file. |
| 2099 | Patch files are files whose names usually end in |
| 2100 | <filename>.patch</filename> or <filename>.diff</filename> but |
| 2101 | can end with compressed suffixes such as |
| 2102 | <filename>diff.gz</filename> and |
| 2103 | <filename>patch.bz2</filename>, for example. |
| 2104 | The build system automatically applies patches as described |
| 2105 | in the |
| 2106 | "<link linkend='new-recipe-patching-code'>Patching Code</link>" section. |
| 2107 | </para> |
| 2108 | </section> |
| 2109 | |
| 2110 | <section id='new-recipe-unpacking-code'> |
| 2111 | <title>Unpacking Code</title> |
| 2112 | |
| 2113 | <para> |
| 2114 | During the build, the |
| 2115 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-unpack'><filename>do_unpack</filename></ulink> |
| 2116 | task unpacks the source with |
| 2117 | <filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-S'><filename>S</filename></ulink><filename>}</filename> |
| 2118 | pointing to where it is unpacked. |
| 2119 | </para> |
| 2120 | |
| 2121 | <para> |
| 2122 | If you are fetching your source files from an upstream source |
| 2123 | archived tarball and the tarball's internal structure matches |
| 2124 | the common convention of a top-level subdirectory named |
| 2125 | <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>, |
| 2126 | then you do not need to set <filename>S</filename>. |
| 2127 | However, if <filename>SRC_URI</filename> specifies to fetch |
| 2128 | source from an archive that does not use this convention, |
| 2129 | or from an SCM like Git or Subversion, your recipe needs to |
| 2130 | define <filename>S</filename>. |
| 2131 | </para> |
| 2132 | |
| 2133 | <para> |
| 2134 | If processing your recipe using BitBake successfully unpacks |
| 2135 | the source files, you need to be sure that the directory |
| 2136 | pointed to by <filename>${S}</filename> matches the structure |
| 2137 | of the source. |
| 2138 | </para> |
| 2139 | </section> |
| 2140 | |
| 2141 | <section id='new-recipe-patching-code'> |
| 2142 | <title>Patching Code</title> |
| 2143 | |
| 2144 | <para> |
| 2145 | Sometimes it is necessary to patch code after it has been |
| 2146 | fetched. |
| 2147 | Any files mentioned in <filename>SRC_URI</filename> whose |
| 2148 | names end in <filename>.patch</filename> or |
| 2149 | <filename>.diff</filename> or compressed versions of these |
| 2150 | suffixes (e.g. <filename>diff.gz</filename> are treated as |
| 2151 | patches. |
| 2152 | The |
| 2153 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-patch'><filename>do_patch</filename></ulink> |
| 2154 | task automatically applies these patches. |
| 2155 | </para> |
| 2156 | |
| 2157 | <para> |
| 2158 | The build system should be able to apply patches with the "-p1" |
| 2159 | option (i.e. one directory level in the path will be stripped |
| 2160 | off). |
| 2161 | If your patch needs to have more directory levels stripped off, |
| 2162 | specify the number of levels using the "striplevel" option in |
| 2163 | the <filename>SRC_URI</filename> entry for the patch. |
| 2164 | Alternatively, if your patch needs to be applied in a specific |
| 2165 | subdirectory that is not specified in the patch file, use the |
| 2166 | "patchdir" option in the entry. |
| 2167 | </para> |
| 2168 | |
| 2169 | <para> |
| 2170 | As with all local files referenced in |
| 2171 | <ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'><filename>SRC_URI</filename></ulink> |
| 2172 | using <filename>file://</filename>, you should place |
| 2173 | patch files in a directory next to the recipe either |
| 2174 | named the same as the base name of the recipe |
| 2175 | (<ulink url='&YOCTO_DOCS_REF_URL;#var-BP'><filename>BP</filename></ulink> |
| 2176 | and |
| 2177 | <ulink url='&YOCTO_DOCS_REF_URL;#var-BPN'><filename>BPN</filename></ulink>) |
| 2178 | or "files". |
| 2179 | </para> |
| 2180 | </section> |
| 2181 | |
| 2182 | <section id='new-recipe-licensing'> |
| 2183 | <title>Licensing</title> |
| 2184 | |
| 2185 | <para> |
| 2186 | Your recipe needs to have both the |
| 2187 | <ulink url='&YOCTO_DOCS_REF_URL;#var-LICENSE'><filename>LICENSE</filename></ulink> |
| 2188 | and |
| 2189 | <ulink url='&YOCTO_DOCS_REF_URL;#var-LIC_FILES_CHKSUM'><filename>LIC_FILES_CHKSUM</filename></ulink> |
| 2190 | variables: |
| 2191 | <itemizedlist> |
| 2192 | <listitem><para><emphasis><filename>LICENSE</filename>:</emphasis> |
| 2193 | This variable specifies the license for the software. |
| 2194 | If you do not know the license under which the software |
| 2195 | you are building is distributed, you should go to the |
| 2196 | source code and look for that information. |
| 2197 | Typical files containing this information include |
| 2198 | <filename>COPYING</filename>, |
| 2199 | <filename>LICENSE</filename>, and |
| 2200 | <filename>README</filename> files. |
| 2201 | You could also find the information near the top of |
| 2202 | a source file. |
| 2203 | For example, given a piece of software licensed under |
| 2204 | the GNU General Public License version 2, you would |
| 2205 | set <filename>LICENSE</filename> as follows: |
| 2206 | <literallayout class='monospaced'> |
| 2207 | LICENSE = "GPLv2" |
| 2208 | </literallayout></para> |
| 2209 | <para>The licenses you specify within |
| 2210 | <filename>LICENSE</filename> can have any name as long |
| 2211 | as you do not use spaces, since spaces are used as |
| 2212 | separators between license names. |
| 2213 | For standard licenses, use the names of the files in |
| 2214 | <filename>meta/files/common-licenses/</filename> |
| 2215 | or the <filename>SPDXLICENSEMAP</filename> flag names |
| 2216 | defined in <filename>meta/conf/licenses.conf</filename>. |
| 2217 | </para></listitem> |
| 2218 | <listitem><para><emphasis><filename>LIC_FILES_CHKSUM</filename>:</emphasis> |
| 2219 | The OpenEmbedded build system uses this variable to |
| 2220 | make sure the license text has not changed. |
| 2221 | If it has, the build produces an error and it affords |
| 2222 | you the chance to figure it out and correct the problem. |
| 2223 | </para> |
| 2224 | <para>You need to specify all applicable licensing |
| 2225 | files for the software. |
| 2226 | At the end of the configuration step, the build process |
| 2227 | will compare the checksums of the files to be sure |
| 2228 | the text has not changed. |
| 2229 | Any differences result in an error with the message |
| 2230 | containing the current checksum. |
| 2231 | For more explanation and examples of how to set the |
| 2232 | <filename>LIC_FILES_CHKSUM</filename> variable, see the |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 2233 | "<link link='usingpoky-configuring-LIC_FILES_CHKSUM'>Tracking License Changes</link>" |
| 2234 | section.</para> |
| 2235 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 2236 | <para>To determine the correct checksum string, you |
| 2237 | can list the appropriate files in the |
| 2238 | <filename>LIC_FILES_CHKSUM</filename> variable with |
| 2239 | incorrect md5 strings, attempt to build the software, |
| 2240 | and then note the resulting error messages that will |
| 2241 | report the correct md5 strings. |
| 2242 | See the |
| 2243 | "<link linkend='new-recipe-fetching-code'>Fetching Code</link>" |
| 2244 | section for additional information. |
| 2245 | </para> |
| 2246 | |
| 2247 | <para> |
| 2248 | Here is an example that assumes the software has a |
| 2249 | <filename>COPYING</filename> file: |
| 2250 | <literallayout class='monospaced'> |
| 2251 | LIC_FILES_CHKSUM = "file://COPYING;md5=xxx" |
| 2252 | </literallayout> |
| 2253 | When you try to build the software, the build system |
| 2254 | will produce an error and give you the correct string |
| 2255 | that you can substitute into the recipe file for a |
| 2256 | subsequent build. |
| 2257 | </para></listitem> |
| 2258 | </itemizedlist> |
| 2259 | </para> |
| 2260 | |
| 2261 | <!-- |
| 2262 | |
| 2263 | <para> |
| 2264 | For trying this out I created a new recipe named |
| 2265 | <filename>htop_1.0.2.bb</filename> and put it in |
| 2266 | <filename>poky/meta/recipes-extended/htop</filename>. |
| 2267 | There are two license type statements in my very simple |
| 2268 | recipe: |
| 2269 | <literallayout class='monospaced'> |
| 2270 | LICENSE = "" |
| 2271 | |
| 2272 | LIC_FILES_CHKSUM = "" |
| 2273 | |
| 2274 | SRC_URI[md5sum] = "" |
| 2275 | SRC_URI[sha256sum] = "" |
| 2276 | </literallayout> |
| 2277 | Evidently, you need to run a <filename>bitbake -c cleanall htop</filename>. |
| 2278 | Next, you delete or comment out the two <filename>SRC_URI</filename> |
| 2279 | lines at the end and then attempt to build the software with |
| 2280 | <filename>bitbake htop</filename>. |
| 2281 | Doing so causes BitBake to report some errors and and give |
| 2282 | you the actual strings you need for the last two |
| 2283 | <filename>SRC_URI</filename> lines. |
| 2284 | Prior to this, you have to dig around in the home page of the |
| 2285 | source for <filename>htop</filename> and determine that the |
| 2286 | software is released under GPLv2. |
| 2287 | You can provide that in the <filename>LICENSE</filename> |
| 2288 | statement. |
| 2289 | Now you edit your recipe to have those two strings for |
| 2290 | the <filename>SRC_URI</filename> statements: |
| 2291 | <literallayout class='monospaced'> |
| 2292 | LICENSE = "GPLv2" |
| 2293 | |
| 2294 | LIC_FILES_CHKSUM = "" |
| 2295 | |
| 2296 | SRC_URI = "${SOURCEFORGE_MIRROR}/htop/htop-${PV}.tar.gz" |
| 2297 | SRC_URI[md5sum] = "0d01cca8df3349c74569cefebbd9919e" |
| 2298 | SRC_URI[sha256sum] = "ee60657b044ece0df096c053060df7abf3cce3a568ab34d260049e6a37ccd8a1" |
| 2299 | </literallayout> |
| 2300 | At this point, you can build the software again using the |
| 2301 | <filename>bitbake htop</filename> command. |
| 2302 | There is just a set of errors now associated with the |
| 2303 | empty <filename>LIC_FILES_CHKSUM</filename> variable now. |
| 2304 | </para> |
| 2305 | --> |
| 2306 | |
| 2307 | </section> |
| 2308 | |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 2309 | <section id='new-dependencies'> |
| 2310 | <title>Dependencies</title> |
| 2311 | |
| 2312 | <para> |
| 2313 | Most software packages have a short list of other packages |
| 2314 | that they require, which are called dependencies. |
| 2315 | These dependencies fall into two main categories: build-time |
| 2316 | dependencies, which are required when the software is built; |
| 2317 | and runtime dependencies, which are required to be installed |
| 2318 | on the target in order for the software to run. |
| 2319 | </para> |
| 2320 | |
| 2321 | <para> |
| 2322 | Within a recipe, you specify build-time dependencies using the |
| 2323 | <ulink url='&YOCTO_DOCS_REF_URL;#var-DEPENDS'><filename>DEPENDS</filename></ulink> |
| 2324 | variable. |
| 2325 | Although nuances exist, items specified in |
| 2326 | <filename>DEPENDS</filename> should be names of other recipes. |
| 2327 | It is important that you specify all build-time dependencies |
| 2328 | explicitly. |
| 2329 | If you do not, due to the parallel nature of BitBake's |
| 2330 | execution, you can end up with a race condition where the |
| 2331 | dependency is present for one task of a recipe (e.g. |
| 2332 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-configure'><filename>do_configure</filename></ulink>) |
| 2333 | and then gone when the next task runs (e.g. |
| 2334 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-compile'><filename>do_compile</filename></ulink>). |
| 2335 | </para> |
| 2336 | |
| 2337 | <para> |
| 2338 | Another consideration is that configure scripts might |
| 2339 | automatically check for optional dependencies and enable |
| 2340 | corresponding functionality if those dependencies are found. |
| 2341 | This behavior means that to ensure deterministic results and |
| 2342 | thus avoid more race conditions, you need to either explicitly |
| 2343 | specify these dependencies as well, or tell the configure |
| 2344 | script explicitly to disable the functionality. |
| 2345 | If you wish to make a recipe that is more generally useful |
| 2346 | (e.g. publish the recipe in a layer for others to use), |
| 2347 | instead of hard-disabling the functionality, you can use the |
| 2348 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGECONFIG'><filename>PACKAGECONFIG</filename></ulink> |
| 2349 | variable to allow functionality and the corresponding |
| 2350 | dependencies to be enabled and disabled easily by other |
| 2351 | users of the recipe. |
| 2352 | </para> |
| 2353 | |
| 2354 | <para> |
| 2355 | Similar to build-time dependencies, you specify runtime |
| 2356 | dependencies through a variable - |
| 2357 | <ulink url='&YOCTO_DOCS_REF_URL;#var-RDEPENDS'><filename>RDEPENDS</filename></ulink>, |
| 2358 | which is package-specific. |
| 2359 | All variables that are package-specific need to have the name |
| 2360 | of the package added to the end as an override. |
| 2361 | Since the main package for a recipe has the same name as the |
| 2362 | recipe, and the recipe's name can be found through the |
| 2363 | <filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-PN'><filename>PN</filename></ulink><filename>}</filename> |
| 2364 | variable, then you specify the dependencies for the main |
| 2365 | package by setting <filename>RDEPENDS_${PN}</filename>. |
| 2366 | If the package were named <filename>${PN}-tools</filename>, |
| 2367 | then you would set <filename>RDEPENDS_${PN}-tools</filename>, |
| 2368 | and so forth. |
| 2369 | </para> |
| 2370 | |
| 2371 | <para> |
| 2372 | Some runtime dependencies will be set automatically at |
| 2373 | packaging time. |
| 2374 | These dependencies include any shared library dependencies |
| 2375 | (i.e. if a package "example" contains "libexample" and |
| 2376 | another package "mypackage" contains a binary that links to |
| 2377 | "libexample" then the OpenEmbedded build system will |
| 2378 | automatically add a runtime dependency to "mypackage" on |
| 2379 | "example"). |
| 2380 | See the |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 2381 | "<ulink url='&YOCTO_DOCS_OM_URL;#automatically-added-runtime-dependencies'>Automatically Added Runtime Dependencies</ulink>" |
| 2382 | section in the Yocto Project Overview and Concepts Manual for |
| 2383 | further details. |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 2384 | </para> |
| 2385 | </section> |
| 2386 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 2387 | <section id='new-recipe-configuring-the-recipe'> |
| 2388 | <title>Configuring the Recipe</title> |
| 2389 | |
| 2390 | <para> |
| 2391 | Most software provides some means of setting build-time |
| 2392 | configuration options before compilation. |
| 2393 | Typically, setting these options is accomplished by running a |
Brad Bishop | 64c979e | 2019-11-04 13:55:29 -0500 | [diff] [blame] | 2394 | configure script with options, or by modifying a build |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 2395 | configuration file. |
Patrick Williams | f1e5d69 | 2016-03-30 15:21:19 -0500 | [diff] [blame] | 2396 | <note> |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 2397 | As of Yocto Project Release 1.7, some of the core recipes |
Patrick Williams | f1e5d69 | 2016-03-30 15:21:19 -0500 | [diff] [blame] | 2398 | that package binary configuration scripts now disable the |
| 2399 | scripts due to the scripts previously requiring error-prone |
| 2400 | path substitution. |
| 2401 | The OpenEmbedded build system uses |
| 2402 | <filename>pkg-config</filename> now, which is much more |
| 2403 | robust. |
| 2404 | You can find a list of the <filename>*-config</filename> |
| 2405 | scripts that are disabled list in the |
| 2406 | "<ulink url='&YOCTO_DOCS_REF_URL;#migration-1.7-binary-configuration-scripts-disabled'>Binary Configuration Scripts Disabled</ulink>" |
| 2407 | section in the Yocto Project Reference Manual. |
| 2408 | </note> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 2409 | </para> |
| 2410 | |
| 2411 | <para> |
| 2412 | A major part of build-time configuration is about checking for |
| 2413 | build-time dependencies and possibly enabling optional |
| 2414 | functionality as a result. |
| 2415 | You need to specify any build-time dependencies for the |
| 2416 | software you are building in your recipe's |
| 2417 | <ulink url='&YOCTO_DOCS_REF_URL;#var-DEPENDS'><filename>DEPENDS</filename></ulink> |
| 2418 | value, in terms of other recipes that satisfy those |
| 2419 | dependencies. |
| 2420 | You can often find build-time or runtime |
| 2421 | dependencies described in the software's documentation. |
| 2422 | </para> |
| 2423 | |
| 2424 | <para> |
| 2425 | The following list provides configuration items of note based |
| 2426 | on how your software is built: |
| 2427 | <itemizedlist> |
| 2428 | <listitem><para><emphasis>Autotools:</emphasis> |
| 2429 | If your source files have a |
| 2430 | <filename>configure.ac</filename> file, then your |
| 2431 | software is built using Autotools. |
| 2432 | If this is the case, you just need to worry about |
| 2433 | modifying the configuration.</para> |
Brad Bishop | 64c979e | 2019-11-04 13:55:29 -0500 | [diff] [blame] | 2434 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 2435 | <para>When using Autotools, your recipe needs to inherit |
| 2436 | the |
| 2437 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-autotools'><filename>autotools</filename></ulink> |
| 2438 | class and your recipe does not have to contain a |
| 2439 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-configure'><filename>do_configure</filename></ulink> |
| 2440 | task. |
| 2441 | However, you might still want to make some adjustments. |
| 2442 | For example, you can set |
| 2443 | <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] | 2444 | or |
| 2445 | <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] | 2446 | to pass any needed configure options that are specific |
Brad Bishop | 64c979e | 2019-11-04 13:55:29 -0500 | [diff] [blame] | 2447 | to the recipe. |
| 2448 | </para></listitem> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 2449 | <listitem><para><emphasis>CMake:</emphasis> |
| 2450 | If your source files have a |
| 2451 | <filename>CMakeLists.txt</filename> file, then your |
| 2452 | software is built using CMake. |
| 2453 | If this is the case, you just need to worry about |
| 2454 | modifying the configuration.</para> |
Brad Bishop | 64c979e | 2019-11-04 13:55:29 -0500 | [diff] [blame] | 2455 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 2456 | <para>When you use CMake, your recipe needs to inherit |
| 2457 | the |
| 2458 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-cmake'><filename>cmake</filename></ulink> |
| 2459 | class and your recipe does not have to contain a |
| 2460 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-configure'><filename>do_configure</filename></ulink> |
| 2461 | task. |
| 2462 | You can make some adjustments by setting |
| 2463 | <ulink url='&YOCTO_DOCS_REF_URL;#var-EXTRA_OECMAKE'><filename>EXTRA_OECMAKE</filename></ulink> |
| 2464 | to pass any needed configure options that are specific |
Brad Bishop | 64c979e | 2019-11-04 13:55:29 -0500 | [diff] [blame] | 2465 | to the recipe. |
| 2466 | <note> |
| 2467 | If you need to install one or more custom CMake |
| 2468 | toolchain files that are supplied by the |
| 2469 | application you are building, install the files to |
| 2470 | <filename>${D}${datadir}/cmake/</filename> Modules |
| 2471 | during |
| 2472 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-install'><filename>do_install</filename></ulink>. |
| 2473 | </note> |
| 2474 | </para></listitem> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 2475 | <listitem><para><emphasis>Other:</emphasis> |
| 2476 | If your source files do not have a |
| 2477 | <filename>configure.ac</filename> or |
| 2478 | <filename>CMakeLists.txt</filename> file, then your |
| 2479 | software is built using some method other than Autotools |
| 2480 | or CMake. |
| 2481 | If this is the case, you normally need to provide a |
| 2482 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-configure'><filename>do_configure</filename></ulink> |
| 2483 | task in your recipe |
| 2484 | unless, of course, there is nothing to configure. |
| 2485 | </para> |
| 2486 | <para>Even if your software is not being built by |
| 2487 | Autotools or CMake, you still might not need to deal |
| 2488 | with any configuration issues. |
| 2489 | You need to determine if configuration is even a required step. |
| 2490 | You might need to modify a Makefile or some configuration file |
| 2491 | used for the build to specify necessary build options. |
| 2492 | Or, perhaps you might need to run a provided, custom |
| 2493 | configure script with the appropriate options.</para> |
| 2494 | <para>For the case involving a custom configure |
| 2495 | script, you would run |
| 2496 | <filename>./configure --help</filename> and look for |
| 2497 | the options you need to set.</para></listitem> |
| 2498 | </itemizedlist> |
| 2499 | </para> |
| 2500 | |
| 2501 | <para> |
| 2502 | Once configuration succeeds, it is always good practice to |
| 2503 | look at the <filename>log.do_configure</filename> file to |
| 2504 | ensure that the appropriate options have been enabled and no |
| 2505 | additional build-time dependencies need to be added to |
| 2506 | <filename>DEPENDS</filename>. |
| 2507 | For example, if the configure script reports that it found |
| 2508 | something not mentioned in <filename>DEPENDS</filename>, or |
| 2509 | that it did not find something that it needed for some |
| 2510 | desired optional functionality, then you would need to add |
| 2511 | those to <filename>DEPENDS</filename>. |
| 2512 | Looking at the log might also reveal items being checked for, |
| 2513 | enabled, or both that you do not want, or items not being found |
| 2514 | that are in <filename>DEPENDS</filename>, in which case |
| 2515 | you would need to look at passing extra options to the |
| 2516 | configure script as needed. |
| 2517 | For reference information on configure options specific to the |
| 2518 | software you are building, you can consult the output of the |
| 2519 | <filename>./configure --help</filename> command within |
| 2520 | <filename>${S}</filename> or consult the software's upstream |
| 2521 | documentation. |
| 2522 | </para> |
| 2523 | </section> |
| 2524 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 2525 | <section id='new-recipe-using-headers-to-interface-with-devices'> |
| 2526 | <title>Using Headers to Interface with Devices</title> |
| 2527 | |
| 2528 | <para> |
| 2529 | If your recipe builds an application that needs to |
| 2530 | communicate with some device or needs an API into a custom |
| 2531 | kernel, you will need to provide appropriate header files. |
| 2532 | Under no circumstances should you ever modify the existing |
| 2533 | <filename>meta/recipes-kernel/linux-libc-headers/linux-libc-headers.inc</filename> |
| 2534 | file. |
| 2535 | These headers are used to build <filename>libc</filename> and |
| 2536 | must not be compromised with custom or machine-specific |
| 2537 | header information. |
| 2538 | If you customize <filename>libc</filename> through modified |
| 2539 | headers all other applications that use |
| 2540 | <filename>libc</filename> thus become affected. |
| 2541 | <note><title>Warning</title> |
| 2542 | Never copy and customize the <filename>libc</filename> |
| 2543 | header file (i.e. |
| 2544 | <filename>meta/recipes-kernel/linux-libc-headers/linux-libc-headers.inc</filename>). |
| 2545 | </note> |
| 2546 | The correct way to interface to a device or custom kernel is |
| 2547 | to use a separate package that provides the additional headers |
| 2548 | for the driver or other unique interfaces. |
| 2549 | When doing so, your application also becomes responsible for |
| 2550 | creating a dependency on that specific provider. |
| 2551 | </para> |
| 2552 | |
| 2553 | <para> |
| 2554 | Consider the following: |
| 2555 | <itemizedlist> |
| 2556 | <listitem><para> |
| 2557 | Never modify |
| 2558 | <filename>linux-libc-headers.inc</filename>. |
| 2559 | Consider that file to be part of the |
| 2560 | <filename>libc</filename> system, and not something |
| 2561 | you use to access the kernel directly. |
| 2562 | You should access <filename>libc</filename> through |
| 2563 | specific <filename>libc</filename> calls. |
| 2564 | </para></listitem> |
| 2565 | <listitem><para> |
| 2566 | Applications that must talk directly to devices |
| 2567 | should either provide necessary headers themselves, |
| 2568 | or establish a dependency on a special headers package |
| 2569 | that is specific to that driver. |
| 2570 | </para></listitem> |
| 2571 | </itemizedlist> |
| 2572 | </para> |
| 2573 | |
| 2574 | <para> |
| 2575 | For example, suppose you want to modify an existing header |
| 2576 | that adds I/O control or network support. |
| 2577 | If the modifications are used by a small number programs, |
| 2578 | providing a unique version of a header is easy and has little |
| 2579 | impact. |
| 2580 | When doing so, bear in mind the guidelines in the previous |
| 2581 | list. |
| 2582 | <note> |
| 2583 | If for some reason your changes need to modify the behavior |
| 2584 | of the <filename>libc</filename>, and subsequently all |
| 2585 | other applications on the system, use a |
| 2586 | <filename>.bbappend</filename> to modify the |
| 2587 | <filename>linux-kernel-headers.inc</filename> file. |
| 2588 | However, take care to not make the changes |
| 2589 | machine specific. |
| 2590 | </note> |
| 2591 | </para> |
| 2592 | |
| 2593 | <para> |
| 2594 | Consider a case where your kernel is older and you need |
| 2595 | an older <filename>libc</filename> ABI. |
| 2596 | The headers installed by your recipe should still be a |
| 2597 | standard mainline kernel, not your own custom one. |
| 2598 | </para> |
| 2599 | |
| 2600 | <para> |
| 2601 | When you use custom kernel headers you need to get them from |
| 2602 | <ulink url='&YOCTO_DOCS_REF_URL;#var-STAGING_KERNEL_DIR'><filename>STAGING_KERNEL_DIR</filename></ulink>, |
| 2603 | which is the directory with kernel headers that are |
| 2604 | required to build out-of-tree modules. |
| 2605 | Your recipe will also need the following: |
| 2606 | <literallayout class='monospaced'> |
| 2607 | do_configure[depends] += "virtual/kernel:do_shared_workdir" |
| 2608 | </literallayout> |
| 2609 | </para> |
| 2610 | </section> |
| 2611 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 2612 | <section id='new-recipe-compilation'> |
| 2613 | <title>Compilation</title> |
| 2614 | |
| 2615 | <para> |
| 2616 | During a build, the <filename>do_compile</filename> task |
| 2617 | happens after source is fetched, unpacked, and configured. |
| 2618 | If the recipe passes through <filename>do_compile</filename> |
| 2619 | successfully, nothing needs to be done. |
| 2620 | </para> |
| 2621 | |
| 2622 | <para> |
| 2623 | However, if the compile step fails, you need to diagnose the |
| 2624 | failure. |
Patrick Williams | f1e5d69 | 2016-03-30 15:21:19 -0500 | [diff] [blame] | 2625 | Here are some common issues that cause failures. |
| 2626 | <note> |
| 2627 | For cases where improper paths are detected for |
| 2628 | configuration files or for when libraries/headers cannot |
| 2629 | be found, be sure you are using the more robust |
| 2630 | <filename>pkg-config</filename>. |
| 2631 | See the note in section |
| 2632 | "<link linkend='new-recipe-configuring-the-recipe'>Configuring the Recipe</link>" |
| 2633 | for additional information. |
| 2634 | </note> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 2635 | <itemizedlist> |
| 2636 | <listitem><para><emphasis>Parallel build failures:</emphasis> |
| 2637 | These failures manifest themselves as intermittent |
| 2638 | errors, or errors reporting that a file or directory |
| 2639 | that should be created by some other part of the build |
| 2640 | process could not be found. |
| 2641 | This type of failure can occur even if, upon inspection, |
| 2642 | the file or directory does exist after the build has |
| 2643 | failed, because that part of the build process happened |
| 2644 | in the wrong order.</para> |
| 2645 | <para>To fix the problem, you need to either satisfy |
| 2646 | the missing dependency in the Makefile or whatever |
| 2647 | script produced the Makefile, or (as a workaround) |
| 2648 | set |
| 2649 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PARALLEL_MAKE'><filename>PARALLEL_MAKE</filename></ulink> |
| 2650 | to an empty string: |
| 2651 | <literallayout class='monospaced'> |
| 2652 | PARALLEL_MAKE = "" |
| 2653 | </literallayout></para> |
| 2654 | <para> |
| 2655 | For information on parallel Makefile issues, see the |
| 2656 | "<link linkend='debugging-parallel-make-races'>Debugging Parallel Make Races</link>" |
| 2657 | section. |
| 2658 | </para></listitem> |
| 2659 | <listitem><para><emphasis>Improper host path usage:</emphasis> |
| 2660 | This failure applies to recipes building for the target |
| 2661 | or <filename>nativesdk</filename> only. |
| 2662 | The failure occurs when the compilation process uses |
| 2663 | improper headers, libraries, or other files from the |
| 2664 | host system when cross-compiling for the target. |
| 2665 | </para> |
| 2666 | <para>To fix the problem, examine the |
| 2667 | <filename>log.do_compile</filename> file to identify |
| 2668 | the host paths being used (e.g. |
| 2669 | <filename>/usr/include</filename>, |
| 2670 | <filename>/usr/lib</filename>, and so forth) and then |
| 2671 | either add configure options, apply a patch, or do both. |
| 2672 | </para></listitem> |
| 2673 | <listitem><para><emphasis>Failure to find required |
| 2674 | libraries/headers:</emphasis> |
| 2675 | If a build-time dependency is missing because it has |
| 2676 | not been declared in |
| 2677 | <ulink url='&YOCTO_DOCS_REF_URL;#var-DEPENDS'><filename>DEPENDS</filename></ulink>, |
| 2678 | or because the dependency exists but the path used by |
| 2679 | the build process to find the file is incorrect and the |
| 2680 | configure step did not detect it, the compilation |
| 2681 | process could fail. |
| 2682 | For either of these failures, the compilation process |
| 2683 | notes that files could not be found. |
| 2684 | In these cases, you need to go back and add additional |
| 2685 | options to the configure script as well as possibly |
| 2686 | add additional build-time dependencies to |
| 2687 | <filename>DEPENDS</filename>.</para> |
| 2688 | <para>Occasionally, it is necessary to apply a patch |
| 2689 | to the source to ensure the correct paths are used. |
| 2690 | If you need to specify paths to find files staged |
| 2691 | into the sysroot from other recipes, use the variables |
| 2692 | that the OpenEmbedded build system provides |
| 2693 | (e.g. |
| 2694 | <filename>STAGING_BINDIR</filename>, |
| 2695 | <filename>STAGING_INCDIR</filename>, |
| 2696 | <filename>STAGING_DATADIR</filename>, and so forth). |
| 2697 | <!-- |
| 2698 | (e.g. |
| 2699 | <ulink url='&YOCTO_DOCS_REF_URL;#var-STAGING_BINDIR'><filename>STAGING_BINDIR</filename></ulink>, |
| 2700 | <ulink url='&YOCTO_DOCS_REF_URL;#var-STAGING_INCDIR'><filename>STAGING_INCDIR</filename></ulink>, |
| 2701 | <ulink url='&YOCTO_DOCS_REF_URL;#var-STAGING_DATADIR'><filename>STAGING_DATADIR</filename></ulink>, |
| 2702 | and so forth). |
| 2703 | --> |
| 2704 | </para></listitem> |
| 2705 | </itemizedlist> |
| 2706 | </para> |
| 2707 | </section> |
| 2708 | |
| 2709 | <section id='new-recipe-installing'> |
| 2710 | <title>Installing</title> |
| 2711 | |
| 2712 | <para> |
| 2713 | During <filename>do_install</filename>, the task copies the |
| 2714 | built files along with their hierarchy to locations that |
| 2715 | would mirror their locations on the target device. |
| 2716 | The installation process copies files from the |
| 2717 | <filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-S'><filename>S</filename></ulink><filename>}</filename>, |
| 2718 | <filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-B'><filename>B</filename></ulink><filename>}</filename>, |
| 2719 | and |
| 2720 | <filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-WORKDIR'><filename>WORKDIR</filename></ulink><filename>}</filename> |
| 2721 | directories to the |
| 2722 | <filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-D'><filename>D</filename></ulink><filename>}</filename> |
| 2723 | directory to create the structure as it should appear on the |
| 2724 | target system. |
| 2725 | </para> |
| 2726 | |
| 2727 | <para> |
| 2728 | How your software is built affects what you must do to be |
| 2729 | sure your software is installed correctly. |
| 2730 | The following list describes what you must do for installation |
| 2731 | depending on the type of build system used by the software |
| 2732 | being built: |
| 2733 | <itemizedlist> |
| 2734 | <listitem><para><emphasis>Autotools and CMake:</emphasis> |
| 2735 | If the software your recipe is building uses Autotools |
| 2736 | or CMake, the OpenEmbedded build |
| 2737 | system understands how to install the software. |
| 2738 | Consequently, you do not have to have a |
| 2739 | <filename>do_install</filename> task as part of your |
| 2740 | recipe. |
| 2741 | You just need to make sure the install portion of the |
| 2742 | build completes with no issues. |
| 2743 | However, if you wish to install additional files not |
| 2744 | already being installed by |
| 2745 | <filename>make install</filename>, you should do this |
| 2746 | using a <filename>do_install_append</filename> function |
| 2747 | using the install command as described in |
| 2748 | the "Manual" bulleted item later in this list. |
| 2749 | </para></listitem> |
| 2750 | <listitem><para><emphasis>Other (using |
| 2751 | <filename>make install</filename>):</emphasis> |
| 2752 | You need to define a |
| 2753 | <filename>do_install</filename> function in your |
| 2754 | recipe. |
| 2755 | The function should call |
| 2756 | <filename>oe_runmake install</filename> and will likely |
| 2757 | need to pass in the destination directory as well. |
| 2758 | How you pass that path is dependent on how the |
| 2759 | <filename>Makefile</filename> being run is written |
| 2760 | (e.g. <filename>DESTDIR=${D}</filename>, |
| 2761 | <filename>PREFIX=${D}</filename>, |
| 2762 | <filename>INSTALLROOT=${D}</filename>, and so forth). |
| 2763 | </para> |
| 2764 | <para>For an example recipe using |
| 2765 | <filename>make install</filename>, see the |
| 2766 | "<link linkend='new-recipe-makefile-based-package'>Makefile-Based Package</link>" |
| 2767 | section.</para></listitem> |
| 2768 | <listitem><para><emphasis>Manual:</emphasis> |
| 2769 | You need to define a |
| 2770 | <filename>do_install</filename> function in your |
| 2771 | recipe. |
| 2772 | The function must first use |
| 2773 | <filename>install -d</filename> to create the |
| 2774 | directories under |
| 2775 | <filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-D'><filename>D</filename></ulink><filename>}</filename>. |
| 2776 | Once the directories exist, your function can use |
| 2777 | <filename>install</filename> to manually install the |
| 2778 | built software into the directories.</para> |
| 2779 | <para>You can find more information on |
| 2780 | <filename>install</filename> at |
| 2781 | <ulink url='http://www.gnu.org/software/coreutils/manual/html_node/install-invocation.html'></ulink>. |
| 2782 | </para></listitem> |
| 2783 | </itemizedlist> |
| 2784 | </para> |
| 2785 | |
| 2786 | <para> |
| 2787 | For the scenarios that do not use Autotools or |
| 2788 | CMake, you need to track the installation |
| 2789 | and diagnose and fix any issues until everything installs |
| 2790 | correctly. |
| 2791 | You need to look in the default location of |
| 2792 | <filename>${D}</filename>, which is |
| 2793 | <filename>${WORKDIR}/image</filename>, to be sure your |
| 2794 | files have been installed correctly. |
| 2795 | </para> |
| 2796 | |
| 2797 | <note><title>Notes</title> |
| 2798 | <itemizedlist> |
| 2799 | <listitem><para> |
| 2800 | During the installation process, you might need to |
| 2801 | modify some of the installed files to suit the target |
| 2802 | layout. |
| 2803 | For example, you might need to replace hard-coded paths |
| 2804 | in an initscript with values of variables provided by |
| 2805 | the build system, such as replacing |
| 2806 | <filename>/usr/bin/</filename> with |
| 2807 | <filename>${bindir}</filename>. |
| 2808 | If you do perform such modifications during |
| 2809 | <filename>do_install</filename>, be sure to modify the |
| 2810 | destination file after copying rather than before |
| 2811 | copying. |
| 2812 | Modifying after copying ensures that the build system |
| 2813 | can re-execute <filename>do_install</filename> if |
| 2814 | needed. |
| 2815 | </para></listitem> |
| 2816 | <listitem><para> |
| 2817 | <filename>oe_runmake install</filename>, which can be |
| 2818 | run directly or can be run indirectly by the |
| 2819 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-autotools'><filename>autotools</filename></ulink> |
| 2820 | and |
| 2821 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-cmake'><filename>cmake</filename></ulink> |
| 2822 | classes, runs <filename>make install</filename> in |
| 2823 | parallel. |
| 2824 | Sometimes, a Makefile can have missing dependencies |
| 2825 | between targets that can result in race conditions. |
| 2826 | If you experience intermittent failures during |
| 2827 | <filename>do_install</filename>, you might be able to |
| 2828 | work around them by disabling parallel Makefile |
| 2829 | installs by adding the following to the recipe: |
| 2830 | <literallayout class='monospaced'> |
| 2831 | PARALLEL_MAKEINST = "" |
| 2832 | </literallayout> |
| 2833 | See |
| 2834 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PARALLEL_MAKEINST'><filename>PARALLEL_MAKEINST</filename></ulink> |
| 2835 | for additional information. |
| 2836 | </para></listitem> |
Brad Bishop | 64c979e | 2019-11-04 13:55:29 -0500 | [diff] [blame] | 2837 | <listitem><para> |
| 2838 | If you need to install one or more custom CMake |
| 2839 | toolchain files that are supplied by the |
| 2840 | application you are building, install the files to |
| 2841 | <filename>${D}${datadir}/cmake/</filename> Modules |
| 2842 | during |
| 2843 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-install'><filename>do_install</filename></ulink>. |
| 2844 | </para></listitem> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 2845 | </itemizedlist> |
| 2846 | </note> |
| 2847 | </section> |
| 2848 | |
| 2849 | <section id='new-recipe-enabling-system-services'> |
| 2850 | <title>Enabling System Services</title> |
| 2851 | |
| 2852 | <para> |
| 2853 | If you want to install a service, which is a process that |
| 2854 | usually starts on boot and runs in the background, then |
| 2855 | you must include some additional definitions in your recipe. |
| 2856 | </para> |
| 2857 | |
| 2858 | <para> |
| 2859 | If you are adding services and the service initialization |
| 2860 | script or the service file itself is not installed, you must |
| 2861 | provide for that installation in your recipe using a |
| 2862 | <filename>do_install_append</filename> function. |
| 2863 | If your recipe already has a <filename>do_install</filename> |
| 2864 | function, update the function near its end rather than |
| 2865 | adding an additional <filename>do_install_append</filename> |
| 2866 | function. |
| 2867 | </para> |
| 2868 | |
| 2869 | <para> |
| 2870 | When you create the installation for your services, you need |
| 2871 | to accomplish what is normally done by |
| 2872 | <filename>make install</filename>. |
| 2873 | In other words, make sure your installation arranges the output |
| 2874 | similar to how it is arranged on the target system. |
| 2875 | </para> |
| 2876 | |
| 2877 | <para> |
| 2878 | The OpenEmbedded build system provides support for starting |
| 2879 | services two different ways: |
| 2880 | <itemizedlist> |
| 2881 | <listitem><para><emphasis>SysVinit:</emphasis> |
| 2882 | SysVinit is a system and service manager that |
| 2883 | manages the init system used to control the very basic |
| 2884 | functions of your system. |
| 2885 | The init program is the first program |
| 2886 | started by the Linux kernel when the system boots. |
| 2887 | Init then controls the startup, running and shutdown |
| 2888 | of all other programs.</para> |
| 2889 | <para>To enable a service using SysVinit, your recipe |
| 2890 | needs to inherit the |
| 2891 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-update-rc.d'><filename>update-rc.d</filename></ulink> |
| 2892 | class. |
| 2893 | The class helps facilitate safely installing the |
| 2894 | package on the target.</para> |
| 2895 | <para>You will need to set the |
| 2896 | <ulink url='&YOCTO_DOCS_REF_URL;#var-INITSCRIPT_PACKAGES'><filename>INITSCRIPT_PACKAGES</filename></ulink>, |
| 2897 | <ulink url='&YOCTO_DOCS_REF_URL;#var-INITSCRIPT_NAME'><filename>INITSCRIPT_NAME</filename></ulink>, |
| 2898 | and |
| 2899 | <ulink url='&YOCTO_DOCS_REF_URL;#var-INITSCRIPT_PARAMS'><filename>INITSCRIPT_PARAMS</filename></ulink> |
| 2900 | variables within your recipe.</para></listitem> |
| 2901 | <listitem><para><emphasis>systemd:</emphasis> |
| 2902 | System Management Daemon (systemd) was designed to |
| 2903 | replace SysVinit and to provide |
| 2904 | enhanced management of services. |
| 2905 | For more information on systemd, see the systemd |
| 2906 | homepage at |
| 2907 | <ulink url='http://freedesktop.org/wiki/Software/systemd/'></ulink>. |
| 2908 | </para> |
| 2909 | <para>To enable a service using systemd, your recipe |
| 2910 | needs to inherit the |
| 2911 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-systemd'><filename>systemd</filename></ulink> |
| 2912 | class. |
| 2913 | See the <filename>systemd.bbclass</filename> file |
| 2914 | located in your |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 2915 | <ulink url='&YOCTO_DOCS_REF_URL;#source-directory'>Source Directory</ulink>. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 2916 | section for more information. |
| 2917 | </para></listitem> |
| 2918 | </itemizedlist> |
| 2919 | </para> |
| 2920 | </section> |
| 2921 | |
| 2922 | <section id='new-recipe-packaging'> |
| 2923 | <title>Packaging</title> |
| 2924 | |
| 2925 | <para> |
| 2926 | Successful packaging is a combination of automated processes |
| 2927 | performed by the OpenEmbedded build system and some |
| 2928 | specific steps you need to take. |
| 2929 | The following list describes the process: |
| 2930 | <itemizedlist> |
| 2931 | <listitem><para><emphasis>Splitting Files</emphasis>: |
| 2932 | The <filename>do_package</filename> task splits the |
| 2933 | files produced by the recipe into logical components. |
| 2934 | Even software that produces a single binary might |
| 2935 | still have debug symbols, documentation, and other |
| 2936 | logical components that should be split out. |
| 2937 | The <filename>do_package</filename> task ensures |
| 2938 | that files are split up and packaged correctly. |
| 2939 | </para></listitem> |
| 2940 | <listitem><para><emphasis>Running QA Checks</emphasis>: |
| 2941 | The |
| 2942 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-insane'><filename>insane</filename></ulink> |
| 2943 | class adds a step to |
| 2944 | the package generation process so that output quality |
| 2945 | assurance checks are generated by the OpenEmbedded |
| 2946 | build system. |
| 2947 | This step performs a range of checks to be sure the |
| 2948 | build's output is free of common problems that show |
| 2949 | up during runtime. |
| 2950 | For information on these checks, see the |
| 2951 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-insane'><filename>insane</filename></ulink> |
| 2952 | class and the |
| 2953 | "<ulink url='&YOCTO_DOCS_REF_URL;#ref-qa-checks'>QA Error and Warning Messages</ulink>" |
| 2954 | chapter in the Yocto Project Reference Manual. |
| 2955 | </para></listitem> |
| 2956 | <listitem><para><emphasis>Hand-Checking Your Packages</emphasis>: |
| 2957 | After you build your software, you need to be sure |
| 2958 | your packages are correct. |
| 2959 | Examine the |
| 2960 | <filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-WORKDIR'><filename>WORKDIR</filename></ulink><filename>}/packages-split</filename> |
| 2961 | directory and make sure files are where you expect |
| 2962 | them to be. |
| 2963 | If you discover problems, you can set |
| 2964 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGES'><filename>PACKAGES</filename></ulink>, |
| 2965 | <ulink url='&YOCTO_DOCS_REF_URL;#var-FILES'><filename>FILES</filename></ulink>, |
| 2966 | <filename>do_install(_append)</filename>, and so forth as |
| 2967 | needed. |
| 2968 | </para></listitem> |
| 2969 | <listitem><para><emphasis>Splitting an Application into Multiple Packages</emphasis>: |
| 2970 | If you need to split an application into several |
| 2971 | packages, see the |
| 2972 | "<link linkend='splitting-an-application-into-multiple-packages'>Splitting an Application into Multiple Packages</link>" |
| 2973 | section for an example. |
| 2974 | </para></listitem> |
| 2975 | <listitem><para><emphasis>Installing a Post-Installation Script</emphasis>: |
| 2976 | For an example showing how to install a |
| 2977 | post-installation script, see the |
| 2978 | "<link linkend='new-recipe-post-installation-scripts'>Post-Installation Scripts</link>" |
| 2979 | section. |
| 2980 | </para></listitem> |
| 2981 | <listitem><para><emphasis>Marking Package Architecture</emphasis>: |
| 2982 | Depending on what your recipe is building and how it |
| 2983 | is configured, it might be important to mark the |
| 2984 | packages produced as being specific to a particular |
| 2985 | machine, or to mark them as not being specific to |
Patrick Williams | f1e5d69 | 2016-03-30 15:21:19 -0500 | [diff] [blame] | 2986 | a particular machine or architecture at all.</para> |
| 2987 | <para>By default, packages apply to any machine with the |
| 2988 | same architecture as the target machine. |
| 2989 | When a recipe produces packages that are |
| 2990 | machine-specific (e.g. the |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 2991 | <ulink url='&YOCTO_DOCS_REF_URL;#var-MACHINE'><filename>MACHINE</filename></ulink> |
| 2992 | value is passed into the configure script or a patch |
Patrick Williams | f1e5d69 | 2016-03-30 15:21:19 -0500 | [diff] [blame] | 2993 | is applied only for a particular machine), you should |
| 2994 | mark them as such by adding the following to the |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 2995 | recipe: |
| 2996 | <literallayout class='monospaced'> |
| 2997 | PACKAGE_ARCH = "${MACHINE_ARCH}" |
Patrick Williams | f1e5d69 | 2016-03-30 15:21:19 -0500 | [diff] [blame] | 2998 | </literallayout></para> |
| 2999 | <para>On the other hand, if the recipe produces packages |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 3000 | that do not contain anything specific to the target |
| 3001 | machine or architecture at all (e.g. recipes |
| 3002 | that simply package script files or configuration |
| 3003 | files), you should use the |
| 3004 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-allarch'><filename>allarch</filename></ulink> |
| 3005 | class to do this for you by adding this to your |
| 3006 | recipe: |
| 3007 | <literallayout class='monospaced'> |
| 3008 | inherit allarch |
| 3009 | </literallayout> |
| 3010 | Ensuring that the package architecture is correct is |
| 3011 | not critical while you are doing the first few builds |
| 3012 | of your recipe. |
| 3013 | However, it is important in order |
| 3014 | to ensure that your recipe rebuilds (or does not |
| 3015 | rebuild) appropriately in response to changes in |
| 3016 | configuration, and to ensure that you get the |
| 3017 | appropriate packages installed on the target machine, |
| 3018 | particularly if you run separate builds for more |
| 3019 | than one target machine. |
| 3020 | </para></listitem> |
| 3021 | </itemizedlist> |
| 3022 | </para> |
| 3023 | </section> |
| 3024 | |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 3025 | <section id='new-sharing-files-between-recipes'> |
| 3026 | <title>Sharing Files Between Recipes</title> |
| 3027 | |
| 3028 | <para> |
| 3029 | Recipes often need to use files provided by other recipes on |
| 3030 | the build host. |
| 3031 | For example, an application linking to a common library needs |
| 3032 | access to the library itself and its associated headers. |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 3033 | The way this access is accomplished is by populating a sysroot |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 3034 | with files. |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 3035 | Each recipe has two sysroots in its work directory, one for |
| 3036 | target files |
| 3037 | (<filename>recipe-sysroot</filename>) and one for files that |
| 3038 | are native to the build host |
| 3039 | (<filename>recipe-sysroot-native</filename>). |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 3040 | <note> |
| 3041 | You could find the term "staging" used within the Yocto |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 3042 | project regarding files populating sysroots (e.g. the |
Brad Bishop | 37a0e4d | 2017-12-04 01:01:44 -0500 | [diff] [blame] | 3043 | <ulink url='&YOCTO_DOCS_REF_URL;#var-STAGING_DIR'><filename>STAGING_DIR</filename></ulink> |
| 3044 | variable). |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 3045 | </note> |
| 3046 | </para> |
| 3047 | |
| 3048 | <para> |
| 3049 | Recipes should never populate the sysroot directly (i.e. write |
| 3050 | files into sysroot). |
| 3051 | Instead, files should be installed into standard locations |
| 3052 | during the |
| 3053 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-install'><filename>do_install</filename></ulink> |
| 3054 | task within the |
| 3055 | <filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-D'><filename>D</filename></ulink><filename>}</filename> |
| 3056 | directory. |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 3057 | The reason for this limitation is that almost all files that |
| 3058 | populate the sysroot are cataloged in manifests in order to |
| 3059 | ensure the files can be removed later when a recipe is either |
| 3060 | modified or removed. |
| 3061 | Thus, the sysroot is able to remain free from stale files. |
| 3062 | </para> |
| 3063 | |
| 3064 | <para> |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 3065 | A subset of the files installed by the |
| 3066 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-install'><filename>do_install</filename></ulink> |
| 3067 | task are used by the |
| 3068 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-populate_sysroot'><filename>do_populate_sysroot</filename></ulink> |
| 3069 | task as defined by the the |
| 3070 | <ulink url='&YOCTO_DOCS_REF_URL;#var-SYSROOT_DIRS'><filename>SYSROOT_DIRS</filename></ulink> |
| 3071 | variable to automatically populate the sysroot. |
Brad Bishop | 37a0e4d | 2017-12-04 01:01:44 -0500 | [diff] [blame] | 3072 | It is possible to modify the list of directories that populate |
| 3073 | the sysroot. |
| 3074 | The following example shows how you could add the |
| 3075 | <filename>/opt</filename> directory to the list of |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 3076 | directories within a recipe: |
Brad Bishop | 37a0e4d | 2017-12-04 01:01:44 -0500 | [diff] [blame] | 3077 | <literallayout class='monospaced'> |
| 3078 | SYSROOT_DIRS += "/opt" |
| 3079 | </literallayout> |
| 3080 | </para> |
| 3081 | |
| 3082 | <para> |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 3083 | For a more complete description of the |
| 3084 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-populate_sysroot'><filename>do_populate_sysroot</filename></ulink> |
| 3085 | task and its associated functions, see the |
| 3086 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-staging'><filename>staging</filename></ulink> |
| 3087 | class. |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 3088 | </para> |
| 3089 | </section> |
| 3090 | |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 3091 | <section id='metadata-virtual-providers'> |
| 3092 | <title>Using Virtual Providers</title> |
| 3093 | |
| 3094 | <para> |
| 3095 | Prior to a build, if you know that several different recipes |
| 3096 | provide the same functionality, you can use a virtual provider |
| 3097 | (i.e. <filename>virtual/*</filename>) as a placeholder for the |
| 3098 | actual provider. |
| 3099 | The actual provider is determined at build-time. |
| 3100 | </para> |
| 3101 | |
| 3102 | <para> |
| 3103 | A common scenario where a virtual provider is used would be |
| 3104 | for the kernel recipe. |
| 3105 | Suppose you have three kernel recipes whose |
| 3106 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PN'><filename>PN</filename></ulink> |
| 3107 | values map to <filename>kernel-big</filename>, |
| 3108 | <filename>kernel-mid</filename>, and |
| 3109 | <filename>kernel-small</filename>. |
| 3110 | Furthermore, each of these recipes in some way uses a |
| 3111 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PROVIDES'><filename>PROVIDES</filename></ulink> |
| 3112 | statement that essentially identifies itself as being able |
| 3113 | to provide <filename>virtual/kernel</filename>. |
| 3114 | Here is one way through the |
| 3115 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-kernel'><filename>kernel</filename></ulink> |
| 3116 | class: |
| 3117 | <literallayout class='monospaced'> |
| 3118 | PROVIDES += "${@ "virtual/kernel" if (d.getVar("KERNEL_PACKAGE_NAME") == "kernel") else "" }" |
| 3119 | </literallayout> |
| 3120 | Any recipe that inherits the <filename>kernel</filename> class |
| 3121 | is going to utilize a <filename>PROVIDES</filename> statement |
| 3122 | that identifies that recipe as being able to provide the |
| 3123 | <filename>virtual/kernel</filename> item. |
| 3124 | </para> |
| 3125 | |
| 3126 | <para> |
| 3127 | Now comes the time to actually build an image and you need a |
| 3128 | kernel recipe, but which one? |
| 3129 | You can configure your build to call out the kernel recipe |
| 3130 | you want by using the |
| 3131 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PREFERRED_PROVIDER'><filename>PREFERRED_PROVIDER</filename></ulink> |
| 3132 | variable. |
| 3133 | As an example, consider the |
| 3134 | <ulink url='https://git.yoctoproject.org/cgit/cgit.cgi/poky/tree/meta/conf/machine/include/x86-base.inc'><filename>x86-base.inc</filename></ulink> |
| 3135 | include file, which is a machine |
| 3136 | (i.e. <ulink url='&YOCTO_DOCS_REF_URL;#var-MACHINE'><filename>MACHINE</filename></ulink>) |
| 3137 | configuration file. |
| 3138 | This include file is the reason all x86-based machines use the |
| 3139 | <filename>linux-yocto</filename> kernel. |
| 3140 | Here are the relevant lines from the include file: |
| 3141 | <literallayout class='monospaced'> |
| 3142 | PREFERRED_PROVIDER_virtual/kernel ??= "linux-yocto" |
| 3143 | PREFERRED_VERSION_linux-yocto ??= "4.15%" |
| 3144 | </literallayout> |
| 3145 | </para> |
| 3146 | |
| 3147 | <para> |
| 3148 | When you use a virtual provider, you do not have to |
| 3149 | "hard code" a recipe name as a build dependency. |
| 3150 | You can use the |
| 3151 | <ulink url='&YOCTO_DOCS_REF_URL;#var-DEPENDS'><filename>DEPENDS</filename></ulink> |
| 3152 | variable to state the build is dependent on |
| 3153 | <filename>virtual/kernel</filename> for example: |
| 3154 | <literallayout class='monospaced'> |
| 3155 | DEPENDS = "virtual/kernel" |
| 3156 | </literallayout> |
| 3157 | During the build, the OpenEmbedded build system picks |
| 3158 | the correct recipe needed for the |
| 3159 | <filename>virtual/kernel</filename> dependency based on the |
| 3160 | <filename>PREFERRED_PROVIDER</filename> variable. |
| 3161 | If you want to use the small kernel mentioned at the beginning |
| 3162 | of this section, configure your build as follows: |
| 3163 | <literallayout class='monospaced'> |
| 3164 | PREFERRED_PROVIDER_virtual/kernel ??= "kernel-small" |
| 3165 | </literallayout> |
| 3166 | <note> |
| 3167 | Any recipe that |
| 3168 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PROVIDES'><filename>PROVIDES</filename></ulink> |
| 3169 | a <filename>virtual/*</filename> item that is ultimately |
| 3170 | not selected through |
| 3171 | <filename>PREFERRED_PROVIDER</filename> does not get built. |
| 3172 | Preventing these recipes from building is usually the |
| 3173 | desired behavior since this mechanism's purpose is to |
| 3174 | select between mutually exclusive alternative providers. |
| 3175 | </note> |
| 3176 | </para> |
| 3177 | |
| 3178 | <para> |
| 3179 | The following lists specific examples of virtual providers: |
| 3180 | <itemizedlist> |
| 3181 | <listitem><para> |
| 3182 | <filename>virtual/kernel</filename>: |
| 3183 | Provides the name of the kernel recipe to use when |
| 3184 | building a kernel image. |
| 3185 | </para></listitem> |
| 3186 | <listitem><para> |
| 3187 | <filename>virtual/bootloader</filename>: |
| 3188 | Provides the name of the bootloader to use when |
| 3189 | building an image. |
| 3190 | </para></listitem> |
| 3191 | <listitem><para> |
| 3192 | <filename>virtual/mesa</filename>: |
| 3193 | Provides <filename>gbm.pc</filename>. |
| 3194 | </para></listitem> |
| 3195 | <listitem><para> |
| 3196 | <filename>virtual/egl</filename>: |
| 3197 | Provides <filename>egl.pc</filename> and possibly |
| 3198 | <filename>wayland-egl.pc</filename>. |
| 3199 | </para></listitem> |
| 3200 | <listitem><para> |
| 3201 | <filename>virtual/libgl</filename>: |
| 3202 | Provides <filename>gl.pc</filename> (i.e. libGL). |
| 3203 | </para></listitem> |
| 3204 | <listitem><para> |
| 3205 | <filename>virtual/libgles1</filename>: |
| 3206 | Provides <filename>glesv1_cm.pc</filename> |
| 3207 | (i.e. libGLESv1_CM). |
| 3208 | </para></listitem> |
| 3209 | <listitem><para> |
| 3210 | <filename>virtual/libgles2</filename>: |
| 3211 | Provides <filename>glesv2.pc</filename> |
| 3212 | (i.e. libGLESv2). |
| 3213 | </para></listitem> |
| 3214 | </itemizedlist> |
| 3215 | </para> |
| 3216 | </section> |
| 3217 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 3218 | <section id='properly-versioning-pre-release-recipes'> |
| 3219 | <title>Properly Versioning Pre-Release Recipes</title> |
| 3220 | |
| 3221 | <para> |
| 3222 | Sometimes the name of a recipe can lead to versioning |
| 3223 | problems when the recipe is upgraded to a final release. |
| 3224 | For example, consider the |
| 3225 | <filename>irssi_0.8.16-rc1.bb</filename> recipe file in |
| 3226 | the list of example recipes in the |
| 3227 | "<link linkend='new-recipe-storing-and-naming-the-recipe'>Storing and Naming the Recipe</link>" |
| 3228 | section. |
| 3229 | This recipe is at a release candidate stage (i.e. |
| 3230 | "rc1"). |
| 3231 | When the recipe is released, the recipe filename becomes |
| 3232 | <filename>irssi_0.8.16.bb</filename>. |
| 3233 | The version change from <filename>0.8.16-rc1</filename> |
| 3234 | to <filename>0.8.16</filename> is seen as a decrease by the |
| 3235 | build system and package managers, so the resulting packages |
| 3236 | will not correctly trigger an upgrade. |
| 3237 | </para> |
| 3238 | |
| 3239 | <para> |
| 3240 | In order to ensure the versions compare properly, the |
| 3241 | recommended convention is to set |
| 3242 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PV'><filename>PV</filename></ulink> |
| 3243 | within the recipe to |
| 3244 | "<replaceable>previous_version</replaceable>+<replaceable>current_version</replaceable>". |
| 3245 | You can use an additional variable so that you can use the |
| 3246 | current version elsewhere. |
| 3247 | Here is an example: |
| 3248 | <literallayout class='monospaced'> |
| 3249 | REALPV = "0.8.16-rc1" |
| 3250 | PV = "0.8.15+${REALPV}" |
| 3251 | </literallayout> |
| 3252 | </para> |
| 3253 | </section> |
| 3254 | |
| 3255 | <section id='new-recipe-post-installation-scripts'> |
| 3256 | <title>Post-Installation Scripts</title> |
| 3257 | |
| 3258 | <para> |
| 3259 | Post-installation scripts run immediately after installing |
| 3260 | a package on the target or during image creation when a |
| 3261 | package is included in an image. |
| 3262 | To add a post-installation script to a package, add a |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 3263 | <filename>pkg_postinst_</filename><replaceable>PACKAGENAME</replaceable><filename>()</filename> function to |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 3264 | the recipe file (<filename>.bb</filename>) and replace |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 3265 | <replaceable>PACKAGENAME</replaceable> with the name of the package |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 3266 | you want to attach to the <filename>postinst</filename> |
| 3267 | script. |
| 3268 | To apply the post-installation script to the main package |
| 3269 | for the recipe, which is usually what is required, specify |
| 3270 | <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] | 3271 | in place of <replaceable>PACKAGENAME</replaceable>. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 3272 | </para> |
| 3273 | |
| 3274 | <para> |
| 3275 | A post-installation function has the following structure: |
| 3276 | <literallayout class='monospaced'> |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 3277 | pkg_postinst_<replaceable>PACKAGENAME</replaceable>() { |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 3278 | # Commands to carry out |
| 3279 | } |
| 3280 | </literallayout> |
| 3281 | </para> |
| 3282 | |
| 3283 | <para> |
| 3284 | The script defined in the post-installation function is |
| 3285 | called when the root filesystem is created. |
| 3286 | If the script succeeds, the package is marked as installed. |
Brad Bishop | 37a0e4d | 2017-12-04 01:01:44 -0500 | [diff] [blame] | 3287 | <note> |
| 3288 | Any RPM post-installation script that runs on the target |
| 3289 | should return a 0 exit code. |
| 3290 | RPM does not allow non-zero exit codes for these scripts, |
| 3291 | and the RPM package manager will cause the package to fail |
| 3292 | installation on the target. |
| 3293 | </note> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 3294 | </para> |
| 3295 | |
| 3296 | <para> |
| 3297 | Sometimes it is necessary for the execution of a |
| 3298 | post-installation script to be delayed until the first boot. |
| 3299 | For example, the script might need to be executed on the |
| 3300 | device itself. |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 3301 | To delay script execution until boot time, you must explicitly |
| 3302 | mark post installs to defer to the target. |
| 3303 | You can use <filename>pkg_postinst_ontarget()</filename> or |
| 3304 | call |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 3305 | <filename>postinst_intercept delay_to_first_boot</filename> |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 3306 | from <filename>pkg_postinst()</filename>. |
| 3307 | Any failure of a <filename>pkg_postinst()</filename> script |
| 3308 | (including exit 1) triggers an error during the |
| 3309 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-rootfs'><filename>do_rootfs</filename></ulink> |
| 3310 | task. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 3311 | </para> |
| 3312 | |
| 3313 | <para> |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 3314 | If you have recipes that use |
| 3315 | <filename>pkg_postinst</filename> function |
| 3316 | and they require the use of non-standard native |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 3317 | tools that have dependencies during rootfs construction, you |
| 3318 | need to use the |
| 3319 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_WRITE_DEPS'><filename>PACKAGE_WRITE_DEPS</filename></ulink> |
| 3320 | variable in your recipe to list these tools. |
| 3321 | If you do not use this variable, the tools might be missing and |
| 3322 | execution of the post-installation script is deferred until |
| 3323 | first boot. |
| 3324 | Deferring the script to first boot is undesirable and for |
| 3325 | read-only rootfs impossible. |
| 3326 | </para> |
| 3327 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 3328 | <note> |
| 3329 | Equivalent support for pre-install, pre-uninstall, and |
| 3330 | post-uninstall scripts exist by way of |
| 3331 | <filename>pkg_preinst</filename>, |
| 3332 | <filename>pkg_prerm</filename>, and |
| 3333 | <filename>pkg_postrm</filename>, respectively. |
| 3334 | These scrips work in exactly the same way as does |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 3335 | <filename>pkg_postinst</filename> with the exception |
| 3336 | that they run at different times. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 3337 | Also, because of when they run, they are not applicable to |
| 3338 | being run at image creation time like |
| 3339 | <filename>pkg_postinst</filename>. |
| 3340 | </note> |
| 3341 | </section> |
| 3342 | |
| 3343 | <section id='new-recipe-testing'> |
| 3344 | <title>Testing</title> |
| 3345 | |
| 3346 | <para> |
| 3347 | The final step for completing your recipe is to be sure that |
| 3348 | the software you built runs correctly. |
| 3349 | To accomplish runtime testing, add the build's output |
| 3350 | packages to your image and test them on the target. |
| 3351 | </para> |
| 3352 | |
| 3353 | <para> |
| 3354 | For information on how to customize your image by adding |
| 3355 | specific packages, see the |
| 3356 | "<link linkend='usingpoky-extend-customimage'>Customizing Images</link>" |
| 3357 | section. |
| 3358 | </para> |
| 3359 | </section> |
| 3360 | |
| 3361 | <section id='new-recipe-testing-examples'> |
| 3362 | <title>Examples</title> |
| 3363 | |
| 3364 | <para> |
| 3365 | To help summarize how to write a recipe, this section provides |
| 3366 | some examples given various scenarios: |
| 3367 | <itemizedlist> |
| 3368 | <listitem><para>Recipes that use local files</para></listitem> |
| 3369 | <listitem><para>Using an Autotooled package</para></listitem> |
| 3370 | <listitem><para>Using a Makefile-based package</para></listitem> |
| 3371 | <listitem><para>Splitting an application into multiple packages</para></listitem> |
| 3372 | <listitem><para>Adding binaries to an image</para></listitem> |
| 3373 | </itemizedlist> |
| 3374 | </para> |
| 3375 | |
| 3376 | <section id='new-recipe-single-c-file-package-hello-world'> |
| 3377 | <title>Single .c File Package (Hello World!)</title> |
| 3378 | |
| 3379 | <para> |
| 3380 | Building an application from a single file that is stored |
| 3381 | locally (e.g. under <filename>files</filename>) requires |
| 3382 | a recipe that has the file listed in the |
| 3383 | <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'>SRC_URI</ulink></filename> |
| 3384 | variable. |
| 3385 | Additionally, you need to manually write the |
| 3386 | <filename>do_compile</filename> and |
| 3387 | <filename>do_install</filename> tasks. |
| 3388 | The <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-S'>S</ulink></filename> |
| 3389 | variable defines the directory containing the source code, |
| 3390 | which is set to |
| 3391 | <ulink url='&YOCTO_DOCS_REF_URL;#var-WORKDIR'><filename>WORKDIR</filename></ulink> |
| 3392 | in this case - the directory BitBake uses for the build. |
| 3393 | <literallayout class='monospaced'> |
| 3394 | SUMMARY = "Simple helloworld application" |
| 3395 | SECTION = "examples" |
| 3396 | LICENSE = "MIT" |
| 3397 | LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302" |
| 3398 | |
| 3399 | SRC_URI = "file://helloworld.c" |
| 3400 | |
| 3401 | S = "${WORKDIR}" |
| 3402 | |
| 3403 | do_compile() { |
| 3404 | ${CC} helloworld.c -o helloworld |
| 3405 | } |
| 3406 | |
| 3407 | do_install() { |
| 3408 | install -d ${D}${bindir} |
| 3409 | install -m 0755 helloworld ${D}${bindir} |
| 3410 | } |
| 3411 | </literallayout> |
| 3412 | </para> |
| 3413 | |
| 3414 | <para> |
| 3415 | By default, the <filename>helloworld</filename>, |
| 3416 | <filename>helloworld-dbg</filename>, and |
| 3417 | <filename>helloworld-dev</filename> packages are built. |
| 3418 | For information on how to customize the packaging process, |
| 3419 | see the |
| 3420 | "<link linkend='splitting-an-application-into-multiple-packages'>Splitting an Application into Multiple Packages</link>" |
| 3421 | section. |
| 3422 | </para> |
| 3423 | </section> |
| 3424 | |
| 3425 | <section id='new-recipe-autotooled-package'> |
| 3426 | <title>Autotooled Package</title> |
| 3427 | <para> |
| 3428 | Applications that use Autotools such as <filename>autoconf</filename> and |
| 3429 | <filename>automake</filename> require a recipe that has a source archive listed in |
| 3430 | <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'>SRC_URI</ulink></filename> and |
| 3431 | also inherit the |
| 3432 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-autotools'><filename>autotools</filename></ulink> |
| 3433 | class, which contains the definitions of all the steps |
| 3434 | needed to build an Autotool-based application. |
| 3435 | The result of the build is automatically packaged. |
| 3436 | And, if the application uses NLS for localization, packages with local information are |
| 3437 | generated (one package per language). |
| 3438 | Following is one example: (<filename>hello_2.3.bb</filename>) |
| 3439 | <literallayout class='monospaced'> |
| 3440 | SUMMARY = "GNU Helloworld application" |
| 3441 | SECTION = "examples" |
| 3442 | LICENSE = "GPLv2+" |
| 3443 | LIC_FILES_CHKSUM = "file://COPYING;md5=751419260aa954499f7abaabaa882bbe" |
| 3444 | |
| 3445 | SRC_URI = "${GNU_MIRROR}/hello/hello-${PV}.tar.gz" |
| 3446 | |
| 3447 | inherit autotools gettext |
| 3448 | </literallayout> |
| 3449 | </para> |
| 3450 | |
| 3451 | <para> |
| 3452 | The variable |
| 3453 | <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-LIC_FILES_CHKSUM'>LIC_FILES_CHKSUM</ulink></filename> |
| 3454 | is used to track source license changes as described in the |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 3455 | "<link linkend='usingpoky-configuring-LIC_FILES_CHKSUM'>Tracking License Changes</link>" |
| 3456 | section in the Yocto Project Overview and Concepts Manual. |
| 3457 | You can quickly create Autotool-based recipes in a manner |
| 3458 | similar to the previous example. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 3459 | </para> |
| 3460 | </section> |
| 3461 | |
| 3462 | <section id='new-recipe-makefile-based-package'> |
| 3463 | <title>Makefile-Based Package</title> |
| 3464 | |
| 3465 | <para> |
| 3466 | Applications that use GNU <filename>make</filename> also require a recipe that has |
| 3467 | the source archive listed in |
| 3468 | <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'>SRC_URI</ulink></filename>. |
| 3469 | You do not need to add a <filename>do_compile</filename> step since by default BitBake |
| 3470 | starts the <filename>make</filename> command to compile the application. |
| 3471 | 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] | 3472 | <ulink url='&YOCTO_DOCS_REF_URL;#var-EXTRA_OEMAKE'><filename>EXTRA_OEMAKE</filename></ulink> |
| 3473 | or |
| 3474 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGECONFIG_CONFARGS'><filename>PACKAGECONFIG_CONFARGS</filename></ulink> |
| 3475 | variables. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 3476 | BitBake passes these options into the GNU <filename>make</filename> invocation. |
| 3477 | Note that a <filename>do_install</filename> task is still required. |
| 3478 | Otherwise, BitBake runs an empty <filename>do_install</filename> task by default. |
| 3479 | </para> |
| 3480 | |
| 3481 | <para> |
| 3482 | Some applications might require extra parameters to be passed to the compiler. |
| 3483 | For example, the application might need an additional header path. |
| 3484 | You can accomplish this by adding to the |
| 3485 | <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-CFLAGS'>CFLAGS</ulink></filename> variable. |
| 3486 | The following example shows this: |
| 3487 | <literallayout class='monospaced'> |
| 3488 | CFLAGS_prepend = "-I ${S}/include " |
| 3489 | </literallayout> |
| 3490 | </para> |
| 3491 | |
| 3492 | <para> |
| 3493 | In the following example, <filename>mtd-utils</filename> is a makefile-based package: |
| 3494 | <literallayout class='monospaced'> |
| 3495 | SUMMARY = "Tools for managing memory technology devices" |
| 3496 | SECTION = "base" |
| 3497 | DEPENDS = "zlib lzo e2fsprogs util-linux" |
| 3498 | HOMEPAGE = "http://www.linux-mtd.infradead.org/" |
| 3499 | LICENSE = "GPLv2+" |
| 3500 | LIC_FILES_CHKSUM = "file://COPYING;md5=0636e73ff0215e8d672dc4c32c317bb3 \ |
| 3501 | file://include/common.h;beginline=1;endline=17;md5=ba05b07912a44ea2bf81ce409380049c" |
| 3502 | |
| 3503 | # Use the latest version at 26 Oct, 2013 |
| 3504 | SRCREV = "9f107132a6a073cce37434ca9cda6917dd8d866b" |
| 3505 | SRC_URI = "git://git.infradead.org/mtd-utils.git \ |
| 3506 | file://add-exclusion-to-mkfs-jffs2-git-2.patch \ |
| 3507 | " |
| 3508 | |
| 3509 | PV = "1.5.1+git${SRCPV}" |
| 3510 | |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 3511 | S = "${WORKDIR}/git" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 3512 | |
| 3513 | EXTRA_OEMAKE = "'CC=${CC}' 'RANLIB=${RANLIB}' 'AR=${AR}' 'CFLAGS=${CFLAGS} -I${S}/include -DWITHOUT_XATTR' 'BUILDDIR=${S}'" |
| 3514 | |
| 3515 | do_install () { |
| 3516 | oe_runmake install DESTDIR=${D} SBINDIR=${sbindir} MANDIR=${mandir} INCLUDEDIR=${includedir} |
| 3517 | } |
| 3518 | |
| 3519 | PACKAGES =+ "mtd-utils-jffs2 mtd-utils-ubifs mtd-utils-misc" |
| 3520 | |
| 3521 | FILES_mtd-utils-jffs2 = "${sbindir}/mkfs.jffs2 ${sbindir}/jffs2dump ${sbindir}/jffs2reader ${sbindir}/sumtool" |
| 3522 | FILES_mtd-utils-ubifs = "${sbindir}/mkfs.ubifs ${sbindir}/ubi*" |
| 3523 | FILES_mtd-utils-misc = "${sbindir}/nftl* ${sbindir}/ftl* ${sbindir}/rfd* ${sbindir}/doc* ${sbindir}/serve_image ${sbindir}/recv_image" |
| 3524 | |
| 3525 | PARALLEL_MAKE = "" |
| 3526 | |
| 3527 | BBCLASSEXTEND = "native" |
| 3528 | </literallayout> |
| 3529 | </para> |
| 3530 | </section> |
| 3531 | |
| 3532 | <section id='splitting-an-application-into-multiple-packages'> |
| 3533 | <title>Splitting an Application into Multiple Packages</title> |
| 3534 | |
| 3535 | <para> |
| 3536 | You can use the variables |
| 3537 | <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGES'>PACKAGES</ulink></filename> and |
| 3538 | <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-FILES'>FILES</ulink></filename> |
| 3539 | to split an application into multiple packages. |
| 3540 | </para> |
| 3541 | |
| 3542 | <para> |
| 3543 | Following is an example that uses the <filename>libxpm</filename> recipe. |
| 3544 | By default, this recipe generates a single package that contains the library along |
| 3545 | with a few binaries. |
| 3546 | You can modify the recipe to split the binaries into separate packages: |
| 3547 | <literallayout class='monospaced'> |
| 3548 | require xorg-lib-common.inc |
| 3549 | |
| 3550 | SUMMARY = "Xpm: X Pixmap extension library" |
| 3551 | LICENSE = "BSD" |
| 3552 | LIC_FILES_CHKSUM = "file://COPYING;md5=51f4270b012ecd4ab1a164f5f4ed6cf7" |
| 3553 | DEPENDS += "libxext libsm libxt" |
| 3554 | PE = "1" |
| 3555 | |
| 3556 | XORG_PN = "libXpm" |
| 3557 | |
| 3558 | PACKAGES =+ "sxpm cxpm" |
| 3559 | FILES_cxpm = "${bindir}/cxpm" |
| 3560 | FILES_sxpm = "${bindir}/sxpm" |
| 3561 | </literallayout> |
| 3562 | </para> |
| 3563 | |
| 3564 | <para> |
| 3565 | In the previous example, we want to ship the <filename>sxpm</filename> |
| 3566 | and <filename>cxpm</filename> binaries in separate packages. |
| 3567 | Since <filename>bindir</filename> would be packaged into the main |
| 3568 | <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-PN'>PN</ulink></filename> |
| 3569 | package by default, we prepend the <filename>PACKAGES</filename> |
| 3570 | variable so additional package names are added to the start of list. |
| 3571 | This results in the extra <filename>FILES_*</filename> |
| 3572 | variables then containing information that define which files and |
| 3573 | directories go into which packages. |
| 3574 | Files included by earlier packages are skipped by latter packages. |
| 3575 | Thus, the main <filename>PN</filename> package |
| 3576 | does not include the above listed files. |
| 3577 | </para> |
| 3578 | </section> |
| 3579 | |
| 3580 | <section id='packaging-externally-produced-binaries'> |
| 3581 | <title>Packaging Externally Produced Binaries</title> |
| 3582 | |
| 3583 | <para> |
| 3584 | Sometimes, you need to add pre-compiled binaries to an |
| 3585 | image. |
| 3586 | For example, suppose that binaries for proprietary code |
| 3587 | exist, which are created by a particular division of a |
| 3588 | company. |
| 3589 | Your part of the company needs to use those binaries as |
| 3590 | part of an image that you are building using the |
| 3591 | OpenEmbedded build system. |
| 3592 | Since you only have the binaries and not the source code, |
| 3593 | you cannot use a typical recipe that expects to fetch the |
| 3594 | source specified in |
| 3595 | <ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'><filename>SRC_URI</filename></ulink> |
| 3596 | and then compile it. |
| 3597 | </para> |
| 3598 | |
| 3599 | <para> |
| 3600 | One method is to package the binaries and then install them |
| 3601 | as part of the image. |
| 3602 | Generally, it is not a good idea to package binaries |
| 3603 | since, among other things, it can hinder the ability to |
| 3604 | reproduce builds and could lead to compatibility problems |
| 3605 | with ABI in the future. |
| 3606 | However, sometimes you have no choice. |
| 3607 | </para> |
| 3608 | |
| 3609 | <para> |
| 3610 | The easiest solution is to create a recipe that uses |
| 3611 | the |
| 3612 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-bin-package'><filename>bin_package</filename></ulink> |
| 3613 | class and to be sure that you are using default locations |
| 3614 | for build artifacts. |
| 3615 | In most cases, the <filename>bin_package</filename> class |
| 3616 | handles "skipping" the configure and compile steps as well |
| 3617 | as sets things up to grab packages from the appropriate |
| 3618 | area. |
| 3619 | In particular, this class sets <filename>noexec</filename> |
| 3620 | on both the |
| 3621 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-configure'><filename>do_configure</filename></ulink> |
| 3622 | and |
| 3623 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-compile'><filename>do_compile</filename></ulink> |
| 3624 | tasks, sets |
| 3625 | <filename>FILES_${PN}</filename> to "/" so that it picks |
| 3626 | up all files, and sets up a |
| 3627 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-install'><filename>do_install</filename></ulink> |
| 3628 | task, which effectively copies all files from |
| 3629 | <filename>${S}</filename> to <filename>${D}</filename>. |
| 3630 | The <filename>bin_package</filename> class works well when |
| 3631 | the files extracted into <filename>${S}</filename> are |
| 3632 | already laid out in the way they should be laid out |
| 3633 | on the target. |
| 3634 | For more information on these variables, see the |
| 3635 | <ulink url='&YOCTO_DOCS_REF_URL;#var-FILES'><filename>FILES</filename></ulink>, |
| 3636 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PN'><filename>PN</filename></ulink>, |
| 3637 | <ulink url='&YOCTO_DOCS_REF_URL;#var-S'><filename>S</filename></ulink>, |
| 3638 | and |
| 3639 | <ulink url='&YOCTO_DOCS_REF_URL;#var-D'><filename>D</filename></ulink> |
| 3640 | variables in the Yocto Project Reference Manual's variable |
| 3641 | glossary. |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 3642 | <note><title>Notes</title> |
| 3643 | <itemizedlist> |
| 3644 | <listitem><para> |
| 3645 | Using |
| 3646 | <ulink url='&YOCTO_DOCS_REF_URL;#var-DEPENDS'><filename>DEPENDS</filename></ulink> |
| 3647 | is a good idea even for components distributed |
| 3648 | in binary form, and is often necessary for |
| 3649 | shared libraries. |
| 3650 | For a shared library, listing the library |
| 3651 | dependencies in |
| 3652 | <filename>DEPENDS</filename> makes sure that |
| 3653 | the libraries are available in the staging |
| 3654 | sysroot when other recipes link against the |
| 3655 | library, which might be necessary for |
| 3656 | successful linking. |
| 3657 | </para></listitem> |
| 3658 | <listitem><para> |
| 3659 | Using <filename>DEPENDS</filename> also |
| 3660 | allows runtime dependencies between packages |
| 3661 | to be added automatically. |
| 3662 | See the |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 3663 | "<ulink url='&YOCTO_DOCS_OM_URL;#automatically-added-runtime-dependencies'>Automatically Added Runtime Dependencies</ulink>" |
| 3664 | section in the Yocto Project Overview and |
| 3665 | Concepts Manual for more information. |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 3666 | </para></listitem> |
| 3667 | </itemizedlist> |
| 3668 | </note> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 3669 | </para> |
| 3670 | |
| 3671 | <para> |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 3672 | If you cannot use the <filename>bin_package</filename> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 3673 | class, you need to be sure you are doing the following: |
| 3674 | <itemizedlist> |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 3675 | <listitem><para> |
| 3676 | Create a recipe where the |
| 3677 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-configure'><filename>do_configure</filename></ulink> |
| 3678 | and |
| 3679 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-compile'><filename>do_compile</filename></ulink> |
| 3680 | tasks do nothing: |
| 3681 | It is usually sufficient to just not define these |
| 3682 | tasks in the recipe, because the default |
| 3683 | implementations do nothing unless a Makefile is |
| 3684 | found in |
| 3685 | <filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-S'><filename>S</filename></ulink><filename>}</filename>. |
| 3686 | </para> |
| 3687 | |
| 3688 | <para>If |
| 3689 | <filename>${S}</filename> might contain a Makefile, |
| 3690 | or if you inherit some class that replaces |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 3691 | <filename>do_configure</filename> and |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 3692 | <filename>do_compile</filename> with custom |
| 3693 | versions, then you can use the |
| 3694 | <filename>[</filename><ulink url='&YOCTO_DOCS_BB_URL;#variable-flags'><filename>noexec</filename></ulink><filename>]</filename> |
| 3695 | flag to turn the tasks into no-ops, as follows: |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 3696 | <literallayout class='monospaced'> |
| 3697 | do_configure[noexec] = "1" |
| 3698 | do_compile[noexec] = "1" |
| 3699 | </literallayout> |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 3700 | Unlike |
| 3701 | <ulink url='&YOCTO_DOCS_BB_URL;#deleting-a-task'><filename>deleting the tasks</filename></ulink>, |
| 3702 | using the flag preserves the dependency chain from |
| 3703 | the |
| 3704 | <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>, |
| 3705 | and |
| 3706 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-patch'><filename>do_patch</filename></ulink> |
| 3707 | tasks to the |
| 3708 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-install'><filename>do_install</filename></ulink> |
| 3709 | task. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 3710 | </para></listitem> |
| 3711 | <listitem><para>Make sure your |
| 3712 | <filename>do_install</filename> task installs the |
| 3713 | binaries appropriately. |
| 3714 | </para></listitem> |
| 3715 | <listitem><para>Ensure that you set up |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 3716 | <ulink url='&YOCTO_DOCS_REF_URL;#var-FILES'><filename>FILES</filename></ulink> |
| 3717 | (usually |
| 3718 | <filename>FILES_${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-PN'><filename>PN</filename></ulink><filename>}</filename>) |
| 3719 | to point to the files you have installed, which of |
| 3720 | course depends on where you have installed them |
| 3721 | and whether those files are in different locations |
| 3722 | than the defaults. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 3723 | </para></listitem> |
| 3724 | </itemizedlist> |
| 3725 | </para> |
| 3726 | </section> |
| 3727 | </section> |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 3728 | |
| 3729 | <section id="following-recipe-style-guidelines"> |
| 3730 | <title>Following Recipe Style Guidelines</title> |
| 3731 | |
| 3732 | <para> |
| 3733 | When writing recipes, it is good to conform to existing |
| 3734 | style guidelines. |
| 3735 | The |
| 3736 | <ulink url='http://www.openembedded.org/wiki/Styleguide'>OpenEmbedded Styleguide</ulink> |
| 3737 | wiki page provides rough guidelines for preferred recipe style. |
| 3738 | </para> |
| 3739 | |
| 3740 | <para> |
| 3741 | It is common for existing recipes to deviate a bit from this |
| 3742 | style. |
| 3743 | However, aiming for at least a consistent style is a good idea. |
| 3744 | Some practices, such as omitting spaces around |
| 3745 | <filename>=</filename> operators in assignments or ordering |
| 3746 | recipe components in an erratic way, are widely seen as poor |
| 3747 | style. |
| 3748 | </para> |
| 3749 | </section> |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 3750 | |
| 3751 | <section id='recipe-syntax'> |
| 3752 | <title>Recipe Syntax</title> |
| 3753 | |
| 3754 | <para> |
| 3755 | Understanding recipe file syntax is important for writing |
| 3756 | recipes. |
| 3757 | The following list overviews the basic items that make up a |
| 3758 | BitBake recipe file. |
| 3759 | For more complete BitBake syntax descriptions, see the |
| 3760 | "<ulink url='&YOCTO_DOCS_BB_URL;#bitbake-user-manual-metadata'>Syntax and Operators</ulink>" |
| 3761 | chapter of the BitBake User Manual. |
| 3762 | <itemizedlist> |
| 3763 | <listitem><para> |
| 3764 | <emphasis>Variable Assignments and Manipulations:</emphasis> |
| 3765 | Variable assignments allow a value to be assigned to a |
| 3766 | variable. |
| 3767 | The assignment can be static text or might include |
| 3768 | the contents of other variables. |
| 3769 | In addition to the assignment, appending and prepending |
| 3770 | operations are also supported.</para> |
| 3771 | |
| 3772 | <para>The following example shows some of the ways |
| 3773 | you can use variables in recipes: |
| 3774 | <literallayout class='monospaced'> |
| 3775 | S = "${WORKDIR}/postfix-${PV}" |
| 3776 | CFLAGS += "-DNO_ASM" |
| 3777 | SRC_URI_append = " file://fixup.patch" |
| 3778 | </literallayout> |
| 3779 | </para></listitem> |
| 3780 | <listitem><para> |
| 3781 | <emphasis>Functions:</emphasis> |
| 3782 | Functions provide a series of actions to be performed. |
| 3783 | You usually use functions to override the default |
| 3784 | implementation of a task function or to complement |
| 3785 | a default function (i.e. append or prepend to an |
| 3786 | existing function). |
| 3787 | Standard functions use <filename>sh</filename> shell |
| 3788 | syntax, although access to OpenEmbedded variables and |
| 3789 | internal methods are also available.</para> |
| 3790 | |
| 3791 | <para>The following is an example function from the |
| 3792 | <filename>sed</filename> recipe: |
| 3793 | <literallayout class='monospaced'> |
| 3794 | do_install () { |
| 3795 | autotools_do_install |
| 3796 | install -d ${D}${base_bindir} |
| 3797 | mv ${D}${bindir}/sed ${D}${base_bindir}/sed |
| 3798 | rmdir ${D}${bindir}/ |
| 3799 | } |
| 3800 | </literallayout> |
| 3801 | It is also possible to implement new functions that |
| 3802 | are called between existing tasks as long as the |
| 3803 | new functions are not replacing or complementing the |
| 3804 | default functions. |
| 3805 | You can implement functions in Python |
| 3806 | instead of shell. |
| 3807 | Both of these options are not seen in the majority of |
| 3808 | recipes. |
| 3809 | </para></listitem> |
| 3810 | <listitem><para><emphasis>Keywords:</emphasis> |
| 3811 | BitBake recipes use only a few keywords. |
| 3812 | You use keywords to include common |
| 3813 | functions (<filename>inherit</filename>), load parts |
| 3814 | of a recipe from other files |
| 3815 | (<filename>include</filename> and |
| 3816 | <filename>require</filename>) and export variables |
| 3817 | to the environment (<filename>export</filename>). |
| 3818 | </para> |
| 3819 | |
| 3820 | <para>The following example shows the use of some of |
| 3821 | these keywords: |
| 3822 | <literallayout class='monospaced'> |
| 3823 | export POSTCONF = "${STAGING_BINDIR}/postconf" |
| 3824 | inherit autoconf |
| 3825 | require otherfile.inc |
| 3826 | </literallayout> |
| 3827 | </para></listitem> |
| 3828 | <listitem><para> |
| 3829 | <emphasis>Comments (#):</emphasis> |
| 3830 | Any lines that begin with the hash character |
| 3831 | (<filename>#</filename>) are treated as comment lines |
| 3832 | and are ignored: |
| 3833 | <literallayout class='monospaced'> |
| 3834 | # This is a comment |
| 3835 | </literallayout> |
| 3836 | </para></listitem> |
| 3837 | </itemizedlist> |
| 3838 | </para> |
| 3839 | |
| 3840 | <para> |
| 3841 | This next list summarizes the most important and most commonly |
| 3842 | used parts of the recipe syntax. |
| 3843 | For more information on these parts of the syntax, you can |
| 3844 | reference the |
| 3845 | <ulink url='&YOCTO_DOCS_BB_URL;#bitbake-user-manual-metadata'>Syntax and Operators</ulink> |
| 3846 | chapter in the BitBake User Manual. |
| 3847 | <itemizedlist> |
| 3848 | <listitem><para> |
| 3849 | <emphasis>Line Continuation (\):</emphasis> |
| 3850 | Use the backward slash (<filename>\</filename>) |
| 3851 | character to split a statement over multiple lines. |
| 3852 | Place the slash character at the end of the line that |
| 3853 | is to be continued on the next line: |
| 3854 | <literallayout class='monospaced'> |
| 3855 | VAR = "A really long \ |
| 3856 | line" |
| 3857 | </literallayout> |
| 3858 | <note> |
| 3859 | You cannot have any characters including spaces |
| 3860 | or tabs after the slash character. |
| 3861 | </note> |
| 3862 | </para></listitem> |
| 3863 | <listitem><para> |
| 3864 | <emphasis>Using Variables (${<replaceable>VARNAME</replaceable>}):</emphasis> |
| 3865 | Use the <filename>${<replaceable>VARNAME</replaceable>}</filename> |
| 3866 | syntax to access the contents of a variable: |
| 3867 | <literallayout class='monospaced'> |
| 3868 | SRC_URI = "${SOURCEFORGE_MIRROR}/libpng/zlib-${PV}.tar.gz" |
| 3869 | </literallayout> |
| 3870 | <note> |
| 3871 | It is important to understand that the value of a |
| 3872 | variable expressed in this form does not get |
| 3873 | substituted automatically. |
| 3874 | The expansion of these expressions happens |
| 3875 | on-demand later (e.g. usually when a function that |
| 3876 | makes reference to the variable executes). |
| 3877 | This behavior ensures that the values are most |
| 3878 | appropriate for the context in which they are |
| 3879 | finally used. |
| 3880 | On the rare occasion that you do need the variable |
| 3881 | expression to be expanded immediately, you can use |
| 3882 | the <filename>:=</filename> operator instead of |
| 3883 | <filename>=</filename> when you make the |
| 3884 | assignment, but this is not generally needed. |
| 3885 | </note> |
| 3886 | </para></listitem> |
| 3887 | <listitem><para> |
| 3888 | <emphasis>Quote All Assignments ("<replaceable>value</replaceable>"):</emphasis> |
| 3889 | Use double quotes around values in all variable |
| 3890 | assignments (e.g. |
| 3891 | <filename>"<replaceable>value</replaceable>"</filename>). |
| 3892 | Following is an example: |
| 3893 | <literallayout class='monospaced'> |
| 3894 | VAR1 = "${OTHERVAR}" |
| 3895 | VAR2 = "The version is ${PV}" |
| 3896 | </literallayout> |
| 3897 | </para></listitem> |
| 3898 | <listitem><para> |
| 3899 | <emphasis>Conditional Assignment (?=):</emphasis> |
| 3900 | Conditional assignment is used to assign a |
| 3901 | value to a variable, but only when the variable is |
| 3902 | currently unset. |
| 3903 | Use the question mark followed by the equal sign |
| 3904 | (<filename>?=</filename>) to make a "soft" assignment |
| 3905 | used for conditional assignment. |
| 3906 | Typically, "soft" assignments are used in the |
| 3907 | <filename>local.conf</filename> file for variables |
| 3908 | that are allowed to come through from the external |
| 3909 | environment. |
| 3910 | </para> |
| 3911 | |
| 3912 | <para>Here is an example where |
| 3913 | <filename>VAR1</filename> is set to "New value" if |
| 3914 | it is currently empty. |
| 3915 | However, if <filename>VAR1</filename> has already been |
| 3916 | set, it remains unchanged: |
| 3917 | <literallayout class='monospaced'> |
| 3918 | VAR1 ?= "New value" |
| 3919 | </literallayout> |
| 3920 | In this next example, <filename>VAR1</filename> |
| 3921 | is left with the value "Original value": |
| 3922 | <literallayout class='monospaced'> |
| 3923 | VAR1 = "Original value" |
| 3924 | VAR1 ?= "New value" |
| 3925 | </literallayout> |
| 3926 | </para></listitem> |
| 3927 | <listitem><para> |
| 3928 | <emphasis>Appending (+=):</emphasis> |
| 3929 | Use the plus character followed by the equals sign |
| 3930 | (<filename>+=</filename>) to append values to existing |
| 3931 | variables. |
| 3932 | <note> |
| 3933 | This operator adds a space between the existing |
| 3934 | content of the variable and the new content. |
| 3935 | </note></para> |
| 3936 | |
| 3937 | <para>Here is an example: |
| 3938 | <literallayout class='monospaced'> |
| 3939 | SRC_URI += "file://fix-makefile.patch" |
| 3940 | </literallayout> |
| 3941 | </para></listitem> |
| 3942 | <listitem><para> |
| 3943 | <emphasis>Prepending (=+):</emphasis> |
| 3944 | Use the equals sign followed by the plus character |
| 3945 | (<filename>=+</filename>) to prepend values to existing |
| 3946 | variables. |
| 3947 | <note> |
| 3948 | This operator adds a space between the new content |
| 3949 | and the existing content of the variable. |
| 3950 | </note></para> |
| 3951 | |
| 3952 | <para>Here is an example: |
| 3953 | <literallayout class='monospaced'> |
| 3954 | VAR =+ "Starts" |
| 3955 | </literallayout> |
| 3956 | </para></listitem> |
| 3957 | <listitem><para> |
| 3958 | <emphasis>Appending (_append):</emphasis> |
| 3959 | Use the <filename>_append</filename> operator to |
| 3960 | append values to existing variables. |
| 3961 | This operator does not add any additional space. |
| 3962 | Also, the operator is applied after all the |
| 3963 | <filename>+=</filename>, and |
| 3964 | <filename>=+</filename> operators have been applied and |
| 3965 | after all <filename>=</filename> assignments have |
| 3966 | occurred. |
| 3967 | </para> |
| 3968 | |
| 3969 | <para>The following example shows the space being |
| 3970 | explicitly added to the start to ensure the appended |
| 3971 | value is not merged with the existing value: |
| 3972 | <literallayout class='monospaced'> |
| 3973 | SRC_URI_append = " file://fix-makefile.patch" |
| 3974 | </literallayout> |
| 3975 | You can also use the <filename>_append</filename> |
| 3976 | operator with overrides, which results in the actions |
| 3977 | only being performed for the specified target or |
| 3978 | machine: |
| 3979 | <literallayout class='monospaced'> |
| 3980 | SRC_URI_append_sh4 = " file://fix-makefile.patch" |
| 3981 | </literallayout> |
| 3982 | </para></listitem> |
| 3983 | <listitem><para> |
| 3984 | <emphasis>Prepending (_prepend):</emphasis> |
| 3985 | Use the <filename>_prepend</filename> operator to |
| 3986 | prepend values to existing variables. |
| 3987 | This operator does not add any additional space. |
| 3988 | Also, the operator is applied after all the |
| 3989 | <filename>+=</filename>, and |
| 3990 | <filename>=+</filename> operators have been applied and |
| 3991 | after all <filename>=</filename> assignments have |
| 3992 | occurred. |
| 3993 | </para> |
| 3994 | |
| 3995 | <para>The following example shows the space being |
| 3996 | explicitly added to the end to ensure the prepended |
| 3997 | value is not merged with the existing value: |
| 3998 | <literallayout class='monospaced'> |
| 3999 | CFLAGS_prepend = "-I${S}/myincludes " |
| 4000 | </literallayout> |
| 4001 | You can also use the <filename>_prepend</filename> |
| 4002 | operator with overrides, which results in the actions |
| 4003 | only being performed for the specified target or |
| 4004 | machine: |
| 4005 | <literallayout class='monospaced'> |
| 4006 | CFLAGS_prepend_sh4 = "-I${S}/myincludes " |
| 4007 | </literallayout> |
| 4008 | </para></listitem> |
| 4009 | <listitem><para> |
| 4010 | <emphasis>Overrides:</emphasis> |
| 4011 | You can use overrides to set a value conditionally, |
| 4012 | typically based on how the recipe is being built. |
| 4013 | For example, to set the |
| 4014 | <ulink url='&YOCTO_DOCS_REF_URL;#var-KBRANCH'><filename>KBRANCH</filename></ulink> |
| 4015 | variable's value to "standard/base" for any target |
| 4016 | <ulink url='&YOCTO_DOCS_REF_URL;#var-MACHINE'><filename>MACHINE</filename></ulink>, |
| 4017 | except for qemuarm where it should be set to |
| 4018 | "standard/arm-versatile-926ejs", you would do the |
| 4019 | following: |
| 4020 | <literallayout class='monospaced'> |
| 4021 | KBRANCH = "standard/base" |
| 4022 | KBRANCH_qemuarm = "standard/arm-versatile-926ejs" |
| 4023 | </literallayout> |
| 4024 | Overrides are also used to separate alternate values |
| 4025 | of a variable in other situations. |
| 4026 | For example, when setting variables such as |
| 4027 | <ulink url='&YOCTO_DOCS_REF_URL;#var-FILES'><filename>FILES</filename></ulink> |
| 4028 | and |
| 4029 | <ulink url='&YOCTO_DOCS_REF_URL;#var-RDEPENDS'><filename>RDEPENDS</filename></ulink> |
| 4030 | that are specific to individual packages produced by |
| 4031 | a recipe, you should always use an override that |
| 4032 | specifies the name of the package. |
| 4033 | </para></listitem> |
| 4034 | <listitem><para> |
| 4035 | <emphasis>Indentation:</emphasis> |
| 4036 | Use spaces for indentation rather than than tabs. |
| 4037 | For shell functions, both currently work. |
| 4038 | However, it is a policy decision of the Yocto Project |
| 4039 | to use tabs in shell functions. |
| 4040 | Realize that some layers have a policy to use spaces |
| 4041 | for all indentation. |
| 4042 | </para></listitem> |
| 4043 | <listitem><para> |
| 4044 | <emphasis>Using Python for Complex Operations:</emphasis> |
| 4045 | For more advanced processing, it is possible to use |
| 4046 | Python code during variable assignments (e.g. |
| 4047 | search and replacement on a variable).</para> |
| 4048 | |
| 4049 | <para>You indicate Python code using the |
| 4050 | <filename>${@<replaceable>python_code</replaceable>}</filename> |
| 4051 | syntax for the variable assignment: |
| 4052 | <literallayout class='monospaced'> |
| 4053 | SRC_URI = "ftp://ftp.info-zip.org/pub/infozip/src/zip${@d.getVar('PV',1).replace('.', '')}.tgz |
| 4054 | </literallayout> |
| 4055 | </para></listitem> |
| 4056 | <listitem><para> |
| 4057 | <emphasis>Shell Function Syntax:</emphasis> |
| 4058 | Write shell functions as if you were writing a shell |
| 4059 | script when you describe a list of actions to take. |
| 4060 | You should ensure that your script works with a generic |
| 4061 | <filename>sh</filename> and that it does not require |
| 4062 | any <filename>bash</filename> or other shell-specific |
| 4063 | functionality. |
| 4064 | The same considerations apply to various system |
| 4065 | utilities (e.g. <filename>sed</filename>, |
| 4066 | <filename>grep</filename>, <filename>awk</filename>, |
| 4067 | and so forth) that you might wish to use. |
| 4068 | If in doubt, you should check with multiple |
| 4069 | implementations - including those from BusyBox. |
| 4070 | </para></listitem> |
| 4071 | </itemizedlist> |
| 4072 | </para> |
| 4073 | </section> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 4074 | </section> |
| 4075 | |
| 4076 | <section id="platdev-newmachine"> |
| 4077 | <title>Adding a New Machine</title> |
| 4078 | |
| 4079 | <para> |
| 4080 | Adding a new machine to the Yocto Project is a straightforward |
| 4081 | process. |
| 4082 | This section describes how to add machines that are similar |
| 4083 | to those that the Yocto Project already supports. |
| 4084 | <note> |
| 4085 | Although well within the capabilities of the Yocto Project, |
| 4086 | adding a totally new architecture might require |
| 4087 | changes to <filename>gcc/glibc</filename> and to the site |
| 4088 | information, which is beyond the scope of this manual. |
| 4089 | </note> |
| 4090 | </para> |
| 4091 | |
| 4092 | <para> |
| 4093 | For a complete example that shows how to add a new machine, |
| 4094 | see the |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 4095 | "<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>" |
| 4096 | section in the Yocto Project Board Support Package (BSP) |
| 4097 | Developer's Guide. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 4098 | </para> |
| 4099 | |
| 4100 | <section id="platdev-newmachine-conffile"> |
| 4101 | <title>Adding the Machine Configuration File</title> |
| 4102 | |
| 4103 | <para> |
| 4104 | To add a new machine, you need to add a new machine |
| 4105 | configuration file to the layer's |
| 4106 | <filename>conf/machine</filename> directory. |
| 4107 | This configuration file provides details about the device |
| 4108 | you are adding. |
| 4109 | </para> |
| 4110 | |
| 4111 | <para> |
| 4112 | The OpenEmbedded build system uses the root name of the |
| 4113 | machine configuration file to reference the new machine. |
| 4114 | For example, given a machine configuration file named |
| 4115 | <filename>crownbay.conf</filename>, the build system |
| 4116 | recognizes the machine as "crownbay". |
| 4117 | </para> |
| 4118 | |
| 4119 | <para> |
| 4120 | The most important variables you must set in your machine |
| 4121 | configuration file or include from a lower-level configuration |
| 4122 | file are as follows: |
| 4123 | <itemizedlist> |
| 4124 | <listitem><para><filename><ulink url='&YOCTO_DOCS_REF_URL;#var-TARGET_ARCH'>TARGET_ARCH</ulink></filename> |
| 4125 | (e.g. "arm")</para></listitem> |
| 4126 | <listitem><para><filename><ulink url='&YOCTO_DOCS_REF_URL;#var-PREFERRED_PROVIDER'>PREFERRED_PROVIDER</ulink>_virtual/kernel</filename> |
| 4127 | </para></listitem> |
| 4128 | <listitem><para><filename><ulink url='&YOCTO_DOCS_REF_URL;#var-MACHINE_FEATURES'>MACHINE_FEATURES</ulink></filename> |
| 4129 | (e.g. "apm screen wifi")</para></listitem> |
| 4130 | </itemizedlist> |
| 4131 | </para> |
| 4132 | |
| 4133 | <para> |
| 4134 | You might also need these variables: |
| 4135 | <itemizedlist> |
| 4136 | <listitem><para><filename><ulink url='&YOCTO_DOCS_REF_URL;#var-SERIAL_CONSOLES'>SERIAL_CONSOLES</ulink></filename> |
| 4137 | (e.g. "115200;ttyS0 115200;ttyS1")</para></listitem> |
| 4138 | <listitem><para><filename><ulink url='&YOCTO_DOCS_REF_URL;#var-KERNEL_IMAGETYPE'>KERNEL_IMAGETYPE</ulink></filename> |
| 4139 | (e.g. "zImage")</para></listitem> |
| 4140 | <listitem><para><filename><ulink url='&YOCTO_DOCS_REF_URL;#var-IMAGE_FSTYPES'>IMAGE_FSTYPES</ulink></filename> |
| 4141 | (e.g. "tar.gz jffs2")</para></listitem> |
| 4142 | </itemizedlist> |
| 4143 | </para> |
| 4144 | |
| 4145 | <para> |
| 4146 | You can find full details on these variables in the reference |
| 4147 | section. |
| 4148 | You can leverage existing machine <filename>.conf</filename> |
| 4149 | files from <filename>meta-yocto-bsp/conf/machine/</filename>. |
| 4150 | </para> |
| 4151 | </section> |
| 4152 | |
| 4153 | <section id="platdev-newmachine-kernel"> |
| 4154 | <title>Adding a Kernel for the Machine</title> |
| 4155 | |
| 4156 | <para> |
| 4157 | The OpenEmbedded build system needs to be able to build a kernel |
| 4158 | for the machine. |
| 4159 | You need to either create a new kernel recipe for this machine, |
| 4160 | or extend an existing kernel recipe. |
| 4161 | You can find several kernel recipe examples in the |
| 4162 | Source Directory at |
| 4163 | <filename>meta/recipes-kernel/linux</filename> |
| 4164 | that you can use as references. |
| 4165 | </para> |
| 4166 | |
| 4167 | <para> |
| 4168 | If you are creating a new kernel recipe, normal recipe-writing |
| 4169 | rules apply for setting up a |
| 4170 | <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'>SRC_URI</ulink></filename>. |
| 4171 | Thus, you need to specify any necessary patches and set |
| 4172 | <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-S'>S</ulink></filename> |
| 4173 | to point at the source code. |
| 4174 | You need to create a <filename>do_configure</filename> task that |
| 4175 | configures the unpacked kernel with a |
| 4176 | <filename>defconfig</filename> file. |
| 4177 | You can do this by using a <filename>make defconfig</filename> |
| 4178 | command or, more commonly, by copying in a suitable |
| 4179 | <filename>defconfig</filename> file and then running |
| 4180 | <filename>make oldconfig</filename>. |
| 4181 | By making use of <filename>inherit kernel</filename> and |
| 4182 | potentially some of the <filename>linux-*.inc</filename> files, |
| 4183 | most other functionality is centralized and the defaults of the |
| 4184 | class normally work well. |
| 4185 | </para> |
| 4186 | |
| 4187 | <para> |
| 4188 | If you are extending an existing kernel recipe, it is usually |
| 4189 | a matter of adding a suitable <filename>defconfig</filename> |
| 4190 | file. |
| 4191 | The file needs to be added into a location similar to |
| 4192 | <filename>defconfig</filename> files used for other machines |
| 4193 | in a given kernel recipe. |
| 4194 | A possible way to do this is by listing the file in the |
| 4195 | <filename>SRC_URI</filename> and adding the machine to the |
| 4196 | expression in |
| 4197 | <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-COMPATIBLE_MACHINE'>COMPATIBLE_MACHINE</ulink></filename>: |
| 4198 | <literallayout class='monospaced'> |
| 4199 | COMPATIBLE_MACHINE = '(qemux86|qemumips)' |
| 4200 | </literallayout> |
| 4201 | For more information on <filename>defconfig</filename> files, |
| 4202 | see the |
| 4203 | "<ulink url='&YOCTO_DOCS_KERNEL_DEV_URL;#changing-the-configuration'>Changing the Configuration</ulink>" |
| 4204 | section in the Yocto Project Linux Kernel Development Manual. |
| 4205 | </para> |
| 4206 | </section> |
| 4207 | |
| 4208 | <section id="platdev-newmachine-formfactor"> |
| 4209 | <title>Adding a Formfactor Configuration File</title> |
| 4210 | |
| 4211 | <para> |
| 4212 | A formfactor configuration file provides information about the |
| 4213 | target hardware for which the image is being built and information that |
| 4214 | the build system cannot obtain from other sources such as the kernel. |
| 4215 | Some examples of information contained in a formfactor configuration file include |
| 4216 | framebuffer orientation, whether or not the system has a keyboard, |
| 4217 | the positioning of the keyboard in relation to the screen, and |
| 4218 | the screen resolution. |
| 4219 | </para> |
| 4220 | |
| 4221 | <para> |
| 4222 | The build system uses reasonable defaults in most cases. |
| 4223 | However, if customization is |
| 4224 | necessary, you need to create a <filename>machconfig</filename> file |
| 4225 | in the <filename>meta/recipes-bsp/formfactor/files</filename> |
| 4226 | directory. |
| 4227 | This directory contains directories for specific machines such as |
| 4228 | <filename>qemuarm</filename> and <filename>qemux86</filename>. |
| 4229 | For information about the settings available and the defaults, see the |
| 4230 | <filename>meta/recipes-bsp/formfactor/files/config</filename> file found in the |
| 4231 | same area. |
| 4232 | </para> |
| 4233 | |
| 4234 | <para> |
| 4235 | Following is an example for "qemuarm" machine: |
| 4236 | <literallayout class='monospaced'> |
| 4237 | HAVE_TOUCHSCREEN=1 |
| 4238 | HAVE_KEYBOARD=1 |
| 4239 | |
| 4240 | DISPLAY_CAN_ROTATE=0 |
| 4241 | DISPLAY_ORIENTATION=0 |
| 4242 | #DISPLAY_WIDTH_PIXELS=640 |
| 4243 | #DISPLAY_HEIGHT_PIXELS=480 |
| 4244 | #DISPLAY_BPP=16 |
| 4245 | DISPLAY_DPI=150 |
| 4246 | DISPLAY_SUBPIXEL_ORDER=vrgb |
| 4247 | </literallayout> |
| 4248 | </para> |
| 4249 | </section> |
| 4250 | </section> |
| 4251 | |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 4252 | <section id='gs-upgrading-recipes'> |
| 4253 | <title>Upgrading Recipes</title> |
| 4254 | |
| 4255 | <para> |
| 4256 | Over time, upstream developers publish new versions for software |
| 4257 | built by layer recipes. |
| 4258 | It is recommended to keep recipes up-to-date with upstream |
| 4259 | version releases. |
Brad Bishop | 15ae250 | 2019-06-18 21:44:24 -0400 | [diff] [blame] | 4260 | </para> |
| 4261 | |
| 4262 | <para> |
| 4263 | While several methods exist that allow you upgrade a recipe, |
| 4264 | you might consider checking on the upgrade status of a recipe |
| 4265 | first. |
| 4266 | You can do so using the |
| 4267 | <filename>devtool check-upgrade-status</filename> command. |
| 4268 | See the |
| 4269 | "<ulink url='&YOCTO_DOCS_REF_URL;#devtool-checking-on-the-upgrade-status-of-a-recipe'>Checking on the Upgrade Status of a Recipe</ulink>" |
| 4270 | section in the Yocto Project Reference Manual for more information. |
| 4271 | </para> |
| 4272 | |
| 4273 | <para> |
| 4274 | The remainder of this section describes three ways you can |
| 4275 | upgrade a recipe. |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 4276 | You can use the Automated Upgrade Helper (AUH) to set up |
| 4277 | automatic version upgrades. |
| 4278 | Alternatively, you can use <filename>devtool upgrade</filename> |
| 4279 | to set up semi-automatic version upgrades. |
Brad Bishop | 15ae250 | 2019-06-18 21:44:24 -0400 | [diff] [blame] | 4280 | Finally, you can manually upgrade a recipe by editing the |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 4281 | recipe itself. |
| 4282 | </para> |
| 4283 | |
| 4284 | <section id='gs-using-the-auto-upgrade-helper'> |
| 4285 | <title>Using the Auto Upgrade Helper (AUH)</title> |
| 4286 | |
| 4287 | <para> |
| 4288 | The AUH utility works in conjunction with the |
| 4289 | OpenEmbedded build system in order to automatically generate |
| 4290 | upgrades for recipes based on new versions being |
| 4291 | published upstream. |
| 4292 | Use AUH when you want to create a service that performs the |
| 4293 | upgrades automatically and optionally sends you an email with |
| 4294 | the results. |
| 4295 | </para> |
| 4296 | |
| 4297 | <para> |
| 4298 | AUH allows you to update several recipes with a single use. |
| 4299 | You can also optionally perform build and integration tests |
| 4300 | using images with the results saved to your hard drive and |
| 4301 | emails of results optionally sent to recipe maintainers. |
| 4302 | Finally, AUH creates Git commits with appropriate commit |
| 4303 | messages in the layer's tree for the changes made to recipes. |
| 4304 | <note> |
| 4305 | Conditions do exist when you should not use AUH to upgrade |
| 4306 | recipes and you should instead use either |
| 4307 | <filename>devtool upgrade</filename> or upgrade your |
| 4308 | recipes manually: |
| 4309 | <itemizedlist> |
| 4310 | <listitem><para> |
| 4311 | When AUH cannot complete the upgrade sequence. |
| 4312 | This situation usually results because custom |
| 4313 | patches carried by the recipe cannot be |
| 4314 | automatically rebased to the new version. |
| 4315 | In this case, <filename>devtool upgrade</filename> |
| 4316 | allows you to manually resolve conflicts. |
| 4317 | </para></listitem> |
| 4318 | <listitem><para> |
| 4319 | When for any reason you want fuller control over |
| 4320 | the upgrade process. |
| 4321 | For example, when you want special arrangements |
| 4322 | for testing. |
| 4323 | </para></listitem> |
| 4324 | </itemizedlist> |
| 4325 | </note> |
| 4326 | </para> |
| 4327 | |
| 4328 | <para> |
| 4329 | The following steps describe how to set up the AUH utility: |
| 4330 | <orderedlist> |
| 4331 | <listitem><para> |
| 4332 | <emphasis>Be Sure the Development Host is Set Up:</emphasis> |
| 4333 | You need to be sure that your development host is |
| 4334 | set up to use the Yocto Project. |
| 4335 | For information on how to set up your host, see the |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 4336 | "<link linkend='dev-preparing-the-build-host'>Preparing the Build Host</link>" |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 4337 | section. |
| 4338 | </para></listitem> |
| 4339 | <listitem><para> |
| 4340 | <emphasis>Make Sure Git is Configured:</emphasis> |
| 4341 | The AUH utility requires Git to be configured because |
| 4342 | AUH uses Git to save upgrades. |
| 4343 | Thus, you must have Git user and email configured. |
| 4344 | The following command shows your configurations: |
| 4345 | <literallayout class='monospaced'> |
| 4346 | $ git config --list |
| 4347 | </literallayout> |
| 4348 | If you do not have the user and email configured, you |
| 4349 | can use the following commands to do so: |
| 4350 | <literallayout class='monospaced'> |
| 4351 | $ git config --global user.name <replaceable>some_name</replaceable> |
| 4352 | $ git config --global user.email <replaceable>username</replaceable>@<replaceable>domain</replaceable>.com |
| 4353 | </literallayout> |
| 4354 | </para></listitem> |
| 4355 | <listitem><para> |
| 4356 | <emphasis>Clone the AUH Repository:</emphasis> |
| 4357 | To use AUH, you must clone the repository onto your |
| 4358 | development host. |
| 4359 | The following command uses Git to create a local |
| 4360 | copy of the repository on your system: |
| 4361 | <literallayout class='monospaced'> |
| 4362 | $ git clone git://git.yoctoproject.org/auto-upgrade-helper |
| 4363 | Cloning into 'auto-upgrade-helper'... |
| 4364 | remote: Counting objects: 768, done. |
| 4365 | remote: Compressing objects: 100% (300/300), done. |
| 4366 | remote: Total 768 (delta 499), reused 703 (delta 434) |
| 4367 | Receiving objects: 100% (768/768), 191.47 KiB | 98.00 KiB/s, done. |
| 4368 | Resolving deltas: 100% (499/499), done. |
| 4369 | Checking connectivity... done. |
| 4370 | </literallayout> |
| 4371 | AUH is not part of the |
| 4372 | <ulink url='&YOCTO_DOCS_REF_URL;#oe-core'>OpenEmbedded-Core (OE-Core)</ulink> |
| 4373 | or |
| 4374 | <ulink url='&YOCTO_DOCS_REF_URL;#poky'>Poky</ulink> |
| 4375 | repositories. |
| 4376 | </para></listitem> |
| 4377 | <listitem><para> |
| 4378 | <emphasis>Create a Dedicated Build Directory:</emphasis> |
| 4379 | Run the |
| 4380 | <ulink url='&YOCTO_DOCS_REF_URL;#structure-core-script'><filename>oe-init-build-env</filename></ulink> |
| 4381 | script to create a fresh build directory that you |
| 4382 | use exclusively for running the AUH utility: |
| 4383 | <literallayout class='monospaced'> |
| 4384 | $ cd ~/poky |
| 4385 | $ source oe-init-build-env <replaceable>your_AUH_build_directory</replaceable> |
| 4386 | </literallayout> |
| 4387 | Re-using an existing build directory and its |
| 4388 | configurations is not recommended as existing settings |
| 4389 | could cause AUH to fail or behave undesirably. |
| 4390 | </para></listitem> |
| 4391 | <listitem><para> |
| 4392 | <emphasis>Make Configurations in Your Local Configuration File:</emphasis> |
| 4393 | Several settings need to exist in the |
| 4394 | <filename>local.conf</filename> file in the build |
| 4395 | directory you just created for AUH. |
| 4396 | Make these following configurations: |
| 4397 | <itemizedlist> |
| 4398 | <listitem><para> |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 4399 | If you want to enable |
| 4400 | <ulink url='&YOCTO_DOCS_DEV_URL;#maintaining-build-output-quality'>Build History</ulink>, |
| 4401 | which is optional, you need the following |
| 4402 | lines in the |
| 4403 | <filename>conf/local.conf</filename> file: |
| 4404 | <literallayout class='monospaced'> |
| 4405 | INHERIT =+ "buildhistory" |
| 4406 | BUILDHISTORY_COMMIT = "1" |
| 4407 | </literallayout> |
| 4408 | With this configuration and a successful |
| 4409 | upgrade, a build history "diff" file appears in |
| 4410 | the |
| 4411 | <filename>upgrade-helper/work/recipe/buildhistory-diff.txt</filename> |
| 4412 | file found in your build directory. |
| 4413 | </para></listitem> |
| 4414 | <listitem><para> |
| 4415 | If you want to enable testing through the |
| 4416 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-testimage*'><filename>testimage</filename></ulink> |
| 4417 | class, which is optional, you need to have the |
| 4418 | following set in your |
| 4419 | <filename>conf/local.conf</filename> file: |
| 4420 | <literallayout class='monospaced'> |
| 4421 | INHERIT += "testimage" |
| 4422 | </literallayout> |
| 4423 | <note> |
| 4424 | If your distro does not enable by default |
| 4425 | ptest, which Poky does, you need the |
| 4426 | following in your |
| 4427 | <filename>local.conf</filename> file: |
| 4428 | <literallayout class='monospaced'> |
| 4429 | DISTRO_FEATURES_append = " ptest" |
| 4430 | </literallayout> |
| 4431 | </note> |
| 4432 | </para></listitem> |
| 4433 | </itemizedlist> |
| 4434 | </para></listitem> |
| 4435 | <listitem><para> |
| 4436 | <emphasis>Optionally Start a vncserver:</emphasis> |
| 4437 | If you are running in a server without an X11 session, |
| 4438 | you need to start a vncserver: |
| 4439 | <literallayout class='monospaced'> |
| 4440 | $ vncserver :1 |
| 4441 | $ export DISPLAY=:1 |
| 4442 | </literallayout> |
| 4443 | </para></listitem> |
| 4444 | <listitem><para> |
| 4445 | <emphasis>Create and Edit an AUH Configuration File:</emphasis> |
| 4446 | You need to have the |
| 4447 | <filename>upgrade-helper/upgrade-helper.conf</filename> |
| 4448 | configuration file in your build directory. |
| 4449 | You can find a sample configuration file in the |
| 4450 | <ulink url='http://git.yoctoproject.org/cgit/cgit.cgi/auto-upgrade-helper/tree/'>AUH source repository</ulink>. |
| 4451 | </para> |
| 4452 | |
| 4453 | <para>Read through the sample file and make |
| 4454 | configurations as needed. |
| 4455 | For example, if you enabled build history in your |
| 4456 | <filename>local.conf</filename> as described earlier, |
| 4457 | you must enable it in |
| 4458 | <filename>upgrade-helper.conf</filename>.</para> |
| 4459 | |
| 4460 | <para>Also, if you are using the default |
| 4461 | <filename>maintainers.inc</filename> file supplied |
| 4462 | with Poky and located in |
| 4463 | <filename>meta-yocto</filename> and you do not set a |
| 4464 | "maintainers_whitelist" or "global_maintainer_override" |
| 4465 | in the <filename>upgrade-helper.conf</filename> |
| 4466 | configuration, and you specify "-e all" on the |
| 4467 | AUH command-line, the utility automatically sends out |
| 4468 | emails to all the default maintainers. |
| 4469 | Please avoid this. |
| 4470 | </para></listitem> |
| 4471 | </orderedlist> |
| 4472 | </para> |
| 4473 | |
| 4474 | <para> |
| 4475 | This next set of examples describes how to use the AUH: |
| 4476 | <itemizedlist> |
| 4477 | <listitem><para> |
| 4478 | <emphasis>Upgrading a Specific Recipe:</emphasis> |
| 4479 | To upgrade a specific recipe, use the following |
| 4480 | form: |
| 4481 | <literallayout class='monospaced'> |
| 4482 | $ upgrade-helper.py <replaceable>recipe_name</replaceable> |
| 4483 | </literallayout> |
| 4484 | For example, this command upgrades the |
| 4485 | <filename>xmodmap</filename> recipe: |
| 4486 | <literallayout class='monospaced'> |
| 4487 | $ upgrade-helper.py xmodmap |
| 4488 | </literallayout> |
| 4489 | </para></listitem> |
| 4490 | <listitem><para> |
| 4491 | <emphasis>Upgrading a Specific Recipe to a Particular Version:</emphasis> |
| 4492 | To upgrade a specific recipe to a particular version, |
| 4493 | use the following form: |
| 4494 | <literallayout class='monospaced'> |
| 4495 | $ upgrade-helper.py <replaceable>recipe_name</replaceable> -t <replaceable>version</replaceable> |
| 4496 | </literallayout> |
| 4497 | For example, this command upgrades the |
| 4498 | <filename>xmodmap</filename> recipe to version |
| 4499 | 1.2.3: |
| 4500 | <literallayout class='monospaced'> |
| 4501 | $ upgrade-helper.py xmodmap -t 1.2.3 |
| 4502 | </literallayout> |
| 4503 | </para></listitem> |
| 4504 | <listitem><para> |
| 4505 | <emphasis>Upgrading all Recipes to the Latest Versions and Suppressing Email Notifications:</emphasis> |
| 4506 | To upgrade all recipes to their most recent versions |
| 4507 | and suppress the email notifications, use the following |
| 4508 | command: |
| 4509 | <literallayout class='monospaced'> |
| 4510 | $ upgrade-helper.py all |
| 4511 | </literallayout> |
| 4512 | </para></listitem> |
| 4513 | <listitem><para> |
| 4514 | <emphasis>Upgrading all Recipes to the Latest Versions and Send Email Notifications:</emphasis> |
| 4515 | To upgrade all recipes to their most recent versions |
| 4516 | and send email messages to maintainers for each |
| 4517 | attempted recipe as well as a status email, use the |
| 4518 | following command: |
| 4519 | <literallayout class='monospaced'> |
| 4520 | $ upgrade-helper.py -e all |
| 4521 | </literallayout> |
| 4522 | </para></listitem> |
| 4523 | </itemizedlist> |
| 4524 | </para> |
| 4525 | |
| 4526 | <para> |
| 4527 | Once you have run the AUH utility, you can find the results |
| 4528 | in the AUH build directory: |
| 4529 | <literallayout class='monospaced'> |
| 4530 | ${BUILDDIR}/upgrade-helper/<replaceable>timestamp</replaceable> |
| 4531 | </literallayout> |
| 4532 | The AUH utility also creates recipe update commits from |
| 4533 | successful upgrade attempts in the layer tree. |
| 4534 | </para> |
| 4535 | |
| 4536 | <para> |
| 4537 | You can easily set up to run the AUH utility on a regular |
| 4538 | basis by using a cron job. |
| 4539 | See the |
| 4540 | <ulink url='http://git.yoctoproject.org/cgit/cgit.cgi/auto-upgrade-helper/tree/weeklyjob.sh'><filename>weeklyjob.sh</filename></ulink> |
| 4541 | file distributed with the utility for an example. |
| 4542 | </para> |
| 4543 | </section> |
| 4544 | |
| 4545 | <section id='gs-using-devtool-upgrade'> |
| 4546 | <title>Using <filename>devtool upgrade</filename></title> |
| 4547 | |
| 4548 | <para> |
| 4549 | As mentioned earlier, an alternative method for upgrading |
| 4550 | recipes to newer versions is to use |
| 4551 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-devtool-reference'><filename>devtool upgrade</filename></ulink>. |
| 4552 | You can read about <filename>devtool upgrade</filename> in |
| 4553 | general in the |
| 4554 | "<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>" |
| 4555 | section in the Yocto Project Application Development and the |
| 4556 | Extensible Software Development Kit (eSDK) Manual. |
| 4557 | </para> |
| 4558 | |
| 4559 | <para> |
| 4560 | To see all the command-line options available with |
| 4561 | <filename>devtool upgrade</filename>, use the following help |
| 4562 | command: |
| 4563 | <literallayout class='monospaced'> |
| 4564 | $ devtool upgrade -h |
| 4565 | </literallayout> |
| 4566 | </para> |
| 4567 | |
| 4568 | <para> |
| 4569 | If you want to find out what version a recipe is currently at |
| 4570 | upstream without any attempt to upgrade your local version of |
| 4571 | the recipe, you can use the following command: |
| 4572 | <literallayout class='monospaced'> |
| 4573 | $ devtool latest-version <replaceable>recipe_name</replaceable> |
| 4574 | </literallayout> |
| 4575 | </para> |
| 4576 | |
| 4577 | <para> |
| 4578 | As mentioned in the previous section describing AUH, |
| 4579 | <filename>devtool upgrade</filename> works in a |
| 4580 | less-automated manner than AUH. |
| 4581 | Specifically, <filename>devtool upgrade</filename> only |
| 4582 | works on a single recipe that you name on the command line, |
| 4583 | cannot perform build and integration testing using images, |
| 4584 | and does not automatically generate commits for changes in |
| 4585 | the source tree. |
| 4586 | Despite all these "limitations", |
| 4587 | <filename>devtool upgrade</filename> updates the recipe file |
| 4588 | to the new upstream version and attempts to rebase custom |
| 4589 | patches contained by the recipe as needed. |
| 4590 | <note> |
| 4591 | AUH uses much of <filename>devtool upgrade</filename> |
| 4592 | behind the scenes making AUH somewhat of a "wrapper" |
| 4593 | application for <filename>devtool upgrade</filename>. |
| 4594 | </note> |
| 4595 | </para> |
| 4596 | |
| 4597 | <para> |
| 4598 | A typical scenario involves having used Git to clone an |
| 4599 | upstream repository that you use during build operations. |
| 4600 | Because you are (or have) built the recipe in the past, the |
| 4601 | layer is likely added to your configuration already. |
| 4602 | If for some reason, the layer is not added, you could add |
| 4603 | it easily using the |
| 4604 | <ulink url='&YOCTO_DOCS_BSP_URL;#creating-a-new-bsp-layer-using-the-bitbake-layers-script'><filename>bitbake-layers</filename></ulink> |
| 4605 | script. |
| 4606 | For example, suppose you use the <filename>nano.bb</filename> |
| 4607 | recipe from the <filename>meta-oe</filename> layer in the |
| 4608 | <filename>meta-openembedded</filename> repository. |
| 4609 | For this example, assume that the layer has been cloned into |
| 4610 | following area: |
| 4611 | <literallayout class='monospaced'> |
| 4612 | /home/scottrif/meta-openembedded |
| 4613 | </literallayout> |
| 4614 | The following command from your |
| 4615 | <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink> |
| 4616 | adds the layer to your build configuration (i.e. |
| 4617 | <filename>${BUILDDIR}/conf/bblayers.conf</filename>): |
| 4618 | <literallayout class='monospaced'> |
| 4619 | $ bitbake-layers add-layer /home/scottrif/meta-openembedded/meta-oe |
| 4620 | NOTE: Starting bitbake server... |
| 4621 | Parsing recipes: 100% |##########################################| Time: 0:00:55 |
| 4622 | Parsing of 1431 .bb files complete (0 cached, 1431 parsed). 2040 targets, 56 skipped, 0 masked, 0 errors. |
| 4623 | Removing 12 recipes from the x86_64 sysroot: 100% |##############| Time: 0:00:00 |
| 4624 | Removing 1 recipes from the x86_64_i586 sysroot: 100% |##########| Time: 0:00:00 |
| 4625 | Removing 5 recipes from the i586 sysroot: 100% |#################| Time: 0:00:00 |
| 4626 | Removing 5 recipes from the qemux86 sysroot: 100% |##############| Time: 0:00:00 |
| 4627 | </literallayout> |
| 4628 | For this example, assume that the <filename>nano.bb</filename> |
| 4629 | recipe that is upstream has a 2.9.3 version number. |
| 4630 | However, the version in the local repository is 2.7.4. |
| 4631 | The following command from your build directory automatically |
| 4632 | upgrades the recipe for you: |
| 4633 | <note> |
| 4634 | Using the <filename>-V</filename> option is not necessary. |
| 4635 | Omitting the version number causes |
| 4636 | <filename>devtool upgrade</filename> to upgrade the recipe |
| 4637 | to the most recent version. |
| 4638 | </note> |
| 4639 | <literallayout class='monospaced'> |
| 4640 | $ devtool upgrade nano -V 2.9.3 |
| 4641 | NOTE: Starting bitbake server... |
| 4642 | NOTE: Creating workspace layer in /home/scottrif/poky/build/workspace |
| 4643 | Parsing recipes: 100% |##########################################| Time: 0:00:46 |
| 4644 | Parsing of 1431 .bb files complete (0 cached, 1431 parsed). 2040 targets, 56 skipped, 0 masked, 0 errors. |
| 4645 | NOTE: Extracting current version source... |
| 4646 | NOTE: Resolving any missing task queue dependencies |
| 4647 | . |
| 4648 | . |
| 4649 | . |
| 4650 | NOTE: Executing SetScene Tasks |
| 4651 | NOTE: Executing RunQueue Tasks |
| 4652 | NOTE: Tasks Summary: Attempted 74 tasks of which 72 didn't need to be rerun and all succeeded. |
| 4653 | Adding changed files: 100% |#####################################| Time: 0:00:00 |
| 4654 | NOTE: Upgraded source extracted to /home/scottrif/poky/build/workspace/sources/nano |
| 4655 | NOTE: New recipe is /home/scottrif/poky/build/workspace/recipes/nano/nano_2.9.3.bb |
| 4656 | </literallayout> |
| 4657 | Continuing with this example, you can use |
| 4658 | <filename>devtool build</filename> to build the newly upgraded |
| 4659 | recipe: |
| 4660 | <literallayout class='monospaced'> |
| 4661 | $ devtool build nano |
| 4662 | NOTE: Starting bitbake server... |
| 4663 | Loading cache: 100% |################################################################################################| Time: 0:00:01 |
| 4664 | Loaded 2040 entries from dependency cache. |
| 4665 | Parsing recipes: 100% |##############################################################################################| Time: 0:00:00 |
| 4666 | Parsing of 1432 .bb files complete (1431 cached, 1 parsed). 2041 targets, 56 skipped, 0 masked, 0 errors. |
| 4667 | NOTE: Resolving any missing task queue dependencies |
| 4668 | . |
| 4669 | . |
| 4670 | . |
| 4671 | NOTE: Executing SetScene Tasks |
| 4672 | NOTE: Executing RunQueue Tasks |
| 4673 | NOTE: nano: compiling from external source tree /home/scottrif/poky/build/workspace/sources/nano |
| 4674 | NOTE: Tasks Summary: Attempted 520 tasks of which 304 didn't need to be rerun and all succeeded. |
| 4675 | </literallayout> |
| 4676 | Within the <filename>devtool upgrade</filename> workflow, |
| 4677 | opportunity exists to deploy and test your rebuilt software. |
| 4678 | For this example, however, running |
| 4679 | <filename>devtool finish</filename> cleans up the workspace |
| 4680 | once the source in your workspace is clean. |
| 4681 | This usually means using Git to stage and submit commits |
| 4682 | for the changes generated by the upgrade process. |
| 4683 | </para> |
| 4684 | |
| 4685 | <para> |
| 4686 | Once the tree is clean, you can clean things up in this |
| 4687 | example with the following command from the |
| 4688 | <filename>${BUILDDIR}/workspace/sources/nano</filename> |
| 4689 | directory: |
| 4690 | <literallayout class='monospaced'> |
| 4691 | $ devtool finish nano meta-oe |
| 4692 | NOTE: Starting bitbake server... |
| 4693 | Loading cache: 100% |################################################################################################| Time: 0:00:00 |
| 4694 | Loaded 2040 entries from dependency cache. |
| 4695 | Parsing recipes: 100% |##############################################################################################| Time: 0:00:01 |
| 4696 | Parsing of 1432 .bb files complete (1431 cached, 1 parsed). 2041 targets, 56 skipped, 0 masked, 0 errors. |
| 4697 | NOTE: Adding new patch 0001-nano.bb-Stuff-I-changed-when-upgrading-nano.bb.patch |
| 4698 | NOTE: Updating recipe nano_2.9.3.bb |
| 4699 | NOTE: Removing file /home/scottrif/meta-openembedded/meta-oe/recipes-support/nano/nano_2.7.4.bb |
| 4700 | NOTE: Moving recipe file to /home/scottrif/meta-openembedded/meta-oe/recipes-support/nano |
| 4701 | NOTE: Leaving source tree /home/scottrif/poky/build/workspace/sources/nano as-is; if you no longer need it then please delete it manually |
| 4702 | </literallayout> |
| 4703 | Using the <filename>devtool finish</filename> command cleans |
| 4704 | up the workspace and creates a patch file based on your |
| 4705 | commits. |
| 4706 | The tool puts all patch files back into the source directory |
| 4707 | in a sub-directory named <filename>nano</filename> in this |
| 4708 | case. |
| 4709 | </para> |
| 4710 | </section> |
| 4711 | |
| 4712 | <section id='dev-manually-upgrading-a-recipe'> |
| 4713 | <title>Manually Upgrading a Recipe</title> |
| 4714 | |
| 4715 | <para> |
| 4716 | If for some reason you choose not to upgrade recipes using the |
| 4717 | <link linkend='gs-using-the-auto-upgrade-helper'>Auto Upgrade Helper (AUH)</link> |
| 4718 | or by using |
| 4719 | <link linkend='gs-using-devtool-upgrade'><filename>devtool upgrade</filename></link>, |
| 4720 | you can manually edit the recipe files to upgrade the versions. |
| 4721 | <note><title>Caution</title> |
| 4722 | Manually updating multiple recipes scales poorly and |
| 4723 | involves many steps. |
| 4724 | The recommendation to upgrade recipe versions is through |
| 4725 | AUH or <filename>devtool upgrade</filename>, both of which |
| 4726 | automate some steps and provide guidance for others needed |
| 4727 | for the manual process. |
| 4728 | </note> |
| 4729 | </para> |
| 4730 | |
| 4731 | <para> |
| 4732 | To manually upgrade recipe versions, follow these general steps: |
| 4733 | <orderedlist> |
| 4734 | <listitem><para> |
| 4735 | <emphasis>Change the Version:</emphasis> |
| 4736 | Rename the recipe such that the version (i.e. the |
| 4737 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PV'><filename>PV</filename></ulink> |
| 4738 | part of the recipe name) changes appropriately. |
| 4739 | If the version is not part of the recipe name, change |
| 4740 | the value as it is set for <filename>PV</filename> |
| 4741 | within the recipe itself. |
| 4742 | </para></listitem> |
| 4743 | <listitem><para> |
| 4744 | <emphasis>Update <filename>SRCREV</filename> if Needed:</emphasis> |
| 4745 | If the source code your recipe builds is fetched from |
| 4746 | Git or some other version control system, update |
| 4747 | <ulink url='&YOCTO_DOCS_REF_URL;#var-SRCREV'><filename>SRCREV</filename></ulink> |
| 4748 | to point to the commit hash that matches the new |
| 4749 | version. |
| 4750 | </para></listitem> |
| 4751 | <listitem><para> |
| 4752 | <emphasis>Build the Software:</emphasis> |
| 4753 | Try to build the recipe using BitBake. |
| 4754 | Typical build failures include the following: |
| 4755 | <itemizedlist> |
| 4756 | <listitem><para> |
| 4757 | License statements were updated for the new |
| 4758 | version. |
| 4759 | For this case, you need to review any changes |
| 4760 | to the license and update the values of |
| 4761 | <ulink url='&YOCTO_DOCS_REF_URL;#var-LICENSE'><filename>LICENSE</filename></ulink> |
| 4762 | and |
| 4763 | <ulink url='&YOCTO_DOCS_REF_URL;#var-LIC_FILES_CHKSUM'><filename>LIC_FILES_CHKSUM</filename></ulink> |
| 4764 | as needed. |
| 4765 | <note> |
| 4766 | License changes are often inconsequential. |
| 4767 | For example, the license text's copyright |
| 4768 | year might have changed. |
| 4769 | </note> |
| 4770 | </para></listitem> |
| 4771 | <listitem><para> |
| 4772 | Custom patches carried by the older version of |
| 4773 | the recipe might fail to apply to the new |
| 4774 | version. |
| 4775 | For these cases, you need to review the |
| 4776 | failures. |
| 4777 | Patches might not be necessary for the new |
| 4778 | version of the software if the upgraded version |
| 4779 | has fixed those issues. |
| 4780 | If a patch is necessary and failing, you need |
| 4781 | to rebase it into the new version. |
| 4782 | </para></listitem> |
| 4783 | </itemizedlist> |
| 4784 | </para></listitem> |
| 4785 | <listitem><para> |
| 4786 | <emphasis>Optionally Attempt to Build for Several Architectures:</emphasis> |
| 4787 | Once you successfully build the new software for a |
| 4788 | given architecture, you could test the build for |
| 4789 | other architectures by changing the |
| 4790 | <ulink url='&YOCTO_DOCS_REF_URL;#var-MACHINE'><filename>MACHINE</filename></ulink> |
| 4791 | variable and rebuilding the software. |
| 4792 | This optional step is especially important if the |
| 4793 | recipe is to be released publicly. |
| 4794 | </para></listitem> |
| 4795 | <listitem><para> |
| 4796 | <emphasis>Check the Upstream Change Log or Release Notes:</emphasis> |
| 4797 | Checking both these reveals if new features exist that |
| 4798 | could break backwards-compatibility. |
| 4799 | If so, you need to take steps to mitigate or eliminate |
| 4800 | that situation. |
| 4801 | </para></listitem> |
| 4802 | <listitem><para> |
| 4803 | <emphasis>Optionally Create a Bootable Image and Test:</emphasis> |
| 4804 | If you want, you can test the new software by booting |
| 4805 | it onto actual hardware. |
| 4806 | </para></listitem> |
| 4807 | <listitem><para> |
| 4808 | <emphasis>Create a Commit with the Change in the Layer Repository:</emphasis> |
| 4809 | After all builds work and any testing is successful, |
| 4810 | you can create commits for any changes in the layer |
| 4811 | holding your upgraded recipe. |
| 4812 | </para></listitem> |
| 4813 | </orderedlist> |
| 4814 | </para> |
| 4815 | </section> |
| 4816 | </section> |
| 4817 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 4818 | <section id='finding-the-temporary-source-code'> |
| 4819 | <title>Finding Temporary Source Code</title> |
| 4820 | |
| 4821 | <para> |
| 4822 | You might find it helpful during development to modify the |
| 4823 | temporary source code used by recipes to build packages. |
| 4824 | For example, suppose you are developing a patch and you need to |
| 4825 | experiment a bit to figure out your solution. |
| 4826 | After you have initially built the package, you can iteratively |
| 4827 | tweak the source code, which is located in the |
| 4828 | <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink>, |
| 4829 | and then you can force a re-compile and quickly test your altered |
| 4830 | code. |
| 4831 | Once you settle on a solution, you can then preserve your changes |
| 4832 | in the form of patches. |
| 4833 | </para> |
| 4834 | |
| 4835 | <para> |
| 4836 | During a build, the unpacked temporary source code used by recipes |
| 4837 | to build packages is available in the Build Directory as |
| 4838 | defined by the |
| 4839 | <ulink url='&YOCTO_DOCS_REF_URL;#var-S'><filename>S</filename></ulink> |
| 4840 | variable. |
| 4841 | Below is the default value for the <filename>S</filename> variable |
| 4842 | as defined in the |
| 4843 | <filename>meta/conf/bitbake.conf</filename> configuration file |
| 4844 | in the |
| 4845 | <ulink url='&YOCTO_DOCS_REF_URL;#source-directory'>Source Directory</ulink>: |
| 4846 | <literallayout class='monospaced'> |
| 4847 | S = "${WORKDIR}/${BP}" |
| 4848 | </literallayout> |
| 4849 | You should be aware that many recipes override the |
| 4850 | <filename>S</filename> variable. |
| 4851 | For example, recipes that fetch their source from Git usually set |
| 4852 | <filename>S</filename> to <filename>${WORKDIR}/git</filename>. |
| 4853 | <note> |
| 4854 | The |
| 4855 | <ulink url='&YOCTO_DOCS_REF_URL;#var-BP'><filename>BP</filename></ulink> |
| 4856 | represents the base recipe name, which consists of the name |
| 4857 | and version: |
| 4858 | <literallayout class='monospaced'> |
| 4859 | BP = "${BPN}-${PV}" |
| 4860 | </literallayout> |
| 4861 | </note> |
| 4862 | </para> |
| 4863 | |
| 4864 | <para> |
| 4865 | The path to the work directory for the recipe |
| 4866 | (<ulink url='&YOCTO_DOCS_REF_URL;#var-WORKDIR'><filename>WORKDIR</filename></ulink>) |
| 4867 | is defined as follows: |
| 4868 | <literallayout class='monospaced'> |
| 4869 | ${TMPDIR}/work/${MULTIMACH_TARGET_SYS}/${PN}/${EXTENDPE}${PV}-${PR} |
| 4870 | </literallayout> |
| 4871 | The actual directory depends on several things: |
| 4872 | <itemizedlist> |
| 4873 | <listitem><para> |
| 4874 | <ulink url='&YOCTO_DOCS_REF_URL;#var-TMPDIR'><filename>TMPDIR</filename></ulink>: |
| 4875 | The top-level build output directory. |
| 4876 | </para></listitem> |
| 4877 | <listitem><para> |
| 4878 | <ulink url='&YOCTO_DOCS_REF_URL;#var-MULTIMACH_TARGET_SYS'><filename>MULTIMACH_TARGET_SYS</filename></ulink>: |
| 4879 | The target system identifier. |
| 4880 | </para></listitem> |
| 4881 | <listitem><para> |
| 4882 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PN'><filename>PN</filename></ulink>: |
| 4883 | The recipe name. |
| 4884 | </para></listitem> |
| 4885 | <listitem><para> |
| 4886 | <ulink url='&YOCTO_DOCS_REF_URL;#var-EXTENDPE'><filename>EXTENDPE</filename></ulink>: |
| 4887 | The epoch - (if |
| 4888 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PE'><filename>PE</filename></ulink> |
| 4889 | is not specified, which is usually the case for most |
| 4890 | recipes, then <filename>EXTENDPE</filename> is blank). |
| 4891 | </para></listitem> |
| 4892 | <listitem><para> |
| 4893 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PV'><filename>PV</filename></ulink>: |
| 4894 | The recipe version. |
| 4895 | </para></listitem> |
| 4896 | <listitem><para> |
| 4897 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PR'><filename>PR</filename></ulink>: |
| 4898 | The recipe revision. |
| 4899 | </para></listitem> |
| 4900 | </itemizedlist> |
| 4901 | </para> |
| 4902 | |
| 4903 | <para> |
| 4904 | As an example, assume a Source Directory top-level folder |
| 4905 | named <filename>poky</filename>, a default Build Directory at |
| 4906 | <filename>poky/build</filename>, and a |
| 4907 | <filename>qemux86-poky-linux</filename> machine target |
| 4908 | system. |
| 4909 | Furthermore, suppose your recipe is named |
| 4910 | <filename>foo_1.3.0.bb</filename>. |
| 4911 | In this case, the work directory the build system uses to |
| 4912 | build the package would be as follows: |
| 4913 | <literallayout class='monospaced'> |
| 4914 | poky/build/tmp/work/qemux86-poky-linux/foo/1.3.0-r0 |
| 4915 | </literallayout> |
| 4916 | </para> |
| 4917 | </section> |
| 4918 | |
| 4919 | <section id="using-a-quilt-workflow"> |
| 4920 | <title>Using Quilt in Your Workflow</title> |
| 4921 | |
| 4922 | <para> |
| 4923 | <ulink url='http://savannah.nongnu.org/projects/quilt'>Quilt</ulink> |
| 4924 | is a powerful tool that allows you to capture source code changes |
| 4925 | without having a clean source tree. |
| 4926 | This section outlines the typical workflow you can use to modify |
| 4927 | source code, test changes, and then preserve the changes in the |
| 4928 | form of a patch all using Quilt. |
| 4929 | <note><title>Tip</title> |
| 4930 | With regard to preserving changes to source files, if you |
| 4931 | clean a recipe or have <filename>rm_work</filename> enabled, |
| 4932 | the |
| 4933 | <ulink url='&YOCTO_DOCS_SDK_URL;#using-devtool-in-your-sdk-workflow'><filename>devtool</filename> workflow</ulink> |
| 4934 | as described in the Yocto Project Application Development |
| 4935 | and the Extensible Software Development Kit (eSDK) manual |
| 4936 | is a safer development flow than the flow that uses Quilt. |
| 4937 | </note> |
| 4938 | </para> |
| 4939 | |
| 4940 | <para> |
| 4941 | Follow these general steps: |
| 4942 | <orderedlist> |
| 4943 | <listitem><para> |
| 4944 | <emphasis>Find the Source Code:</emphasis> |
| 4945 | Temporary source code used by the OpenEmbedded build system |
| 4946 | is kept in the |
| 4947 | <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink>. |
| 4948 | See the |
| 4949 | "<link linkend='finding-the-temporary-source-code'>Finding Temporary Source Code</link>" |
| 4950 | section to learn how to locate the directory that has the |
| 4951 | temporary source code for a particular package. |
| 4952 | </para></listitem> |
| 4953 | <listitem><para> |
| 4954 | <emphasis>Change Your Working Directory:</emphasis> |
| 4955 | You need to be in the directory that has the temporary |
| 4956 | source code. |
| 4957 | That directory is defined by the |
| 4958 | <ulink url='&YOCTO_DOCS_REF_URL;#var-S'><filename>S</filename></ulink> |
| 4959 | variable.</para></listitem> |
| 4960 | <listitem><para> |
| 4961 | <emphasis>Create a New Patch:</emphasis> |
| 4962 | Before modifying source code, you need to create a new |
| 4963 | patch. |
| 4964 | To create a new patch file, use |
| 4965 | <filename>quilt new</filename> as below: |
| 4966 | <literallayout class='monospaced'> |
| 4967 | $ quilt new my_changes.patch |
| 4968 | </literallayout> |
| 4969 | </para></listitem> |
| 4970 | <listitem><para> |
| 4971 | <emphasis>Notify Quilt and Add Files:</emphasis> |
| 4972 | After creating the patch, you need to notify Quilt about |
| 4973 | the files you plan to edit. |
| 4974 | You notify Quilt by adding the files to the patch you |
| 4975 | just created: |
| 4976 | <literallayout class='monospaced'> |
| 4977 | $ quilt add file1.c file2.c file3.c |
| 4978 | </literallayout> |
| 4979 | </para></listitem> |
| 4980 | <listitem><para> |
| 4981 | <emphasis>Edit the Files:</emphasis> |
| 4982 | Make your changes in the source code to the files you added |
| 4983 | to the patch. |
| 4984 | </para></listitem> |
| 4985 | <listitem><para> |
| 4986 | <emphasis>Test Your Changes:</emphasis> |
| 4987 | Once you have modified the source code, the easiest way to |
| 4988 | test your changes is by calling the |
| 4989 | <filename>do_compile</filename> task as shown in the |
| 4990 | following example: |
| 4991 | <literallayout class='monospaced'> |
| 4992 | $ bitbake -c compile -f <replaceable>package</replaceable> |
| 4993 | </literallayout> |
| 4994 | The <filename>-f</filename> or <filename>--force</filename> |
| 4995 | option forces the specified task to execute. |
| 4996 | If you find problems with your code, you can just keep |
| 4997 | editing and re-testing iteratively until things work |
| 4998 | as expected. |
| 4999 | <note> |
| 5000 | All the modifications you make to the temporary |
| 5001 | source code disappear once you run the |
| 5002 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-clean'><filename>do_clean</filename></ulink> |
| 5003 | or |
| 5004 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-cleanall'><filename>do_cleanall</filename></ulink> |
| 5005 | tasks using BitBake (i.e. |
| 5006 | <filename>bitbake -c clean <replaceable>package</replaceable></filename> |
| 5007 | and |
| 5008 | <filename>bitbake -c cleanall <replaceable>package</replaceable></filename>). |
| 5009 | Modifications will also disappear if you use the |
| 5010 | <filename>rm_work</filename> feature as described |
| 5011 | in the |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 5012 | "<ulink url='&YOCTO_DOCS_DEV_URL;#dev-saving-memory-during-a-build'>Conserving Disk Space During Builds</ulink>" |
| 5013 | section. |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 5014 | </note> |
| 5015 | </para></listitem> |
| 5016 | <listitem><para> |
| 5017 | <emphasis>Generate the Patch:</emphasis> |
| 5018 | Once your changes work as expected, you need to use Quilt |
| 5019 | to generate the final patch that contains all your |
| 5020 | modifications. |
| 5021 | <literallayout class='monospaced'> |
| 5022 | $ quilt refresh |
| 5023 | </literallayout> |
| 5024 | At this point, the <filename>my_changes.patch</filename> |
| 5025 | file has all your edits made to the |
| 5026 | <filename>file1.c</filename>, <filename>file2.c</filename>, |
| 5027 | and <filename>file3.c</filename> files.</para> |
| 5028 | |
| 5029 | <para>You can find the resulting patch file in the |
| 5030 | <filename>patches/</filename> subdirectory of the source |
| 5031 | (<filename>S</filename>) directory. |
| 5032 | </para></listitem> |
| 5033 | <listitem><para> |
| 5034 | <emphasis>Copy the Patch File:</emphasis> |
| 5035 | For simplicity, copy the patch file into a directory |
| 5036 | named <filename>files</filename>, which you can create |
| 5037 | in the same directory that holds the recipe |
| 5038 | (<filename>.bb</filename>) file or the append |
| 5039 | (<filename>.bbappend</filename>) file. |
| 5040 | Placing the patch here guarantees that the OpenEmbedded |
| 5041 | build system will find the patch. |
| 5042 | Next, add the patch into the |
| 5043 | <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'>SRC_URI</ulink></filename> |
| 5044 | of the recipe. |
| 5045 | Here is an example: |
| 5046 | <literallayout class='monospaced'> |
| 5047 | SRC_URI += "file://my_changes.patch" |
| 5048 | </literallayout> |
| 5049 | </para></listitem> |
| 5050 | </orderedlist> |
| 5051 | </para> |
| 5052 | </section> |
| 5053 | |
| 5054 | <section id="platdev-appdev-devshell"> |
| 5055 | <title>Using a Development Shell</title> |
| 5056 | |
| 5057 | <para> |
| 5058 | When debugging certain commands or even when just editing packages, |
| 5059 | <filename>devshell</filename> can be a useful tool. |
| 5060 | When you invoke <filename>devshell</filename>, all tasks up to and |
| 5061 | including |
| 5062 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-patch'><filename>do_patch</filename></ulink> |
| 5063 | are run for the specified target. |
| 5064 | Then, a new terminal is opened and you are placed in |
| 5065 | <filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-S'><filename>S</filename></ulink><filename>}</filename>, |
| 5066 | the source directory. |
| 5067 | In the new terminal, all the OpenEmbedded build-related environment variables are |
| 5068 | still defined so you can use commands such as <filename>configure</filename> and |
| 5069 | <filename>make</filename>. |
| 5070 | The commands execute just as if the OpenEmbedded build system were executing them. |
| 5071 | Consequently, working this way can be helpful when debugging a build or preparing |
| 5072 | software to be used with the OpenEmbedded build system. |
| 5073 | </para> |
| 5074 | |
| 5075 | <para> |
| 5076 | Following is an example that uses <filename>devshell</filename> on a target named |
| 5077 | <filename>matchbox-desktop</filename>: |
| 5078 | <literallayout class='monospaced'> |
| 5079 | $ bitbake matchbox-desktop -c devshell |
| 5080 | </literallayout> |
| 5081 | </para> |
| 5082 | |
| 5083 | <para> |
| 5084 | This command spawns a terminal with a shell prompt within the OpenEmbedded build environment. |
| 5085 | The <ulink url='&YOCTO_DOCS_REF_URL;#var-OE_TERMINAL'><filename>OE_TERMINAL</filename></ulink> |
| 5086 | variable controls what type of shell is opened. |
| 5087 | </para> |
| 5088 | |
| 5089 | <para> |
| 5090 | For spawned terminals, the following occurs: |
| 5091 | <itemizedlist> |
| 5092 | <listitem><para>The <filename>PATH</filename> variable includes the |
| 5093 | cross-toolchain.</para></listitem> |
| 5094 | <listitem><para>The <filename>pkgconfig</filename> variables find the correct |
| 5095 | <filename>.pc</filename> files.</para></listitem> |
| 5096 | <listitem><para>The <filename>configure</filename> command finds the |
| 5097 | Yocto Project site files as well as any other necessary files.</para></listitem> |
| 5098 | </itemizedlist> |
| 5099 | </para> |
| 5100 | |
| 5101 | <para> |
| 5102 | Within this environment, you can run configure or compile |
| 5103 | commands as if they were being run by |
| 5104 | the OpenEmbedded build system itself. |
| 5105 | As noted earlier, the working directory also automatically changes to the |
| 5106 | Source Directory (<ulink url='&YOCTO_DOCS_REF_URL;#var-S'><filename>S</filename></ulink>). |
| 5107 | </para> |
| 5108 | |
| 5109 | <para> |
| 5110 | To manually run a specific task using <filename>devshell</filename>, |
| 5111 | run the corresponding <filename>run.*</filename> script in |
| 5112 | the |
| 5113 | <filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-WORKDIR'><filename>WORKDIR</filename></ulink><filename>}/temp</filename> |
| 5114 | directory (e.g., |
| 5115 | <filename>run.do_configure.</filename><replaceable>pid</replaceable>). |
| 5116 | If a task's script does not exist, which would be the case if the task was |
| 5117 | skipped by way of the sstate cache, you can create the task by first running |
| 5118 | it outside of the <filename>devshell</filename>: |
| 5119 | <literallayout class='monospaced'> |
| 5120 | $ bitbake -c <replaceable>task</replaceable> |
| 5121 | </literallayout> |
| 5122 | <note><title>Notes</title> |
| 5123 | <itemizedlist> |
| 5124 | <listitem><para>Execution of a task's <filename>run.*</filename> |
| 5125 | script and BitBake's execution of a task are identical. |
| 5126 | In other words, running the script re-runs the task |
| 5127 | just as it would be run using the |
| 5128 | <filename>bitbake -c</filename> command. |
| 5129 | </para></listitem> |
| 5130 | <listitem><para>Any <filename>run.*</filename> file that does not |
| 5131 | have a <filename>.pid</filename> extension is a |
| 5132 | symbolic link (symlink) to the most recent version of that |
| 5133 | file. |
| 5134 | </para></listitem> |
| 5135 | </itemizedlist> |
| 5136 | </note> |
| 5137 | </para> |
| 5138 | |
| 5139 | <para> |
| 5140 | Remember, that the <filename>devshell</filename> is a mechanism that allows |
| 5141 | you to get into the BitBake task execution environment. |
| 5142 | And as such, all commands must be called just as BitBake would call them. |
| 5143 | That means you need to provide the appropriate options for |
| 5144 | cross-compilation and so forth as applicable. |
| 5145 | </para> |
| 5146 | |
| 5147 | <para> |
| 5148 | When you are finished using <filename>devshell</filename>, exit the shell |
| 5149 | or close the terminal window. |
| 5150 | </para> |
| 5151 | |
| 5152 | <note><title>Notes</title> |
| 5153 | <itemizedlist> |
| 5154 | <listitem><para> |
| 5155 | It is worth remembering that when using <filename>devshell</filename> |
| 5156 | you need to use the full compiler name such as <filename>arm-poky-linux-gnueabi-gcc</filename> |
| 5157 | instead of just using <filename>gcc</filename>. |
| 5158 | The same applies to other applications such as <filename>binutils</filename>, |
| 5159 | <filename>libtool</filename> and so forth. |
| 5160 | BitBake sets up environment variables such as <filename>CC</filename> |
| 5161 | to assist applications, such as <filename>make</filename> to find the correct tools. |
| 5162 | </para></listitem> |
| 5163 | <listitem><para> |
| 5164 | It is also worth noting that <filename>devshell</filename> still works over |
| 5165 | X11 forwarding and similar situations. |
| 5166 | </para></listitem> |
| 5167 | </itemizedlist> |
| 5168 | </note> |
| 5169 | </section> |
| 5170 | |
| 5171 | <section id="platdev-appdev-devpyshell"> |
| 5172 | <title>Using a Development Python Shell</title> |
| 5173 | |
| 5174 | <para> |
| 5175 | Similar to working within a development shell as described in |
| 5176 | the previous section, you can also spawn and work within an |
| 5177 | interactive Python development shell. |
| 5178 | When debugging certain commands or even when just editing packages, |
| 5179 | <filename>devpyshell</filename> can be a useful tool. |
| 5180 | When you invoke <filename>devpyshell</filename>, all tasks up to and |
| 5181 | including |
| 5182 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-patch'><filename>do_patch</filename></ulink> |
| 5183 | are run for the specified target. |
| 5184 | Then a new terminal is opened. |
| 5185 | Additionally, key Python objects and code are available in the same |
| 5186 | way they are to BitBake tasks, in particular, the data store 'd'. |
| 5187 | So, commands such as the following are useful when exploring the data |
| 5188 | store and running functions: |
| 5189 | <literallayout class='monospaced'> |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 5190 | pydevshell> d.getVar("STAGING_DIR") |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 5191 | '/media/build1/poky/build/tmp/sysroots' |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 5192 | pydevshell> d.getVar("STAGING_DIR") |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 5193 | '${TMPDIR}/sysroots' |
| 5194 | pydevshell> d.setVar("FOO", "bar") |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 5195 | pydevshell> d.getVar("FOO") |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 5196 | 'bar' |
| 5197 | pydevshell> d.delVar("FOO") |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 5198 | pydevshell> d.getVar("FOO") |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 5199 | pydevshell> bb.build.exec_func("do_unpack", d) |
| 5200 | pydevshell> |
| 5201 | </literallayout> |
| 5202 | The commands execute just as if the OpenEmbedded build system were executing them. |
| 5203 | Consequently, working this way can be helpful when debugging a build or preparing |
| 5204 | software to be used with the OpenEmbedded build system. |
| 5205 | </para> |
| 5206 | |
| 5207 | <para> |
| 5208 | Following is an example that uses <filename>devpyshell</filename> on a target named |
| 5209 | <filename>matchbox-desktop</filename>: |
| 5210 | <literallayout class='monospaced'> |
| 5211 | $ bitbake matchbox-desktop -c devpyshell |
| 5212 | </literallayout> |
| 5213 | </para> |
| 5214 | |
| 5215 | <para> |
| 5216 | This command spawns a terminal and places you in an interactive |
| 5217 | Python interpreter within the OpenEmbedded build environment. |
| 5218 | The <ulink url='&YOCTO_DOCS_REF_URL;#var-OE_TERMINAL'><filename>OE_TERMINAL</filename></ulink> |
| 5219 | variable controls what type of shell is opened. |
| 5220 | </para> |
| 5221 | |
| 5222 | <para> |
| 5223 | When you are finished using <filename>devpyshell</filename>, you |
| 5224 | can exit the shell either by using Ctrl+d or closing the terminal |
| 5225 | window. |
| 5226 | </para> |
| 5227 | </section> |
| 5228 | |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 5229 | <section id='dev-building'> |
| 5230 | <title>Building</title> |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 5231 | |
| 5232 | <para> |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 5233 | This section describes various build procedures. |
| 5234 | For example, the steps needed for a simple build, a target that |
| 5235 | uses multiple configurations, building an image for more than |
| 5236 | one machine, and so forth. |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 5237 | </para> |
| 5238 | |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 5239 | <section id='dev-building-a-simple-image'> |
| 5240 | <title>Building a Simple Image</title> |
| 5241 | |
| 5242 | <para> |
| 5243 | In the development environment, you need to build an image |
| 5244 | whenever you change hardware support, add or change system |
| 5245 | libraries, or add or change services that have dependencies. |
| 5246 | Several methods exist that allow you to build an image within |
| 5247 | the Yocto Project. |
| 5248 | This section presents the basic steps you need to build a |
| 5249 | simple image using BitBake from a build host running Linux. |
| 5250 | <note><title>Notes</title> |
| 5251 | <itemizedlist> |
| 5252 | <listitem><para> |
| 5253 | For information on how to build an image using |
| 5254 | <ulink url='&YOCTO_DOCS_REF_URL;#toaster-term'>Toaster</ulink>, |
| 5255 | see the |
| 5256 | <ulink url='&YOCTO_DOCS_TOAST_URL;'>Toaster User Manual</ulink>. |
| 5257 | </para></listitem> |
| 5258 | <listitem><para> |
| 5259 | For information on how to use |
| 5260 | <filename>devtool</filename> to build images, see |
| 5261 | the |
| 5262 | "<ulink url='&YOCTO_DOCS_SDK_URL;#using-devtool-in-your-sdk-workflow'>Using <filename>devtool</filename> in Your SDK Workflow</ulink>" |
| 5263 | section in the Yocto Project Application |
| 5264 | Development and the Extensible Software Development |
| 5265 | Kit (eSDK) manual. |
| 5266 | </para></listitem> |
| 5267 | <listitem><para> |
| 5268 | For a quick example on how to build an image using |
| 5269 | the OpenEmbedded build system, see the |
| 5270 | <ulink url='&YOCTO_DOCS_BRIEF_URL;'>Yocto Project Quick Build</ulink> |
| 5271 | document. |
| 5272 | </para></listitem> |
| 5273 | </itemizedlist> |
| 5274 | </note> |
| 5275 | </para> |
| 5276 | |
| 5277 | <para> |
| 5278 | The build process creates an entire Linux distribution from |
| 5279 | source and places it in your |
| 5280 | <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink> |
| 5281 | under <filename>tmp/deploy/images</filename>. |
| 5282 | For detailed information on the build process using BitBake, |
| 5283 | see the |
| 5284 | "<ulink url='&YOCTO_DOCS_OM_URL;#images-dev-environment'>Images</ulink>" |
| 5285 | section in the Yocto Project Overview and Concepts Manual. |
| 5286 | </para> |
| 5287 | |
| 5288 | <para> |
| 5289 | The following figure and list overviews the build process: |
| 5290 | <imagedata fileref="figures/bitbake-build-flow.png" width="7in" depth="4in" align="center" scalefit="1" /> |
| 5291 | <orderedlist> |
| 5292 | <listitem><para> |
| 5293 | <emphasis>Set up Your Host Development System to Support |
| 5294 | Development Using the Yocto Project</emphasis>: |
| 5295 | See the |
| 5296 | "<link linkend='dev-manual-start'>Setting Up to Use the Yocto Project</link>" |
| 5297 | section for options on how to get a build host ready to |
| 5298 | use the Yocto Project. |
| 5299 | </para></listitem> |
| 5300 | <listitem><para> |
| 5301 | <emphasis>Initialize the Build Environment:</emphasis> |
| 5302 | Initialize the build environment by sourcing the build |
| 5303 | environment script (i.e. |
| 5304 | <ulink url='&YOCTO_DOCS_REF_URL;#structure-core-script'><filename>&OE_INIT_FILE;</filename></ulink>): |
| 5305 | <literallayout class='monospaced'> |
| 5306 | $ source &OE_INIT_FILE; [<replaceable>build_dir</replaceable>] |
| 5307 | </literallayout></para> |
| 5308 | |
| 5309 | <para>When you use the initialization script, the |
| 5310 | OpenEmbedded build system uses |
| 5311 | <filename>build</filename> as the default Build |
| 5312 | Directory in your current work directory. |
| 5313 | You can use a <replaceable>build_dir</replaceable> |
| 5314 | argument with the script to specify a different build |
| 5315 | directory. |
| 5316 | <note><title>Tip</title> |
| 5317 | A common practice is to use a different Build |
| 5318 | Directory for different targets. |
| 5319 | For example, <filename>~/build/x86</filename> for a |
| 5320 | <filename>qemux86</filename> target, and |
| 5321 | <filename>~/build/arm</filename> for a |
| 5322 | <filename>qemuarm</filename> target. |
| 5323 | </note> |
| 5324 | </para></listitem> |
| 5325 | <listitem><para> |
| 5326 | <emphasis>Make Sure Your <filename>local.conf</filename> |
| 5327 | File is Correct:</emphasis> |
| 5328 | Ensure the <filename>conf/local.conf</filename> |
| 5329 | configuration file, which is found in the Build |
| 5330 | Directory, is set up how you want it. |
| 5331 | This file defines many aspects of the build environment |
| 5332 | including the target machine architecture through the |
| 5333 | <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-MACHINE'>MACHINE</ulink></filename> variable, |
| 5334 | the packaging format used during the build |
| 5335 | (<ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_CLASSES'><filename>PACKAGE_CLASSES</filename></ulink>), |
| 5336 | and a centralized tarball download directory through the |
| 5337 | <ulink url='&YOCTO_DOCS_REF_URL;#var-DL_DIR'><filename>DL_DIR</filename></ulink> variable. |
| 5338 | </para></listitem> |
| 5339 | <listitem><para> |
| 5340 | <emphasis>Build the Image:</emphasis> |
| 5341 | Build the image using the <filename>bitbake</filename> |
| 5342 | command: |
| 5343 | <literallayout class='monospaced'> |
| 5344 | $ bitbake <replaceable>target</replaceable> |
| 5345 | </literallayout> |
| 5346 | <note> |
| 5347 | For information on BitBake, see the |
| 5348 | <ulink url='&YOCTO_DOCS_BB_URL;'>BitBake User Manual</ulink>. |
| 5349 | </note> |
| 5350 | The <replaceable>target</replaceable> is the name of the |
| 5351 | recipe you want to build. |
| 5352 | Common targets are the images in |
| 5353 | <filename>meta/recipes-core/images</filename>, |
| 5354 | <filename>meta/recipes-sato/images</filename>, and so |
| 5355 | forth all found in the |
| 5356 | <ulink url='&YOCTO_DOCS_REF_URL;#source-directory'>Source Directory</ulink>. |
| 5357 | Or, the target can be the name of a recipe for a |
| 5358 | specific piece of software such as BusyBox. |
| 5359 | For more details about the images the OpenEmbedded build |
| 5360 | system supports, see the |
| 5361 | "<ulink url='&YOCTO_DOCS_REF_URL;#ref-images'>Images</ulink>" |
| 5362 | chapter in the Yocto Project Reference Manual.</para> |
| 5363 | |
| 5364 | <para>As an example, the following command builds the |
| 5365 | <filename>core-image-minimal</filename> image: |
| 5366 | <literallayout class='monospaced'> |
| 5367 | $ bitbake core-image-minimal |
| 5368 | </literallayout> |
| 5369 | Once an image has been built, it often needs to be |
| 5370 | installed. |
| 5371 | The images and kernels built by the OpenEmbedded |
| 5372 | build system are placed in the Build Directory in |
| 5373 | <filename class="directory">tmp/deploy/images</filename>. |
| 5374 | For information on how to run pre-built images such as |
| 5375 | <filename>qemux86</filename> and <filename>qemuarm</filename>, |
| 5376 | see the |
| 5377 | <ulink url='&YOCTO_DOCS_SDK_URL;'>Yocto Project Application Development and the Extensible Software Development Kit (eSDK)</ulink> |
| 5378 | manual. |
| 5379 | For information about how to install these images, |
| 5380 | see the documentation for your particular board or |
| 5381 | machine. |
| 5382 | </para></listitem> |
| 5383 | </orderedlist> |
| 5384 | </para> |
| 5385 | </section> |
| 5386 | |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 5387 | <section id='dev-building-images-for-multiple-targets-using-multiple-configurations'> |
| 5388 | <title>Building Images for Multiple Targets Using Multiple Configurations</title> |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 5389 | |
| 5390 | <para> |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 5391 | You can use a single <filename>bitbake</filename> command |
| 5392 | to build multiple images or packages for different targets |
| 5393 | where each image or package requires a different configuration |
| 5394 | (multiple configuration builds). |
| 5395 | The builds, in this scenario, are sometimes referred to as |
| 5396 | "multiconfigs", and this section uses that term throughout. |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 5397 | </para> |
| 5398 | |
| 5399 | <para> |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 5400 | This section describes how to set up for multiple |
| 5401 | configuration builds and how to account for cross-build |
| 5402 | dependencies between the multiconfigs. |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 5403 | </para> |
| 5404 | |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 5405 | <section id='dev-setting-up-and-running-a-multiple-configuration-build'> |
| 5406 | <title>Setting Up and Running a Multiple Configuration Build</title> |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 5407 | |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 5408 | <para> |
| 5409 | To accomplish a multiple configuration build, you must |
| 5410 | define each target's configuration separately using |
| 5411 | a parallel configuration file in the |
| 5412 | <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink>, |
| 5413 | and you must follow a required file hierarchy. |
| 5414 | Additionally, you must enable the multiple configuration |
| 5415 | builds in your <filename>local.conf</filename> file. |
| 5416 | </para> |
| 5417 | |
| 5418 | <para> |
| 5419 | Follow these steps to set up and execute multiple |
| 5420 | configuration builds: |
| 5421 | <itemizedlist> |
| 5422 | <listitem><para> |
| 5423 | <emphasis>Create Separate Configuration Files</emphasis>: |
| 5424 | You need to create a single configuration file for |
| 5425 | each build target (each multiconfig). |
| 5426 | Minimally, each configuration file must define the |
| 5427 | machine and the temporary directory BitBake uses |
| 5428 | for the build. |
| 5429 | Suggested practice dictates that you do not |
| 5430 | overlap the temporary directories |
| 5431 | used during the builds. |
| 5432 | However, it is possible that you can share the |
| 5433 | temporary directory |
| 5434 | (<ulink url='&YOCTO_DOCS_REF_URL;#var-TMPDIR'><filename>TMPDIR</filename></ulink>). |
| 5435 | For example, consider a scenario with two |
| 5436 | different multiconfigs for the same |
| 5437 | <ulink url='&YOCTO_DOCS_REF_URL;#var-MACHINE'><filename>MACHINE</filename></ulink>: "qemux86" built for |
| 5438 | two distributions such as "poky" and "poky-lsb". |
| 5439 | In this case, you might want to use the same |
| 5440 | <filename>TMPDIR</filename>.</para> |
| 5441 | |
| 5442 | <para>Here is an example showing the minimal |
| 5443 | statements needed in a configuration file for |
| 5444 | a "qemux86" target whose temporary build directory |
| 5445 | is <filename>tmpmultix86</filename>: |
| 5446 | <literallayout class='monospaced'> |
| 5447 | MACHINE="qemux86" |
| 5448 | TMPDIR="${TOPDIR}/tmpmultix86" |
| 5449 | </literallayout></para> |
| 5450 | |
| 5451 | <para>The location for these multiconfig |
| 5452 | configuration files is specific. |
| 5453 | They must reside in the current build directory in |
| 5454 | a sub-directory of <filename>conf</filename> named |
| 5455 | <filename>multiconfig</filename>. |
| 5456 | Following is an example that defines two |
| 5457 | configuration files for the "x86" and "arm" |
| 5458 | multiconfigs: |
| 5459 | <imagedata fileref="figures/multiconfig_files.png" align="center" width="4in" depth="3in" /> |
| 5460 | </para> |
| 5461 | |
| 5462 | <para>The reason for this required file hierarchy |
| 5463 | is because the <filename>BBPATH</filename> variable |
| 5464 | is not constructed until the layers are parsed. |
| 5465 | Consequently, using the configuration file as a |
| 5466 | pre-configuration file is not possible unless it is |
| 5467 | located in the current working directory. |
| 5468 | </para></listitem> |
| 5469 | <listitem><para> |
| 5470 | <emphasis>Add the BitBake Multi-configuration Variable to the Local Configuration File</emphasis>: |
| 5471 | Use the |
| 5472 | <ulink url='&YOCTO_DOCS_REF_URL;#var-BBMULTICONFIG'><filename>BBMULTICONFIG</filename></ulink> |
| 5473 | variable in your |
| 5474 | <filename>conf/local.conf</filename> configuration |
| 5475 | file to specify each multiconfig. |
| 5476 | Continuing with the example from the previous |
| 5477 | figure, the <filename>BBMULTICONFIG</filename> |
| 5478 | variable needs to enable two multiconfigs: "x86" |
| 5479 | and "arm" by specifying each configuration file: |
| 5480 | <literallayout class='monospaced'> |
| 5481 | BBMULTICONFIG = "x86 arm" |
| 5482 | </literallayout> |
Brad Bishop | 64c979e | 2019-11-04 13:55:29 -0500 | [diff] [blame] | 5483 | <note> |
| 5484 | A "default" configuration already exists by |
| 5485 | definition. |
| 5486 | This configuration is named: "" (i.e. empty |
| 5487 | string) and is defined by the variables coming |
| 5488 | from your <filename>local.conf</filename> file. |
| 5489 | Consequently, the previous example actually |
| 5490 | adds two additional configurations to your |
| 5491 | build: "arm" and "x86" along with "". |
| 5492 | </note> |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 5493 | </para></listitem> |
| 5494 | <listitem><para> |
| 5495 | <emphasis>Launch BitBake</emphasis>: |
| 5496 | Use the following BitBake command form to launch the |
| 5497 | multiple configuration build: |
| 5498 | <literallayout class='monospaced'> |
Brad Bishop | f3f93bb | 2019-10-16 14:33:32 -0400 | [diff] [blame] | 5499 | $ 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] | 5500 | </literallayout> |
| 5501 | For the example in this section, the following |
| 5502 | command applies: |
| 5503 | <literallayout class='monospaced'> |
Brad Bishop | f3f93bb | 2019-10-16 14:33:32 -0400 | [diff] [blame] | 5504 | $ 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] | 5505 | </literallayout> |
| 5506 | The previous BitBake command builds a |
| 5507 | <filename>core-image-minimal</filename> image that |
| 5508 | is configured through the |
Brad Bishop | f3f93bb | 2019-10-16 14:33:32 -0400 | [diff] [blame] | 5509 | <filename>x86.conf</filename> configuration file, |
| 5510 | a <filename>core-image-sato</filename> |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 5511 | image that is configured through the |
Brad Bishop | 64c979e | 2019-11-04 13:55:29 -0500 | [diff] [blame] | 5512 | <filename>arm.conf</filename> configuration file |
| 5513 | and a <filename>core-image-base</filename> that is |
| 5514 | configured through your |
| 5515 | <filename>local.conf</filename> configuration file. |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 5516 | </para></listitem> |
| 5517 | </itemizedlist> |
| 5518 | <note> |
| 5519 | Support for multiple configuration builds in the |
| 5520 | Yocto Project &DISTRO; (&DISTRO_NAME;) Release does |
| 5521 | not include Shared State (sstate) optimizations. |
| 5522 | Consequently, if a build uses the same object twice |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 5523 | in, for example, two different |
| 5524 | <filename>TMPDIR</filename> directories, the build |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 5525 | either loads from an existing sstate cache for that |
| 5526 | build at the start or builds the object fresh. |
| 5527 | </note> |
| 5528 | </para> |
| 5529 | </section> |
| 5530 | |
| 5531 | <section id='dev-enabling-multiple-configuration-build-dependencies'> |
| 5532 | <title>Enabling Multiple Configuration Build Dependencies</title> |
| 5533 | |
| 5534 | <para> |
| 5535 | Sometimes dependencies can exist between targets |
| 5536 | (multiconfigs) in a multiple configuration build. |
| 5537 | For example, suppose that in order to build a |
| 5538 | <filename>core-image-sato</filename> image for an "x86" |
| 5539 | multiconfig, the root filesystem of an "arm" |
| 5540 | multiconfig must exist. |
| 5541 | This dependency is essentially that the |
| 5542 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-image'><filename>do_image</filename></ulink> |
| 5543 | task in the <filename>core-image-sato</filename> recipe |
| 5544 | depends on the completion of the |
| 5545 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-rootfs'><filename>do_rootfs</filename></ulink> |
| 5546 | task of the <filename>core-image-minimal</filename> |
| 5547 | recipe. |
| 5548 | </para> |
| 5549 | |
| 5550 | <para> |
| 5551 | To enable dependencies in a multiple configuration |
| 5552 | build, you must declare the dependencies in the recipe |
| 5553 | using the following statement form: |
| 5554 | <literallayout class='monospaced'> |
Brad Bishop | f3f93bb | 2019-10-16 14:33:32 -0400 | [diff] [blame] | 5555 | <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] | 5556 | </literallayout> |
| 5557 | To better show how to use this statement, consider the |
| 5558 | example scenario from the first paragraph of this section. |
| 5559 | The following statement needs to be added to the recipe |
| 5560 | that builds the <filename>core-image-sato</filename> |
| 5561 | image: |
| 5562 | <literallayout class='monospaced'> |
Brad Bishop | f3f93bb | 2019-10-16 14:33:32 -0400 | [diff] [blame] | 5563 | do_image[mcdepends] = "mc:x86:arm:core-image-minimal:do_rootfs" |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 5564 | </literallayout> |
| 5565 | In this example, the |
| 5566 | <replaceable>from_multiconfig</replaceable> is "x86". |
| 5567 | The <replaceable>to_multiconfig</replaceable> is "arm". |
| 5568 | The task on which the <filename>do_image</filename> task |
| 5569 | in the recipe depends is the <filename>do_rootfs</filename> |
| 5570 | task from the <filename>core-image-minimal</filename> |
| 5571 | recipe associated with the "arm" multiconfig. |
| 5572 | </para> |
| 5573 | |
| 5574 | <para> |
| 5575 | Once you set up this dependency, you can build the |
| 5576 | "x86" multiconfig using a BitBake command as follows: |
| 5577 | <literallayout class='monospaced'> |
Brad Bishop | f3f93bb | 2019-10-16 14:33:32 -0400 | [diff] [blame] | 5578 | $ bitbake mc:x86:core-image-sato |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 5579 | </literallayout> |
| 5580 | This command executes all the tasks needed to create |
| 5581 | the <filename>core-image-sato</filename> image for the |
| 5582 | "x86" multiconfig. |
| 5583 | Because of the dependency, BitBake also executes through |
| 5584 | the <filename>do_rootfs</filename> task for the "arm" |
| 5585 | multiconfig build. |
| 5586 | </para> |
| 5587 | |
| 5588 | <para> |
| 5589 | Having a recipe depend on the root filesystem of another |
| 5590 | build might not seem that useful. |
| 5591 | Consider this change to the statement in the |
| 5592 | <filename>core-image-sato</filename> recipe: |
| 5593 | <literallayout class='monospaced'> |
Brad Bishop | f3f93bb | 2019-10-16 14:33:32 -0400 | [diff] [blame] | 5594 | do_image[mcdepends] = "mc:x86:arm:core-image-minimal:do_image" |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 5595 | </literallayout> |
| 5596 | In this case, BitBake must create the |
| 5597 | <filename>core-image-minimal</filename> image for the |
| 5598 | "arm" build since the "x86" build depends on it. |
| 5599 | </para> |
| 5600 | |
| 5601 | <para> |
| 5602 | Because "x86" and "arm" are enabled for multiple |
| 5603 | configuration builds and have separate configuration |
| 5604 | files, BitBake places the artifacts for each build in the |
| 5605 | respective temporary build directories (i.e. |
| 5606 | <ulink url='&YOCTO_DOCS_REF_URL;#var-TMPDIR'><filename>TMPDIR</filename></ulink>). |
| 5607 | </para> |
| 5608 | </section> |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 5609 | </section> |
| 5610 | |
| 5611 | <section id='building-an-initramfs-image'> |
| 5612 | <title>Building an Initial RAM Filesystem (initramfs) Image</title> |
| 5613 | |
| 5614 | <para> |
| 5615 | An initial RAM filesystem (initramfs) image provides a temporary |
| 5616 | root filesystem used for early system initialization (e.g. |
| 5617 | loading of modules needed to locate and mount the "real" root |
| 5618 | filesystem). |
| 5619 | <note> |
| 5620 | The initramfs image is the successor of initial RAM disk |
| 5621 | (initrd). |
| 5622 | It is a "copy in and out" (cpio) archive of the initial |
| 5623 | filesystem that gets loaded into memory during the Linux |
| 5624 | startup process. |
| 5625 | Because Linux uses the contents of the archive during |
| 5626 | initialization, the initramfs image needs to contain all of the |
| 5627 | device drivers and tools needed to mount the final root |
| 5628 | filesystem. |
| 5629 | </note> |
| 5630 | </para> |
| 5631 | |
| 5632 | <para> |
| 5633 | Follow these steps to create an initramfs image: |
| 5634 | <orderedlist> |
| 5635 | <listitem><para> |
| 5636 | <emphasis>Create the initramfs Image Recipe:</emphasis> |
| 5637 | You can reference the |
| 5638 | <filename>core-image-minimal-initramfs.bb</filename> |
| 5639 | recipe found in the <filename>meta/recipes-core</filename> |
| 5640 | directory of the |
| 5641 | <ulink url='&YOCTO_DOCS_REF_URL;#source-directory'>Source Directory</ulink> |
| 5642 | as an example from which to work. |
| 5643 | </para></listitem> |
| 5644 | <listitem><para> |
| 5645 | <emphasis>Decide if You Need to Bundle the initramfs Image |
| 5646 | Into the Kernel Image:</emphasis> |
| 5647 | If you want the initramfs image that is built to be |
| 5648 | bundled in with the kernel image, set the |
| 5649 | <ulink url='&YOCTO_DOCS_REF_URL;#var-INITRAMFS_IMAGE_BUNDLE'><filename>INITRAMFS_IMAGE_BUNDLE</filename></ulink> |
| 5650 | variable to "1" in your <filename>local.conf</filename> |
| 5651 | configuration file and set the |
| 5652 | <ulink url='&YOCTO_DOCS_REF_URL;#var-INITRAMFS_IMAGE'><filename>INITRAMFS_IMAGE</filename></ulink> |
| 5653 | variable in the recipe that builds the kernel image. |
| 5654 | <note><title>Tip</title> |
| 5655 | It is recommended that you do bundle the initramfs |
| 5656 | image with the kernel image to avoid circular |
| 5657 | dependencies between the kernel recipe and the |
| 5658 | initramfs recipe should the initramfs image |
| 5659 | include kernel modules. |
| 5660 | </note> |
| 5661 | Setting the <filename>INITRAMFS_IMAGE_BUNDLE</filename> |
| 5662 | flag causes the initramfs image to be unpacked |
| 5663 | into the <filename>${B}/usr/</filename> directory. |
| 5664 | The unpacked initramfs image is then passed to the kernel's |
| 5665 | <filename>Makefile</filename> using the |
| 5666 | <ulink url='&YOCTO_DOCS_REF_URL;#var-CONFIG_INITRAMFS_SOURCE'><filename>CONFIG_INITRAMFS_SOURCE</filename></ulink> |
| 5667 | variable, allowing the initramfs image to be built into |
| 5668 | the kernel normally. |
| 5669 | <note> |
| 5670 | If you choose to not bundle the initramfs image with |
| 5671 | the kernel image, you are essentially using an |
| 5672 | <ulink url='https://en.wikipedia.org/wiki/Initrd'>Initial RAM Disk (initrd)</ulink>. |
| 5673 | Creating an initrd is handled primarily through the |
| 5674 | <ulink url='&YOCTO_DOCS_REF_URL;#var-INITRD_IMAGE'><filename>INITRD_IMAGE</filename></ulink>, |
| 5675 | <filename>INITRD_LIVE</filename>, and |
| 5676 | <filename>INITRD_IMAGE_LIVE</filename> variables. |
| 5677 | For more information, see the |
| 5678 | <ulink url='&YOCTO_GIT_URL;/cgit/cgit.cgi/poky/tree/meta/classes/image-live.bbclass'><filename>image-live.bbclass</filename></ulink> |
| 5679 | file. |
| 5680 | </note> |
| 5681 | </para></listitem> |
| 5682 | <listitem><para> |
| 5683 | <emphasis>Optionally Add Items to the initramfs Image |
| 5684 | Through the initramfs Image Recipe:</emphasis> |
| 5685 | If you add items to the initramfs image by way of its |
| 5686 | recipe, you should use |
| 5687 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_INSTALL'><filename>PACKAGE_INSTALL</filename></ulink> |
| 5688 | rather than |
| 5689 | <ulink url='&YOCTO_DOCS_REF_URL;#var-IMAGE_INSTALL'><filename>IMAGE_INSTALL</filename></ulink>. |
| 5690 | <filename>PACKAGE_INSTALL</filename> gives more direct |
| 5691 | control of what is added to the image as compared to |
| 5692 | the defaults you might not necessarily want that are |
| 5693 | set by the |
| 5694 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-image'><filename>image</filename></ulink> |
| 5695 | or |
| 5696 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-core-image'><filename>core-image</filename></ulink> |
| 5697 | classes. |
| 5698 | </para></listitem> |
| 5699 | <listitem><para> |
| 5700 | <emphasis>Build the Kernel Image and the initramfs |
| 5701 | Image:</emphasis> |
| 5702 | Build your kernel image using BitBake. |
| 5703 | Because the initramfs image recipe is a dependency of the |
| 5704 | kernel image, the initramfs image is built as well and |
| 5705 | bundled with the kernel image if you used the |
| 5706 | <ulink url='&YOCTO_DOCS_REF_URL;#var-INITRAMFS_IMAGE_BUNDLE'><filename>INITRAMFS_IMAGE_BUNDLE</filename></ulink> |
| 5707 | variable described earlier. |
| 5708 | </para></listitem> |
| 5709 | </orderedlist> |
| 5710 | </para> |
| 5711 | </section> |
| 5712 | |
| 5713 | <section id='building-a-tiny-system'> |
| 5714 | <title>Building a Tiny System</title> |
| 5715 | |
| 5716 | <para> |
| 5717 | Very small distributions have some significant advantages such |
| 5718 | as requiring less on-die or in-package memory (cheaper), better |
| 5719 | performance through efficient cache usage, lower power requirements |
| 5720 | due to less memory, faster boot times, and reduced development |
| 5721 | overhead. |
| 5722 | Some real-world examples where a very small distribution gives |
| 5723 | you distinct advantages are digital cameras, medical devices, |
| 5724 | and small headless systems. |
| 5725 | </para> |
| 5726 | |
| 5727 | <para> |
| 5728 | This section presents information that shows you how you can |
| 5729 | trim your distribution to even smaller sizes than the |
| 5730 | <filename>poky-tiny</filename> distribution, which is around |
| 5731 | 5 Mbytes, that can be built out-of-the-box using the Yocto Project. |
| 5732 | </para> |
| 5733 | |
| 5734 | <section id='tiny-system-overview'> |
| 5735 | <title>Overview</title> |
| 5736 | |
| 5737 | <para> |
| 5738 | The following list presents the overall steps you need to |
| 5739 | consider and perform to create distributions with smaller |
| 5740 | root filesystems, achieve faster boot times, maintain your critical |
| 5741 | functionality, and avoid initial RAM disks: |
| 5742 | <itemizedlist> |
| 5743 | <listitem><para> |
| 5744 | <link linkend='goals-and-guiding-principles'>Determine your goals and guiding principles.</link> |
| 5745 | </para></listitem> |
| 5746 | <listitem><para> |
| 5747 | <link linkend='understand-what-gives-your-image-size'>Understand what contributes to your image size.</link> |
| 5748 | </para></listitem> |
| 5749 | <listitem><para> |
| 5750 | <link linkend='trim-the-root-filesystem'>Reduce the size of the root filesystem.</link> |
| 5751 | </para></listitem> |
| 5752 | <listitem><para> |
| 5753 | <link linkend='trim-the-kernel'>Reduce the size of the kernel.</link> |
| 5754 | </para></listitem> |
| 5755 | <listitem><para> |
| 5756 | <link linkend='remove-package-management-requirements'>Eliminate packaging requirements.</link> |
| 5757 | </para></listitem> |
| 5758 | <listitem><para> |
| 5759 | <link linkend='look-for-other-ways-to-minimize-size'>Look for other ways to minimize size.</link> |
| 5760 | </para></listitem> |
| 5761 | <listitem><para> |
| 5762 | <link linkend='iterate-on-the-process'>Iterate on the process.</link> |
| 5763 | </para></listitem> |
| 5764 | </itemizedlist> |
| 5765 | </para> |
| 5766 | </section> |
| 5767 | |
| 5768 | <section id='goals-and-guiding-principles'> |
| 5769 | <title>Goals and Guiding Principles</title> |
| 5770 | |
| 5771 | <para> |
| 5772 | Before you can reach your destination, you need to know |
| 5773 | where you are going. |
| 5774 | Here is an example list that you can use as a guide when |
| 5775 | creating very small distributions: |
| 5776 | <itemizedlist> |
| 5777 | <listitem><para>Determine how much space you need |
| 5778 | (e.g. a kernel that is 1 Mbyte or less and |
| 5779 | a root filesystem that is 3 Mbytes or less). |
| 5780 | </para></listitem> |
| 5781 | <listitem><para>Find the areas that are currently |
| 5782 | taking 90% of the space and concentrate on reducing |
| 5783 | those areas. |
| 5784 | </para></listitem> |
| 5785 | <listitem><para>Do not create any difficult "hacks" |
| 5786 | to achieve your goals.</para></listitem> |
| 5787 | <listitem><para>Leverage the device-specific |
| 5788 | options.</para></listitem> |
| 5789 | <listitem><para>Work in a separate layer so that you |
| 5790 | keep changes isolated. |
| 5791 | For information on how to create layers, see |
| 5792 | the "<link linkend='understanding-and-creating-layers'>Understanding and Creating Layers</link>" section. |
| 5793 | </para></listitem> |
| 5794 | </itemizedlist> |
| 5795 | </para> |
| 5796 | </section> |
| 5797 | |
| 5798 | <section id='understand-what-gives-your-image-size'> |
| 5799 | <title>Understand What Contributes to Your Image Size</title> |
| 5800 | |
| 5801 | <para> |
| 5802 | It is easiest to have something to start with when creating |
| 5803 | your own distribution. |
| 5804 | You can use the Yocto Project out-of-the-box to create the |
| 5805 | <filename>poky-tiny</filename> distribution. |
| 5806 | Ultimately, you will want to make changes in your own |
| 5807 | distribution that are likely modeled after |
| 5808 | <filename>poky-tiny</filename>. |
| 5809 | <note> |
| 5810 | To use <filename>poky-tiny</filename> in your build, |
| 5811 | set the |
| 5812 | <ulink url='&YOCTO_DOCS_REF_URL;#var-DISTRO'><filename>DISTRO</filename></ulink> |
| 5813 | variable in your |
| 5814 | <filename>local.conf</filename> file to "poky-tiny" |
| 5815 | as described in the |
| 5816 | "<link linkend='creating-your-own-distribution'>Creating Your Own Distribution</link>" |
| 5817 | section. |
| 5818 | </note> |
| 5819 | </para> |
| 5820 | |
| 5821 | <para> |
| 5822 | Understanding some memory concepts will help you reduce the |
| 5823 | system size. |
| 5824 | Memory consists of static, dynamic, and temporary memory. |
| 5825 | Static memory is the TEXT (code), DATA (initialized data |
| 5826 | in the code), and BSS (uninitialized data) sections. |
| 5827 | Dynamic memory represents memory that is allocated at runtime: |
| 5828 | stacks, hash tables, and so forth. |
| 5829 | Temporary memory is recovered after the boot process. |
| 5830 | This memory consists of memory used for decompressing |
| 5831 | the kernel and for the <filename>__init__</filename> |
| 5832 | functions. |
| 5833 | </para> |
| 5834 | |
| 5835 | <para> |
| 5836 | To help you see where you currently are with kernel and root |
| 5837 | filesystem sizes, you can use two tools found in the |
| 5838 | <ulink url='&YOCTO_DOCS_REF_URL;#source-directory'>Source Directory</ulink> in |
| 5839 | the <filename>scripts/tiny/</filename> directory: |
| 5840 | <itemizedlist> |
| 5841 | <listitem><para><filename>ksize.py</filename>: Reports |
| 5842 | component sizes for the kernel build objects. |
| 5843 | </para></listitem> |
| 5844 | <listitem><para><filename>dirsize.py</filename>: Reports |
| 5845 | component sizes for the root filesystem.</para></listitem> |
| 5846 | </itemizedlist> |
| 5847 | This next tool and command help you organize configuration |
| 5848 | fragments and view file dependencies in a human-readable form: |
| 5849 | <itemizedlist> |
| 5850 | <listitem><para><filename>merge_config.sh</filename>: |
| 5851 | Helps you manage configuration files and fragments |
| 5852 | within the kernel. |
| 5853 | With this tool, you can merge individual configuration |
| 5854 | fragments together. |
| 5855 | The tool allows you to make overrides and warns you |
| 5856 | of any missing configuration options. |
| 5857 | The tool is ideal for allowing you to iterate on |
| 5858 | configurations, create minimal configurations, and |
| 5859 | create configuration files for different machines |
| 5860 | without having to duplicate your process.</para> |
| 5861 | <para>The <filename>merge_config.sh</filename> script is |
| 5862 | part of the Linux Yocto kernel Git repositories |
| 5863 | (i.e. <filename>linux-yocto-3.14</filename>, |
| 5864 | <filename>linux-yocto-3.10</filename>, |
| 5865 | <filename>linux-yocto-3.8</filename>, and so forth) |
| 5866 | in the |
| 5867 | <filename>scripts/kconfig</filename> directory.</para> |
| 5868 | <para>For more information on configuration fragments, |
| 5869 | see the |
| 5870 | "<ulink url='&YOCTO_DOCS_KERNEL_DEV_URL;#creating-config-fragments'>Creating Configuration Fragments</ulink>" |
| 5871 | section in the Yocto Project Linux Kernel Development |
| 5872 | Manual. |
| 5873 | </para></listitem> |
| 5874 | <listitem><para><filename>bitbake -u taskexp -g <replaceable>bitbake_target</replaceable></filename>: |
| 5875 | Using the BitBake command with these options brings up |
| 5876 | a Dependency Explorer from which you can view file |
| 5877 | dependencies. |
| 5878 | Understanding these dependencies allows you to make |
| 5879 | informed decisions when cutting out various pieces of the |
| 5880 | kernel and root filesystem.</para></listitem> |
| 5881 | </itemizedlist> |
| 5882 | </para> |
| 5883 | </section> |
| 5884 | |
| 5885 | <section id='trim-the-root-filesystem'> |
| 5886 | <title>Trim the Root Filesystem</title> |
| 5887 | |
| 5888 | <para> |
| 5889 | The root filesystem is made up of packages for booting, |
| 5890 | libraries, and applications. |
| 5891 | To change things, you can configure how the packaging happens, |
| 5892 | which changes the way you build them. |
| 5893 | You can also modify the filesystem itself or select a different |
| 5894 | filesystem. |
| 5895 | </para> |
| 5896 | |
| 5897 | <para> |
| 5898 | First, find out what is hogging your root filesystem by running the |
| 5899 | <filename>dirsize.py</filename> script from your root directory: |
| 5900 | <literallayout class='monospaced'> |
| 5901 | $ cd <replaceable>root-directory-of-image</replaceable> |
| 5902 | $ dirsize.py 100000 > dirsize-100k.log |
| 5903 | $ cat dirsize-100k.log |
| 5904 | </literallayout> |
| 5905 | You can apply a filter to the script to ignore files under |
| 5906 | a certain size. |
| 5907 | The previous example filters out any files below 100 Kbytes. |
| 5908 | The sizes reported by the tool are uncompressed, and thus |
| 5909 | will be smaller by a relatively constant factor in a |
| 5910 | compressed root filesystem. |
| 5911 | When you examine your log file, you can focus on areas of the |
| 5912 | root filesystem that take up large amounts of memory. |
| 5913 | </para> |
| 5914 | |
| 5915 | <para> |
| 5916 | You need to be sure that what you eliminate does not cripple |
| 5917 | the functionality you need. |
| 5918 | One way to see how packages relate to each other is by using |
| 5919 | the Dependency Explorer UI with the BitBake command: |
| 5920 | <literallayout class='monospaced'> |
| 5921 | $ cd <replaceable>image-directory</replaceable> |
| 5922 | $ bitbake -u taskexp -g <replaceable>image</replaceable> |
| 5923 | </literallayout> |
| 5924 | Use the interface to select potential packages you wish to |
| 5925 | eliminate and see their dependency relationships. |
| 5926 | </para> |
| 5927 | |
| 5928 | <para> |
| 5929 | When deciding how to reduce the size, get rid of packages that |
| 5930 | result in minimal impact on the feature set. |
| 5931 | For example, you might not need a VGA display. |
| 5932 | Or, you might be able to get by with <filename>devtmpfs</filename> |
| 5933 | and <filename>mdev</filename> instead of |
| 5934 | <filename>udev</filename>. |
| 5935 | </para> |
| 5936 | |
| 5937 | <para> |
| 5938 | Use your <filename>local.conf</filename> file to make changes. |
| 5939 | For example, to eliminate <filename>udev</filename> and |
| 5940 | <filename>glib</filename>, set the following in the |
| 5941 | local configuration file: |
| 5942 | <literallayout class='monospaced'> |
| 5943 | VIRTUAL-RUNTIME_dev_manager = "" |
| 5944 | </literallayout> |
| 5945 | </para> |
| 5946 | |
| 5947 | <para> |
| 5948 | Finally, you should consider exactly the type of root |
| 5949 | filesystem you need to meet your needs while also reducing |
| 5950 | its size. |
| 5951 | For example, consider <filename>cramfs</filename>, |
| 5952 | <filename>squashfs</filename>, <filename>ubifs</filename>, |
| 5953 | <filename>ext2</filename>, or an <filename>initramfs</filename> |
| 5954 | using <filename>initramfs</filename>. |
| 5955 | Be aware that <filename>ext3</filename> requires a 1 Mbyte |
| 5956 | journal. |
| 5957 | If you are okay with running read-only, you do not need this |
| 5958 | journal. |
| 5959 | </para> |
| 5960 | |
| 5961 | <note> |
| 5962 | After each round of elimination, you need to rebuild your |
| 5963 | system and then use the tools to see the effects of your |
| 5964 | reductions. |
| 5965 | </note> |
| 5966 | </section> |
| 5967 | |
| 5968 | <section id='trim-the-kernel'> |
| 5969 | <title>Trim the Kernel</title> |
| 5970 | |
| 5971 | <para> |
| 5972 | The kernel is built by including policies for hardware-independent |
| 5973 | aspects. |
| 5974 | What subsystems do you enable? |
| 5975 | For what architecture are you building? |
| 5976 | Which drivers do you build by default? |
| 5977 | <note>You can modify the kernel source if you want to help |
| 5978 | with boot time. |
| 5979 | </note> |
| 5980 | </para> |
| 5981 | |
| 5982 | <para> |
| 5983 | Run the <filename>ksize.py</filename> script from the top-level |
| 5984 | Linux build directory to get an idea of what is making up |
| 5985 | the kernel: |
| 5986 | <literallayout class='monospaced'> |
| 5987 | $ cd <replaceable>top-level-linux-build-directory</replaceable> |
| 5988 | $ ksize.py > ksize.log |
| 5989 | $ cat ksize.log |
| 5990 | </literallayout> |
| 5991 | When you examine the log, you will see how much space is |
| 5992 | taken up with the built-in <filename>.o</filename> files for |
| 5993 | drivers, networking, core kernel files, filesystem, sound, |
| 5994 | and so forth. |
| 5995 | The sizes reported by the tool are uncompressed, and thus |
| 5996 | will be smaller by a relatively constant factor in a compressed |
| 5997 | kernel image. |
| 5998 | Look to reduce the areas that are large and taking up around |
| 5999 | the "90% rule." |
| 6000 | </para> |
| 6001 | |
| 6002 | <para> |
| 6003 | To examine, or drill down, into any particular area, use the |
| 6004 | <filename>-d</filename> option with the script: |
| 6005 | <literallayout class='monospaced'> |
| 6006 | $ ksize.py -d > ksize.log |
| 6007 | </literallayout> |
| 6008 | Using this option breaks out the individual file information |
| 6009 | for each area of the kernel (e.g. drivers, networking, and |
| 6010 | so forth). |
| 6011 | </para> |
| 6012 | |
| 6013 | <para> |
| 6014 | Use your log file to see what you can eliminate from the kernel |
| 6015 | based on features you can let go. |
| 6016 | For example, if you are not going to need sound, you do not |
| 6017 | need any drivers that support sound. |
| 6018 | </para> |
| 6019 | |
| 6020 | <para> |
| 6021 | After figuring out what to eliminate, you need to reconfigure |
| 6022 | the kernel to reflect those changes during the next build. |
| 6023 | You could run <filename>menuconfig</filename> and make all your |
| 6024 | changes at once. |
| 6025 | However, that makes it difficult to see the effects of your |
| 6026 | individual eliminations and also makes it difficult to replicate |
| 6027 | the changes for perhaps another target device. |
| 6028 | A better method is to start with no configurations using |
| 6029 | <filename>allnoconfig</filename>, create configuration |
| 6030 | fragments for individual changes, and then manage the |
| 6031 | fragments into a single configuration file using |
| 6032 | <filename>merge_config.sh</filename>. |
| 6033 | The tool makes it easy for you to iterate using the |
| 6034 | configuration change and build cycle. |
| 6035 | </para> |
| 6036 | |
| 6037 | <para> |
| 6038 | Each time you make configuration changes, you need to rebuild |
| 6039 | the kernel and check to see what impact your changes had on |
| 6040 | the overall size. |
| 6041 | </para> |
| 6042 | </section> |
| 6043 | |
| 6044 | <section id='remove-package-management-requirements'> |
| 6045 | <title>Remove Package Management Requirements</title> |
| 6046 | |
| 6047 | <para> |
| 6048 | Packaging requirements add size to the image. |
| 6049 | One way to reduce the size of the image is to remove all the |
| 6050 | packaging requirements from the image. |
| 6051 | This reduction includes both removing the package manager |
| 6052 | and its unique dependencies as well as removing the package |
| 6053 | management data itself. |
| 6054 | </para> |
| 6055 | |
| 6056 | <para> |
| 6057 | To eliminate all the packaging requirements for an image, |
| 6058 | be sure that "package-management" is not part of your |
| 6059 | <ulink url='&YOCTO_DOCS_REF_URL;#var-IMAGE_FEATURES'><filename>IMAGE_FEATURES</filename></ulink> |
| 6060 | statement for the image. |
| 6061 | When you remove this feature, you are removing the package |
| 6062 | manager as well as its dependencies from the root filesystem. |
| 6063 | </para> |
| 6064 | </section> |
| 6065 | |
| 6066 | <section id='look-for-other-ways-to-minimize-size'> |
| 6067 | <title>Look for Other Ways to Minimize Size</title> |
| 6068 | |
| 6069 | <para> |
| 6070 | Depending on your particular circumstances, other areas that you |
| 6071 | can trim likely exist. |
| 6072 | The key to finding these areas is through tools and methods |
| 6073 | described here combined with experimentation and iteration. |
| 6074 | Here are a couple of areas to experiment with: |
| 6075 | <itemizedlist> |
| 6076 | <listitem><para><filename>glibc</filename>: |
| 6077 | In general, follow this process: |
| 6078 | <orderedlist> |
| 6079 | <listitem><para>Remove <filename>glibc</filename> |
| 6080 | features from |
| 6081 | <ulink url='&YOCTO_DOCS_REF_URL;#var-DISTRO_FEATURES'><filename>DISTRO_FEATURES</filename></ulink> |
| 6082 | that you think you do not need.</para></listitem> |
| 6083 | <listitem><para>Build your distribution. |
| 6084 | </para></listitem> |
| 6085 | <listitem><para>If the build fails due to missing |
| 6086 | symbols in a package, determine if you can |
| 6087 | reconfigure the package to not need those |
| 6088 | features. |
| 6089 | For example, change the configuration to not |
| 6090 | support wide character support as is done for |
| 6091 | <filename>ncurses</filename>. |
| 6092 | Or, if support for those characters is needed, |
| 6093 | determine what <filename>glibc</filename> |
| 6094 | features provide the support and restore the |
| 6095 | configuration. |
| 6096 | </para></listitem> |
| 6097 | <listitem><para>Rebuild and repeat the process. |
| 6098 | </para></listitem> |
| 6099 | </orderedlist></para></listitem> |
| 6100 | <listitem><para><filename>busybox</filename>: |
| 6101 | For BusyBox, use a process similar as described for |
| 6102 | <filename>glibc</filename>. |
| 6103 | A difference is you will need to boot the resulting |
| 6104 | system to see if you are able to do everything you |
| 6105 | expect from the running system. |
| 6106 | You need to be sure to integrate configuration fragments |
| 6107 | into Busybox because BusyBox handles its own core |
| 6108 | features and then allows you to add configuration |
| 6109 | fragments on top. |
| 6110 | </para></listitem> |
| 6111 | </itemizedlist> |
| 6112 | </para> |
| 6113 | </section> |
| 6114 | |
| 6115 | <section id='iterate-on-the-process'> |
| 6116 | <title>Iterate on the Process</title> |
| 6117 | |
| 6118 | <para> |
| 6119 | If you have not reached your goals on system size, you need |
| 6120 | to iterate on the process. |
| 6121 | The process is the same. |
| 6122 | Use the tools and see just what is taking up 90% of the root |
| 6123 | filesystem and the kernel. |
| 6124 | Decide what you can eliminate without limiting your device |
| 6125 | beyond what you need. |
| 6126 | </para> |
| 6127 | |
| 6128 | <para> |
| 6129 | Depending on your system, a good place to look might be |
| 6130 | Busybox, which provides a stripped down |
| 6131 | version of Unix tools in a single, executable file. |
| 6132 | You might be able to drop virtual terminal services or perhaps |
| 6133 | ipv6. |
| 6134 | </para> |
| 6135 | </section> |
| 6136 | </section> |
| 6137 | |
| 6138 | <section id='building-images-for-more-than-one-machine'> |
| 6139 | <title>Building Images for More than One Machine</title> |
| 6140 | |
| 6141 | <para> |
| 6142 | A common scenario developers face is creating images for several |
| 6143 | different machines that use the same software environment. |
| 6144 | In this situation, it is tempting to set the |
| 6145 | tunings and optimization flags for each build specifically for |
| 6146 | the targeted hardware (i.e. "maxing out" the tunings). |
| 6147 | Doing so can considerably add to build times and package feed |
| 6148 | maintenance collectively for the machines. |
| 6149 | For example, selecting tunes that are extremely specific to a |
| 6150 | CPU core used in a system might enable some micro optimizations |
| 6151 | in GCC for that particular system but would otherwise not gain |
| 6152 | you much of a performance difference across the other systems |
| 6153 | as compared to using a more general tuning across all the builds |
| 6154 | (e.g. setting |
| 6155 | <ulink url='&YOCTO_DOCS_REF_URL;#var-DEFAULTTUNE'><filename>DEFAULTTUNE</filename></ulink> |
| 6156 | specifically for each machine's build). |
| 6157 | Rather than "max out" each build's tunings, you can take steps that |
| 6158 | cause the OpenEmbedded build system to reuse software across the |
| 6159 | various machines where it makes sense. |
| 6160 | </para> |
| 6161 | |
| 6162 | <para> |
| 6163 | If build speed and package feed maintenance are considerations, |
| 6164 | you should consider the points in this section that can help you |
| 6165 | optimize your tunings to best consider build times and package |
| 6166 | feed maintenance. |
| 6167 | <itemizedlist> |
| 6168 | <listitem><para> |
| 6169 | <emphasis>Share the Build Directory:</emphasis> |
| 6170 | If at all possible, share the |
| 6171 | <ulink url='&YOCTO_DOCS_REF_URL;#var-TMPDIR'><filename>TMPDIR</filename></ulink> |
| 6172 | across builds. |
| 6173 | The Yocto Project supports switching between different |
| 6174 | <ulink url='&YOCTO_DOCS_REF_URL;#var-MACHINE'><filename>MACHINE</filename></ulink> |
| 6175 | values in the same <filename>TMPDIR</filename>. |
| 6176 | This practice is well supported and regularly used by |
| 6177 | developers when building for multiple machines. |
| 6178 | When you use the same <filename>TMPDIR</filename> for |
| 6179 | multiple machine builds, the OpenEmbedded build system can |
| 6180 | reuse the existing native and often cross-recipes for |
| 6181 | multiple machines. |
| 6182 | Thus, build time decreases. |
| 6183 | <note> |
| 6184 | If |
| 6185 | <ulink url='&YOCTO_DOCS_REF_URL;#var-DISTRO'><filename>DISTRO</filename></ulink> |
| 6186 | settings change or fundamental configuration settings |
| 6187 | such as the filesystem layout, you need to work with |
| 6188 | a clean <filename>TMPDIR</filename>. |
| 6189 | Sharing <filename>TMPDIR</filename> under these |
| 6190 | circumstances might work but since it is not |
| 6191 | guaranteed, you should use a clean |
| 6192 | <filename>TMPDIR</filename>. |
| 6193 | </note> |
| 6194 | </para></listitem> |
| 6195 | <listitem><para> |
| 6196 | <emphasis>Enable the Appropriate Package Architecture:</emphasis> |
| 6197 | By default, the OpenEmbedded build system enables three |
| 6198 | levels of package architectures: "all", "tune" or "package", |
| 6199 | and "machine". |
| 6200 | Any given recipe usually selects one of these package |
| 6201 | architectures (types) for its output. |
| 6202 | Depending for what a given recipe creates packages, making |
| 6203 | sure you enable the appropriate package architecture can |
| 6204 | directly impact the build time.</para> |
| 6205 | |
| 6206 | <para>A recipe that just generates scripts can enable |
| 6207 | "all" architecture because there are no binaries to build. |
| 6208 | To specifically enable "all" architecture, be sure your |
| 6209 | recipe inherits the |
| 6210 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-allarch'><filename>allarch</filename></ulink> |
| 6211 | class. |
| 6212 | This class is useful for "all" architectures because it |
| 6213 | configures many variables so packages can be used across |
| 6214 | multiple architectures.</para> |
| 6215 | |
| 6216 | <para>If your recipe needs to generate packages that are |
| 6217 | machine-specific or when one of the build or runtime |
| 6218 | dependencies is already machine-architecture dependent, |
| 6219 | which makes your recipe also machine-architecture dependent, |
| 6220 | make sure your recipe enables the "machine" package |
| 6221 | architecture through the |
| 6222 | <ulink url='&YOCTO_DOCS_REF_URL;#var-MACHINE_ARCH'><filename>MACHINE_ARCH</filename></ulink> |
| 6223 | variable: |
| 6224 | <literallayout class='monospaced'> |
| 6225 | PACKAGE_ARCH = "${MACHINE_ARCH}" |
| 6226 | </literallayout> |
| 6227 | When you do not specifically enable a package |
| 6228 | architecture through the |
| 6229 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_ARCH'><filename>PACKAGE_ARCH</filename></ulink>, |
| 6230 | The OpenEmbedded build system defaults to the |
| 6231 | <ulink url='&YOCTO_DOCS_REF_URL;#var-TUNE_PKGARCH'><filename>TUNE_PKGARCH</filename></ulink> |
| 6232 | setting: |
| 6233 | <literallayout class='monospaced'> |
| 6234 | PACKAGE_ARCH = "${TUNE_PKGARCH}" |
| 6235 | </literallayout> |
| 6236 | </para></listitem> |
| 6237 | <listitem><para> |
| 6238 | <emphasis>Choose a Generic Tuning File if Possible:</emphasis> |
| 6239 | Some tunes are more generic and can run on multiple targets |
| 6240 | (e.g. an <filename>armv5</filename> set of packages could |
| 6241 | run on <filename>armv6</filename> and |
| 6242 | <filename>armv7</filename> processors in most cases). |
| 6243 | Similarly, <filename>i486</filename> binaries could work |
| 6244 | on <filename>i586</filename> and higher processors. |
| 6245 | You should realize, however, that advances on newer |
| 6246 | processor versions would not be used.</para> |
| 6247 | |
| 6248 | <para>If you select the same tune for several different |
| 6249 | machines, the OpenEmbedded build system reuses software |
| 6250 | previously built, thus speeding up the overall build time. |
| 6251 | Realize that even though a new sysroot for each machine is |
| 6252 | generated, the software is not recompiled and only one |
| 6253 | package feed exists. |
| 6254 | </para></listitem> |
| 6255 | <listitem><para> |
| 6256 | <emphasis>Manage Granular Level Packaging:</emphasis> |
| 6257 | Sometimes cases exist where injecting another level of |
| 6258 | package architecture beyond the three higher levels noted |
| 6259 | earlier can be useful. |
| 6260 | For example, consider how NXP (formerly Freescale) allows |
| 6261 | for the easy reuse of binary packages in their layer |
| 6262 | <ulink url='&YOCTO_GIT_URL;/cgit/cgit.cgi/meta-freescale/'><filename>meta-freescale</filename></ulink>. |
| 6263 | In this example, the |
| 6264 | <ulink url='&YOCTO_GIT_URL;/cgit/cgit.cgi/meta-freescale/tree/classes/fsl-dynamic-packagearch.bbclass'><filename>fsl-dynamic-packagearch</filename></ulink> |
| 6265 | class shares GPU packages for i.MX53 boards because |
| 6266 | all boards share the AMD GPU. |
| 6267 | The i.MX6-based boards can do the same because all boards |
| 6268 | share the Vivante GPU. |
| 6269 | This class inspects the BitBake datastore to identify if |
| 6270 | the package provides or depends on one of the |
| 6271 | sub-architecture values. |
| 6272 | If so, the class sets the |
| 6273 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_ARCH'><filename>PACKAGE_ARCH</filename></ulink> |
| 6274 | value based on the <filename>MACHINE_SUBARCH</filename> |
| 6275 | value. |
| 6276 | If the package does not provide or depend on one of the |
| 6277 | sub-architecture values but it matches a value in the |
| 6278 | machine-specific filter, it sets |
| 6279 | <ulink url='&YOCTO_DOCS_REF_URL;#var-MACHINE_ARCH'><filename>MACHINE_ARCH</filename></ulink>. |
| 6280 | This behavior reduces the number of packages built and |
| 6281 | saves build time by reusing binaries. |
| 6282 | </para></listitem> |
| 6283 | <listitem><para> |
| 6284 | <emphasis>Use Tools to Debug Issues:</emphasis> |
| 6285 | Sometimes you can run into situations where software is |
| 6286 | being rebuilt when you think it should not be. |
| 6287 | For example, the OpenEmbedded build system might not be |
| 6288 | using shared state between machines when you think it |
| 6289 | should be. |
| 6290 | These types of situations are usually due to references |
| 6291 | to machine-specific variables such as |
| 6292 | <ulink url='&YOCTO_DOCS_REF_URL;#var-MACHINE'><filename>MACHINE</filename></ulink>, |
| 6293 | <ulink url='&YOCTO_DOCS_REF_URL;#var-SERIAL_CONSOLES'><filename>SERIAL_CONSOLES</filename></ulink>, |
| 6294 | <ulink url='&YOCTO_DOCS_REF_URL;#var-XSERVER'><filename>XSERVER</filename></ulink>, |
| 6295 | <ulink url='&YOCTO_DOCS_REF_URL;#var-MACHINE_FEATURES'><filename>MACHINE_FEATURES</filename></ulink>, |
| 6296 | and so forth in code that is supposed to only be |
| 6297 | tune-specific or when the recipe depends |
| 6298 | (<ulink url='&YOCTO_DOCS_REF_URL;#var-DEPENDS'><filename>DEPENDS</filename></ulink>, |
| 6299 | <ulink url='&YOCTO_DOCS_REF_URL;#var-RDEPENDS'><filename>RDEPENDS</filename></ulink>, |
| 6300 | <ulink url='&YOCTO_DOCS_REF_URL;#var-RRECOMMENDS'><filename>RRECOMMENDS</filename></ulink>, |
| 6301 | <ulink url='&YOCTO_DOCS_REF_URL;#var-RSUGGESTS'><filename>RSUGGESTS</filename></ulink>, |
| 6302 | and so forth) on some other recipe that already has |
| 6303 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_ARCH'><filename>PACKAGE_ARCH</filename></ulink> |
| 6304 | defined as "${MACHINE_ARCH}". |
| 6305 | <note> |
| 6306 | Patches to fix any issues identified are most welcome |
| 6307 | as these issues occasionally do occur. |
| 6308 | </note></para> |
| 6309 | |
| 6310 | <para>For such cases, you can use some tools to help you |
| 6311 | sort out the situation: |
| 6312 | <itemizedlist> |
| 6313 | <listitem><para> |
| 6314 | <emphasis><filename>sstate-diff-machines.sh</filename>:</emphasis> |
| 6315 | You can find this tool in the |
| 6316 | <filename>scripts</filename> directory of the |
| 6317 | Source Repositories. |
| 6318 | See the comments in the script for information on |
| 6319 | how to use the tool. |
| 6320 | </para></listitem> |
| 6321 | <listitem><para> |
| 6322 | <emphasis>BitBake's "-S printdiff" Option:</emphasis> |
| 6323 | Using this option causes BitBake to try to |
| 6324 | establish the closest signature match it can |
| 6325 | (e.g. in the shared state cache) and then run |
| 6326 | <filename>bitbake-diffsigs</filename> over the |
| 6327 | matches to determine the stamps and delta where |
| 6328 | these two stamp trees diverge. |
| 6329 | </para></listitem> |
| 6330 | </itemizedlist> |
| 6331 | </para></listitem> |
| 6332 | </itemizedlist> |
| 6333 | </para> |
| 6334 | </section> |
| 6335 | |
| 6336 | <section id="building-software-from-an-external-source"> |
| 6337 | <title>Building Software from an External Source</title> |
| 6338 | |
| 6339 | <para> |
| 6340 | By default, the OpenEmbedded build system uses the |
| 6341 | <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink> |
| 6342 | when building source code. |
| 6343 | The build process involves fetching the source files, unpacking |
| 6344 | them, and then patching them if necessary before the build takes |
| 6345 | place. |
| 6346 | </para> |
| 6347 | |
| 6348 | <para> |
| 6349 | Situations exist where you might want to build software from source |
| 6350 | files that are external to and thus outside of the |
| 6351 | OpenEmbedded build system. |
| 6352 | For example, suppose you have a project that includes a new BSP with |
| 6353 | a heavily customized kernel. |
| 6354 | And, you want to minimize exposing the build system to the |
| 6355 | development team so that they can focus on their project and |
| 6356 | maintain everyone's workflow as much as possible. |
| 6357 | In this case, you want a kernel source directory on the development |
| 6358 | machine where the development occurs. |
| 6359 | You want the recipe's |
| 6360 | <ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'><filename>SRC_URI</filename></ulink> |
| 6361 | variable to point to the external directory and use it as is, not |
| 6362 | copy it. |
| 6363 | </para> |
| 6364 | |
| 6365 | <para> |
| 6366 | To build from software that comes from an external source, all you |
| 6367 | need to do is inherit the |
| 6368 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-externalsrc'><filename>externalsrc</filename></ulink> |
| 6369 | class and then set the |
| 6370 | <ulink url='&YOCTO_DOCS_REF_URL;#var-EXTERNALSRC'><filename>EXTERNALSRC</filename></ulink> |
| 6371 | variable to point to your external source code. |
| 6372 | Here are the statements to put in your |
| 6373 | <filename>local.conf</filename> file: |
| 6374 | <literallayout class='monospaced'> |
| 6375 | INHERIT += "externalsrc" |
| 6376 | EXTERNALSRC_pn-<replaceable>myrecipe</replaceable> = "<replaceable>path-to-your-source-tree</replaceable>" |
| 6377 | </literallayout> |
| 6378 | </para> |
| 6379 | |
| 6380 | <para> |
| 6381 | This next example shows how to accomplish the same thing by setting |
| 6382 | <filename>EXTERNALSRC</filename> in the recipe itself or in the |
| 6383 | recipe's append file: |
| 6384 | <literallayout class='monospaced'> |
| 6385 | EXTERNALSRC = "<replaceable>path</replaceable>" |
| 6386 | EXTERNALSRC_BUILD = "<replaceable>path</replaceable>" |
| 6387 | </literallayout> |
| 6388 | <note> |
| 6389 | In order for these settings to take effect, you must globally |
| 6390 | or locally inherit the |
| 6391 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-externalsrc'><filename>externalsrc</filename></ulink> |
| 6392 | class. |
| 6393 | </note> |
| 6394 | </para> |
| 6395 | |
| 6396 | <para> |
| 6397 | By default, <filename>externalsrc.bbclass</filename> builds |
| 6398 | the source code in a directory separate from the external source |
| 6399 | directory as specified by |
| 6400 | <ulink url='&YOCTO_DOCS_REF_URL;#var-EXTERNALSRC'><filename>EXTERNALSRC</filename></ulink>. |
| 6401 | If you need to have the source built in the same directory in |
| 6402 | which it resides, or some other nominated directory, you can set |
| 6403 | <ulink url='&YOCTO_DOCS_REF_URL;#var-EXTERNALSRC_BUILD'><filename>EXTERNALSRC_BUILD</filename></ulink> |
| 6404 | to point to that directory: |
| 6405 | <literallayout class='monospaced'> |
| 6406 | EXTERNALSRC_BUILD_pn-<replaceable>myrecipe</replaceable> = "<replaceable>path-to-your-source-tree</replaceable>" |
| 6407 | </literallayout> |
| 6408 | </para> |
| 6409 | </section> |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 6410 | |
| 6411 | <section id="replicating-a-build-offline"> |
| 6412 | <title>Replicating a Build Offline</title> |
| 6413 | |
| 6414 | <para> |
| 6415 | It can be useful to take a "snapshot" of upstream sources |
| 6416 | used in a build and then use that "snapshot" later to |
| 6417 | replicate the build offline. |
| 6418 | To do so, you need to first prepare and populate your downloads |
| 6419 | directory your "snapshot" of files. |
| 6420 | Once your downloads directory is ready, you can use it at |
| 6421 | any time and from any machine to replicate your build. |
| 6422 | </para> |
| 6423 | |
| 6424 | <para> |
| 6425 | Follow these steps to populate your Downloads directory: |
| 6426 | <orderedlist> |
| 6427 | <listitem><para> |
| 6428 | <emphasis>Create a Clean Downloads Directory:</emphasis> |
| 6429 | Start with an empty downloads directory |
| 6430 | (<ulink url='&YOCTO_DOCS_REF_URL;#var-DL_DIR'><filename>DL_DIR</filename></ulink>). |
| 6431 | You start with an empty downloads directory by either |
| 6432 | removing the files in the existing directory or by |
| 6433 | setting |
| 6434 | <filename>DL_DIR</filename> to point to either an |
| 6435 | empty location or one that does not yet exist. |
| 6436 | </para></listitem> |
| 6437 | <listitem><para> |
| 6438 | <emphasis>Generate Tarballs of the Source Git Repositories:</emphasis> |
| 6439 | Edit your <filename>local.conf</filename> configuration |
| 6440 | file as follows: |
| 6441 | <literallayout class='monospaced'> |
| 6442 | DL_DIR = "/home/<replaceable>your-download-dir</replaceable>/" |
| 6443 | BB_GENERATE_MIRROR_TARBALLS = "1" |
| 6444 | </literallayout> |
| 6445 | During the fetch process in the next step, BitBake |
| 6446 | gathers the source files and creates tarballs in |
| 6447 | the directory pointed to by <filename>DL_DIR</filename>. |
| 6448 | See the |
| 6449 | <ulink url='&YOCTO_DOCS_REF_URL;#var-BB_GENERATE_MIRROR_TARBALLS'><filename>BB_GENERATE_MIRROR_TARBALLS</filename></ulink> |
| 6450 | variable for more information. |
| 6451 | </para></listitem> |
| 6452 | <listitem><para> |
| 6453 | <emphasis>Populate Your Downloads Directory Without Building:</emphasis> |
| 6454 | Use BitBake to fetch your sources but inhibit the |
| 6455 | build: |
| 6456 | <literallayout class='monospaced'> |
| 6457 | $ bitbake <replaceable>target</replaceable> --runonly=fetch |
| 6458 | </literallayout> |
| 6459 | The downloads directory (i.e. |
| 6460 | <filename>${DL_DIR}</filename>) now has a "snapshot" of |
| 6461 | the source files in the form of tarballs, which can |
| 6462 | be used for the build. |
| 6463 | </para></listitem> |
| 6464 | <listitem><para> |
| 6465 | <emphasis>Optionally Remove Any Git or other SCM Subdirectories From the Downloads Directory:</emphasis> |
| 6466 | If you want, you can clean up your downloads directory |
| 6467 | by removing any Git or other Source Control Management |
| 6468 | (SCM) subdirectories such as |
| 6469 | <filename>${DL_DIR}/git2/*</filename>. |
| 6470 | The tarballs already contain these subdirectories. |
| 6471 | </para></listitem> |
| 6472 | </orderedlist> |
| 6473 | </para> |
| 6474 | |
| 6475 | <para> |
| 6476 | Once your downloads directory has everything it needs regarding |
| 6477 | source files, you can create your "own-mirror" and build |
| 6478 | your target. |
| 6479 | Understand that you can use the files to build the target |
| 6480 | offline from any machine and at any time. |
| 6481 | </para> |
| 6482 | |
| 6483 | <para> |
| 6484 | Follow these steps to build your target using the files in the |
| 6485 | downloads directory: |
| 6486 | <orderedlist> |
| 6487 | <listitem><para> |
| 6488 | <emphasis>Using Local Files Only:</emphasis> |
| 6489 | Inside your <filename>local.conf</filename> file, add |
| 6490 | the |
| 6491 | <ulink url='&YOCTO_DOCS_REF_URL;#var-SOURCE_MIRROR_URL'><filename>SOURCE_MIRROR_URL</filename></ulink> |
| 6492 | variable, |
| 6493 | inherit the <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-own-mirrors'><filename>own-mirrors</filename></ulink> |
| 6494 | class, and use the |
| 6495 | <ulink url='&YOCTO_DOCS_BB_URL;#var-bb-BB_NO_NETWORK'><filename>BB_NO_NETWORK</filename></ulink> |
| 6496 | variable to your <filename>local.conf</filename>. |
| 6497 | <literallayout class='monospaced'> |
| 6498 | SOURCE_MIRROR_URL ?= "file:///home/<replaceable>your-download-dir</replaceable>/" |
| 6499 | INHERIT += "own-mirrors" |
| 6500 | BB_NO_NETWORK = "1" |
| 6501 | </literallayout> |
| 6502 | The <filename>SOURCE_MIRROR_URL</filename> and |
| 6503 | <filename>own-mirror</filename> class set up the system |
| 6504 | to use the downloads directory as your "own mirror". |
| 6505 | Using the <filename>BB_NO_NETWORK</filename> |
| 6506 | variable makes sure that BitBake's fetching process |
| 6507 | in step 3 stays local, which means files from |
| 6508 | your "own-mirror" are used. |
| 6509 | </para></listitem> |
| 6510 | <listitem><para> |
| 6511 | <emphasis>Start With a Clean Build:</emphasis> |
| 6512 | You can start with a clean build by removing the |
| 6513 | <filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-TMPDIR'><filename>TMPDIR</filename></ulink><filename>}</filename> |
| 6514 | directory or using a new |
| 6515 | <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink>. |
| 6516 | </para></listitem> |
| 6517 | <listitem><para> |
| 6518 | <emphasis>Build Your Target:</emphasis> |
| 6519 | Use BitBake to build your target: |
| 6520 | <literallayout class='monospaced'> |
| 6521 | $ bitbake <replaceable>target</replaceable> |
| 6522 | </literallayout> |
| 6523 | The build completes using the known local "snapshot" of |
| 6524 | source files from your mirror. |
| 6525 | The resulting tarballs for your "snapshot" of source |
| 6526 | files are in the downloads directory. |
| 6527 | <note> |
| 6528 | <para>The offline build does not work if recipes |
| 6529 | attempt to find the latest version of software |
| 6530 | by setting |
| 6531 | <ulink url='&YOCTO_DOCS_REF_URL;#var-SRCREV'><filename>SRCREV</filename></ulink> |
| 6532 | to |
| 6533 | <filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-AUTOREV'><filename>AUTOREV</filename></ulink><filename>}</filename>: |
| 6534 | <literallayout class='monospaced'> |
| 6535 | SRCREV = "${AUTOREV}" |
| 6536 | </literallayout> |
| 6537 | When a recipe sets |
| 6538 | <filename>SRCREV</filename> to |
| 6539 | <filename>${AUTOREV}</filename>, the build system |
| 6540 | accesses the network in an attempt to determine the |
| 6541 | latest version of software from the SCM. |
| 6542 | Typically, recipes that use |
| 6543 | <filename>AUTOREV</filename> are custom or |
| 6544 | modified recipes. |
| 6545 | Recipes that reside in public repositories |
| 6546 | usually do not use <filename>AUTOREV</filename>. |
| 6547 | </para> |
| 6548 | |
| 6549 | <para>If you do have recipes that use |
| 6550 | <filename>AUTOREV</filename>, you can take steps to |
| 6551 | still use the recipes in an offline build. |
| 6552 | Do the following: |
| 6553 | <orderedlist> |
| 6554 | <listitem><para> |
| 6555 | Use a configuration generated by |
| 6556 | enabling |
| 6557 | <link linkend='maintaining-build-output-quality'>build history</link>. |
| 6558 | </para></listitem> |
| 6559 | <listitem><para> |
| 6560 | Use the |
| 6561 | <filename>buildhistory-collect-srcrevs</filename> |
| 6562 | command to collect the stored |
| 6563 | <filename>SRCREV</filename> values from |
| 6564 | the build's history. |
| 6565 | For more information on collecting these |
| 6566 | values, see the |
| 6567 | "<link linkend='build-history-package-information'>Build History Package Information</link>" |
| 6568 | section. |
| 6569 | </para></listitem> |
| 6570 | <listitem><para> |
| 6571 | Once you have the correct source |
| 6572 | revisions, you can modify those recipes |
| 6573 | to to set <filename>SRCREV</filename> |
| 6574 | to specific versions of the software. |
| 6575 | </para></listitem> |
| 6576 | </orderedlist> |
| 6577 | </para> |
| 6578 | </note> |
| 6579 | </para></listitem> |
| 6580 | </orderedlist> |
| 6581 | </para> |
| 6582 | </section> |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 6583 | </section> |
| 6584 | |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 6585 | <section id='speeding-up-a-build'> |
| 6586 | <title>Speeding Up a Build</title> |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 6587 | |
| 6588 | <para> |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 6589 | Build time can be an issue. |
| 6590 | By default, the build system uses simple controls to try and maximize |
| 6591 | build efficiency. |
| 6592 | In general, the default settings for all the following variables |
| 6593 | result in the most efficient build times when dealing with single |
| 6594 | socket systems (i.e. a single CPU). |
| 6595 | If you have multiple CPUs, you might try increasing the default |
| 6596 | values to gain more speed. |
| 6597 | See the descriptions in the glossary for each variable for more |
| 6598 | information: |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 6599 | <itemizedlist> |
| 6600 | <listitem><para> |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 6601 | <ulink url='&YOCTO_DOCS_REF_URL;#var-BB_NUMBER_THREADS'><filename>BB_NUMBER_THREADS</filename>:</ulink> |
| 6602 | The maximum number of threads BitBake simultaneously executes. |
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 | <ulink url='&YOCTO_DOCS_BB_URL;#var-BB_NUMBER_PARSE_THREADS'><filename>BB_NUMBER_PARSE_THREADS</filename>:</ulink> |
| 6606 | The number of threads BitBake uses during parsing. |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 6607 | </para></listitem> |
| 6608 | <listitem><para> |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 6609 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PARALLEL_MAKE'><filename>PARALLEL_MAKE</filename>:</ulink> |
| 6610 | Extra options passed to the <filename>make</filename> command |
| 6611 | during the |
| 6612 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-compile'><filename>do_compile</filename></ulink> |
| 6613 | task in order to specify parallel compilation on the |
| 6614 | local build host. |
| 6615 | </para></listitem> |
| 6616 | <listitem><para> |
| 6617 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PARALLEL_MAKEINST'><filename>PARALLEL_MAKEINST</filename>:</ulink> |
| 6618 | Extra options passed to the <filename>make</filename> command |
| 6619 | during the |
| 6620 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-install'><filename>do_install</filename></ulink> |
| 6621 | task in order to specify parallel installation on the |
| 6622 | local build host. |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 6623 | </para></listitem> |
| 6624 | </itemizedlist> |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 6625 | As mentioned, these variables all scale to the number of processor |
| 6626 | cores available on the build system. |
| 6627 | For single socket systems, this auto-scaling ensures that the build |
| 6628 | system fundamentally takes advantage of potential parallel operations |
| 6629 | during the build based on the build machine's capabilities. |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 6630 | </para> |
| 6631 | |
| 6632 | <para> |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 6633 | Following are additional factors that can affect build speed: |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 6634 | <itemizedlist> |
| 6635 | <listitem><para> |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 6636 | File system type: |
| 6637 | The file system type that the build is being performed on can |
| 6638 | also influence performance. |
| 6639 | Using <filename>ext4</filename> is recommended as compared |
| 6640 | to <filename>ext2</filename> and <filename>ext3</filename> |
| 6641 | due to <filename>ext4</filename> improved features |
| 6642 | such as extents. |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 6643 | </para></listitem> |
| 6644 | <listitem><para> |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 6645 | Disabling the updating of access time using |
| 6646 | <filename>noatime</filename>: |
| 6647 | The <filename>noatime</filename> mount option prevents the |
| 6648 | build system from updating file and directory access times. |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 6649 | </para></listitem> |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 6650 | <listitem><para> |
| 6651 | Setting a longer commit: |
| 6652 | Using the "commit=" mount option increases the interval |
| 6653 | in seconds between disk cache writes. |
| 6654 | Changing this interval from the five second default to |
| 6655 | something longer increases the risk of data loss but decreases |
| 6656 | the need to write to the disk, thus increasing the build |
| 6657 | performance. |
| 6658 | </para></listitem> |
| 6659 | <listitem><para> |
| 6660 | Choosing the packaging backend: |
| 6661 | Of the available packaging backends, IPK is the fastest. |
| 6662 | Additionally, selecting a singular packaging backend also |
| 6663 | helps. |
| 6664 | </para></listitem> |
| 6665 | <listitem><para> |
| 6666 | Using <filename>tmpfs</filename> for |
| 6667 | <ulink url='&YOCTO_DOCS_REF_URL;#var-TMPDIR'><filename>TMPDIR</filename></ulink> |
| 6668 | as a temporary file system: |
| 6669 | While this can help speed up the build, the benefits are |
| 6670 | limited due to the compiler using |
| 6671 | <filename>-pipe</filename>. |
| 6672 | The build system goes to some lengths to avoid |
| 6673 | <filename>sync()</filename> calls into the |
| 6674 | file system on the principle that if there was a significant |
| 6675 | failure, the |
| 6676 | <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink> |
| 6677 | contents could easily be rebuilt. |
| 6678 | </para></listitem> |
| 6679 | <listitem><para> |
| 6680 | Inheriting the |
| 6681 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-rm-work'><filename>rm_work</filename></ulink> |
| 6682 | class: |
| 6683 | Inheriting this class has shown to speed up builds due to |
| 6684 | significantly lower amounts of data stored in the data |
| 6685 | cache as well as on disk. |
| 6686 | Inheriting this class also makes cleanup of |
| 6687 | <ulink url='&YOCTO_DOCS_REF_URL;#var-TMPDIR'><filename>TMPDIR</filename></ulink> |
| 6688 | faster, at the expense of being easily able to dive into the |
| 6689 | source code. |
| 6690 | File system maintainers have recommended that the fastest way |
| 6691 | to clean up large numbers of files is to reformat partitions |
| 6692 | rather than delete files due to the linear nature of |
| 6693 | partitions. |
| 6694 | This, of course, assumes you structure the disk partitions and |
| 6695 | file systems in a way that this is practical. |
| 6696 | </para></listitem> |
| 6697 | </itemizedlist> |
| 6698 | Aside from the previous list, you should keep some trade offs in |
| 6699 | mind that can help you speed up the build: |
| 6700 | <itemizedlist> |
| 6701 | <listitem><para> |
| 6702 | Remove items from |
| 6703 | <ulink url='&YOCTO_DOCS_REF_URL;#var-DISTRO_FEATURES'><filename>DISTRO_FEATURES</filename></ulink> |
| 6704 | that you might not need. |
| 6705 | </para></listitem> |
| 6706 | <listitem><para> |
| 6707 | Exclude debug symbols and other debug information: |
| 6708 | If you do not need these symbols and other debug information, |
| 6709 | disabling the <filename>*-dbg</filename> package generation |
| 6710 | can speed up the build. |
| 6711 | You can disable this generation by setting the |
| 6712 | <ulink url='&YOCTO_DOCS_REF_URL;#var-INHIBIT_PACKAGE_DEBUG_SPLIT'><filename>INHIBIT_PACKAGE_DEBUG_SPLIT</filename></ulink> |
| 6713 | variable to "1". |
| 6714 | </para></listitem> |
| 6715 | <listitem><para> |
| 6716 | Disable static library generation for recipes derived from |
| 6717 | <filename>autoconf</filename> or <filename>libtool</filename>: |
| 6718 | Following is an example showing how to disable static |
| 6719 | libraries and still provide an override to handle exceptions: |
| 6720 | <literallayout class='monospaced'> |
| 6721 | STATICLIBCONF = "--disable-static" |
| 6722 | STATICLIBCONF_sqlite3-native = "" |
| 6723 | EXTRA_OECONF += "${STATICLIBCONF}" |
| 6724 | </literallayout> |
| 6725 | <note><title>Notes</title> |
| 6726 | <itemizedlist> |
| 6727 | <listitem><para> |
| 6728 | Some recipes need static libraries in order to work |
| 6729 | correctly (e.g. <filename>pseudo-native</filename> |
| 6730 | needs <filename>sqlite3-native</filename>). |
| 6731 | Overrides, as in the previous example, account for |
| 6732 | these kinds of exceptions. |
| 6733 | </para></listitem> |
| 6734 | <listitem><para> |
| 6735 | Some packages have packaging code that assumes the |
| 6736 | presence of the static libraries. |
| 6737 | If so, you might need to exclude them as well. |
| 6738 | </para></listitem> |
| 6739 | </itemizedlist> |
| 6740 | </note> |
| 6741 | </para></listitem> |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 6742 | </itemizedlist> |
| 6743 | </para> |
| 6744 | </section> |
| 6745 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 6746 | <section id="platdev-working-with-libraries"> |
| 6747 | <title>Working With Libraries</title> |
| 6748 | |
| 6749 | <para> |
| 6750 | Libraries are an integral part of your system. |
| 6751 | This section describes some common practices you might find |
| 6752 | helpful when working with libraries to build your system: |
| 6753 | <itemizedlist> |
| 6754 | <listitem><para><link linkend='including-static-library-files'>How to include static library files</link> |
| 6755 | </para></listitem> |
| 6756 | <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> |
| 6757 | </para></listitem> |
| 6758 | <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> |
| 6759 | </para></listitem> |
| 6760 | </itemizedlist> |
| 6761 | </para> |
| 6762 | |
| 6763 | <section id='including-static-library-files'> |
| 6764 | <title>Including Static Library Files</title> |
| 6765 | |
| 6766 | <para> |
| 6767 | If you are building a library and the library offers static linking, you can control |
| 6768 | which static library files (<filename>*.a</filename> files) get included in the |
| 6769 | built library. |
| 6770 | </para> |
| 6771 | |
| 6772 | <para> |
| 6773 | The <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGES'><filename>PACKAGES</filename></ulink> |
| 6774 | and <ulink url='&YOCTO_DOCS_REF_URL;#var-FILES'><filename>FILES_*</filename></ulink> |
| 6775 | variables in the |
| 6776 | <filename>meta/conf/bitbake.conf</filename> configuration file define how files installed |
| 6777 | by the <filename>do_install</filename> task are packaged. |
| 6778 | By default, the <filename>PACKAGES</filename> variable includes |
| 6779 | <filename>${PN}-staticdev</filename>, which represents all static library files. |
| 6780 | <note> |
| 6781 | Some previously released versions of the Yocto Project |
| 6782 | defined the static library files through |
| 6783 | <filename>${PN}-dev</filename>. |
| 6784 | </note> |
| 6785 | Following is part of the BitBake configuration file, where |
| 6786 | you can see how the static library files are defined: |
| 6787 | <literallayout class='monospaced'> |
| 6788 | PACKAGE_BEFORE_PN ?= "" |
| 6789 | PACKAGES = "${PN}-dbg ${PN}-staticdev ${PN}-dev ${PN}-doc ${PN}-locale ${PACKAGE_BEFORE_PN} ${PN}" |
| 6790 | PACKAGES_DYNAMIC = "^${PN}-locale-.*" |
| 6791 | FILES = "" |
| 6792 | |
| 6793 | FILES_${PN} = "${bindir}/* ${sbindir}/* ${libexecdir}/* ${libdir}/lib*${SOLIBS} \ |
| 6794 | ${sysconfdir} ${sharedstatedir} ${localstatedir} \ |
| 6795 | ${base_bindir}/* ${base_sbindir}/* \ |
| 6796 | ${base_libdir}/*${SOLIBS} \ |
| 6797 | ${base_prefix}/lib/udev/rules.d ${prefix}/lib/udev/rules.d \ |
| 6798 | ${datadir}/${BPN} ${libdir}/${BPN}/* \ |
| 6799 | ${datadir}/pixmaps ${datadir}/applications \ |
| 6800 | ${datadir}/idl ${datadir}/omf ${datadir}/sounds \ |
| 6801 | ${libdir}/bonobo/servers" |
| 6802 | |
| 6803 | FILES_${PN}-bin = "${bindir}/* ${sbindir}/*" |
| 6804 | |
| 6805 | FILES_${PN}-doc = "${docdir} ${mandir} ${infodir} ${datadir}/gtk-doc \ |
| 6806 | ${datadir}/gnome/help" |
| 6807 | SECTION_${PN}-doc = "doc" |
| 6808 | |
| 6809 | FILES_SOLIBSDEV ?= "${base_libdir}/lib*${SOLIBSDEV} ${libdir}/lib*${SOLIBSDEV}" |
| 6810 | FILES_${PN}-dev = "${includedir} ${FILES_SOLIBSDEV} ${libdir}/*.la \ |
| 6811 | ${libdir}/*.o ${libdir}/pkgconfig ${datadir}/pkgconfig \ |
| 6812 | ${datadir}/aclocal ${base_libdir}/*.o \ |
| 6813 | ${libdir}/${BPN}/*.la ${base_libdir}/*.la" |
| 6814 | SECTION_${PN}-dev = "devel" |
| 6815 | ALLOW_EMPTY_${PN}-dev = "1" |
| 6816 | RDEPENDS_${PN}-dev = "${PN} (= ${EXTENDPKGV})" |
| 6817 | |
| 6818 | FILES_${PN}-staticdev = "${libdir}/*.a ${base_libdir}/*.a ${libdir}/${BPN}/*.a" |
| 6819 | SECTION_${PN}-staticdev = "devel" |
| 6820 | RDEPENDS_${PN}-staticdev = "${PN}-dev (= ${EXTENDPKGV})" |
| 6821 | </literallayout> |
| 6822 | </para> |
| 6823 | </section> |
| 6824 | |
| 6825 | <section id="combining-multiple-versions-library-files-into-one-image"> |
| 6826 | <title>Combining Multiple Versions of Library Files into One Image</title> |
| 6827 | |
| 6828 | <para> |
| 6829 | The build system offers the ability to build libraries with different |
| 6830 | target optimizations or architecture formats and combine these together |
| 6831 | into one system image. |
| 6832 | You can link different binaries in the image |
| 6833 | against the different libraries as needed for specific use cases. |
| 6834 | This feature is called "Multilib." |
| 6835 | </para> |
| 6836 | |
| 6837 | <para> |
| 6838 | An example would be where you have most of a system compiled in 32-bit |
| 6839 | mode using 32-bit libraries, but you have something large, like a database |
| 6840 | engine, that needs to be a 64-bit application and uses 64-bit libraries. |
| 6841 | Multilib allows you to get the best of both 32-bit and 64-bit libraries. |
| 6842 | </para> |
| 6843 | |
| 6844 | <para> |
| 6845 | While the Multilib feature is most commonly used for 32 and 64-bit differences, |
| 6846 | the approach the build system uses facilitates different target optimizations. |
| 6847 | You could compile some binaries to use one set of libraries and other binaries |
| 6848 | to use a different set of libraries. |
| 6849 | The libraries could differ in architecture, compiler options, or other |
| 6850 | optimizations. |
| 6851 | </para> |
| 6852 | |
| 6853 | <para> |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 6854 | Several examples exist in the |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 6855 | <filename>meta-skeleton</filename> layer found in the |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 6856 | <ulink url='&YOCTO_DOCS_REF_URL;#source-directory'>Source Directory</ulink>: |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 6857 | <itemizedlist> |
| 6858 | <listitem><para><filename>conf/multilib-example.conf</filename> |
| 6859 | configuration file</para></listitem> |
| 6860 | <listitem><para><filename>conf/multilib-example2.conf</filename> |
| 6861 | configuration file</para></listitem> |
| 6862 | <listitem><para><filename>recipes-multilib/images/core-image-multilib-example.bb</filename> |
| 6863 | recipe</para></listitem> |
| 6864 | </itemizedlist> |
| 6865 | </para> |
| 6866 | |
| 6867 | <section id='preparing-to-use-multilib'> |
| 6868 | <title>Preparing to Use Multilib</title> |
| 6869 | |
| 6870 | <para> |
| 6871 | User-specific requirements drive the Multilib feature. |
| 6872 | Consequently, there is no one "out-of-the-box" configuration that likely |
| 6873 | exists to meet your needs. |
| 6874 | </para> |
| 6875 | |
| 6876 | <para> |
| 6877 | In order to enable Multilib, you first need to ensure your recipe is |
| 6878 | extended to support multiple libraries. |
| 6879 | Many standard recipes are already extended and support multiple libraries. |
| 6880 | You can check in the <filename>meta/conf/multilib.conf</filename> |
| 6881 | configuration file in the |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 6882 | <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] | 6883 | done using the |
| 6884 | <ulink url='&YOCTO_DOCS_REF_URL;#var-BBCLASSEXTEND'><filename>BBCLASSEXTEND</filename></ulink> |
| 6885 | variable. |
| 6886 | Eventually, all recipes will be covered and this list will |
| 6887 | not be needed. |
| 6888 | </para> |
| 6889 | |
| 6890 | <para> |
| 6891 | For the most part, the Multilib class extension works automatically to |
| 6892 | extend the package name from <filename>${PN}</filename> to |
| 6893 | <filename>${MLPREFIX}${PN}</filename>, where <filename>MLPREFIX</filename> |
| 6894 | is the particular multilib (e.g. "lib32-" or "lib64-"). |
| 6895 | Standard variables such as |
| 6896 | <ulink url='&YOCTO_DOCS_REF_URL;#var-DEPENDS'><filename>DEPENDS</filename></ulink>, |
| 6897 | <ulink url='&YOCTO_DOCS_REF_URL;#var-RDEPENDS'><filename>RDEPENDS</filename></ulink>, |
| 6898 | <ulink url='&YOCTO_DOCS_REF_URL;#var-RPROVIDES'><filename>RPROVIDES</filename></ulink>, |
| 6899 | <ulink url='&YOCTO_DOCS_REF_URL;#var-RRECOMMENDS'><filename>RRECOMMENDS</filename></ulink>, |
| 6900 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGES'><filename>PACKAGES</filename></ulink>, and |
| 6901 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGES_DYNAMIC'><filename>PACKAGES_DYNAMIC</filename></ulink> |
| 6902 | are automatically extended by the system. |
| 6903 | If you are extending any manual code in the recipe, you can use the |
| 6904 | <filename>${MLPREFIX}</filename> variable to ensure those names are extended |
| 6905 | correctly. |
| 6906 | This automatic extension code resides in <filename>multilib.bbclass</filename>. |
| 6907 | </para> |
| 6908 | </section> |
| 6909 | |
| 6910 | <section id='using-multilib'> |
| 6911 | <title>Using Multilib</title> |
| 6912 | |
| 6913 | <para> |
| 6914 | After you have set up the recipes, you need to define the actual |
| 6915 | combination of multiple libraries you want to build. |
| 6916 | You accomplish this through your <filename>local.conf</filename> |
| 6917 | configuration file in the |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 6918 | <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink>. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 6919 | An example configuration would be as follows: |
| 6920 | <literallayout class='monospaced'> |
| 6921 | MACHINE = "qemux86-64" |
| 6922 | require conf/multilib.conf |
| 6923 | MULTILIBS = "multilib:lib32" |
| 6924 | DEFAULTTUNE_virtclass-multilib-lib32 = "x86" |
Patrick Williams | f1e5d69 | 2016-03-30 15:21:19 -0500 | [diff] [blame] | 6925 | IMAGE_INSTALL_append = " lib32-glib-2.0" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 6926 | </literallayout> |
| 6927 | This example enables an |
| 6928 | additional library named <filename>lib32</filename> alongside the |
| 6929 | normal target packages. |
| 6930 | When combining these "lib32" alternatives, the example uses "x86" for tuning. |
| 6931 | For information on this particular tuning, see |
| 6932 | <filename>meta/conf/machine/include/ia32/arch-ia32.inc</filename>. |
| 6933 | </para> |
| 6934 | |
| 6935 | <para> |
Patrick Williams | f1e5d69 | 2016-03-30 15:21:19 -0500 | [diff] [blame] | 6936 | The example then includes <filename>lib32-glib-2.0</filename> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 6937 | in all the images, which illustrates one method of including a |
| 6938 | multiple library dependency. |
| 6939 | You can use a normal image build to include this dependency, |
| 6940 | for example: |
| 6941 | <literallayout class='monospaced'> |
| 6942 | $ bitbake core-image-sato |
| 6943 | </literallayout> |
| 6944 | You can also build Multilib packages specifically with a command like this: |
| 6945 | <literallayout class='monospaced'> |
Patrick Williams | f1e5d69 | 2016-03-30 15:21:19 -0500 | [diff] [blame] | 6946 | $ bitbake lib32-glib-2.0 |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 6947 | </literallayout> |
| 6948 | </para> |
| 6949 | </section> |
| 6950 | |
| 6951 | <section id='additional-implementation-details'> |
| 6952 | <title>Additional Implementation Details</title> |
| 6953 | |
| 6954 | <para> |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 6955 | Generic implementation details as well as details that are |
| 6956 | specific to package management systems exist. |
| 6957 | Following are implementation details that exist regardless |
| 6958 | of the package management system: |
| 6959 | <itemizedlist> |
| 6960 | <listitem><para>The typical convention used for the |
| 6961 | class extension code as used by |
| 6962 | Multilib assumes that all package names specified |
| 6963 | in |
| 6964 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGES'><filename>PACKAGES</filename></ulink> |
| 6965 | that contain <filename>${PN}</filename> have |
| 6966 | <filename>${PN}</filename> at the start of the name. |
| 6967 | When that convention is not followed and |
| 6968 | <filename>${PN}</filename> appears at |
| 6969 | the middle or the end of a name, problems occur. |
| 6970 | </para></listitem> |
| 6971 | <listitem><para>The |
| 6972 | <ulink url='&YOCTO_DOCS_REF_URL;#var-TARGET_VENDOR'><filename>TARGET_VENDOR</filename></ulink> |
| 6973 | value under Multilib will be extended to |
| 6974 | "-<replaceable>vendor</replaceable>ml<replaceable>multilib</replaceable>" |
| 6975 | (e.g. "-pokymllib32" for a "lib32" Multilib with |
| 6976 | Poky). |
| 6977 | The reason for this slightly unwieldy contraction |
| 6978 | is that any "-" characters in the vendor |
| 6979 | string presently break Autoconf's |
| 6980 | <filename>config.sub</filename>, and |
| 6981 | other separators are problematic for different |
| 6982 | reasons. |
| 6983 | </para></listitem> |
| 6984 | </itemizedlist> |
| 6985 | </para> |
Brad Bishop | 37a0e4d | 2017-12-04 01:01:44 -0500 | [diff] [blame] | 6986 | |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 6987 | <para> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 6988 | For the RPM Package Management System, the following implementation details |
| 6989 | exist: |
| 6990 | <itemizedlist> |
| 6991 | <listitem><para>A unique architecture is defined for the Multilib packages, |
| 6992 | along with creating a unique deploy folder under |
| 6993 | <filename>tmp/deploy/rpm</filename> in the |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 6994 | <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink>. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 6995 | For example, consider <filename>lib32</filename> in a |
| 6996 | <filename>qemux86-64</filename> image. |
| 6997 | The possible architectures in the system are "all", "qemux86_64", |
| 6998 | "lib32_qemux86_64", and "lib32_x86".</para></listitem> |
| 6999 | <listitem><para>The <filename>${MLPREFIX}</filename> variable is stripped from |
| 7000 | <filename>${PN}</filename> during RPM packaging. |
| 7001 | The naming for a normal RPM package and a Multilib RPM package in a |
| 7002 | <filename>qemux86-64</filename> system resolves to something similar to |
| 7003 | <filename>bash-4.1-r2.x86_64.rpm</filename> and |
| 7004 | <filename>bash-4.1.r2.lib32_x86.rpm</filename>, respectively. |
| 7005 | </para></listitem> |
| 7006 | <listitem><para>When installing a Multilib image, the RPM backend first |
| 7007 | installs the base image and then installs the Multilib libraries. |
| 7008 | </para></listitem> |
| 7009 | <listitem><para>The build system relies on RPM to resolve the identical files in the |
| 7010 | two (or more) Multilib packages.</para></listitem> |
| 7011 | </itemizedlist> |
| 7012 | </para> |
| 7013 | |
| 7014 | <para> |
| 7015 | For the IPK Package Management System, the following implementation details exist: |
| 7016 | <itemizedlist> |
| 7017 | <listitem><para>The <filename>${MLPREFIX}</filename> is not stripped from |
| 7018 | <filename>${PN}</filename> during IPK packaging. |
| 7019 | The naming for a normal RPM package and a Multilib IPK package in a |
| 7020 | <filename>qemux86-64</filename> system resolves to something like |
| 7021 | <filename>bash_4.1-r2.x86_64.ipk</filename> and |
| 7022 | <filename>lib32-bash_4.1-rw_x86.ipk</filename>, respectively. |
| 7023 | </para></listitem> |
| 7024 | <listitem><para>The IPK deploy folder is not modified with |
| 7025 | <filename>${MLPREFIX}</filename> because packages with and without |
| 7026 | the Multilib feature can exist in the same folder due to the |
| 7027 | <filename>${PN}</filename> differences.</para></listitem> |
| 7028 | <listitem><para>IPK defines a sanity check for Multilib installation |
| 7029 | using certain rules for file comparison, overridden, etc. |
| 7030 | </para></listitem> |
| 7031 | </itemizedlist> |
| 7032 | </para> |
| 7033 | </section> |
| 7034 | </section> |
| 7035 | |
| 7036 | <section id='installing-multiple-versions-of-the-same-library'> |
| 7037 | <title>Installing Multiple Versions of the Same Library</title> |
| 7038 | |
| 7039 | <para> |
| 7040 | Situations can exist where you need to install and use |
| 7041 | multiple versions of the same library on the same system |
| 7042 | at the same time. |
| 7043 | These situations almost always exist when a library API |
| 7044 | changes and you have multiple pieces of software that |
| 7045 | depend on the separate versions of the library. |
| 7046 | To accommodate these situations, you can install multiple |
| 7047 | versions of the same library in parallel on the same system. |
| 7048 | </para> |
| 7049 | |
| 7050 | <para> |
| 7051 | The process is straightforward as long as the libraries use |
| 7052 | proper versioning. |
| 7053 | With properly versioned libraries, all you need to do to |
| 7054 | individually specify the libraries is create separate, |
| 7055 | appropriately named recipes where the |
| 7056 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PN'><filename>PN</filename></ulink> part of the |
| 7057 | name includes a portion that differentiates each library version |
| 7058 | (e.g.the major part of the version number). |
| 7059 | Thus, instead of having a single recipe that loads one version |
| 7060 | of a library (e.g. <filename>clutter</filename>), you provide |
| 7061 | multiple recipes that result in different versions |
| 7062 | of the libraries you want. |
| 7063 | As an example, the following two recipes would allow the |
| 7064 | two separate versions of the <filename>clutter</filename> |
| 7065 | library to co-exist on the same system: |
| 7066 | <literallayout class='monospaced'> |
| 7067 | clutter-1.6_1.6.20.bb |
| 7068 | clutter-1.8_1.8.4.bb |
| 7069 | </literallayout> |
| 7070 | Additionally, if you have other recipes that depend on a given |
| 7071 | library, you need to use the |
| 7072 | <ulink url='&YOCTO_DOCS_REF_URL;#var-DEPENDS'><filename>DEPENDS</filename></ulink> |
| 7073 | variable to create the dependency. |
| 7074 | Continuing with the same example, if you want to have a recipe |
| 7075 | depend on the 1.8 version of the <filename>clutter</filename> |
| 7076 | library, use the following in your recipe: |
| 7077 | <literallayout class='monospaced'> |
| 7078 | DEPENDS = "clutter-1.8" |
| 7079 | </literallayout> |
| 7080 | </para> |
| 7081 | </section> |
| 7082 | </section> |
| 7083 | |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 7084 | <section id='using-x32-psabi'> |
| 7085 | <title>Using x32 psABI</title> |
| 7086 | |
| 7087 | <para> |
| 7088 | x32 processor-specific Application Binary Interface |
| 7089 | (<ulink url='https://software.intel.com/en-us/node/628948'>x32 psABI</ulink>) |
| 7090 | is a native 32-bit processor-specific ABI for |
| 7091 | <trademark class='registered'>Intel</trademark> 64 (x86-64) |
| 7092 | architectures. |
| 7093 | An ABI defines the calling conventions between functions in a |
| 7094 | processing environment. |
| 7095 | The interface determines what registers are used and what the |
| 7096 | sizes are for various C data types. |
| 7097 | </para> |
| 7098 | |
| 7099 | <para> |
| 7100 | Some processing environments prefer using 32-bit applications even |
| 7101 | when running on Intel 64-bit platforms. |
| 7102 | Consider the i386 psABI, which is a very old 32-bit ABI for Intel |
| 7103 | 64-bit platforms. |
| 7104 | The i386 psABI does not provide efficient use and access of the |
| 7105 | Intel 64-bit processor resources, leaving the system underutilized. |
| 7106 | Now consider the x86_64 psABI. |
| 7107 | This ABI is newer and uses 64-bits for data sizes and program |
| 7108 | pointers. |
| 7109 | The extra bits increase the footprint size of the programs, |
| 7110 | libraries, and also increases the memory and file system size |
| 7111 | requirements. |
| 7112 | Executing under the x32 psABI enables user programs to utilize CPU |
| 7113 | and system resources more efficiently while keeping the memory |
| 7114 | footprint of the applications low. |
| 7115 | Extra bits are used for registers but not for addressing mechanisms. |
| 7116 | </para> |
| 7117 | |
| 7118 | <para> |
| 7119 | The Yocto Project supports the final specifications of x32 psABI |
| 7120 | as follows: |
| 7121 | <itemizedlist> |
| 7122 | <listitem><para> |
| 7123 | You can create packages and images in x32 psABI format on |
| 7124 | x86_64 architecture targets. |
| 7125 | </para></listitem> |
| 7126 | <listitem><para> |
| 7127 | You can successfully build recipes with the x32 toolchain. |
| 7128 | </para></listitem> |
| 7129 | <listitem><para> |
| 7130 | You can create and boot |
| 7131 | <filename>core-image-minimal</filename> and |
| 7132 | <filename>core-image-sato</filename> images. |
| 7133 | </para></listitem> |
| 7134 | <listitem><para> |
| 7135 | RPM Package Manager (RPM) support exists for x32 binaries. |
| 7136 | </para></listitem> |
| 7137 | <listitem><para> |
| 7138 | Support for large images exists. |
| 7139 | </para></listitem> |
| 7140 | </itemizedlist> |
| 7141 | </para> |
| 7142 | |
| 7143 | <para> |
| 7144 | To use the x32 psABI, you need to edit your |
| 7145 | <filename>conf/local.conf</filename> configuration file as |
| 7146 | follows: |
| 7147 | <literallayout class='monospaced'> |
| 7148 | MACHINE = "qemux86-64" |
| 7149 | DEFAULTTUNE = "x86-64-x32" |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 7150 | baselib = "${@d.getVar('BASE_LIB_tune-' + (d.getVar('DEFAULTTUNE') \ |
| 7151 | or 'INVALID')) or 'lib'}" |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 7152 | </literallayout> |
| 7153 | Once you have set up your configuration file, use BitBake to |
| 7154 | build an image that supports the x32 psABI. |
| 7155 | Here is an example: |
| 7156 | <literallayout class='monospaced'> |
| 7157 | $ bitbake core-image-sato |
| 7158 | </literallayout> |
| 7159 | </para> |
| 7160 | </section> |
| 7161 | |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 7162 | <section id='enabling-gobject-introspection-support'> |
| 7163 | <title>Enabling GObject Introspection Support</title> |
| 7164 | |
| 7165 | <para> |
| 7166 | <ulink url='https://wiki.gnome.org/Projects/GObjectIntrospection'>GObject introspection</ulink> |
| 7167 | is the standard mechanism for accessing GObject-based software |
| 7168 | from runtime environments. |
| 7169 | GObject is a feature of the GLib library that provides an object |
| 7170 | framework for the GNOME desktop and related software. |
| 7171 | GObject Introspection adds information to GObject that allows |
| 7172 | objects created within it to be represented across different |
| 7173 | programming languages. |
| 7174 | If you want to construct GStreamer pipelines using Python, or |
| 7175 | control UPnP infrastructure using Javascript and GUPnP, |
| 7176 | GObject introspection is the only way to do it. |
| 7177 | </para> |
| 7178 | |
| 7179 | <para> |
| 7180 | This section describes the Yocto Project support for generating |
| 7181 | and packaging GObject introspection data. |
| 7182 | GObject introspection data is a description of the |
| 7183 | API provided by libraries built on top of GLib framework, |
| 7184 | and, in particular, that framework's GObject mechanism. |
| 7185 | GObject Introspection Repository (GIR) files go to |
| 7186 | <filename>-dev</filename> packages, |
| 7187 | <filename>typelib</filename> files go to main packages as they |
| 7188 | are packaged together with libraries that are introspected. |
| 7189 | </para> |
| 7190 | |
| 7191 | <para> |
| 7192 | The data is generated when building such a library, by linking |
| 7193 | the library with a small executable binary that asks the library |
| 7194 | to describe itself, and then executing the binary and |
| 7195 | processing its output. |
| 7196 | </para> |
| 7197 | |
| 7198 | <para> |
| 7199 | Generating this data in a cross-compilation environment |
| 7200 | is difficult because the library is produced for the target |
| 7201 | architecture, but its code needs to be executed on the build host. |
| 7202 | This problem is solved with the OpenEmbedded build system by |
| 7203 | running the code through QEMU, which allows precisely that. |
| 7204 | Unfortunately, QEMU does not always work perfectly as mentioned |
Brad Bishop | 96ff198 | 2019-08-19 13:50:42 -0400 | [diff] [blame] | 7205 | in the |
| 7206 | "<link linkend='known-issues'>Known Issues</link>" section. |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 7207 | </para> |
| 7208 | |
| 7209 | <section id='enabling-the-generation-of-introspection-data'> |
| 7210 | <title>Enabling the Generation of Introspection Data</title> |
| 7211 | |
| 7212 | <para> |
| 7213 | Enabling the generation of introspection data (GIR files) |
| 7214 | in your library package involves the following: |
| 7215 | <orderedlist> |
| 7216 | <listitem><para> |
| 7217 | Inherit the |
| 7218 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-gobject-introspection'><filename>gobject-introspection</filename></ulink> |
| 7219 | class. |
| 7220 | </para></listitem> |
| 7221 | <listitem><para> |
| 7222 | Make sure introspection is not disabled anywhere in |
| 7223 | the recipe or from anything the recipe includes. |
| 7224 | Also, make sure that "gobject-introspection-data" is |
| 7225 | not in |
| 7226 | <ulink url='&YOCTO_DOCS_REF_URL;#var-DISTRO_FEATURES_BACKFILL_CONSIDERED'><filename>DISTRO_FEATURES_BACKFILL_CONSIDERED</filename></ulink> |
| 7227 | and that "qemu-usermode" is not in |
| 7228 | <ulink url='&YOCTO_DOCS_REF_URL;#var-MACHINE_FEATURES_BACKFILL_CONSIDERED'><filename>MACHINE_FEATURES_BACKFILL_CONSIDERED</filename></ulink>. |
| 7229 | If either of these conditions exist, nothing will |
| 7230 | happen. |
| 7231 | </para></listitem> |
| 7232 | <listitem><para> |
| 7233 | Try to build the recipe. |
| 7234 | If you encounter build errors that look like |
| 7235 | something is unable to find |
| 7236 | <filename>.so</filename> libraries, check where these |
| 7237 | libraries are located in the source tree and add |
| 7238 | the following to the recipe: |
| 7239 | <literallayout class='monospaced'> |
| 7240 | GIR_EXTRA_LIBS_PATH = "${B}/<replaceable>something</replaceable>/.libs" |
| 7241 | </literallayout> |
| 7242 | <note> |
| 7243 | See recipes in the <filename>oe-core</filename> |
| 7244 | repository that use that |
| 7245 | <filename>GIR_EXTRA_LIBS_PATH</filename> variable |
| 7246 | as an example. |
| 7247 | </note> |
| 7248 | </para></listitem> |
| 7249 | <listitem><para> |
| 7250 | Look for any other errors, which probably mean that |
| 7251 | introspection support in a package is not entirely |
| 7252 | standard, and thus breaks down in a cross-compilation |
| 7253 | environment. |
| 7254 | For such cases, custom-made fixes are needed. |
| 7255 | A good place to ask and receive help in these cases |
| 7256 | is the |
| 7257 | <ulink url='&YOCTO_DOCS_REF_URL;#resources-mailinglist'>Yocto Project mailing lists</ulink>. |
| 7258 | </para></listitem> |
| 7259 | </orderedlist> |
| 7260 | <note> |
| 7261 | Using a library that no longer builds against the latest |
| 7262 | Yocto Project release and prints introspection related |
| 7263 | errors is a good candidate for the previous procedure. |
| 7264 | </note> |
| 7265 | </para> |
| 7266 | </section> |
| 7267 | |
| 7268 | <section id='disabling-the-generation-of-introspection-data'> |
| 7269 | <title>Disabling the Generation of Introspection Data</title> |
| 7270 | |
| 7271 | <para> |
| 7272 | You might find that you do not want to generate |
| 7273 | introspection data. |
| 7274 | Or, perhaps QEMU does not work on your build host and |
| 7275 | target architecture combination. |
| 7276 | If so, you can use either of the following methods to |
| 7277 | disable GIR file generations: |
| 7278 | <itemizedlist> |
| 7279 | <listitem><para> |
| 7280 | Add the following to your distro configuration: |
| 7281 | <literallayout class='monospaced'> |
| 7282 | DISTRO_FEATURES_BACKFILL_CONSIDERED = "gobject-introspection-data" |
| 7283 | </literallayout> |
| 7284 | Adding this statement disables generating |
| 7285 | introspection data using QEMU but will still enable |
| 7286 | building introspection tools and libraries |
| 7287 | (i.e. building them does not require the use of QEMU). |
| 7288 | </para></listitem> |
| 7289 | <listitem><para> |
| 7290 | Add the following to your machine configuration: |
| 7291 | <literallayout class='monospaced'> |
| 7292 | MACHINE_FEATURES_BACKFILL_CONSIDERED = "qemu-usermode" |
| 7293 | </literallayout> |
| 7294 | Adding this statement disables the use of QEMU |
| 7295 | when building packages for your machine. |
| 7296 | Currently, this feature is used only by introspection |
| 7297 | recipes and has the same effect as the previously |
| 7298 | described option. |
| 7299 | <note> |
| 7300 | Future releases of the Yocto Project might have |
| 7301 | other features affected by this option. |
| 7302 | </note> |
| 7303 | </para></listitem> |
| 7304 | </itemizedlist> |
| 7305 | If you disable introspection data, you can still |
| 7306 | obtain it through other means such as copying the data |
| 7307 | from a suitable sysroot, or by generating it on the |
| 7308 | target hardware. |
| 7309 | The OpenEmbedded build system does not currently |
| 7310 | provide specific support for these techniques. |
| 7311 | </para> |
| 7312 | </section> |
| 7313 | |
| 7314 | <section id='testing-that-introspection-works-in-an-image'> |
| 7315 | <title>Testing that Introspection Works in an Image</title> |
| 7316 | |
| 7317 | <para> |
| 7318 | Use the following procedure to test if generating |
| 7319 | introspection data is working in an image: |
| 7320 | <orderedlist> |
| 7321 | <listitem><para> |
| 7322 | Make sure that "gobject-introspection-data" is not in |
| 7323 | <ulink url='&YOCTO_DOCS_REF_URL;#var-DISTRO_FEATURES_BACKFILL_CONSIDERED'><filename>DISTRO_FEATURES_BACKFILL_CONSIDERED</filename></ulink> |
| 7324 | and that "qemu-usermode" is not in |
| 7325 | <ulink url='&YOCTO_DOCS_REF_URL;#var-MACHINE_FEATURES_BACKFILL_CONSIDERED'><filename>MACHINE_FEATURES_BACKFILL_CONSIDERED</filename></ulink>. |
| 7326 | </para></listitem> |
| 7327 | <listitem><para> |
| 7328 | Build <filename>core-image-sato</filename>. |
| 7329 | </para></listitem> |
| 7330 | <listitem><para> |
| 7331 | Launch a Terminal and then start Python in the |
| 7332 | terminal. |
| 7333 | </para></listitem> |
| 7334 | <listitem><para> |
| 7335 | Enter the following in the terminal: |
| 7336 | <literallayout class='monospaced'> |
| 7337 | >>> from gi.repository import GLib |
| 7338 | >>> GLib.get_host_name() |
| 7339 | </literallayout> |
| 7340 | </para></listitem> |
| 7341 | <listitem><para> |
| 7342 | For something a little more advanced, enter the |
| 7343 | following: |
| 7344 | <literallayout class='monospaced'> |
| 7345 | http://python-gtk-3-tutorial.readthedocs.org/en/latest/introduction.html |
| 7346 | </literallayout> |
| 7347 | </para></listitem> |
| 7348 | </orderedlist> |
| 7349 | </para> |
| 7350 | </section> |
| 7351 | |
| 7352 | <section id='known-issues'> |
| 7353 | <title>Known Issues</title> |
| 7354 | |
| 7355 | <para> |
| 7356 | The following know issues exist for |
| 7357 | GObject Introspection Support: |
| 7358 | <itemizedlist> |
| 7359 | <listitem><para> |
| 7360 | <filename>qemu-ppc64</filename> immediately crashes. |
| 7361 | Consequently, you cannot build introspection data on |
| 7362 | that architecture. |
| 7363 | </para></listitem> |
| 7364 | <listitem><para> |
| 7365 | x32 is not supported by QEMU. |
| 7366 | Consequently, introspection data is disabled. |
| 7367 | </para></listitem> |
| 7368 | <listitem><para> |
| 7369 | musl causes transient GLib binaries to crash on |
| 7370 | assertion failures. |
| 7371 | Consequently, generating introspection data is |
| 7372 | disabled. |
| 7373 | </para></listitem> |
| 7374 | <listitem><para> |
| 7375 | Because QEMU is not able to run the binaries correctly, |
| 7376 | introspection is disabled for some specific packages |
| 7377 | under specific architectures (e.g. |
| 7378 | <filename>gcr</filename>, |
| 7379 | <filename>libsecret</filename>, and |
| 7380 | <filename>webkit</filename>). |
| 7381 | </para></listitem> |
| 7382 | <listitem><para> |
| 7383 | QEMU usermode might not work properly when running |
| 7384 | 64-bit binaries under 32-bit host machines. |
| 7385 | In particular, "qemumips64" is known to not work under |
| 7386 | i686. |
| 7387 | </para></listitem> |
| 7388 | </itemizedlist> |
| 7389 | </para> |
| 7390 | </section> |
| 7391 | </section> |
| 7392 | |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 7393 | <section id='dev-optionally-using-an-external-toolchain'> |
| 7394 | <title>Optionally Using an External Toolchain</title> |
| 7395 | |
| 7396 | <para> |
| 7397 | You might want to use an external toolchain as part of your |
| 7398 | development. |
| 7399 | If this is the case, the fundamental steps you need to accomplish |
| 7400 | are as follows: |
| 7401 | <itemizedlist> |
| 7402 | <listitem><para> |
| 7403 | Understand where the installed toolchain resides. |
| 7404 | For cases where you need to build the external toolchain, |
| 7405 | you would need to take separate steps to build and install |
| 7406 | the toolchain. |
| 7407 | </para></listitem> |
| 7408 | <listitem><para> |
| 7409 | Make sure you add the layer that contains the toolchain to |
| 7410 | your <filename>bblayers.conf</filename> file through the |
| 7411 | <ulink url='&YOCTO_DOCS_REF_URL;#var-BBLAYERS'><filename>BBLAYERS</filename></ulink> |
| 7412 | variable. |
| 7413 | </para></listitem> |
| 7414 | <listitem><para> |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 7415 | Set the <filename>EXTERNAL_TOOLCHAIN</filename> |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 7416 | variable in your <filename>local.conf</filename> file |
| 7417 | to the location in which you installed the toolchain. |
| 7418 | </para></listitem> |
| 7419 | </itemizedlist> |
| 7420 | A good example of an external toolchain used with the Yocto Project |
| 7421 | is <trademark class='registered'>Mentor Graphics</trademark> |
| 7422 | Sourcery G++ Toolchain. |
| 7423 | You can see information on how to use that particular layer in the |
| 7424 | <filename>README</filename> file at |
| 7425 | <ulink url='http://github.com/MentorEmbedded/meta-sourcery/'></ulink>. |
| 7426 | You can find further information by reading about the |
| 7427 | <ulink url='&YOCTO_DOCS_REF_URL;#var-TCMODE'><filename>TCMODE</filename></ulink> |
| 7428 | variable in the Yocto Project Reference Manual's variable glossary. |
| 7429 | </para> |
| 7430 | </section> |
| 7431 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 7432 | <section id='creating-partitioned-images-using-wic'> |
| 7433 | <title>Creating Partitioned Images Using Wic</title> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 7434 | |
| 7435 | <para> |
| 7436 | Creating an image for a particular hardware target using the |
| 7437 | OpenEmbedded build system does not necessarily mean you can boot |
| 7438 | that image as is on your device. |
| 7439 | Physical devices accept and boot images in various ways depending |
| 7440 | on the specifics of the device. |
| 7441 | Usually, information about the hardware can tell you what image |
| 7442 | format the device requires. |
| 7443 | Should your device require multiple partitions on an SD card, flash, |
| 7444 | or an HDD, you can use the OpenEmbedded Image Creator, |
Brad Bishop | 37a0e4d | 2017-12-04 01:01:44 -0500 | [diff] [blame] | 7445 | Wic, to create the properly partitioned image. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 7446 | </para> |
| 7447 | |
| 7448 | <para> |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 7449 | The <filename>wic</filename> command generates partitioned |
| 7450 | images from existing OpenEmbedded build artifacts. |
| 7451 | Image generation is driven by partitioning commands |
| 7452 | contained in an Openembedded kickstart file |
| 7453 | (<filename>.wks</filename>) specified either directly on |
| 7454 | the command line or as one of a selection of canned |
| 7455 | kickstart files as shown with the |
| 7456 | <filename>wic list images</filename> command in the |
| 7457 | "<link linkend='using-a-provided-kickstart-file'>Using an Existing Kickstart File</link>" |
| 7458 | section. |
| 7459 | When you apply the command to a given set of build |
| 7460 | artifacts, the result is an image or set of images that |
| 7461 | can be directly written onto media and used on a particular |
| 7462 | system. |
| 7463 | <note> |
| 7464 | For a kickstart file reference, see the |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 7465 | "<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] | 7466 | Chapter in the Yocto Project Reference Manual. |
| 7467 | </note> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 7468 | </para> |
| 7469 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 7470 | <para> |
| 7471 | The <filename>wic</filename> command and the infrastructure |
| 7472 | it is based on is by definition incomplete. |
| 7473 | The purpose of the command is to allow the generation of |
| 7474 | customized images, and as such, was designed to be |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 7475 | completely extensible through a plugin interface. |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 7476 | See the |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 7477 | "<link linkend='wic-using-the-wic-plugin-interface'>Using the Wic PlugIn Interface</link>" |
| 7478 | section for information on these plugins. |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 7479 | </para> |
| 7480 | |
| 7481 | <para> |
| 7482 | This section provides some background information on Wic, |
| 7483 | describes what you need to have in |
| 7484 | place to run the tool, provides instruction on how to use |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 7485 | the Wic utility, provides information on using the Wic plugins |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 7486 | interface, and provides several examples that show how to use |
| 7487 | Wic. |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 7488 | </para> |
| 7489 | |
| 7490 | <section id='wic-background'> |
| 7491 | <title>Background</title> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 7492 | |
| 7493 | <para> |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 7494 | This section provides some background on the Wic utility. |
| 7495 | While none of this information is required to use |
| 7496 | Wic, you might find it interesting. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 7497 | <itemizedlist> |
| 7498 | <listitem><para> |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 7499 | The name "Wic" is derived from OpenEmbedded |
| 7500 | Image Creator (oeic). |
| 7501 | The "oe" diphthong in "oeic" was promoted to the |
| 7502 | letter "w", because "oeic" is both difficult to |
| 7503 | remember and to pronounce. |
| 7504 | </para></listitem> |
| 7505 | <listitem><para> |
| 7506 | Wic is loosely based on the |
| 7507 | Meego Image Creator (<filename>mic</filename>) |
| 7508 | framework. |
| 7509 | The Wic implementation has been |
| 7510 | heavily modified to make direct use of OpenEmbedded |
| 7511 | build artifacts instead of package installation and |
| 7512 | configuration, which are already incorporated within |
| 7513 | the OpenEmbedded artifacts. |
| 7514 | </para></listitem> |
| 7515 | <listitem><para> |
| 7516 | Wic is a completely independent |
| 7517 | standalone utility that initially provides |
| 7518 | easier-to-use and more flexible replacements for an |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 7519 | existing functionality in OE-Core's |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 7520 | <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] | 7521 | class. |
| 7522 | The difference between Wic and those examples is |
| 7523 | that with Wic the functionality of those scripts is |
| 7524 | implemented by a general-purpose partitioning language, |
| 7525 | which is based on Redhat kickstart syntax. |
| 7526 | </para></listitem> |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 7527 | </itemizedlist> |
| 7528 | </para> |
| 7529 | </section> |
| 7530 | |
| 7531 | <section id='wic-requirements'> |
| 7532 | <title>Requirements</title> |
| 7533 | |
| 7534 | <para> |
| 7535 | In order to use the Wic utility with the OpenEmbedded Build |
| 7536 | system, your system needs to meet the following |
| 7537 | requirements: |
| 7538 | <itemizedlist> |
| 7539 | <listitem><para> |
| 7540 | The Linux distribution on your development host must |
| 7541 | support the Yocto Project. |
| 7542 | See the |
| 7543 | "<ulink url='&YOCTO_DOCS_REF_URL;#detailed-supported-distros'>Supported Linux Distributions</ulink>" |
| 7544 | section in the Yocto Project Reference Manual for |
| 7545 | the list of distributions that support the |
| 7546 | Yocto Project. |
| 7547 | </para></listitem> |
| 7548 | <listitem><para> |
| 7549 | The standard system utilities, such as |
| 7550 | <filename>cp</filename>, must be installed on your |
| 7551 | development host system. |
| 7552 | </para></listitem> |
| 7553 | <listitem><para> |
| 7554 | You must have sourced the build environment |
| 7555 | setup script (i.e. |
| 7556 | <ulink url='&YOCTO_DOCS_REF_URL;#structure-core-script'><filename>&OE_INIT_FILE;</filename></ulink>) |
| 7557 | found in the |
| 7558 | <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink>. |
| 7559 | </para></listitem> |
| 7560 | <listitem><para> |
| 7561 | You need to have the build artifacts already |
| 7562 | available, which typically means that you must |
| 7563 | have already created an image using the |
| 7564 | Openembedded build system (e.g. |
| 7565 | <filename>core-image-minimal</filename>). |
| 7566 | While it might seem redundant to generate an image |
| 7567 | in order to create an image using |
| 7568 | Wic, the current version of |
| 7569 | Wic requires the artifacts |
| 7570 | in the form generated by the OpenEmbedded build |
| 7571 | system. |
| 7572 | </para></listitem> |
| 7573 | <listitem><para> |
| 7574 | You must build several native tools, which are |
| 7575 | built to run on the build system: |
| 7576 | <literallayout class='monospaced'> |
| 7577 | $ bitbake parted-native dosfstools-native mtools-native |
| 7578 | </literallayout> |
| 7579 | </para></listitem> |
| 7580 | <listitem><para> |
Brad Bishop | 37a0e4d | 2017-12-04 01:01:44 -0500 | [diff] [blame] | 7581 | Include "wic" as part of the |
| 7582 | <ulink url='&YOCTO_DOCS_REF_URL;#var-IMAGE_FSTYPES'><filename>IMAGE_FSTYPES</filename></ulink> |
| 7583 | variable. |
| 7584 | </para></listitem> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 7585 | <listitem><para> |
Brad Bishop | 37a0e4d | 2017-12-04 01:01:44 -0500 | [diff] [blame] | 7586 | Include the name of the |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 7587 | <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] | 7588 | as part of the |
| 7589 | <ulink url='&YOCTO_DOCS_REF_URL;#var-WKS_FILE'><filename>WKS_FILE</filename></ulink> |
| 7590 | variable |
| 7591 | </para></listitem> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 7592 | </itemizedlist> |
| 7593 | </para> |
| 7594 | </section> |
| 7595 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 7596 | <section id='wic-getting-help'> |
| 7597 | <title>Getting Help</title> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 7598 | |
| 7599 | <para> |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 7600 | You can get general help for the <filename>wic</filename> |
| 7601 | command by entering the <filename>wic</filename> command |
| 7602 | by itself or by entering the command with a help argument |
| 7603 | as follows: |
| 7604 | <literallayout class='monospaced'> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 7605 | $ wic -h |
| 7606 | $ wic --help |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 7607 | $ wic help |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 7608 | </literallayout> |
| 7609 | </para> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 7610 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 7611 | <para> |
| 7612 | Currently, Wic supports seven commands: |
| 7613 | <filename>cp</filename>, <filename>create</filename>, |
| 7614 | <filename>help</filename>, <filename>list</filename>, |
| 7615 | <filename>ls</filename>, <filename>rm</filename>, and |
| 7616 | <filename>write</filename>. |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 7617 | You can get help for all these commands except "help" by |
| 7618 | using the following form: |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 7619 | <literallayout class='monospaced'> |
Brad Bishop | 37a0e4d | 2017-12-04 01:01:44 -0500 | [diff] [blame] | 7620 | $ wic help <replaceable>command</replaceable> |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 7621 | </literallayout> |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 7622 | For example, the following command returns help for the |
| 7623 | <filename>write</filename> command: |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 7624 | <literallayout class='monospaced'> |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 7625 | $ wic help write |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 7626 | </literallayout> |
| 7627 | </para> |
Brad Bishop | 37a0e4d | 2017-12-04 01:01:44 -0500 | [diff] [blame] | 7628 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 7629 | <para> |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 7630 | Wic supports help for three topics: |
| 7631 | <filename>overview</filename>, |
| 7632 | <filename>plugins</filename>, and |
| 7633 | <filename>kickstart</filename>. |
| 7634 | You can get help for any topic using the following form: |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 7635 | <literallayout class='monospaced'> |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 7636 | $ wic help <replaceable>topic</replaceable> |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 7637 | </literallayout> |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 7638 | For example, the following returns overview help for Wic: |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 7639 | <literallayout class='monospaced'> |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 7640 | $ wic help overview |
| 7641 | </literallayout> |
| 7642 | </para> |
| 7643 | |
| 7644 | <para> |
| 7645 | One additional level of help exists for Wic. |
| 7646 | You can get help on individual images through the |
| 7647 | <filename>list</filename> command. |
| 7648 | You can use the <filename>list</filename> command to return the |
| 7649 | available Wic images as follows: |
| 7650 | <literallayout class='monospaced'> |
| 7651 | $ wic list images |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 7652 | genericx86 Create an EFI disk image for genericx86* |
| 7653 | beaglebone-yocto Create SD card image for Beaglebone |
| 7654 | edgerouter Create SD card image for Edgerouter |
| 7655 | qemux86-directdisk Create a qemu machine 'pcbios' direct disk image |
| 7656 | directdisk-gpt Create a 'pcbios' direct disk image |
| 7657 | mkefidisk Create an EFI disk image |
| 7658 | directdisk Create a 'pcbios' direct disk image |
| 7659 | systemd-bootdisk Create an EFI disk image with systemd-boot |
| 7660 | mkhybridiso Create a hybrid ISO image |
| 7661 | sdimage-bootpart Create SD card image with a boot partition |
| 7662 | directdisk-multi-rootfs Create multi rootfs image using rootfs plugin |
| 7663 | directdisk-bootloader-config Create a 'pcbios' direct disk image with custom bootloader config |
| 7664 | </literallayout> |
| 7665 | Once you know the list of available Wic images, you can use |
| 7666 | <filename>help</filename> with the command to get help on a |
| 7667 | particular image. |
| 7668 | For example, the following command returns help on the |
| 7669 | "beaglebone-yocto" image: |
| 7670 | <literallayout class='monospaced'> |
| 7671 | $ wic list beaglebone-yocto help |
| 7672 | |
| 7673 | |
| 7674 | Creates a partitioned SD card image for Beaglebone. |
| 7675 | Boot files are located in the first vfat partition. |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 7676 | </literallayout> |
| 7677 | </para> |
| 7678 | </section> |
Brad Bishop | 37a0e4d | 2017-12-04 01:01:44 -0500 | [diff] [blame] | 7679 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 7680 | <section id='operational-modes'> |
| 7681 | <title>Operational Modes</title> |
| 7682 | |
| 7683 | <para> |
| 7684 | You can use Wic in two different |
| 7685 | modes, depending on how much control you need for |
| 7686 | specifying the Openembedded build artifacts that are |
| 7687 | used for creating the image: Raw and Cooked: |
| 7688 | <itemizedlist> |
| 7689 | <listitem><para> |
| 7690 | <emphasis>Raw Mode:</emphasis> |
| 7691 | You explicitly specify build artifacts through |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 7692 | Wic command-line arguments. |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 7693 | </para></listitem> |
| 7694 | <listitem><para> |
| 7695 | <emphasis>Cooked Mode:</emphasis> |
| 7696 | The current |
| 7697 | <ulink url='&YOCTO_DOCS_REF_URL;#var-MACHINE'><filename>MACHINE</filename></ulink> |
| 7698 | setting and image name are used to automatically |
| 7699 | locate and provide the build artifacts. |
| 7700 | You just supply a kickstart file and the name |
| 7701 | of the image from which to use artifacts. |
| 7702 | </para></listitem> |
| 7703 | </itemizedlist> |
| 7704 | </para> |
| 7705 | |
| 7706 | <para> |
| 7707 | Regardless of the mode you use, you need to have the build |
| 7708 | artifacts ready and available. |
| 7709 | </para> |
| 7710 | |
| 7711 | <section id='raw-mode'> |
| 7712 | <title>Raw Mode</title> |
Brad Bishop | 37a0e4d | 2017-12-04 01:01:44 -0500 | [diff] [blame] | 7713 | |
| 7714 | <para> |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 7715 | Running Wic in raw mode allows you to specify all the |
| 7716 | partitions through the <filename>wic</filename> |
| 7717 | command line. |
| 7718 | The primary use for raw mode is if you have built |
| 7719 | your kernel outside of the Yocto Project |
| 7720 | <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink>. |
| 7721 | In other words, you can point to arbitrary kernel, |
| 7722 | root filesystem locations, and so forth. |
| 7723 | Contrast this behavior with cooked mode where Wic |
| 7724 | looks in the Build Directory (e.g. |
| 7725 | <filename>tmp/deploy/images/</filename><replaceable>machine</replaceable>). |
Brad Bishop | 37a0e4d | 2017-12-04 01:01:44 -0500 | [diff] [blame] | 7726 | </para> |
| 7727 | |
| 7728 | <para> |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 7729 | The general form of the |
| 7730 | <filename>wic</filename> command in raw mode is: |
| 7731 | <literallayout class='monospaced'> |
| 7732 | $ wic create <replaceable>wks_file</replaceable> <replaceable>options</replaceable> ... |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 7733 | |
Brad Bishop | 37a0e4d | 2017-12-04 01:01:44 -0500 | [diff] [blame] | 7734 | Where: |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 7735 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 7736 | <replaceable>wks_file</replaceable>: |
Brad Bishop | 37a0e4d | 2017-12-04 01:01:44 -0500 | [diff] [blame] | 7737 | An OpenEmbedded kickstart file. You can provide |
| 7738 | your own custom file or use a file from a set of |
| 7739 | existing files as described by further options. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 7740 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 7741 | optional arguments: |
| 7742 | -h, --help show this help message and exit |
| 7743 | -o <replaceable>OUTDIR</replaceable>, --outdir <replaceable>OUTDIR</replaceable> |
| 7744 | name of directory to create image in |
| 7745 | -e <replaceable>IMAGE_NAME</replaceable>, --image-name <replaceable>IMAGE_NAME</replaceable> |
| 7746 | name of the image to use the artifacts from e.g. core- |
| 7747 | image-sato |
| 7748 | -r <replaceable>ROOTFS_DIR</replaceable>, --rootfs-dir <replaceable>ROOTFS_DIR</replaceable> |
| 7749 | path to the /rootfs dir to use as the .wks rootfs |
| 7750 | source |
| 7751 | -b <replaceable>BOOTIMG_DIR</replaceable>, --bootimg-dir <replaceable>BOOTIMG_DIR</replaceable> |
| 7752 | path to the dir containing the boot artifacts (e.g. |
| 7753 | /EFI or /syslinux dirs) to use as the .wks bootimg |
| 7754 | source |
| 7755 | -k <replaceable>KERNEL_DIR</replaceable>, --kernel-dir <replaceable>KERNEL_DIR</replaceable> |
| 7756 | path to the dir containing the kernel to use in the |
| 7757 | .wks bootimg |
| 7758 | -n <replaceable>NATIVE_SYSROOT</replaceable>, --native-sysroot <replaceable>NATIVE_SYSROOT</replaceable> |
| 7759 | path to the native sysroot containing the tools to use |
| 7760 | to build the image |
| 7761 | -s, --skip-build-check |
| 7762 | skip the build check |
| 7763 | -f, --build-rootfs build rootfs |
| 7764 | -c {gzip,bzip2,xz}, --compress-with {gzip,bzip2,xz} |
| 7765 | compress image with specified compressor |
| 7766 | -m, --bmap generate .bmap |
| 7767 | --no-fstab-update Do not change fstab file. |
| 7768 | -v <replaceable>VARS_DIR</replaceable>, --vars <replaceable>VARS_DIR</replaceable> |
| 7769 | directory with <image>.env files that store bitbake |
| 7770 | variables |
| 7771 | -D, --debug output debug information |
| 7772 | </literallayout> |
| 7773 | <note> |
| 7774 | You do not need root privileges to run |
| 7775 | Wic. |
| 7776 | In fact, you should not run as root when using the |
| 7777 | utility. |
| 7778 | </note> |
| 7779 | </para> |
| 7780 | </section> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 7781 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 7782 | <section id='cooked-mode'> |
| 7783 | <title>Cooked Mode</title> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 7784 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 7785 | <para> |
| 7786 | Running Wic in cooked mode leverages off artifacts in |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 7787 | the Build Directory. |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 7788 | In other words, you do not have to specify kernel or |
| 7789 | root filesystem locations as part of the command. |
| 7790 | All you need to provide is a kickstart file and the |
| 7791 | name of the image from which to use artifacts by using |
| 7792 | the "-e" option. |
| 7793 | Wic looks in the Build Directory (e.g. |
| 7794 | <filename>tmp/deploy/images/</filename><replaceable>machine</replaceable>) |
| 7795 | for artifacts. |
| 7796 | </para> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 7797 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 7798 | <para> |
| 7799 | The general form of the <filename>wic</filename> |
| 7800 | command using Cooked Mode is as follows: |
| 7801 | <literallayout class='monospaced'> |
| 7802 | $ wic create <replaceable>wks_file</replaceable> -e <replaceable>IMAGE_NAME</replaceable> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 7803 | |
Brad Bishop | 37a0e4d | 2017-12-04 01:01:44 -0500 | [diff] [blame] | 7804 | Where: |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 7805 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 7806 | <replaceable>wks_file</replaceable>: |
| 7807 | An OpenEmbedded kickstart file. You can provide |
| 7808 | your own custom file or use a file from a set of |
| 7809 | existing files provided with the Yocto Project |
| 7810 | release. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 7811 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 7812 | required argument: |
| 7813 | -e <replaceable>IMAGE_NAME</replaceable>, --image-name <replaceable>IMAGE_NAME</replaceable> |
| 7814 | name of the image to use the artifacts from e.g. core- |
| 7815 | image-sato |
Brad Bishop | 37a0e4d | 2017-12-04 01:01:44 -0500 | [diff] [blame] | 7816 | </literallayout> |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 7817 | </para> |
| 7818 | </section> |
| 7819 | </section> |
| 7820 | |
| 7821 | <section id='using-a-provided-kickstart-file'> |
| 7822 | <title>Using an Existing Kickstart File</title> |
| 7823 | |
| 7824 | <para> |
| 7825 | If you do not want to create your own kickstart file, you |
| 7826 | can use an existing file provided by the Wic installation. |
| 7827 | As shipped, kickstart files can be found in the |
| 7828 | Yocto Project |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 7829 | <ulink url='&YOCTO_DOCS_OM_URL;#source-repositories'>Source Repositories</ulink> |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 7830 | in the following two locations: |
| 7831 | <literallayout class='monospaced'> |
| 7832 | poky/meta-yocto-bsp/wic |
| 7833 | poky/scripts/lib/wic/canned-wks |
| 7834 | </literallayout> |
| 7835 | Use the following command to list the available kickstart |
| 7836 | files: |
| 7837 | <literallayout class='monospaced'> |
| 7838 | $ wic list images |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 7839 | genericx86 Create an EFI disk image for genericx86* |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 7840 | beaglebone-yocto Create SD card image for Beaglebone |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 7841 | edgerouter Create SD card image for Edgerouter |
| 7842 | qemux86-directdisk Create a qemu machine 'pcbios' direct disk image |
| 7843 | directdisk-gpt Create a 'pcbios' direct disk image |
| 7844 | mkefidisk Create an EFI disk image |
| 7845 | directdisk Create a 'pcbios' direct disk image |
| 7846 | systemd-bootdisk Create an EFI disk image with systemd-boot |
| 7847 | mkhybridiso Create a hybrid ISO image |
| 7848 | sdimage-bootpart Create SD card image with a boot partition |
| 7849 | directdisk-multi-rootfs Create multi rootfs image using rootfs plugin |
| 7850 | directdisk-bootloader-config Create a 'pcbios' direct disk image with custom bootloader config |
| 7851 | </literallayout> |
| 7852 | When you use an existing file, you do not have to use the |
| 7853 | <filename>.wks</filename> extension. |
| 7854 | Here is an example in Raw Mode that uses the |
| 7855 | <filename>directdisk</filename> file: |
| 7856 | <literallayout class='monospaced'> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 7857 | $ wic create directdisk -r <replaceable>rootfs_dir</replaceable> -b <replaceable>bootimg_dir</replaceable> \ |
| 7858 | -k <replaceable>kernel_dir</replaceable> -n <replaceable>native_sysroot</replaceable> |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 7859 | </literallayout> |
| 7860 | </para> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 7861 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 7862 | <para> |
| 7863 | Here are the actual partition language commands |
| 7864 | used in the <filename>genericx86.wks</filename> file to |
| 7865 | generate an image: |
| 7866 | <literallayout class='monospaced'> |
| 7867 | # short-description: Create an EFI disk image for genericx86* |
| 7868 | # long-description: Creates a partitioned EFI disk image for genericx86* machines |
| 7869 | part /boot --source bootimg-efi --sourceparams="loader=grub-efi" --ondisk sda --label msdos --active --align 1024 |
| 7870 | 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] | 7871 | part swap --ondisk sda --size 44 --label swap1 --fstype=swap |
| 7872 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 7873 | bootloader --ptable gpt --timeout=5 --append="rootfstype=ext4 console=ttyS0,115200 console=tty0" |
| 7874 | </literallayout> |
| 7875 | </para> |
| 7876 | </section> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 7877 | |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 7878 | <section id='wic-using-the-wic-plugin-interface'> |
| 7879 | <title>Using the Wic Plugin Interface</title> |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 7880 | |
| 7881 | <para> |
| 7882 | You can extend and specialize Wic functionality by using |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 7883 | Wic plugins. |
| 7884 | This section explains the Wic plugin interface. |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 7885 | <note> |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 7886 | Wic plugins consist of "source" and "imager" plugins. |
| 7887 | Imager plugins are beyond the scope of this section. |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 7888 | </note> |
| 7889 | </para> |
| 7890 | |
| 7891 | <para> |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 7892 | Source plugins provide a mechanism to customize partition |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 7893 | content during the Wic image generation process. |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 7894 | You can use source plugins to map values that you specify |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 7895 | using <filename>--source</filename> commands in kickstart |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 7896 | files (i.e. <filename>*.wks</filename>) to a plugin |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 7897 | implementation used to populate a given partition. |
| 7898 | <note> |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 7899 | If you use plugins that have build-time dependencies |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 7900 | (e.g. native tools, bootloaders, and so forth) |
| 7901 | when building a Wic image, you need to specify those |
| 7902 | dependencies using the |
| 7903 | <ulink url='&YOCTO_DOCS_REF_URL;#var-WKS_FILE_DEPENDS'><filename>WKS_FILE_DEPENDS</filename></ulink> |
| 7904 | variable. |
| 7905 | </note> |
| 7906 | </para> |
| 7907 | |
| 7908 | <para> |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 7909 | Source plugins are subclasses defined in plugin files. |
| 7910 | As shipped, the Yocto Project provides several plugin |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 7911 | files. |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 7912 | You can see the source plugin files that ship with the |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 7913 | Yocto Project |
| 7914 | <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] | 7915 | Each of these plugin files contains source plugins that |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 7916 | are designed to populate a specific Wic image partition. |
| 7917 | </para> |
| 7918 | |
| 7919 | <para> |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 7920 | Source plugins are subclasses of the |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 7921 | <filename>SourcePlugin</filename> class, which is |
| 7922 | defined in the |
| 7923 | <filename>poky/scripts/lib/wic/pluginbase.py</filename> |
| 7924 | file. |
| 7925 | For example, the <filename>BootimgEFIPlugin</filename> |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 7926 | source plugin found in the |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 7927 | <filename>bootimg-efi.py</filename> file is a subclass of |
| 7928 | the <filename>SourcePlugin</filename> class, which is found |
| 7929 | in the <filename>pluginbase.py</filename> file. |
| 7930 | </para> |
| 7931 | |
| 7932 | <para> |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 7933 | You can also implement source plugins in a layer outside |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 7934 | of the Source Repositories (external layer). |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 7935 | To do so, be sure that your plugin files are located in |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 7936 | a directory whose path is |
| 7937 | <filename>scripts/lib/wic/plugins/source/</filename> |
| 7938 | within your external layer. |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 7939 | When the plugin files are located there, the source |
| 7940 | plugins they contain are made available to Wic. |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 7941 | </para> |
| 7942 | |
| 7943 | <para> |
| 7944 | When the Wic implementation needs to invoke a |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 7945 | partition-specific implementation, it looks for the plugin |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 7946 | with the same name as the <filename>--source</filename> |
| 7947 | parameter used in the kickstart file given to that |
| 7948 | partition. |
| 7949 | For example, if the partition is set up using the following |
| 7950 | command in a kickstart file: |
| 7951 | <literallayout class='monospaced'> |
| 7952 | part /boot --source bootimg-pcbios --ondisk sda --label boot --active --align 1024 |
| 7953 | </literallayout> |
| 7954 | The methods defined as class members of the matching |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 7955 | source plugin (i.e. <filename>bootimg-pcbios</filename>) |
| 7956 | in the <filename>bootimg-pcbios.py</filename> plugin file |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 7957 | are used. |
| 7958 | </para> |
| 7959 | |
| 7960 | <para> |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 7961 | To be more concrete, here is the corresponding plugin |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 7962 | definition from the <filename>bootimg-pcbios.py</filename> |
| 7963 | file for the previous command along with an example |
| 7964 | method called by the Wic implementation when it needs to |
| 7965 | prepare a partition using an implementation-specific |
| 7966 | function: |
| 7967 | <literallayout class='monospaced'> |
| 7968 | . |
| 7969 | . |
| 7970 | . |
| 7971 | class BootimgPcbiosPlugin(SourcePlugin): |
| 7972 | """ |
| 7973 | Create MBR boot partition and install syslinux on it. |
| 7974 | """ |
| 7975 | |
| 7976 | name = 'bootimg-pcbios' |
| 7977 | . |
| 7978 | . |
| 7979 | . |
| 7980 | @classmethod |
| 7981 | def do_prepare_partition(cls, part, source_params, creator, cr_workdir, |
| 7982 | oe_builddir, bootimg_dir, kernel_dir, |
| 7983 | rootfs_dir, native_sysroot): |
| 7984 | """ |
| 7985 | Called to do the actual content population for a partition i.e. it |
| 7986 | 'prepares' the partition to be incorporated into the image. |
| 7987 | In this case, prepare content for legacy bios boot partition. |
| 7988 | """ |
| 7989 | . |
| 7990 | . |
| 7991 | . |
| 7992 | </literallayout> |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 7993 | If a subclass (plugin) itself does not implement a |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 7994 | particular function, Wic locates and uses the default |
| 7995 | version in the superclass. |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 7996 | It is for this reason that all source plugins are derived |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 7997 | from the <filename>SourcePlugin</filename> class. |
| 7998 | </para> |
| 7999 | |
| 8000 | <para> |
| 8001 | The <filename>SourcePlugin</filename> class defined in |
| 8002 | the <filename>pluginbase.py</filename> file defines |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 8003 | a set of methods that source plugins can implement or |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 8004 | override. |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 8005 | Any plugins (subclass of |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 8006 | <filename>SourcePlugin</filename>) that do not implement |
| 8007 | a particular method inherit the implementation of the |
| 8008 | method from the <filename>SourcePlugin</filename> class. |
| 8009 | For more information, see the |
| 8010 | <filename>SourcePlugin</filename> class in the |
| 8011 | <filename>pluginbase.py</filename> file for details: |
| 8012 | </para> |
| 8013 | |
| 8014 | <para> |
| 8015 | The following list describes the methods implemented in the |
| 8016 | <filename>SourcePlugin</filename> class: |
| 8017 | <itemizedlist> |
| 8018 | <listitem><para> |
| 8019 | <emphasis><filename>do_prepare_partition()</filename>:</emphasis> |
| 8020 | Called to populate a partition with actual content. |
| 8021 | In other words, the method prepares the final |
| 8022 | partition image that is incorporated into the |
| 8023 | disk image. |
| 8024 | </para></listitem> |
| 8025 | <listitem><para> |
| 8026 | <emphasis><filename>do_configure_partition()</filename>:</emphasis> |
| 8027 | Called before |
| 8028 | <filename>do_prepare_partition()</filename> to |
| 8029 | create custom configuration files for a partition |
| 8030 | (e.g. syslinux or grub configuration files). |
| 8031 | </para></listitem> |
| 8032 | <listitem><para> |
| 8033 | <emphasis><filename>do_install_disk()</filename>:</emphasis> |
| 8034 | Called after all partitions have been prepared and |
| 8035 | assembled into a disk image. |
| 8036 | This method provides a hook to allow finalization |
| 8037 | of a disk image (e.g. writing an MBR). |
| 8038 | </para></listitem> |
| 8039 | <listitem><para> |
| 8040 | <emphasis><filename>do_stage_partition()</filename>:</emphasis> |
| 8041 | Special content-staging hook called before |
| 8042 | <filename>do_prepare_partition()</filename>. |
| 8043 | This method is normally empty.</para> |
| 8044 | |
| 8045 | <para>Typically, a partition just uses the passed-in |
| 8046 | parameters (e.g. the unmodified value of |
| 8047 | <filename>bootimg_dir</filename>). |
| 8048 | However, in some cases, things might need to be |
| 8049 | more tailored. |
| 8050 | As an example, certain files might additionally |
| 8051 | need to be taken from |
| 8052 | <filename>bootimg_dir + /boot</filename>. |
| 8053 | This hook allows those files to be staged in a |
| 8054 | customized fashion. |
| 8055 | <note> |
| 8056 | <filename>get_bitbake_var()</filename> |
| 8057 | allows you to access non-standard variables |
| 8058 | that you might want to use for this |
| 8059 | behavior. |
| 8060 | </note> |
| 8061 | </para></listitem> |
| 8062 | </itemizedlist> |
| 8063 | </para> |
| 8064 | |
| 8065 | <para> |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 8066 | You can extend the source plugin mechanism. |
| 8067 | To add more hooks, create more source plugin methods |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 8068 | within <filename>SourcePlugin</filename> and the |
| 8069 | corresponding derived subclasses. |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 8070 | The code that calls the plugin methods uses the |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 8071 | <filename>plugin.get_source_plugin_methods()</filename> |
| 8072 | function to find the method or methods needed by the call. |
| 8073 | Retrieval of those methods is accomplished by filling up |
| 8074 | a dict with keys that contain the method names of interest. |
| 8075 | On success, these will be filled in with the actual |
| 8076 | methods. |
| 8077 | See the Wic implementation for examples and details. |
| 8078 | </para> |
| 8079 | </section> |
| 8080 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 8081 | <section id='wic-usage-examples'> |
| 8082 | <title>Examples</title> |
| 8083 | |
| 8084 | <para> |
| 8085 | This section provides several examples that show how to use |
| 8086 | the Wic utility. |
| 8087 | All the examples assume the list of requirements in the |
| 8088 | "<link linkend='wic-requirements'>Requirements</link>" |
| 8089 | section have been met. |
| 8090 | The examples assume the previously generated image is |
| 8091 | <filename>core-image-minimal</filename>. |
| 8092 | </para> |
| 8093 | |
| 8094 | <section id='generate-an-image-using-a-provided-kickstart-file'> |
| 8095 | <title>Generate an Image using an Existing Kickstart File</title> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 8096 | |
| 8097 | <para> |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 8098 | This example runs in Cooked Mode and uses the |
| 8099 | <filename>mkefidisk</filename> kickstart file: |
| 8100 | <literallayout class='monospaced'> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 8101 | $ wic create mkefidisk -e core-image-minimal |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 8102 | INFO: Building wic-tools... |
| 8103 | . |
| 8104 | . |
| 8105 | . |
| 8106 | INFO: The new image(s) can be found here: |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 8107 | ./mkefidisk-201804191017-sda.direct |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 8108 | |
| 8109 | The following build artifacts were used to create the image(s): |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 8110 | ROOTFS_DIR: /home/stephano/build/master/build/tmp-glibc/work/qemux86-oe-linux/core-image-minimal/1.0-r0/rootfs |
| 8111 | BOOTIMG_DIR: /home/stephano/build/master/build/tmp-glibc/work/qemux86-oe-linux/core-image-minimal/1.0-r0/recipe-sysroot/usr/share |
| 8112 | KERNEL_DIR: /home/stephano/build/master/build/tmp-glibc/deploy/images/qemux86 |
| 8113 | 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] | 8114 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 8115 | INFO: The image(s) were created using OE kickstart file: |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 8116 | /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] | 8117 | </literallayout> |
| 8118 | The previous example shows the easiest way to create |
| 8119 | an image by running in cooked mode and supplying |
| 8120 | a kickstart file and the "-e" option to point to the |
| 8121 | existing build artifacts. |
| 8122 | Your <filename>local.conf</filename> file needs to have |
| 8123 | the |
| 8124 | <ulink url='&YOCTO_DOCS_REF_URL;#var-MACHINE'><filename>MACHINE</filename></ulink> |
| 8125 | variable set to the machine you are using, which is |
| 8126 | "qemux86" in this example. |
| 8127 | </para> |
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 | Once the image builds, the output provides image |
| 8131 | location, artifact use, and kickstart file information. |
| 8132 | <note> |
| 8133 | You should always verify the details provided in the |
| 8134 | output to make sure that the image was indeed |
| 8135 | created exactly as expected. |
| 8136 | </note> |
| 8137 | </para> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 8138 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 8139 | <para> |
| 8140 | Continuing with the example, you can now write the |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 8141 | image from the Build Directory onto a USB stick, or |
| 8142 | whatever media for which you built your image, and boot |
| 8143 | from the media. |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 8144 | You can write the image by using |
| 8145 | <filename>bmaptool</filename> or |
| 8146 | <filename>dd</filename>: |
| 8147 | <literallayout class='monospaced'> |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 8148 | $ 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] | 8149 | </literallayout> |
| 8150 | or |
| 8151 | <literallayout class='monospaced'> |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 8152 | $ 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] | 8153 | </literallayout> |
| 8154 | <note> |
| 8155 | For more information on how to use the |
| 8156 | <filename>bmaptool</filename> to flash a device |
| 8157 | with an image, see the |
| 8158 | "<link linkend='flashing-images-using-bmaptool'>Flashing Images Using <filename>bmaptool</filename></link>" |
| 8159 | section. |
| 8160 | </note> |
| 8161 | </para> |
| 8162 | </section> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 8163 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 8164 | <section id='using-a-modified-kickstart-file'> |
| 8165 | <title>Using a Modified Kickstart File</title> |
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 | Because partitioned image creation is driven by the |
| 8169 | kickstart file, it is easy to affect image creation by |
| 8170 | changing the parameters in the file. |
| 8171 | This next example demonstrates that through modification |
| 8172 | of the <filename>directdisk-gpt</filename> kickstart |
| 8173 | file. |
| 8174 | </para> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 8175 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 8176 | <para> |
| 8177 | As mentioned earlier, you can use the command |
| 8178 | <filename>wic list images</filename> to show the list |
| 8179 | of existing kickstart files. |
| 8180 | The directory in which the |
| 8181 | <filename>directdisk-gpt.wks</filename> file resides is |
| 8182 | <filename>scripts/lib/image/canned-wks/</filename>, |
| 8183 | which is located in the |
| 8184 | <ulink url='&YOCTO_DOCS_REF_URL;#source-directory'>Source Directory</ulink> |
| 8185 | (e.g. <filename>poky</filename>). |
| 8186 | Because available files reside in this directory, |
| 8187 | you can create and add your own custom files to the |
| 8188 | directory. |
| 8189 | Subsequent use of the |
| 8190 | <filename>wic list images</filename> command would then |
| 8191 | include your kickstart files. |
| 8192 | </para> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 8193 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 8194 | <para> |
| 8195 | In this example, the existing |
| 8196 | <filename>directdisk-gpt</filename> file already does |
| 8197 | most of what is needed. |
| 8198 | However, for the hardware in this example, the image |
| 8199 | will need to boot from <filename>sdb</filename> instead |
| 8200 | of <filename>sda</filename>, which is what the |
| 8201 | <filename>directdisk-gpt</filename> kickstart file |
| 8202 | uses. |
| 8203 | </para> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 8204 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 8205 | <para> |
| 8206 | The example begins by making a copy of the |
| 8207 | <filename>directdisk-gpt.wks</filename> file in the |
| 8208 | <filename>scripts/lib/image/canned-wks</filename> |
| 8209 | directory and then by changing the lines that specify |
| 8210 | the target disk from which to boot. |
| 8211 | <literallayout class='monospaced'> |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 8212 | $ cp /home/stephano/poky/scripts/lib/wic/canned-wks/directdisk-gpt.wks \ |
| 8213 | /home/stephano/poky/scripts/lib/wic/canned-wks/directdisksdb-gpt.wks |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 8214 | </literallayout> |
| 8215 | Next, the example modifies the |
| 8216 | <filename>directdisksdb-gpt.wks</filename> file and |
| 8217 | changes all instances of |
| 8218 | "<filename>--ondisk sda</filename>" to |
| 8219 | "<filename>--ondisk sdb</filename>". |
| 8220 | The example changes the following two lines and leaves |
| 8221 | the remaining lines untouched: |
| 8222 | <literallayout class='monospaced'> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 8223 | part /boot --source bootimg-pcbios --ondisk sdb --label boot --active --align 1024 |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 8224 | part / --source rootfs --ondisk sdb --fstype=ext4 --label platform --align 1024 --use-uuid |
| 8225 | </literallayout> |
| 8226 | Once the lines are changed, the example generates the |
| 8227 | <filename>directdisksdb-gpt</filename> image. |
| 8228 | The command points the process at the |
| 8229 | <filename>core-image-minimal</filename> artifacts for |
| 8230 | the Next Unit of Computing (nuc) |
| 8231 | <ulink url='&YOCTO_DOCS_REF_URL;#var-MACHINE'><filename>MACHINE</filename></ulink> |
| 8232 | the <filename>local.conf</filename>. |
| 8233 | <literallayout class='monospaced'> |
| 8234 | $ wic create directdisksdb-gpt -e core-image-minimal |
| 8235 | INFO: Building wic-tools... |
| 8236 | . |
| 8237 | . |
| 8238 | . |
| 8239 | Initialising tasks: 100% |#######################################| Time: 0:00:01 |
| 8240 | NOTE: Executing SetScene Tasks |
| 8241 | NOTE: Executing RunQueue Tasks |
| 8242 | NOTE: Tasks Summary: Attempted 1161 tasks of which 1157 didn't need to be rerun and all succeeded. |
| 8243 | INFO: Creating image(s)... |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 8244 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 8245 | INFO: The new image(s) can be found here: |
| 8246 | ./directdisksdb-gpt-201710090938-sdb.direct |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 8247 | |
| 8248 | The following build artifacts were used to create the image(s): |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 8249 | ROOTFS_DIR: /home/stephano/build/master/build/tmp-glibc/work/qemux86-oe-linux/core-image-minimal/1.0-r0/rootfs |
| 8250 | BOOTIMG_DIR: /home/stephano/build/master/build/tmp-glibc/work/qemux86-oe-linux/core-image-minimal/1.0-r0/recipe-sysroot/usr/share |
| 8251 | KERNEL_DIR: /home/stephano/build/master/build/tmp-glibc/deploy/images/qemux86 |
| 8252 | 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] | 8253 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 8254 | INFO: The image(s) were created using OE kickstart file: |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 8255 | /home/stephano/poky/scripts/lib/wic/canned-wks/directdisksdb-gpt.wks |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 8256 | </literallayout> |
| 8257 | Continuing with the example, you can now directly |
| 8258 | <filename>dd</filename> the image to a USB stick, or |
| 8259 | whatever media for which you built your image, |
| 8260 | and boot the resulting media: |
| 8261 | <literallayout class='monospaced'> |
| 8262 | $ sudo dd if=directdisksdb-gpt-201710090938-sdb.direct of=/dev/sdb |
| 8263 | 140966+0 records in |
| 8264 | 140966+0 records out |
| 8265 | 72174592 bytes (72 MB, 69 MiB) copied, 78.0282 s, 925 kB/s |
| 8266 | $ sudo eject /dev/sdb |
| 8267 | </literallayout> |
| 8268 | </para> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 8269 | </section> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 8270 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 8271 | <section id='using-a-modified-kickstart-file-and-running-in-raw-mode'> |
| 8272 | <title>Using a Modified Kickstart File and Running in Raw Mode</title> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 8273 | |
Brad Bishop | 37a0e4d | 2017-12-04 01:01:44 -0500 | [diff] [blame] | 8274 | <para> |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 8275 | This next example manually specifies each build artifact |
| 8276 | (runs in Raw Mode) and uses a modified kickstart file. |
| 8277 | The example also uses the <filename>-o</filename> option |
| 8278 | to cause Wic to create the output |
| 8279 | somewhere other than the default output directory, |
| 8280 | which is the current directory: |
| 8281 | <literallayout class='monospaced'> |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 8282 | $ wic create /home/stephano/my_yocto/test.wks -o /home/stephano/testwic \ |
| 8283 | --rootfs-dir /home/stephano/build/master/build/tmp/work/qemux86-poky-linux/core-image-minimal/1.0-r0/rootfs \ |
| 8284 | --bootimg-dir /home/stephano/build/master/build/tmp/work/qemux86-poky-linux/core-image-minimal/1.0-r0/recipe-sysroot/usr/share \ |
| 8285 | --kernel-dir /home/stephano/build/master/build/tmp/deploy/images/qemux86 \ |
| 8286 | --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] | 8287 | |
| 8288 | INFO: Creating image(s)... |
| 8289 | |
| 8290 | INFO: The new image(s) can be found here: |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 8291 | /home/stephano/testwic/test-201710091445-sdb.direct |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 8292 | |
| 8293 | The following build artifacts were used to create the image(s): |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 8294 | ROOTFS_DIR: /home/stephano/build/master/build/tmp-glibc/work/qemux86-oe-linux/core-image-minimal/1.0-r0/rootfs |
| 8295 | BOOTIMG_DIR: /home/stephano/build/master/build/tmp-glibc/work/qemux86-oe-linux/core-image-minimal/1.0-r0/recipe-sysroot/usr/share |
| 8296 | KERNEL_DIR: /home/stephano/build/master/build/tmp-glibc/deploy/images/qemux86 |
| 8297 | 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] | 8298 | |
| 8299 | INFO: The image(s) were created using OE kickstart file: |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 8300 | /home/stephano/my_yocto/test.wks |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 8301 | </literallayout> |
| 8302 | For this example, |
| 8303 | <ulink url='&YOCTO_DOCS_REF_URL;#var-MACHINE'><filename>MACHINE</filename></ulink> |
| 8304 | did not have to be specified in the |
| 8305 | <filename>local.conf</filename> file since the |
| 8306 | artifact is manually specified. |
Brad Bishop | 37a0e4d | 2017-12-04 01:01:44 -0500 | [diff] [blame] | 8307 | </para> |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 8308 | </section> |
| 8309 | |
| 8310 | <section id='using-wic-to-manipulate-an-image'> |
| 8311 | <title>Using Wic to Manipulate an Image</title> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 8312 | |
Brad Bishop | 37a0e4d | 2017-12-04 01:01:44 -0500 | [diff] [blame] | 8313 | <para> |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 8314 | Wic image manipulation allows you to shorten turnaround |
| 8315 | time during image development. |
| 8316 | For example, you can use Wic to delete the kernel partition |
| 8317 | of a Wic image and then insert a newly built kernel. |
| 8318 | This saves you time from having to rebuild the entire image |
| 8319 | each time you modify the kernel. |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 8320 | <note> |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 8321 | In order to use Wic to manipulate a Wic image as in |
| 8322 | this example, your development machine must have the |
| 8323 | <filename>mtools</filename> package installed. |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 8324 | </note> |
Brad Bishop | 37a0e4d | 2017-12-04 01:01:44 -0500 | [diff] [blame] | 8325 | </para> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 8326 | |
Brad Bishop | 37a0e4d | 2017-12-04 01:01:44 -0500 | [diff] [blame] | 8327 | <para> |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 8328 | The following example examines the contents of the Wic |
| 8329 | image, deletes the existing kernel, and then inserts a |
| 8330 | new kernel: |
| 8331 | <orderedlist> |
Brad Bishop | 37a0e4d | 2017-12-04 01:01:44 -0500 | [diff] [blame] | 8332 | <listitem><para> |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 8333 | <emphasis>List the Partitions:</emphasis> |
| 8334 | Use the <filename>wic ls</filename> command to list |
| 8335 | all the partitions in the Wic image: |
| 8336 | <literallayout class='monospaced'> |
| 8337 | $ wic ls tmp/deploy/images/qemux86/core-image-minimal-qemux86.wic |
| 8338 | Num Start End Size Fstype |
| 8339 | 1 1048576 25041919 23993344 fat16 |
| 8340 | 2 25165824 72157183 46991360 ext4 |
| 8341 | </literallayout> |
| 8342 | The previous output shows two partitions in the |
| 8343 | <filename>core-image-minimal-qemux86.wic</filename> |
| 8344 | image. |
| 8345 | </para></listitem> |
| 8346 | <listitem><para> |
| 8347 | <emphasis>Examine a Particular Partition:</emphasis> |
| 8348 | Use the <filename>wic ls</filename> command again |
| 8349 | but in a different form to examine a particular |
Brad Bishop | 37a0e4d | 2017-12-04 01:01:44 -0500 | [diff] [blame] | 8350 | partition. |
Brad Bishop | 37a0e4d | 2017-12-04 01:01:44 -0500 | [diff] [blame] | 8351 | <note> |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 8352 | You can get command usage on any Wic command |
| 8353 | using the following form: |
| 8354 | <literallayout class='monospaced'> |
| 8355 | $ wic help <replaceable>command</replaceable> |
| 8356 | </literallayout> |
| 8357 | For example, the following command shows you |
| 8358 | the various ways to use the |
| 8359 | <filename>wic ls</filename> command: |
| 8360 | <literallayout class='monospaced'> |
| 8361 | $ wic help ls |
| 8362 | </literallayout> |
Brad Bishop | 37a0e4d | 2017-12-04 01:01:44 -0500 | [diff] [blame] | 8363 | </note> |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 8364 | The following command shows what is in Partition |
| 8365 | one: |
| 8366 | <literallayout class='monospaced'> |
| 8367 | $ wic ls tmp/deploy/images/qemux86/core-image-minimal-qemux86.wic:1 |
| 8368 | Volume in drive : is boot |
| 8369 | Volume Serial Number is E894-1809 |
| 8370 | Directory for ::/ |
Brad Bishop | 37a0e4d | 2017-12-04 01:01:44 -0500 | [diff] [blame] | 8371 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 8372 | libcom32 c32 186500 2017-10-09 16:06 |
| 8373 | libutil c32 24148 2017-10-09 16:06 |
| 8374 | syslinux cfg 220 2017-10-09 16:06 |
| 8375 | vesamenu c32 27104 2017-10-09 16:06 |
| 8376 | vmlinuz 6904608 2017-10-09 16:06 |
| 8377 | 5 files 7 142 580 bytes |
| 8378 | 16 582 656 bytes free |
| 8379 | </literallayout> |
| 8380 | The previous output shows five files, with the |
| 8381 | <filename>vmlinuz</filename> being the kernel. |
| 8382 | <note> |
| 8383 | If you see the following error, you need to |
| 8384 | update or create a |
| 8385 | <filename>~/.mtoolsrc</filename> file and |
| 8386 | be sure to have the line “mtools_skip_check=1“ |
| 8387 | in the file. |
| 8388 | Then, run the Wic command again: |
| 8389 | <literallayout class='monospaced'> |
| 8390 | ERROR: _exec_cmd: /usr/bin/mdir -i /tmp/wic-parttfokuwra ::/ returned '1' instead of 0 |
| 8391 | output: Total number of sectors (47824) not a multiple of sectors per track (32)! |
| 8392 | Add mtools_skip_check=1 to your .mtoolsrc file to skip this test |
| 8393 | </literallayout> |
| 8394 | </note> |
| 8395 | </para></listitem> |
| 8396 | <listitem><para> |
| 8397 | <emphasis>Remove the Old Kernel:</emphasis> |
| 8398 | Use the <filename>wic rm</filename> command to |
| 8399 | remove the <filename>vmlinuz</filename> file |
| 8400 | (kernel): |
| 8401 | <literallayout class='monospaced'> |
| 8402 | $ wic rm tmp/deploy/images/qemux86/core-image-minimal-qemux86.wic:1/vmlinuz |
| 8403 | </literallayout> |
| 8404 | </para></listitem> |
| 8405 | <listitem><para> |
| 8406 | <emphasis>Add In the New Kernel:</emphasis> |
| 8407 | Use the <filename>wic cp</filename> command to |
| 8408 | add the updated kernel to the Wic image. |
| 8409 | Depending on how you built your kernel, it could |
| 8410 | be in different places. |
| 8411 | If you used <filename>devtool</filename> and |
| 8412 | an SDK to build your kernel, it resides in the |
| 8413 | <filename>tmp/work</filename> directory of the |
| 8414 | extensible SDK. |
| 8415 | If you used <filename>make</filename> to build the |
| 8416 | kernel, the kernel will be in the |
| 8417 | <filename>workspace/sources</filename> area. |
| 8418 | </para> |
Brad Bishop | 37a0e4d | 2017-12-04 01:01:44 -0500 | [diff] [blame] | 8419 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 8420 | <para>The following example assumes |
| 8421 | <filename>devtool</filename> was used to build |
| 8422 | the kernel: |
| 8423 | <literallayout class='monospaced'> |
| 8424 | 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 \ |
| 8425 | ~/poky/build/tmp/deploy/images/qemux86/core-image-minimal-qemux86.wic:1/vmlinuz |
| 8426 | </literallayout> |
| 8427 | Once the new kernel is added back into the image, |
| 8428 | you can use the <filename>dd</filename> |
| 8429 | command or |
| 8430 | <link linkend='flashing-images-using-bmaptool'><filename>bmaptool</filename></link> |
| 8431 | to flash your wic image onto an SD card |
| 8432 | or USB stick and test your target. |
| 8433 | <note> |
| 8434 | Using <filename>bmaptool</filename> is |
| 8435 | generally 10 to 20 times faster than using |
| 8436 | <filename>dd</filename>. |
| 8437 | </note> |
| 8438 | </para></listitem> |
| 8439 | </orderedlist> |
| 8440 | </para> |
| 8441 | </section> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 8442 | </section> |
| 8443 | </section> |
| 8444 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 8445 | <section id='flashing-images-using-bmaptool'> |
| 8446 | <title>Flashing Images Using <filename>bmaptool</filename></title> |
| 8447 | |
| 8448 | <para> |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 8449 | A fast and easy way to flash an image to a bootable device |
| 8450 | is to use Bmaptool, which is integrated into the OpenEmbedded |
| 8451 | build system. |
| 8452 | Bmaptool is a generic tool that creates a file's block map (bmap) |
| 8453 | and then uses that map to copy the file. |
| 8454 | As compared to traditional tools such as dd or cp, Bmaptool |
| 8455 | can copy (or flash) large files like raw system image files |
| 8456 | much faster. |
| 8457 | <note><title>Notes</title> |
| 8458 | <itemizedlist> |
| 8459 | <listitem><para> |
| 8460 | If you are using Ubuntu or Debian distributions, you |
| 8461 | can install the <filename>bmap-tools</filename> package |
| 8462 | using the following command and then use the tool |
| 8463 | without specifying <filename>PATH</filename> even from |
| 8464 | the root account: |
| 8465 | <literallayout class='monospaced'> |
| 8466 | $ sudo apt-get install bmap-tools |
| 8467 | </literallayout> |
| 8468 | </para></listitem> |
| 8469 | <listitem><para> |
| 8470 | If you are unable to install the |
| 8471 | <filename>bmap-tools</filename> package, you will |
| 8472 | need to build Bmaptool before using it. |
| 8473 | Use the following command: |
| 8474 | <literallayout class='monospaced'> |
| 8475 | $ bitbake bmap-tools-native |
| 8476 | </literallayout> |
| 8477 | </para></listitem> |
| 8478 | </itemizedlist> |
| 8479 | </note> |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 8480 | </para> |
| 8481 | |
| 8482 | <para> |
| 8483 | Following, is an example that shows how to flash a Wic image. |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 8484 | Realize that while this example uses a Wic image, you can use |
| 8485 | Bmaptool to flash any type of image. |
| 8486 | Use these steps to flash an image using Bmaptool: |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 8487 | <orderedlist> |
| 8488 | <listitem><para> |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 8489 | <emphasis>Update your <filename>local.conf</filename> File:</emphasis> |
| 8490 | You need to have the following set in your |
| 8491 | <filename>local.conf</filename> file before building |
| 8492 | your image: |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 8493 | <literallayout class='monospaced'> |
| 8494 | IMAGE_FSTYPES += "wic wic.bmap" |
| 8495 | </literallayout> |
| 8496 | </para></listitem> |
| 8497 | <listitem><para> |
| 8498 | <emphasis>Get Your Image:</emphasis> |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 8499 | Either have your image ready (pre-built with the |
| 8500 | <ulink url='&YOCTO_DOCS_REF_URL;#var-IMAGE_FSTYPES'><filename>IMAGE_FSTYPES</filename></ulink> |
| 8501 | setting previously mentioned) or take the step to build |
| 8502 | the image: |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 8503 | <literallayout class='monospaced'> |
| 8504 | $ bitbake <replaceable>image</replaceable> |
| 8505 | </literallayout> |
| 8506 | </para></listitem> |
| 8507 | <listitem><para> |
| 8508 | <emphasis>Flash the Device:</emphasis> |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 8509 | Flash the device with the image by using Bmaptool |
| 8510 | depending on your particular setup. |
| 8511 | The following commands assume the image resides in the |
| 8512 | Build Directory's <filename>deploy/images/</filename> |
| 8513 | area: |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 8514 | <itemizedlist> |
| 8515 | <listitem><para> |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 8516 | If you have write access to the media, use this |
| 8517 | command form: |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 8518 | <literallayout class='monospaced'> |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 8519 | $ 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] | 8520 | </literallayout> |
| 8521 | </para></listitem> |
| 8522 | <listitem><para> |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 8523 | If you do not have write access to the media, set |
| 8524 | your permissions first and then use the same |
| 8525 | command form: |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 8526 | <literallayout class='monospaced'> |
| 8527 | $ sudo chmod 666 /dev/sd<replaceable>X</replaceable> |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 8528 | $ 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] | 8529 | </literallayout> |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 8530 | </para></listitem> |
| 8531 | </itemizedlist> |
| 8532 | </para></listitem> |
| 8533 | </orderedlist> |
| 8534 | </para> |
| 8535 | |
| 8536 | <para> |
| 8537 | For help on the <filename>bmaptool</filename> command, use the |
| 8538 | following command: |
Brad Bishop | 37a0e4d | 2017-12-04 01:01:44 -0500 | [diff] [blame] | 8539 | <literallayout class='monospaced'> |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 8540 | $ bmaptool --help |
Brad Bishop | 37a0e4d | 2017-12-04 01:01:44 -0500 | [diff] [blame] | 8541 | </literallayout> |
Brad Bishop | 37a0e4d | 2017-12-04 01:01:44 -0500 | [diff] [blame] | 8542 | </para> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 8543 | </section> |
| 8544 | |
| 8545 | <section id='making-images-more-secure'> |
| 8546 | <title>Making Images More Secure</title> |
| 8547 | |
| 8548 | <para> |
| 8549 | Security is of increasing concern for embedded devices. |
| 8550 | Consider the issues and problems discussed in just this |
| 8551 | sampling of work found across the Internet: |
| 8552 | <itemizedlist> |
| 8553 | <listitem><para><emphasis> |
| 8554 | "<ulink url='https://www.schneier.com/blog/archives/2014/01/security_risks_9.html'>Security Risks of Embedded Systems</ulink>"</emphasis> |
| 8555 | by Bruce Schneier |
| 8556 | </para></listitem> |
| 8557 | <listitem><para><emphasis> |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 8558 | "<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] | 8559 | by Carna Botnet</para></listitem> |
| 8560 | <listitem><para><emphasis> |
| 8561 | "<ulink url='http://elinux.org/images/6/6f/Security-issues.pdf'>Security Issues for Embedded Devices</ulink>"</emphasis> |
| 8562 | by Jake Edge |
| 8563 | </para></listitem> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 8564 | </itemizedlist> |
| 8565 | </para> |
| 8566 | |
| 8567 | <para> |
| 8568 | When securing your image is of concern, there are steps, tools, |
| 8569 | and variables that you can consider to help you reach the |
| 8570 | security goals you need for your particular device. |
| 8571 | Not all situations are identical when it comes to making an |
| 8572 | image secure. |
| 8573 | Consequently, this section provides some guidance and suggestions |
| 8574 | for consideration when you want to make your image more secure. |
| 8575 | <note> |
| 8576 | Because the security requirements and risks are |
| 8577 | different for every type of device, this section cannot |
| 8578 | provide a complete reference on securing your custom OS. |
| 8579 | It is strongly recommended that you also consult other sources |
| 8580 | of information on embedded Linux system hardening and on |
| 8581 | security. |
| 8582 | </note> |
| 8583 | </para> |
| 8584 | |
| 8585 | <section id='general-considerations'> |
| 8586 | <title>General Considerations</title> |
| 8587 | |
| 8588 | <para> |
| 8589 | General considerations exist that help you create more |
| 8590 | secure images. |
| 8591 | You should consider the following suggestions to help |
| 8592 | make your device more secure: |
| 8593 | <itemizedlist> |
| 8594 | <listitem><para> |
| 8595 | Scan additional code you are adding to the system |
| 8596 | (e.g. application code) by using static analysis |
| 8597 | tools. |
| 8598 | Look for buffer overflows and other potential |
| 8599 | security problems. |
| 8600 | </para></listitem> |
| 8601 | <listitem><para> |
| 8602 | Pay particular attention to the security for |
| 8603 | any web-based administration interface. |
| 8604 | </para> |
| 8605 | <para>Web interfaces typically need to perform |
| 8606 | administrative functions and tend to need to run with |
| 8607 | elevated privileges. |
| 8608 | Thus, the consequences resulting from the interface's |
| 8609 | security becoming compromised can be serious. |
| 8610 | Look for common web vulnerabilities such as |
| 8611 | cross-site-scripting (XSS), unvalidated inputs, |
| 8612 | and so forth.</para> |
| 8613 | <para>As with system passwords, the default credentials |
| 8614 | for accessing a web-based interface should not be the |
| 8615 | same across all devices. |
| 8616 | This is particularly true if the interface is enabled |
| 8617 | by default as it can be assumed that many end-users |
| 8618 | will not change the credentials. |
| 8619 | </para></listitem> |
| 8620 | <listitem><para> |
| 8621 | Ensure you can update the software on the device to |
| 8622 | mitigate vulnerabilities discovered in the future. |
| 8623 | This consideration especially applies when your |
| 8624 | device is network-enabled. |
| 8625 | </para></listitem> |
| 8626 | <listitem><para> |
| 8627 | Ensure you remove or disable debugging functionality |
| 8628 | before producing the final image. |
| 8629 | For information on how to do this, see the |
| 8630 | "<link linkend='considerations-specific-to-the-openembedded-build-system'>Considerations Specific to the OpenEmbedded Build System</link>" |
| 8631 | section. |
| 8632 | </para></listitem> |
| 8633 | <listitem><para> |
| 8634 | Ensure you have no network services listening that |
| 8635 | are not needed. |
| 8636 | </para></listitem> |
| 8637 | <listitem><para> |
| 8638 | Remove any software from the image that is not needed. |
| 8639 | </para></listitem> |
| 8640 | <listitem><para> |
| 8641 | Enable hardware support for secure boot functionality |
| 8642 | when your device supports this functionality. |
| 8643 | </para></listitem> |
| 8644 | </itemizedlist> |
| 8645 | </para> |
| 8646 | </section> |
| 8647 | |
| 8648 | <section id='security-flags'> |
| 8649 | <title>Security Flags</title> |
| 8650 | |
| 8651 | <para> |
| 8652 | The Yocto Project has security flags that you can enable that |
| 8653 | help make your build output more secure. |
| 8654 | The security flags are in the |
| 8655 | <filename>meta/conf/distro/include/security_flags.inc</filename> |
| 8656 | file in your |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 8657 | <ulink url='&YOCTO_DOCS_REF_URL;#source-directory'>Source Directory</ulink> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 8658 | (e.g. <filename>poky</filename>). |
| 8659 | <note> |
| 8660 | Depending on the recipe, certain security flags are enabled |
| 8661 | and disabled by default. |
| 8662 | </note> |
| 8663 | </para> |
| 8664 | |
| 8665 | <para> |
| 8666 | <!-- |
| 8667 | The GCC/LD flags in <filename>security_flags.inc</filename> |
| 8668 | enable more secure code generation. |
| 8669 | By including the <filename>security_flags.inc</filename> |
| 8670 | file, you enable flags to the compiler and linker that cause |
| 8671 | them to generate more secure code. |
| 8672 | <note> |
| 8673 | The GCC/LD flags are enabled by default in the |
| 8674 | <filename>poky-lsb</filename> distribution. |
| 8675 | </note> |
| 8676 | --> |
| 8677 | Use the following line in your |
| 8678 | <filename>local.conf</filename> file or in your custom |
| 8679 | distribution configuration file to enable the security |
| 8680 | compiler and linker flags for your build: |
| 8681 | <literallayout class='monospaced'> |
| 8682 | require conf/distro/include/security_flags.inc |
| 8683 | </literallayout> |
| 8684 | </para> |
| 8685 | </section> |
| 8686 | |
| 8687 | <section id='considerations-specific-to-the-openembedded-build-system'> |
| 8688 | <title>Considerations Specific to the OpenEmbedded Build System</title> |
| 8689 | |
| 8690 | <para> |
| 8691 | You can take some steps that are specific to the |
| 8692 | OpenEmbedded build system to make your images more secure: |
| 8693 | <itemizedlist> |
| 8694 | <listitem><para> |
| 8695 | Ensure "debug-tweaks" is not one of your selected |
| 8696 | <ulink url='&YOCTO_DOCS_REF_URL;#var-IMAGE_FEATURES'><filename>IMAGE_FEATURES</filename></ulink>. |
| 8697 | When creating a new project, the default is to provide you |
| 8698 | with an initial <filename>local.conf</filename> file that |
| 8699 | enables this feature using the |
| 8700 | <ulink url='&YOCTO_DOCS_REF_URL;#var-EXTRA_IMAGE_FEATURES'><filename>EXTRA_IMAGE_FEATURES</filename></ulink> variable with the line: |
| 8701 | <literallayout class='monospaced'> |
| 8702 | EXTRA_IMAGE_FEATURES = "debug-tweaks" |
| 8703 | </literallayout> |
| 8704 | To disable that feature, simply comment out that line in your |
| 8705 | <filename>local.conf</filename> file, or |
| 8706 | make sure <filename>IMAGE_FEATURES</filename> does not contain |
| 8707 | "debug-tweaks" before producing your final image. |
| 8708 | Among other things, leaving this in place sets the |
| 8709 | root password as blank, which makes logging in for |
| 8710 | debugging or inspection easy during |
| 8711 | development but also means anyone can easily log in |
| 8712 | during production. |
| 8713 | </para></listitem> |
| 8714 | <listitem><para> |
| 8715 | It is possible to set a root password for the image |
| 8716 | and also to set passwords for any extra users you might |
| 8717 | add (e.g. administrative or service type users). |
| 8718 | When you set up passwords for multiple images or |
| 8719 | users, you should not duplicate passwords. |
| 8720 | </para> |
| 8721 | <para> |
| 8722 | To set up passwords, use the |
| 8723 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-extrausers'><filename>extrausers</filename></ulink> |
| 8724 | class, which is the preferred method. |
| 8725 | For an example on how to set up both root and user |
| 8726 | passwords, see the |
| 8727 | "<ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-extrausers'><filename>extrausers.bbclass</filename></ulink>" |
| 8728 | section. |
| 8729 | <note> |
| 8730 | When adding extra user accounts or setting a |
| 8731 | root password, be cautious about setting the |
| 8732 | same password on every device. |
| 8733 | If you do this, and the password you have set |
| 8734 | is exposed, then every device is now potentially |
| 8735 | compromised. |
| 8736 | If you need this access but want to ensure |
| 8737 | security, consider setting a different, |
| 8738 | random password for each device. |
| 8739 | Typically, you do this as a separate step after |
| 8740 | you deploy the image onto the device. |
| 8741 | </note> |
| 8742 | </para></listitem> |
| 8743 | <listitem><para> |
| 8744 | Consider enabling a Mandatory Access Control (MAC) |
| 8745 | framework such as SMACK or SELinux and tuning it |
| 8746 | appropriately for your device's usage. |
| 8747 | You can find more information in the |
| 8748 | <ulink url='http://git.yoctoproject.org/cgit/cgit.cgi/meta-selinux/'><filename>meta-selinux</filename></ulink> |
| 8749 | layer. |
| 8750 | </para></listitem> |
| 8751 | </itemizedlist> |
| 8752 | </para> |
| 8753 | |
| 8754 | <para> |
| 8755 | </para> |
| 8756 | </section> |
| 8757 | |
| 8758 | <section id='tools-for-hardening-your-image'> |
| 8759 | <title>Tools for Hardening Your Image</title> |
| 8760 | |
| 8761 | <para> |
| 8762 | The Yocto Project provides tools for making your image |
| 8763 | more secure. |
| 8764 | You can find these tools in the |
| 8765 | <filename>meta-security</filename> layer of the |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 8766 | <ulink url='&YOCTO_GIT_URL;'>Yocto Project Source Repositories</ulink>. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 8767 | </para> |
| 8768 | </section> |
| 8769 | </section> |
| 8770 | |
| 8771 | <section id='creating-your-own-distribution'> |
| 8772 | <title>Creating Your Own Distribution</title> |
| 8773 | |
| 8774 | <para> |
| 8775 | When you build an image using the Yocto Project and |
| 8776 | do not alter any distribution |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 8777 | <ulink url='&YOCTO_DOCS_REF_URL;#metadata'>Metadata</ulink>, |
| 8778 | you are creating a Poky distribution. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 8779 | If you wish to gain more control over package alternative |
| 8780 | selections, compile-time options, and other low-level |
| 8781 | configurations, you can create your own distribution. |
| 8782 | </para> |
| 8783 | |
| 8784 | <para> |
| 8785 | To create your own distribution, the basic steps consist of |
| 8786 | creating your own distribution layer, creating your own |
| 8787 | distribution configuration file, and then adding any needed |
| 8788 | code and Metadata to the layer. |
| 8789 | The following steps provide some more detail: |
| 8790 | <itemizedlist> |
| 8791 | <listitem><para><emphasis>Create a layer for your new distro:</emphasis> |
| 8792 | Create your distribution layer so that you can keep your |
| 8793 | Metadata and code for the distribution separate. |
| 8794 | It is strongly recommended that you create and use your own |
| 8795 | layer for configuration and code. |
| 8796 | Using your own layer as compared to just placing |
| 8797 | configurations in a <filename>local.conf</filename> |
| 8798 | configuration file makes it easier to reproduce the same |
| 8799 | build configuration when using multiple build machines. |
| 8800 | See the |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 8801 | "<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] | 8802 | section for information on how to quickly set up a layer. |
| 8803 | </para></listitem> |
| 8804 | <listitem><para><emphasis>Create the distribution configuration file:</emphasis> |
| 8805 | The distribution configuration file needs to be created in |
| 8806 | the <filename>conf/distro</filename> directory of your |
| 8807 | layer. |
| 8808 | You need to name it using your distribution name |
| 8809 | (e.g. <filename>mydistro.conf</filename>). |
| 8810 | <note> |
| 8811 | The |
| 8812 | <ulink url='&YOCTO_DOCS_REF_URL;#var-DISTRO'><filename>DISTRO</filename></ulink> |
| 8813 | variable in your |
| 8814 | <filename>local.conf</filename> file determines the |
| 8815 | name of your distribution. |
| 8816 | </note></para> |
| 8817 | <para>You can split out parts of your configuration file |
| 8818 | into include files and then "require" them from within |
| 8819 | your distribution configuration file. |
| 8820 | Be sure to place the include files in the |
| 8821 | <filename>conf/distro/include</filename> directory of |
| 8822 | your layer. |
| 8823 | A common example usage of include files would be to |
| 8824 | separate out the selection of desired version and revisions |
| 8825 | for individual recipes. |
| 8826 | </para> |
| 8827 | <para>Your configuration file needs to set the following |
| 8828 | required variables: |
| 8829 | <literallayout class='monospaced'> |
| 8830 | <ulink url='&YOCTO_DOCS_REF_URL;#var-DISTRO_NAME'><filename>DISTRO_NAME</filename></ulink> |
| 8831 | <ulink url='&YOCTO_DOCS_REF_URL;#var-DISTRO_VERSION'><filename>DISTRO_VERSION</filename></ulink> |
| 8832 | </literallayout> |
| 8833 | These following variables are optional and you typically |
| 8834 | set them from the distribution configuration file: |
| 8835 | <literallayout class='monospaced'> |
| 8836 | <ulink url='&YOCTO_DOCS_REF_URL;#var-DISTRO_FEATURES'><filename>DISTRO_FEATURES</filename></ulink> |
| 8837 | <ulink url='&YOCTO_DOCS_REF_URL;#var-DISTRO_EXTRA_RDEPENDS'><filename>DISTRO_EXTRA_RDEPENDS</filename></ulink> |
| 8838 | <ulink url='&YOCTO_DOCS_REF_URL;#var-DISTRO_EXTRA_RRECOMMENDS'><filename>DISTRO_EXTRA_RRECOMMENDS</filename></ulink> |
| 8839 | <ulink url='&YOCTO_DOCS_REF_URL;#var-TCLIBC'><filename>TCLIBC</filename></ulink> |
| 8840 | </literallayout> |
| 8841 | <tip> |
| 8842 | If you want to base your distribution configuration file |
| 8843 | on the very basic configuration from OE-Core, you |
| 8844 | can use |
| 8845 | <filename>conf/distro/defaultsetup.conf</filename> as |
| 8846 | a reference and just include variables that differ |
| 8847 | as compared to <filename>defaultsetup.conf</filename>. |
| 8848 | Alternatively, you can create a distribution |
| 8849 | configuration file from scratch using the |
| 8850 | <filename>defaultsetup.conf</filename> file |
| 8851 | or configuration files from other distributions |
| 8852 | such as Poky or Angstrom as references. |
| 8853 | </tip></para></listitem> |
| 8854 | <listitem><para><emphasis>Provide miscellaneous variables:</emphasis> |
| 8855 | Be sure to define any other variables for which you want to |
| 8856 | create a default or enforce as part of the distribution |
| 8857 | configuration. |
| 8858 | You can include nearly any variable from the |
| 8859 | <filename>local.conf</filename> file. |
| 8860 | The variables you use are not limited to the list in the |
| 8861 | previous bulleted item.</para></listitem> |
| 8862 | <listitem><para><emphasis>Point to Your distribution configuration file:</emphasis> |
| 8863 | In your <filename>local.conf</filename> file in the |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 8864 | <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink>, |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 8865 | set your |
| 8866 | <ulink url='&YOCTO_DOCS_REF_URL;#var-DISTRO'><filename>DISTRO</filename></ulink> |
| 8867 | variable to point to your distribution's configuration file. |
| 8868 | For example, if your distribution's configuration file is |
| 8869 | named <filename>mydistro.conf</filename>, then you point |
| 8870 | to it as follows: |
| 8871 | <literallayout class='monospaced'> |
| 8872 | DISTRO = "mydistro" |
| 8873 | </literallayout></para></listitem> |
| 8874 | <listitem><para><emphasis>Add more to the layer if necessary:</emphasis> |
| 8875 | Use your layer to hold other information needed for the |
| 8876 | distribution: |
| 8877 | <itemizedlist> |
| 8878 | <listitem><para>Add recipes for installing |
| 8879 | distro-specific configuration files that are not |
| 8880 | already installed by another recipe. |
| 8881 | If you have distro-specific configuration files |
| 8882 | that are included by an existing recipe, you should |
| 8883 | add an append file (<filename>.bbappend</filename>) |
| 8884 | for those. |
| 8885 | For general information and recommendations |
| 8886 | on how to add recipes to your layer, see the |
| 8887 | "<link linkend='creating-your-own-layer'>Creating Your Own Layer</link>" |
| 8888 | and |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 8889 | "<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] | 8890 | sections.</para></listitem> |
| 8891 | <listitem><para>Add any image recipes that are specific |
| 8892 | to your distribution.</para></listitem> |
| 8893 | <listitem><para>Add a <filename>psplash</filename> |
| 8894 | append file for a branded splash screen. |
| 8895 | For information on append files, see the |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 8896 | "<link linkend='using-bbappend-files'>Using .bbappend Files in Your Layer</link>" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 8897 | section.</para></listitem> |
| 8898 | <listitem><para>Add any other append files to make |
| 8899 | custom changes that are specific to individual |
| 8900 | recipes.</para></listitem> |
| 8901 | </itemizedlist></para></listitem> |
| 8902 | </itemizedlist> |
| 8903 | </para> |
| 8904 | </section> |
| 8905 | |
| 8906 | <section id='creating-a-custom-template-configuration-directory'> |
| 8907 | <title>Creating a Custom Template Configuration Directory</title> |
| 8908 | |
| 8909 | <para> |
| 8910 | If you are producing your own customized version |
| 8911 | of the build system for use by other users, you might |
| 8912 | want to customize the message shown by the setup script or |
| 8913 | you might want to change the template configuration files (i.e. |
| 8914 | <filename>local.conf</filename> and |
| 8915 | <filename>bblayers.conf</filename>) that are created in |
| 8916 | a new build directory. |
| 8917 | </para> |
| 8918 | |
| 8919 | <para> |
| 8920 | The OpenEmbedded build system uses the environment variable |
| 8921 | <filename>TEMPLATECONF</filename> to locate the directory |
| 8922 | from which it gathers configuration information that ultimately |
| 8923 | ends up in the |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 8924 | <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 8925 | <filename>conf</filename> directory. |
| 8926 | By default, <filename>TEMPLATECONF</filename> is set as |
| 8927 | follows in the <filename>poky</filename> repository: |
| 8928 | <literallayout class='monospaced'> |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 8929 | TEMPLATECONF=${TEMPLATECONF:-meta-poky/conf} |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 8930 | </literallayout> |
| 8931 | This is the directory used by the build system to find templates |
| 8932 | from which to build some key configuration files. |
| 8933 | If you look at this directory, you will see the |
| 8934 | <filename>bblayers.conf.sample</filename>, |
| 8935 | <filename>local.conf.sample</filename>, and |
| 8936 | <filename>conf-notes.txt</filename> files. |
| 8937 | The build system uses these files to form the respective |
| 8938 | <filename>bblayers.conf</filename> file, |
| 8939 | <filename>local.conf</filename> file, and display the list of |
| 8940 | BitBake targets when running the setup script. |
| 8941 | </para> |
| 8942 | |
| 8943 | <para> |
| 8944 | To override these default configuration files with |
| 8945 | configurations you want used within every new |
| 8946 | Build Directory, simply set the |
| 8947 | <filename>TEMPLATECONF</filename> variable to your directory. |
| 8948 | The <filename>TEMPLATECONF</filename> variable is set in the |
| 8949 | <filename>.templateconf</filename> file, which is in the |
| 8950 | top-level |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 8951 | <ulink url='&YOCTO_DOCS_REF_URL;#source-directory'>Source Directory</ulink> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 8952 | folder (e.g. <filename>poky</filename>). |
| 8953 | Edit the <filename>.templateconf</filename> so that it can locate |
| 8954 | your directory. |
| 8955 | </para> |
| 8956 | |
| 8957 | <para> |
| 8958 | Best practices dictate that you should keep your |
| 8959 | template configuration directory in your custom distribution layer. |
| 8960 | For example, suppose you have a layer named |
| 8961 | <filename>meta-mylayer</filename> located in your home directory |
| 8962 | and you want your template configuration directory named |
| 8963 | <filename>myconf</filename>. |
| 8964 | Changing the <filename>.templateconf</filename> as follows |
| 8965 | causes the OpenEmbedded build system to look in your directory |
| 8966 | and base its configuration files on the |
| 8967 | <filename>*.sample</filename> configuration files it finds. |
| 8968 | The final configuration files (i.e. |
| 8969 | <filename>local.conf</filename> and |
| 8970 | <filename>bblayers.conf</filename> ultimately still end up in |
| 8971 | your Build Directory, but they are based on your |
| 8972 | <filename>*.sample</filename> files. |
| 8973 | <literallayout class='monospaced'> |
| 8974 | TEMPLATECONF=${TEMPLATECONF:-meta-mylayer/myconf} |
| 8975 | </literallayout> |
| 8976 | </para> |
| 8977 | |
| 8978 | <para> |
| 8979 | Aside from the <filename>*.sample</filename> configuration files, |
| 8980 | the <filename>conf-notes.txt</filename> also resides in the |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 8981 | default <filename>meta-poky/conf</filename> directory. |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 8982 | The script that sets up the build environment |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 8983 | (i.e. |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 8984 | <ulink url="&YOCTO_DOCS_REF_URL;#structure-core-script"><filename>&OE_INIT_FILE;</filename></ulink>) |
| 8985 | uses this file to display BitBake targets as part of the script |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 8986 | output. |
| 8987 | Customizing this <filename>conf-notes.txt</filename> file is a |
| 8988 | good way to make sure your list of custom targets appears |
| 8989 | as part of the script's output. |
| 8990 | </para> |
| 8991 | |
| 8992 | <para> |
| 8993 | Here is the default list of targets displayed as a result of |
| 8994 | running either of the setup scripts: |
| 8995 | <literallayout class='monospaced'> |
| 8996 | You can now run 'bitbake <target>' |
| 8997 | |
| 8998 | Common targets are: |
| 8999 | core-image-minimal |
| 9000 | core-image-sato |
| 9001 | meta-toolchain |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 9002 | meta-ide-support |
| 9003 | </literallayout> |
| 9004 | </para> |
| 9005 | |
| 9006 | <para> |
| 9007 | Changing the listed common targets is as easy as editing your |
| 9008 | version of <filename>conf-notes.txt</filename> in your |
| 9009 | custom template configuration directory and making sure you |
| 9010 | have <filename>TEMPLATECONF</filename> set to your directory. |
| 9011 | </para> |
| 9012 | </section> |
| 9013 | |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 9014 | <section id='dev-saving-memory-during-a-build'> |
| 9015 | <title>Conserving Disk Space During Builds</title> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 9016 | |
| 9017 | <para> |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 9018 | To help conserve disk space during builds, you can add the |
| 9019 | following statement to your project's |
| 9020 | <filename>local.conf</filename> configuration file found in the |
| 9021 | <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink>: |
| 9022 | <literallayout class='monospaced'> |
| 9023 | INHERIT += "rm_work" |
| 9024 | </literallayout> |
| 9025 | Adding this statement deletes the work directory used for building |
| 9026 | a recipe once the recipe is built. |
| 9027 | For more information on "rm_work", see the |
| 9028 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-rm-work'><filename>rm_work</filename></ulink> |
| 9029 | class in the Yocto Project Reference Manual. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 9030 | </para> |
| 9031 | </section> |
| 9032 | |
| 9033 | <section id='working-with-packages'> |
| 9034 | <title>Working with Packages</title> |
| 9035 | |
| 9036 | <para> |
| 9037 | This section describes a few tasks that involve packages: |
| 9038 | <itemizedlist> |
| 9039 | <listitem><para> |
| 9040 | <link linkend='excluding-packages-from-an-image'>Excluding packages from an image</link> |
| 9041 | </para></listitem> |
| 9042 | <listitem><para> |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 9043 | <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] | 9044 | </para></listitem> |
| 9045 | <listitem><para> |
| 9046 | <link linkend='handling-optional-module-packaging'>Handling optional module packaging</link> |
| 9047 | </para></listitem> |
| 9048 | <listitem><para> |
Brad Bishop | 15ae250 | 2019-06-18 21:44:24 -0400 | [diff] [blame] | 9049 | <link linkend='using-runtime-package-management'>Using runtime package management</link> |
| 9050 | </para></listitem> |
| 9051 | <listitem><para> |
| 9052 | <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] | 9053 | </para></listitem> |
| 9054 | <listitem><para> |
| 9055 | <link linkend='testing-packages-with-ptest'>Setting up and running package test (ptest)</link> |
| 9056 | </para></listitem> |
Brad Bishop | 15ae250 | 2019-06-18 21:44:24 -0400 | [diff] [blame] | 9057 | <listitem><para> |
| 9058 | <link linkend='creating-node-package-manager-npm-packages'>Creating node package manager (NPM) packages</link> |
| 9059 | </para></listitem> |
Andrew Geissler | 1e34c2d | 2020-05-29 16:02:59 -0500 | [diff] [blame^] | 9060 | <listitem><para> |
| 9061 | <link linkend='adding-custom-metadata-to-packages'>Adding custom metadata to packages</link> |
| 9062 | </para></listitem> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 9063 | </itemizedlist> |
| 9064 | </para> |
| 9065 | |
| 9066 | <section id='excluding-packages-from-an-image'> |
| 9067 | <title>Excluding Packages from an Image</title> |
| 9068 | |
| 9069 | <para> |
| 9070 | You might find it necessary to prevent specific packages |
| 9071 | from being installed into an image. |
| 9072 | If so, you can use several variables to direct the build |
| 9073 | system to essentially ignore installing recommended packages |
| 9074 | or to not install a package at all. |
| 9075 | </para> |
| 9076 | |
| 9077 | <para> |
| 9078 | The following list introduces variables you can use to |
| 9079 | prevent packages from being installed into your image. |
| 9080 | Each of these variables only works with IPK and RPM |
| 9081 | package types. |
| 9082 | Support for Debian packages does not exist. |
| 9083 | Also, you can use these variables from your |
| 9084 | <filename>local.conf</filename> file or attach them to a |
| 9085 | specific image recipe by using a recipe name override. |
| 9086 | For more detail on the variables, see the descriptions in the |
| 9087 | Yocto Project Reference Manual's glossary chapter. |
| 9088 | <itemizedlist> |
| 9089 | <listitem><para><ulink url='&YOCTO_DOCS_REF_URL;#var-BAD_RECOMMENDATIONS'><filename>BAD_RECOMMENDATIONS</filename></ulink>: |
| 9090 | Use this variable to specify "recommended-only" |
| 9091 | packages that you do not want installed. |
| 9092 | </para></listitem> |
| 9093 | <listitem><para><ulink url='&YOCTO_DOCS_REF_URL;#var-NO_RECOMMENDATIONS'><filename>NO_RECOMMENDATIONS</filename></ulink>: |
| 9094 | Use this variable to prevent all "recommended-only" |
| 9095 | packages from being installed. |
| 9096 | </para></listitem> |
| 9097 | <listitem><para><ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_EXCLUDE'><filename>PACKAGE_EXCLUDE</filename></ulink>: |
| 9098 | Use this variable to prevent specific packages from |
| 9099 | being installed regardless of whether they are |
| 9100 | "recommended-only" or not. |
| 9101 | You need to realize that the build process could |
| 9102 | fail with an error when you |
| 9103 | prevent the installation of a package whose presence |
| 9104 | is required by an installed package. |
| 9105 | </para></listitem> |
| 9106 | </itemizedlist> |
| 9107 | </para> |
| 9108 | </section> |
| 9109 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 9110 | <section id='incrementing-a-binary-package-version'> |
| 9111 | <title>Incrementing a Package Version</title> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 9112 | |
| 9113 | <para> |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 9114 | This section provides some background on how binary package |
| 9115 | versioning is accomplished and presents some of the services, |
| 9116 | variables, and terminology involved. |
| 9117 | </para> |
| 9118 | |
| 9119 | <para> |
| 9120 | In order to understand binary package versioning, you need |
| 9121 | to consider the following: |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 9122 | <itemizedlist> |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 9123 | <listitem><para> |
| 9124 | Binary Package: The binary package that is eventually |
| 9125 | built and installed into an image. |
| 9126 | </para></listitem> |
| 9127 | <listitem><para> |
| 9128 | Binary Package Version: The binary package version |
| 9129 | is composed of two components - a version and a |
| 9130 | revision. |
| 9131 | <note> |
| 9132 | Technically, a third component, the "epoch" (i.e. |
| 9133 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PE'><filename>PE</filename></ulink>) |
| 9134 | is involved but this discussion for the most part |
| 9135 | ignores <filename>PE</filename>. |
| 9136 | </note> |
| 9137 | The version and revision are taken from the |
| 9138 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PV'><filename>PV</filename></ulink> |
| 9139 | and |
| 9140 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PR'><filename>PR</filename></ulink> |
| 9141 | variables, respectively. |
| 9142 | </para></listitem> |
| 9143 | <listitem><para> |
| 9144 | <filename>PV</filename>: The recipe version. |
| 9145 | <filename>PV</filename> represents the version of the |
| 9146 | software being packaged. |
| 9147 | Do not confuse <filename>PV</filename> with the |
| 9148 | binary package version. |
| 9149 | </para></listitem> |
| 9150 | <listitem><para> |
| 9151 | <filename>PR</filename>: The recipe revision. |
| 9152 | </para></listitem> |
| 9153 | <listitem><para> |
| 9154 | <ulink url='&YOCTO_DOCS_REF_URL;#var-SRCPV'><filename>SRCPV</filename></ulink>: |
| 9155 | The OpenEmbedded build system uses this string |
| 9156 | to help define the value of <filename>PV</filename> |
| 9157 | when the source code revision needs to be included |
| 9158 | in it. |
| 9159 | </para></listitem> |
| 9160 | <listitem><para> |
| 9161 | <ulink url='https://wiki.yoctoproject.org/wiki/PR_Service'>PR Service</ulink>: |
| 9162 | A network-based service that helps automate keeping |
| 9163 | package feeds compatible with existing package |
| 9164 | manager applications such as RPM, APT, and OPKG. |
| 9165 | </para></listitem> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 9166 | </itemizedlist> |
| 9167 | </para> |
| 9168 | |
| 9169 | <para> |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 9170 | Whenever the binary package content changes, the binary package |
| 9171 | version must change. |
| 9172 | Changing the binary package version is accomplished by changing |
| 9173 | or "bumping" the <filename>PR</filename> and/or |
| 9174 | <filename>PV</filename> values. |
| 9175 | Increasing these values occurs one of two ways: |
| 9176 | <itemizedlist> |
| 9177 | <listitem><para>Automatically using a Package Revision |
| 9178 | Service (PR Service). |
| 9179 | </para></listitem> |
| 9180 | <listitem><para>Manually incrementing the |
| 9181 | <filename>PR</filename> and/or |
| 9182 | <filename>PV</filename> variables. |
| 9183 | </para></listitem> |
| 9184 | </itemizedlist> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 9185 | </para> |
| 9186 | |
| 9187 | <para> |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 9188 | Given a primary challenge of any build system and its users |
| 9189 | is how to maintain a package feed that is compatible with |
| 9190 | existing package manager applications such as RPM, APT, and |
| 9191 | OPKG, using an automated system is much preferred over a |
| 9192 | manual system. |
| 9193 | In either system, the main requirement is that binary package |
| 9194 | version numbering increases in a linear fashion and that a |
| 9195 | number of version components exist that support that linear |
| 9196 | progression. |
| 9197 | For information on how to ensure package revisioning remains |
| 9198 | linear, see the |
| 9199 | "<link linkend='automatically-incrementing-a-binary-package-revision-number'>Automatically Incrementing a Binary Package Revision Number</link>" |
| 9200 | section. |
| 9201 | </para> |
| 9202 | |
| 9203 | <para> |
| 9204 | The following three sections provide related information on the |
| 9205 | PR Service, the manual method for "bumping" |
| 9206 | <filename>PR</filename> and/or <filename>PV</filename>, and |
| 9207 | on how to ensure binary package revisioning remains linear. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 9208 | </para> |
| 9209 | |
| 9210 | <section id='working-with-a-pr-service'> |
| 9211 | <title>Working With a PR Service</title> |
| 9212 | |
| 9213 | <para> |
| 9214 | As mentioned, attempting to maintain revision numbers in the |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 9215 | <ulink url='&YOCTO_DOCS_REF_URL;#metadata'>Metadata</ulink> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 9216 | is error prone, inaccurate, and causes problems for people |
| 9217 | submitting recipes. |
| 9218 | Conversely, the PR Service automatically generates |
| 9219 | increasing numbers, particularly the revision field, |
| 9220 | which removes the human element. |
| 9221 | <note> |
| 9222 | For additional information on using a PR Service, you |
| 9223 | can see the |
| 9224 | <ulink url='&YOCTO_WIKI_URL;/wiki/PR_Service'>PR Service</ulink> |
| 9225 | wiki page. |
| 9226 | </note> |
| 9227 | </para> |
| 9228 | |
| 9229 | <para> |
| 9230 | The Yocto Project uses variables in order of |
| 9231 | decreasing priority to facilitate revision numbering (i.e. |
| 9232 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PE'><filename>PE</filename></ulink>, |
| 9233 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PV'><filename>PV</filename></ulink>, and |
| 9234 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PR'><filename>PR</filename></ulink> |
| 9235 | for epoch, version, and revision, respectively). |
| 9236 | The values are highly dependent on the policies and |
| 9237 | procedures of a given distribution and package feed. |
| 9238 | </para> |
| 9239 | |
| 9240 | <para> |
| 9241 | Because the OpenEmbedded build system uses |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 9242 | "<ulink url='&YOCTO_DOCS_OM_URL;#overview-checksums'>signatures</ulink>", |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 9243 | which are unique to a given build, the build system |
| 9244 | knows when to rebuild packages. |
| 9245 | All the inputs into a given task are represented by a |
| 9246 | signature, which can trigger a rebuild when different. |
| 9247 | Thus, the build system itself does not rely on the |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 9248 | <filename>PR</filename>, <filename>PV</filename>, and |
| 9249 | <filename>PE</filename> numbers to trigger a rebuild. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 9250 | The signatures, however, can be used to generate |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 9251 | these values. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 9252 | </para> |
| 9253 | |
| 9254 | <para> |
| 9255 | The PR Service works with both |
| 9256 | <filename>OEBasic</filename> and |
| 9257 | <filename>OEBasicHash</filename> generators. |
| 9258 | The value of <filename>PR</filename> bumps when the |
| 9259 | checksum changes and the different generator mechanisms |
| 9260 | change signatures under different circumstances. |
| 9261 | </para> |
| 9262 | |
| 9263 | <para> |
| 9264 | As implemented, the build system includes values from |
| 9265 | the PR Service into the <filename>PR</filename> field as |
| 9266 | an addition using the form "<filename>.x</filename>" so |
| 9267 | <filename>r0</filename> becomes <filename>r0.1</filename>, |
| 9268 | <filename>r0.2</filename> and so forth. |
| 9269 | This scheme allows existing <filename>PR</filename> values |
| 9270 | to be used for whatever reasons, which include manual |
| 9271 | <filename>PR</filename> bumps, should it be necessary. |
| 9272 | </para> |
| 9273 | |
| 9274 | <para> |
| 9275 | By default, the PR Service is not enabled or running. |
| 9276 | Thus, the packages generated are just "self consistent". |
| 9277 | The build system adds and removes packages and |
| 9278 | there are no guarantees about upgrade paths but images |
| 9279 | will be consistent and correct with the latest changes. |
| 9280 | </para> |
| 9281 | |
| 9282 | <para> |
| 9283 | The simplest form for a PR Service is for it to exist |
| 9284 | for a single host development system that builds the |
| 9285 | package feed (building system). |
| 9286 | For this scenario, you can enable a local PR Service by |
| 9287 | setting |
| 9288 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PRSERV_HOST'><filename>PRSERV_HOST</filename></ulink> |
| 9289 | in your <filename>local.conf</filename> file in the |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 9290 | <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink>: |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 9291 | <literallayout class='monospaced'> |
| 9292 | PRSERV_HOST = "localhost:0" |
| 9293 | </literallayout> |
| 9294 | Once the service is started, packages will automatically |
| 9295 | get increasing <filename>PR</filename> values and |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 9296 | BitBake takes care of starting and stopping the server. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 9297 | </para> |
| 9298 | |
| 9299 | <para> |
| 9300 | If you have a more complex setup where multiple host |
| 9301 | development systems work against a common, shared package |
| 9302 | feed, you have a single PR Service running and it is |
| 9303 | connected to each building system. |
| 9304 | For this scenario, you need to start the PR Service using |
| 9305 | the <filename>bitbake-prserv</filename> command: |
| 9306 | <literallayout class='monospaced'> |
| 9307 | bitbake-prserv --host <replaceable>ip</replaceable> --port <replaceable>port</replaceable> --start |
| 9308 | </literallayout> |
| 9309 | In addition to hand-starting the service, you need to |
| 9310 | update the <filename>local.conf</filename> file of each |
| 9311 | building system as described earlier so each system |
| 9312 | points to the server and port. |
| 9313 | </para> |
| 9314 | |
| 9315 | <para> |
| 9316 | It is also recommended you use build history, which adds |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 9317 | some sanity checks to binary package versions, in |
| 9318 | conjunction with the server that is running the PR Service. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 9319 | To enable build history, add the following to each building |
| 9320 | system's <filename>local.conf</filename> file: |
| 9321 | <literallayout class='monospaced'> |
| 9322 | # It is recommended to activate "buildhistory" for testing the PR service |
| 9323 | INHERIT += "buildhistory" |
| 9324 | BUILDHISTORY_COMMIT = "1" |
| 9325 | </literallayout> |
| 9326 | For information on build history, see the |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 9327 | "<link linkend='maintaining-build-output-quality'>Maintaining Build Output Quality</link>" |
| 9328 | section. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 9329 | </para> |
| 9330 | |
| 9331 | <note> |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 9332 | <para> |
| 9333 | The OpenEmbedded build system does not maintain |
| 9334 | <filename>PR</filename> information as part of the |
| 9335 | shared state (sstate) packages. |
| 9336 | If you maintain an sstate feed, its expected that either |
| 9337 | all your building systems that contribute to the sstate |
| 9338 | feed use a shared PR Service, or you do not run a PR |
| 9339 | Service on any of your building systems. |
| 9340 | Having some systems use a PR Service while others do |
| 9341 | not leads to obvious problems. |
| 9342 | </para> |
| 9343 | |
| 9344 | <para> |
| 9345 | For more information on shared state, see the |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 9346 | "<ulink url='&YOCTO_DOCS_OM_URL;#shared-state-cache'>Shared State Cache</ulink>" |
| 9347 | section in the Yocto Project Overview and Concepts |
| 9348 | Manual. |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 9349 | </para> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 9350 | </note> |
| 9351 | </section> |
| 9352 | |
| 9353 | <section id='manually-bumping-pr'> |
| 9354 | <title>Manually Bumping PR</title> |
| 9355 | |
| 9356 | <para> |
| 9357 | The alternative to setting up a PR Service is to manually |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 9358 | "bump" the |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 9359 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PR'><filename>PR</filename></ulink> |
| 9360 | variable. |
| 9361 | </para> |
| 9362 | |
| 9363 | <para> |
Brad Bishop | 37a0e4d | 2017-12-04 01:01:44 -0500 | [diff] [blame] | 9364 | If a committed change results in changing the package |
| 9365 | output, then the value of the PR variable needs to be |
| 9366 | increased (or "bumped") as part of that commit. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 9367 | For new recipes you should add the <filename>PR</filename> |
Brad Bishop | 37a0e4d | 2017-12-04 01:01:44 -0500 | [diff] [blame] | 9368 | variable and set its initial value equal to "r0", which is |
| 9369 | the default. |
| 9370 | Even though the default value is "r0", the practice of |
| 9371 | adding it to a new recipe makes it harder to forget to bump |
| 9372 | the variable when you make changes to the recipe in future. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 9373 | </para> |
| 9374 | |
| 9375 | <para> |
Brad Bishop | 37a0e4d | 2017-12-04 01:01:44 -0500 | [diff] [blame] | 9376 | If you are sharing a common <filename>.inc</filename> file |
| 9377 | with multiple recipes, you can also use the |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 9378 | <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] | 9379 | variable to ensure that the recipes sharing the |
| 9380 | <filename>.inc</filename> file are rebuilt when the |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 9381 | <filename>.inc</filename> file itself is changed. |
Brad Bishop | 37a0e4d | 2017-12-04 01:01:44 -0500 | [diff] [blame] | 9382 | The <filename>.inc</filename> file must set |
| 9383 | <filename>INC_PR</filename> (initially to "r0"), and all |
| 9384 | recipes referring to it should set <filename>PR</filename> |
| 9385 | to "${INC_PR}.0" initially, incrementing the last number |
| 9386 | when the recipe is changed. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 9387 | If the <filename>.inc</filename> file is changed then its |
| 9388 | <filename>INC_PR</filename> should be incremented. |
| 9389 | </para> |
| 9390 | |
| 9391 | <para> |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 9392 | When upgrading the version of a binary package, assuming the |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 9393 | <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-PV'>PV</ulink></filename> |
| 9394 | changes, the <filename>PR</filename> variable should be |
Brad Bishop | 37a0e4d | 2017-12-04 01:01:44 -0500 | [diff] [blame] | 9395 | reset to "r0" (or "${INC_PR}.0" if you are using |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 9396 | <filename>INC_PR</filename>). |
| 9397 | </para> |
| 9398 | |
| 9399 | <para> |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 9400 | Usually, version increases occur only to binary packages. |
Brad Bishop | 37a0e4d | 2017-12-04 01:01:44 -0500 | [diff] [blame] | 9401 | However, if for some reason <filename>PV</filename> changes |
| 9402 | but does not increase, you can increase the |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 9403 | <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-PE'>PE</ulink></filename> |
| 9404 | variable (Package Epoch). |
| 9405 | The <filename>PE</filename> variable defaults to "0". |
| 9406 | </para> |
| 9407 | |
| 9408 | <para> |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 9409 | Binary package version numbering strives to follow the |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 9410 | <ulink url='http://www.debian.org/doc/debian-policy/ch-controlfields.html'> |
| 9411 | Debian Version Field Policy Guidelines</ulink>. |
Brad Bishop | 37a0e4d | 2017-12-04 01:01:44 -0500 | [diff] [blame] | 9412 | These guidelines define how versions are compared and what |
| 9413 | "increasing" a version means. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 9414 | </para> |
| 9415 | </section> |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 9416 | |
| 9417 | <section id='automatically-incrementing-a-binary-package-revision-number'> |
| 9418 | <title>Automatically Incrementing a Package Version Number</title> |
| 9419 | |
| 9420 | <para> |
| 9421 | When fetching a repository, BitBake uses the |
| 9422 | <ulink url='&YOCTO_DOCS_REF_URL;#var-SRCREV'><filename>SRCREV</filename></ulink> |
| 9423 | variable to determine the specific source code revision |
| 9424 | from which to build. |
| 9425 | You set the <filename>SRCREV</filename> variable to |
| 9426 | <ulink url='&YOCTO_DOCS_REF_URL;#var-AUTOREV'><filename>AUTOREV</filename></ulink> |
| 9427 | to cause the OpenEmbedded build system to automatically use the |
| 9428 | latest revision of the software: |
| 9429 | <literallayout class='monospaced'> |
| 9430 | SRCREV = "${AUTOREV}" |
| 9431 | </literallayout> |
| 9432 | </para> |
| 9433 | |
| 9434 | <para> |
| 9435 | Furthermore, you need to reference <filename>SRCPV</filename> |
| 9436 | in <filename>PV</filename> in order to automatically update |
| 9437 | the version whenever the revision of the source code |
| 9438 | changes. |
| 9439 | Here is an example: |
| 9440 | <literallayout class='monospaced'> |
| 9441 | PV = "1.0+git${SRCPV}" |
| 9442 | </literallayout> |
| 9443 | The OpenEmbedded build system substitutes |
| 9444 | <filename>SRCPV</filename> with the following: |
| 9445 | <literallayout class='monospaced'> |
| 9446 | AUTOINC+<replaceable>source_code_revision</replaceable> |
| 9447 | </literallayout> |
| 9448 | The build system replaces the <filename>AUTOINC</filename> with |
| 9449 | a number. |
| 9450 | The number used depends on the state of the PR Service: |
| 9451 | <itemizedlist> |
| 9452 | <listitem><para> |
| 9453 | If PR Service is enabled, the build system increments |
| 9454 | the number, which is similar to the behavior of |
| 9455 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PR'><filename>PR</filename></ulink>. |
| 9456 | This behavior results in linearly increasing package |
| 9457 | versions, which is desirable. |
| 9458 | Here is an example: |
| 9459 | <literallayout class='monospaced'> |
| 9460 | hello-world-git_0.0+git0+b6558dd387-r0.0_armv7a-neon.ipk |
| 9461 | hello-world-git_0.0+git1+dd2f5c3565-r0.0_armv7a-neon.ipk |
| 9462 | </literallayout> |
| 9463 | </para></listitem> |
| 9464 | <listitem><para> |
| 9465 | If PR Service is not enabled, the build system |
| 9466 | replaces the <filename>AUTOINC</filename> |
| 9467 | placeholder with zero (i.e. "0"). |
| 9468 | This results in changing the package version since |
| 9469 | the source revision is included. |
| 9470 | However, package versions are not increased linearly. |
| 9471 | Here is an example: |
| 9472 | <literallayout class='monospaced'> |
| 9473 | hello-world-git_0.0+git0+b6558dd387-r0.0_armv7a-neon.ipk |
| 9474 | hello-world-git_0.0+git0+dd2f5c3565-r0.0_armv7a-neon.ipk |
| 9475 | </literallayout> |
| 9476 | </para></listitem> |
| 9477 | </itemizedlist> |
| 9478 | </para> |
| 9479 | |
| 9480 | <para> |
| 9481 | In summary, the OpenEmbedded build system does not track the |
| 9482 | history of binary package versions for this purpose. |
| 9483 | <filename>AUTOINC</filename>, in this case, is comparable to |
| 9484 | <filename>PR</filename>. |
| 9485 | If PR server is not enabled, <filename>AUTOINC</filename> |
| 9486 | in the package version is simply replaced by "0". |
| 9487 | If PR server is enabled, the build system keeps track of the |
| 9488 | package versions and bumps the number when the package |
| 9489 | revision changes. |
| 9490 | </para> |
| 9491 | </section> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 9492 | </section> |
| 9493 | |
| 9494 | <section id='handling-optional-module-packaging'> |
| 9495 | <title>Handling Optional Module Packaging</title> |
| 9496 | |
| 9497 | <para> |
| 9498 | Many pieces of software split functionality into optional |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 9499 | modules (or plugins) and the plugins that are built |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 9500 | might depend on configuration options. |
| 9501 | To avoid having to duplicate the logic that determines what |
| 9502 | modules are available in your recipe or to avoid having |
| 9503 | to package each module by hand, the OpenEmbedded build system |
| 9504 | provides functionality to handle module packaging dynamically. |
| 9505 | </para> |
| 9506 | |
| 9507 | <para> |
| 9508 | To handle optional module packaging, you need to do two things: |
| 9509 | <itemizedlist> |
| 9510 | <listitem><para>Ensure the module packaging is actually |
| 9511 | done.</para></listitem> |
| 9512 | <listitem><para>Ensure that any dependencies on optional |
| 9513 | modules from other recipes are satisfied by your recipe. |
| 9514 | </para></listitem> |
| 9515 | </itemizedlist> |
| 9516 | </para> |
| 9517 | |
| 9518 | <section id='making-sure-the-packaging-is-done'> |
| 9519 | <title>Making Sure the Packaging is Done</title> |
| 9520 | |
| 9521 | <para> |
| 9522 | To ensure the module packaging actually gets done, you use |
| 9523 | the <filename>do_split_packages</filename> function within |
| 9524 | the <filename>populate_packages</filename> Python function |
| 9525 | in your recipe. |
| 9526 | The <filename>do_split_packages</filename> function |
| 9527 | searches for a pattern of files or directories under a |
| 9528 | specified path and creates a package for each one it finds |
| 9529 | by appending to the |
| 9530 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGES'><filename>PACKAGES</filename></ulink> |
| 9531 | variable and setting the appropriate values for |
| 9532 | <filename>FILES_packagename</filename>, |
| 9533 | <filename>RDEPENDS_packagename</filename>, |
| 9534 | <filename>DESCRIPTION_packagename</filename>, and so forth. |
| 9535 | Here is an example from the <filename>lighttpd</filename> |
| 9536 | recipe: |
| 9537 | <literallayout class='monospaced'> |
| 9538 | python populate_packages_prepend () { |
| 9539 | lighttpd_libdir = d.expand('${libdir}') |
| 9540 | do_split_packages(d, lighttpd_libdir, '^mod_(.*)\.so$', |
| 9541 | 'lighttpd-module-%s', 'Lighttpd module for %s', |
| 9542 | extra_depends='') |
| 9543 | } |
| 9544 | </literallayout> |
| 9545 | The previous example specifies a number of things in the |
| 9546 | call to <filename>do_split_packages</filename>. |
| 9547 | <itemizedlist> |
| 9548 | <listitem><para>A directory within the files installed |
| 9549 | by your recipe through <filename>do_install</filename> |
| 9550 | in which to search.</para></listitem> |
| 9551 | <listitem><para>A regular expression used to match module |
| 9552 | files in that directory. |
| 9553 | In the example, note the parentheses () that mark |
| 9554 | the part of the expression from which the module |
| 9555 | name should be derived.</para></listitem> |
| 9556 | <listitem><para>A pattern to use for the package names. |
| 9557 | </para></listitem> |
| 9558 | <listitem><para>A description for each package. |
| 9559 | </para></listitem> |
| 9560 | <listitem><para>An empty string for |
| 9561 | <filename>extra_depends</filename>, which disables |
| 9562 | the default dependency on the main |
| 9563 | <filename>lighttpd</filename> package. |
| 9564 | Thus, if a file in <filename>${libdir}</filename> |
| 9565 | called <filename>mod_alias.so</filename> is found, |
| 9566 | a package called <filename>lighttpd-module-alias</filename> |
| 9567 | is created for it and the |
| 9568 | <ulink url='&YOCTO_DOCS_REF_URL;#var-DESCRIPTION'><filename>DESCRIPTION</filename></ulink> |
| 9569 | is set to "Lighttpd module for alias".</para></listitem> |
| 9570 | </itemizedlist> |
| 9571 | </para> |
| 9572 | |
| 9573 | <para> |
| 9574 | Often, packaging modules is as simple as the previous |
| 9575 | example. |
| 9576 | However, more advanced options exist that you can use |
| 9577 | within <filename>do_split_packages</filename> to modify its |
| 9578 | behavior. |
| 9579 | And, if you need to, you can add more logic by specifying |
| 9580 | a hook function that is called for each package. |
| 9581 | It is also perfectly acceptable to call |
| 9582 | <filename>do_split_packages</filename> multiple times if |
| 9583 | you have more than one set of modules to package. |
| 9584 | </para> |
| 9585 | |
| 9586 | <para> |
| 9587 | For more examples that show how to use |
| 9588 | <filename>do_split_packages</filename>, see the |
| 9589 | <filename>connman.inc</filename> file in the |
| 9590 | <filename>meta/recipes-connectivity/connman/</filename> |
| 9591 | directory of the <filename>poky</filename> |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 9592 | <ulink url='&YOCTO_DOCS_OM_URL;#yocto-project-repositories'>source repository</ulink>. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 9593 | You can also find examples in |
| 9594 | <filename>meta/classes/kernel.bbclass</filename>. |
| 9595 | </para> |
| 9596 | |
| 9597 | <para> |
| 9598 | Following is a reference that shows |
| 9599 | <filename>do_split_packages</filename> mandatory and |
| 9600 | optional arguments: |
| 9601 | <literallayout class='monospaced'> |
| 9602 | Mandatory arguments |
| 9603 | |
| 9604 | root |
| 9605 | The path in which to search |
| 9606 | file_regex |
| 9607 | Regular expression to match searched files. |
| 9608 | Use parentheses () to mark the part of this |
| 9609 | expression that should be used to derive the |
| 9610 | module name (to be substituted where %s is |
| 9611 | used in other function arguments as noted below) |
| 9612 | output_pattern |
| 9613 | Pattern to use for the package names. Must |
| 9614 | include %s. |
| 9615 | description |
| 9616 | Description to set for each package. Must |
| 9617 | include %s. |
| 9618 | |
| 9619 | Optional arguments |
| 9620 | |
| 9621 | postinst |
| 9622 | Postinstall script to use for all packages |
| 9623 | (as a string) |
| 9624 | recursive |
| 9625 | True to perform a recursive search - default |
| 9626 | False |
| 9627 | hook |
| 9628 | A hook function to be called for every match. |
| 9629 | The function will be called with the following |
| 9630 | arguments (in the order listed): |
| 9631 | |
| 9632 | f |
| 9633 | Full path to the file/directory match |
| 9634 | pkg |
| 9635 | The package name |
| 9636 | file_regex |
| 9637 | As above |
| 9638 | output_pattern |
| 9639 | As above |
| 9640 | modulename |
| 9641 | The module name derived using file_regex |
| 9642 | |
| 9643 | extra_depends |
| 9644 | Extra runtime dependencies (RDEPENDS) to be |
| 9645 | set for all packages. The default value of None |
| 9646 | causes a dependency on the main package |
| 9647 | (${PN}) - if you do not want this, pass empty |
| 9648 | string '' for this parameter. |
| 9649 | aux_files_pattern |
| 9650 | Extra item(s) to be added to FILES for each |
| 9651 | package. Can be a single string item or a list |
| 9652 | of strings for multiple items. Must include %s. |
| 9653 | postrm |
| 9654 | postrm script to use for all packages (as a |
| 9655 | string) |
| 9656 | allow_dirs |
| 9657 | True to allow directories to be matched - |
| 9658 | default False |
| 9659 | prepend |
| 9660 | If True, prepend created packages to PACKAGES |
| 9661 | instead of the default False which appends them |
| 9662 | match_path |
| 9663 | match file_regex on the whole relative path to |
| 9664 | the root rather than just the file name |
| 9665 | aux_files_pattern_verbatim |
| 9666 | Extra item(s) to be added to FILES for each |
| 9667 | package, using the actual derived module name |
| 9668 | rather than converting it to something legal |
| 9669 | for a package name. Can be a single string item |
| 9670 | or a list of strings for multiple items. Must |
| 9671 | include %s. |
| 9672 | allow_links |
| 9673 | True to allow symlinks to be matched - default |
| 9674 | False |
| 9675 | summary |
| 9676 | Summary to set for each package. Must include %s; |
| 9677 | defaults to description if not set. |
| 9678 | </literallayout> |
| 9679 | </para> |
| 9680 | </section> |
| 9681 | |
| 9682 | <section id='satisfying-dependencies'> |
| 9683 | <title>Satisfying Dependencies</title> |
| 9684 | |
| 9685 | <para> |
| 9686 | The second part for handling optional module packaging |
| 9687 | is to ensure that any dependencies on optional modules |
| 9688 | from other recipes are satisfied by your recipe. |
| 9689 | You can be sure these dependencies are satisfied by |
| 9690 | using the |
| 9691 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGES_DYNAMIC'><filename>PACKAGES_DYNAMIC</filename></ulink> variable. |
| 9692 | Here is an example that continues with the |
| 9693 | <filename>lighttpd</filename> recipe shown earlier: |
| 9694 | <literallayout class='monospaced'> |
| 9695 | PACKAGES_DYNAMIC = "lighttpd-module-.*" |
| 9696 | </literallayout> |
| 9697 | The name specified in the regular expression can of |
| 9698 | course be anything. |
| 9699 | In this example, it is <filename>lighttpd-module-</filename> |
| 9700 | and is specified as the prefix to ensure that any |
| 9701 | <ulink url='&YOCTO_DOCS_REF_URL;#var-RDEPENDS'><filename>RDEPENDS</filename></ulink> |
| 9702 | and <ulink url='&YOCTO_DOCS_REF_URL;#var-RRECOMMENDS'><filename>RRECOMMENDS</filename></ulink> |
| 9703 | on a package name starting with the prefix are satisfied |
| 9704 | during build time. |
| 9705 | If you are using <filename>do_split_packages</filename> |
| 9706 | as described in the previous section, the value you put in |
| 9707 | <filename>PACKAGES_DYNAMIC</filename> should correspond to |
| 9708 | the name pattern specified in the call to |
| 9709 | <filename>do_split_packages</filename>. |
| 9710 | </para> |
| 9711 | </section> |
| 9712 | </section> |
| 9713 | |
| 9714 | <section id='using-runtime-package-management'> |
| 9715 | <title>Using Runtime Package Management</title> |
| 9716 | |
| 9717 | <para> |
| 9718 | During a build, BitBake always transforms a recipe into one or |
| 9719 | more packages. |
| 9720 | For example, BitBake takes the <filename>bash</filename> recipe |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 9721 | and produces a number of packages (e.g. |
| 9722 | <filename>bash</filename>, <filename>bash-bashbug</filename>, |
| 9723 | <filename>bash-completion</filename>, |
| 9724 | <filename>bash-completion-dbg</filename>, |
| 9725 | <filename>bash-completion-dev</filename>, |
| 9726 | <filename>bash-completion-extra</filename>, |
| 9727 | <filename>bash-dbg</filename>, and so forth). |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 9728 | Not all generated packages are included in an image. |
| 9729 | </para> |
| 9730 | |
| 9731 | <para> |
| 9732 | In several situations, you might need to update, add, remove, |
| 9733 | or query the packages on a target device at runtime |
| 9734 | (i.e. without having to generate a new image). |
| 9735 | Examples of such situations include: |
| 9736 | <itemizedlist> |
| 9737 | <listitem><para> |
| 9738 | You want to provide in-the-field updates to deployed |
| 9739 | devices (e.g. security updates). |
| 9740 | </para></listitem> |
| 9741 | <listitem><para> |
| 9742 | You want to have a fast turn-around development cycle |
| 9743 | for one or more applications that run on your device. |
| 9744 | </para></listitem> |
| 9745 | <listitem><para> |
| 9746 | You want to temporarily install the "debug" packages |
| 9747 | of various applications on your device so that |
| 9748 | debugging can be greatly improved by allowing |
| 9749 | access to symbols and source debugging. |
| 9750 | </para></listitem> |
| 9751 | <listitem><para> |
| 9752 | You want to deploy a more minimal package selection of |
| 9753 | your device but allow in-the-field updates to add a |
| 9754 | larger selection for customization. |
| 9755 | </para></listitem> |
| 9756 | </itemizedlist> |
| 9757 | </para> |
| 9758 | |
| 9759 | <para> |
| 9760 | In all these situations, you have something similar to a more |
| 9761 | traditional Linux distribution in that in-field devices |
| 9762 | are able to receive pre-compiled packages from a server for |
| 9763 | installation or update. |
| 9764 | Being able to install these packages on a running, |
| 9765 | in-field device is what is termed "runtime package |
| 9766 | management". |
| 9767 | </para> |
| 9768 | |
| 9769 | <para> |
| 9770 | In order to use runtime package management, you |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 9771 | need a host or server machine that serves up the pre-compiled |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 9772 | packages plus the required metadata. |
| 9773 | You also need package manipulation tools on the target. |
| 9774 | The build machine is a likely candidate to act as the server. |
| 9775 | However, that machine does not necessarily have to be the |
| 9776 | package server. |
| 9777 | The build machine could push its artifacts to another machine |
| 9778 | that acts as the server (e.g. Internet-facing). |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 9779 | In fact, doing so is advantageous for a production |
| 9780 | environment as getting the packages away from the |
| 9781 | development system's build directory prevents accidental |
| 9782 | overwrites. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 9783 | </para> |
| 9784 | |
| 9785 | <para> |
| 9786 | A simple build that targets just one device produces |
| 9787 | more than one package database. |
| 9788 | In other words, the packages produced by a build are separated |
| 9789 | out into a couple of different package groupings based on |
| 9790 | criteria such as the target's CPU architecture, the target |
| 9791 | board, or the C library used on the target. |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 9792 | For example, a build targeting the <filename>qemux86</filename> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 9793 | device produces the following three package databases: |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 9794 | <filename>noarch</filename>, <filename>i586</filename>, and |
| 9795 | <filename>qemux86</filename>. |
| 9796 | If you wanted your <filename>qemux86</filename> device to be |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 9797 | aware of all the packages that were available to it, |
| 9798 | you would need to point it to each of these databases |
| 9799 | individually. |
| 9800 | In a similar way, a traditional Linux distribution usually is |
| 9801 | configured to be aware of a number of software repositories |
| 9802 | from which it retrieves packages. |
| 9803 | </para> |
| 9804 | |
| 9805 | <para> |
| 9806 | Using runtime package management is completely optional and |
| 9807 | not required for a successful build or deployment in any |
| 9808 | way. |
| 9809 | But if you want to make use of runtime package management, |
| 9810 | you need to do a couple things above and beyond the basics. |
| 9811 | The remainder of this section describes what you need to do. |
| 9812 | </para> |
| 9813 | |
| 9814 | <section id='runtime-package-management-build'> |
| 9815 | <title>Build Considerations</title> |
| 9816 | |
| 9817 | <para> |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 9818 | This section describes build considerations of which you |
| 9819 | need to be aware in order to provide support for runtime |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 9820 | package management. |
| 9821 | </para> |
| 9822 | |
| 9823 | <para> |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 9824 | When BitBake generates packages, it needs to know |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 9825 | what format or formats to use. |
| 9826 | In your configuration, you use the |
| 9827 | <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] | 9828 | variable to specify the format: |
| 9829 | <orderedlist> |
| 9830 | <listitem><para> |
| 9831 | Open the <filename>local.conf</filename> file |
| 9832 | inside your |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 9833 | <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink> |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 9834 | (e.g. <filename>~/poky/build/conf/local.conf</filename>). |
| 9835 | </para></listitem> |
| 9836 | <listitem><para> |
| 9837 | Select the desired package format as follows: |
| 9838 | <literallayout class='monospaced'> |
| 9839 | PACKAGE_CLASSES ?= “package_<replaceable>packageformat</replaceable>” |
| 9840 | </literallayout> |
| 9841 | where <replaceable>packageformat</replaceable> |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 9842 | can be "ipk", "rpm", "deb", or "tar" which are the |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 9843 | supported package formats. |
| 9844 | <note> |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 9845 | Because the Yocto Project supports four |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 9846 | different package formats, you can set the |
| 9847 | variable with more than one argument. |
| 9848 | However, the OpenEmbedded build system only |
| 9849 | uses the first argument when creating an image |
| 9850 | or Software Development Kit (SDK). |
| 9851 | </note> |
| 9852 | </para></listitem> |
| 9853 | </orderedlist> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 9854 | </para> |
| 9855 | |
| 9856 | <para> |
| 9857 | If you would like your image to start off with a basic |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 9858 | package database containing the packages in your current |
| 9859 | build as well as to have the relevant tools available on the |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 9860 | target for runtime package management, you can include |
| 9861 | "package-management" in the |
| 9862 | <ulink url='&YOCTO_DOCS_REF_URL;#var-IMAGE_FEATURES'><filename>IMAGE_FEATURES</filename></ulink> |
| 9863 | variable. |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 9864 | Including "package-management" in this configuration |
| 9865 | variable ensures that when the image is assembled for your |
| 9866 | target, the image includes the currently-known package |
| 9867 | databases as well as the target-specific tools required |
| 9868 | for runtime package management to be performed on the |
| 9869 | target. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 9870 | However, this is not strictly necessary. |
| 9871 | You could start your image off without any databases |
| 9872 | but only include the required on-target package |
| 9873 | tool(s). |
| 9874 | As an example, you could include "opkg" in your |
| 9875 | <ulink url='&YOCTO_DOCS_REF_URL;#var-IMAGE_INSTALL'><filename>IMAGE_INSTALL</filename></ulink> |
| 9876 | variable if you are using the IPK package format. |
| 9877 | You can then initialize your target's package database(s) |
| 9878 | later once your image is up and running. |
| 9879 | </para> |
| 9880 | |
| 9881 | <para> |
| 9882 | Whenever you perform any sort of build step that can |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 9883 | potentially generate a package or modify existing |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 9884 | package, it is always a good idea to re-generate the |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 9885 | package index after the build by using the following |
| 9886 | command: |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 9887 | <literallayout class='monospaced'> |
| 9888 | $ bitbake package-index |
| 9889 | </literallayout> |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 9890 | It might be tempting to build the package and the |
| 9891 | package index at the same time with a command such as |
| 9892 | the following: |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 9893 | <literallayout class='monospaced'> |
| 9894 | $ bitbake <replaceable>some-package</replaceable> package-index |
| 9895 | </literallayout> |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 9896 | Do not do this as BitBake does not schedule the package |
| 9897 | index for after the completion of the package you are |
| 9898 | building. |
| 9899 | Consequently, you cannot be sure of the package index |
| 9900 | including information for the package you just built. |
| 9901 | Thus, be sure to run the package update step separately |
| 9902 | after building any packages. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 9903 | </para> |
| 9904 | |
| 9905 | <para> |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 9906 | You can use the |
| 9907 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_FEED_ARCHS'><filename>PACKAGE_FEED_ARCHS</filename></ulink>, |
| 9908 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_FEED_BASE_PATHS'><filename>PACKAGE_FEED_BASE_PATHS</filename></ulink>, |
| 9909 | and |
| 9910 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_FEED_URIS'><filename>PACKAGE_FEED_URIS</filename></ulink> |
| 9911 | variables to pre-configure target images to use a package |
| 9912 | feed. |
| 9913 | If you do not define these variables, then manual steps |
| 9914 | as described in the subsequent sections are necessary to |
| 9915 | configure the target. |
| 9916 | You should set these variables before building the image |
| 9917 | in order to produce a correctly configured image. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 9918 | </para> |
| 9919 | |
| 9920 | <para> |
| 9921 | When your build is complete, your packages reside in the |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 9922 | <filename>${TMPDIR}/deploy/<replaceable>packageformat</replaceable></filename> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 9923 | directory. |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 9924 | For example, if |
| 9925 | <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] | 9926 | is <filename>tmp</filename> and your selected package type |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 9927 | is RPM, then your RPM packages are available in |
| 9928 | <filename>tmp/deploy/rpm</filename>. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 9929 | </para> |
| 9930 | </section> |
| 9931 | |
| 9932 | <section id='runtime-package-management-server'> |
| 9933 | <title>Host or Server Machine Setup</title> |
| 9934 | |
| 9935 | <para> |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 9936 | Although other protocols are possible, a server using HTTP |
| 9937 | typically serves packages. |
| 9938 | If you want to use HTTP, then set up and configure a |
| 9939 | web server such as Apache 2, lighttpd, or |
| 9940 | SimpleHTTPServer on the machine serving the packages. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 9941 | </para> |
| 9942 | |
| 9943 | <para> |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 9944 | To keep things simple, this section describes how to set |
| 9945 | up a SimpleHTTPServer web server to share package feeds |
| 9946 | from the developer's machine. |
| 9947 | Although this server might not be the best for a production |
| 9948 | environment, the setup is simple and straight forward. |
| 9949 | Should you want to use a different server more suited for |
| 9950 | production (e.g. Apache 2, Lighttpd, or Nginx), take the |
| 9951 | appropriate steps to do so. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 9952 | </para> |
| 9953 | |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 9954 | <para> |
| 9955 | From within the build directory where you have built an |
| 9956 | image based on your packaging choice (i.e. the |
| 9957 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_CLASSES'><filename>PACKAGE_CLASSES</filename></ulink> |
| 9958 | setting), simply start the server. |
| 9959 | The following example assumes a build directory of |
| 9960 | <filename>~/poky/build/tmp/deploy/rpm</filename> and a |
| 9961 | <filename>PACKAGE_CLASSES</filename> setting of |
| 9962 | "package_rpm": |
| 9963 | <literallayout class='monospaced'> |
| 9964 | $ cd ~/poky/build/tmp/deploy/rpm |
| 9965 | $ python -m SimpleHTTPServer |
| 9966 | </literallayout> |
| 9967 | </para> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 9968 | </section> |
| 9969 | |
| 9970 | <section id='runtime-package-management-target'> |
| 9971 | <title>Target Setup</title> |
| 9972 | |
| 9973 | <para> |
| 9974 | Setting up the target differs depending on the |
| 9975 | package management system. |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 9976 | This section provides information for RPM, IPK, and DEB. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 9977 | </para> |
| 9978 | |
| 9979 | <section id='runtime-package-management-target-rpm'> |
| 9980 | <title>Using RPM</title> |
| 9981 | |
| 9982 | <para> |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 9983 | The |
| 9984 | <ulink url='https://en.wikipedia.org/wiki/DNF_(software)'>Dandified Packaging Tool</ulink> |
| 9985 | (DNF) performs runtime package management of RPM |
| 9986 | packages. |
| 9987 | In order to use DNF for runtime package management, |
| 9988 | you must perform an initial setup on the target |
| 9989 | machine for cases where the |
| 9990 | <filename>PACKAGE_FEED_*</filename> variables were not |
| 9991 | set as part of the image that is running on the |
| 9992 | target. |
| 9993 | This means if you built your image and did not not use |
| 9994 | these variables as part of the build and your image is |
| 9995 | now running on the target, you need to perform the |
| 9996 | steps in this section if you want to use runtime |
| 9997 | package management. |
| 9998 | <note> |
| 9999 | For information on the |
| 10000 | <filename>PACKAGE_FEED_*</filename> variables, see |
| 10001 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_FEED_ARCHS'><filename>PACKAGE_FEED_ARCHS</filename></ulink>, |
| 10002 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_FEED_BASE_PATHS'><filename>PACKAGE_FEED_BASE_PATHS</filename></ulink>, |
| 10003 | and |
| 10004 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_FEED_URIS'><filename>PACKAGE_FEED_URIS</filename></ulink> |
| 10005 | in the Yocto Project Reference Manual variables |
| 10006 | glossary. |
| 10007 | </note> |
| 10008 | </para> |
| 10009 | |
| 10010 | <para> |
| 10011 | On the target, you must inform DNF that package |
| 10012 | databases are available. |
| 10013 | You do this by creating a file named |
| 10014 | <filename>/etc/yum.repos.d/oe-packages.repo</filename> |
| 10015 | and defining the <filename>oe-packages</filename>. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 10016 | </para> |
| 10017 | |
| 10018 | <para> |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 10019 | As an example, assume the target is able to use the |
| 10020 | following package databases: |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 10021 | <filename>all</filename>, <filename>i586</filename>, |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 10022 | and <filename>qemux86</filename> from a server named |
| 10023 | <filename>my.server</filename>. |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 10024 | The specifics for setting up the web server are up to |
| 10025 | you. |
| 10026 | The critical requirement is that the URIs in the |
| 10027 | target repository configuration point to the |
| 10028 | correct remote location for the feeds. |
| 10029 | <note><title>Tip</title> |
| 10030 | For development purposes, you can point the web |
| 10031 | server to the build system's |
| 10032 | <filename>deploy</filename> directory. |
| 10033 | However, for production use, it is better to copy |
| 10034 | the package directories to a location outside of |
| 10035 | the build area and use that location. |
| 10036 | Doing so avoids situations where the build system |
| 10037 | overwrites or changes the |
| 10038 | <filename>deploy</filename> directory. |
| 10039 | </note> |
| 10040 | </para> |
| 10041 | |
| 10042 | <para> |
| 10043 | When telling DNF where to look for the package |
| 10044 | databases, you must declare individual locations |
| 10045 | per architecture or a single location used for all |
| 10046 | architectures. |
| 10047 | You cannot do both: |
| 10048 | <itemizedlist> |
| 10049 | <listitem><para> |
| 10050 | <emphasis>Create an Explicit List of Architectures:</emphasis> |
| 10051 | Define individual base URLs to identify where |
| 10052 | each package database is located: |
| 10053 | <literallayout class='monospaced'> |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 10054 | [oe-packages] |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 10055 | 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] | 10056 | </literallayout> |
| 10057 | This example informs DNF about individual |
| 10058 | package databases for all three architectures. |
| 10059 | </para></listitem> |
| 10060 | <listitem><para> |
| 10061 | <emphasis>Create a Single (Full) Package Index:</emphasis> |
| 10062 | Define a single base URL that identifies where |
| 10063 | a full package database is located: |
| 10064 | <literallayout class='monospaced'> |
| 10065 | [oe-packages] |
| 10066 | baseurl=http://my.server/rpm |
| 10067 | </literallayout> |
| 10068 | This example informs DNF about a single package |
| 10069 | database that contains all the package index |
| 10070 | information for all supported architectures. |
| 10071 | </para></listitem> |
| 10072 | </itemizedlist> |
| 10073 | </para> |
| 10074 | |
| 10075 | <para> |
| 10076 | Once you have informed DNF where to find the package |
| 10077 | databases, you need to fetch them: |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 10078 | <literallayout class='monospaced'> |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 10079 | # dnf makecache |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 10080 | </literallayout> |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 10081 | DNF is now able to find, install, and upgrade packages |
| 10082 | from the specified repository or repositories. |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 10083 | <note> |
| 10084 | See the |
| 10085 | <ulink url='http://dnf.readthedocs.io/en/latest/'>DNF documentation</ulink> |
| 10086 | for additional information. |
| 10087 | </note> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 10088 | </para> |
| 10089 | </section> |
| 10090 | |
| 10091 | <section id='runtime-package-management-target-ipk'> |
| 10092 | <title>Using IPK</title> |
| 10093 | |
| 10094 | <para> |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 10095 | The <filename>opkg</filename> application performs |
| 10096 | runtime package management of IPK packages. |
| 10097 | You must perform an initial setup for |
| 10098 | <filename>opkg</filename> on the target machine |
| 10099 | if the |
| 10100 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_FEED_ARCHS'><filename>PACKAGE_FEED_ARCHS</filename></ulink>, |
| 10101 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_FEED_BASE_PATHS'><filename>PACKAGE_FEED_BASE_PATHS</filename></ulink>, and |
| 10102 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_FEED_URIS'><filename>PACKAGE_FEED_URIS</filename></ulink> |
| 10103 | variables have not been set or the target image was |
| 10104 | built before the variables were set. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 10105 | </para> |
| 10106 | |
| 10107 | <para> |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 10108 | The <filename>opkg</filename> application uses |
| 10109 | configuration files to find available package |
| 10110 | databases. |
| 10111 | Thus, you need to create a configuration file inside |
| 10112 | the <filename>/etc/opkg/</filename> direction, which |
| 10113 | informs <filename>opkg</filename> of any repository |
| 10114 | you want to use. |
| 10115 | </para> |
| 10116 | |
| 10117 | <para> |
| 10118 | As an example, suppose you are serving packages from a |
| 10119 | <filename>ipk/</filename> directory containing the |
| 10120 | <filename>i586</filename>, |
| 10121 | <filename>all</filename>, and |
| 10122 | <filename>qemux86</filename> databases through an |
| 10123 | HTTP server named <filename>my.server</filename>. |
| 10124 | On the target, create a configuration file |
| 10125 | (e.g. <filename>my_repo.conf</filename>) inside the |
| 10126 | <filename>/etc/opkg/</filename> directory containing |
| 10127 | the following: |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 10128 | <literallayout class='monospaced'> |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 10129 | src/gz all http://my.server/ipk/all |
| 10130 | src/gz i586 http://my.server/ipk/i586 |
| 10131 | src/gz qemux86 http://my.server/ipk/qemux86 |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 10132 | </literallayout> |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 10133 | Next, instruct <filename>opkg</filename> to fetch |
| 10134 | the repository information: |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 10135 | <literallayout class='monospaced'> |
| 10136 | # opkg update |
| 10137 | </literallayout> |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 10138 | The <filename>opkg</filename> application is now able |
| 10139 | to find, install, and upgrade packages from the |
| 10140 | specified repository. |
| 10141 | </para> |
| 10142 | </section> |
| 10143 | |
| 10144 | <section id='runtime-package-management-target-deb'> |
| 10145 | <title>Using DEB</title> |
| 10146 | |
| 10147 | <para> |
| 10148 | The <filename>apt</filename> application performs |
| 10149 | runtime package management of DEB packages. |
| 10150 | This application uses a source list file to find |
| 10151 | available package databases. |
| 10152 | You must perform an initial setup for |
| 10153 | <filename>apt</filename> on the target machine |
| 10154 | if the |
| 10155 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_FEED_ARCHS'><filename>PACKAGE_FEED_ARCHS</filename></ulink>, |
| 10156 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_FEED_BASE_PATHS'><filename>PACKAGE_FEED_BASE_PATHS</filename></ulink>, and |
| 10157 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_FEED_URIS'><filename>PACKAGE_FEED_URIS</filename></ulink> |
| 10158 | variables have not been set or the target image was |
| 10159 | built before the variables were set. |
| 10160 | </para> |
| 10161 | |
| 10162 | <para> |
| 10163 | To inform <filename>apt</filename> of the repository |
| 10164 | you want to use, you might create a list file (e.g. |
| 10165 | <filename>my_repo.list</filename>) inside the |
| 10166 | <filename>/etc/apt/sources.list.d/</filename> |
| 10167 | directory. |
| 10168 | As an example, suppose you are serving packages from a |
| 10169 | <filename>deb/</filename> directory containing the |
| 10170 | <filename>i586</filename>, |
| 10171 | <filename>all</filename>, and |
| 10172 | <filename>qemux86</filename> databases through an |
| 10173 | HTTP server named <filename>my.server</filename>. |
| 10174 | The list file should contain: |
| 10175 | <literallayout class='monospaced'> |
| 10176 | deb http://my.server/deb/all ./ |
| 10177 | deb http://my.server/deb/i586 ./ |
| 10178 | deb http://my.server/deb/qemux86 ./ |
| 10179 | </literallayout> |
| 10180 | Next, instruct the <filename>apt</filename> |
| 10181 | application to fetch the repository information: |
| 10182 | <literallayout class='monospaced'> |
| 10183 | # apt-get update |
| 10184 | </literallayout> |
| 10185 | After this step, <filename>apt</filename> is able |
| 10186 | to find, install, and upgrade packages from the |
| 10187 | specified repository. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 10188 | </para> |
| 10189 | </section> |
| 10190 | </section> |
| 10191 | </section> |
| 10192 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 10193 | <section id='generating-and-using-signed-packages'> |
| 10194 | <title>Generating and Using Signed Packages</title> |
| 10195 | <para> |
| 10196 | In order to add security to RPM packages used during a build, |
| 10197 | you can take steps to securely sign them. |
| 10198 | Once a signature is verified, the OpenEmbedded build system |
| 10199 | can use the package in the build. |
| 10200 | If security fails for a signed package, the build system |
| 10201 | aborts the build. |
| 10202 | </para> |
| 10203 | |
| 10204 | <para> |
| 10205 | This section describes how to sign RPM packages during a build |
| 10206 | and how to use signed package feeds (repositories) when |
| 10207 | doing a build. |
| 10208 | </para> |
| 10209 | |
| 10210 | <section id='signing-rpm-packages'> |
| 10211 | <title>Signing RPM Packages</title> |
| 10212 | |
| 10213 | <para> |
| 10214 | To enable signing RPM packages, you must set up the |
| 10215 | following configurations in either your |
| 10216 | <filename>local.config</filename> or |
| 10217 | <filename>distro.config</filename> file: |
| 10218 | <literallayout class='monospaced'> |
| 10219 | # Inherit sign_rpm.bbclass to enable signing functionality |
| 10220 | INHERIT += " sign_rpm" |
| 10221 | # Define the GPG key that will be used for signing. |
| 10222 | RPM_GPG_NAME = "<replaceable>key_name</replaceable>" |
| 10223 | # Provide passphrase for the key |
| 10224 | RPM_GPG_PASSPHRASE = "<replaceable>passphrase</replaceable>" |
| 10225 | </literallayout> |
| 10226 | <note> |
| 10227 | Be sure to supply appropriate values for both |
| 10228 | <replaceable>key_name</replaceable> and |
| 10229 | <replaceable>passphrase</replaceable> |
| 10230 | </note> |
| 10231 | Aside from the |
| 10232 | <filename>RPM_GPG_NAME</filename> and |
| 10233 | <filename>RPM_GPG_PASSPHRASE</filename> variables in the |
| 10234 | previous example, two optional variables related to signing |
| 10235 | exist: |
| 10236 | <itemizedlist> |
| 10237 | <listitem><para> |
| 10238 | <emphasis><filename>GPG_BIN</filename>:</emphasis> |
| 10239 | Specifies a <filename>gpg</filename> binary/wrapper |
| 10240 | that is executed when the package is signed. |
| 10241 | </para></listitem> |
| 10242 | <listitem><para> |
| 10243 | <emphasis><filename>GPG_PATH</filename>:</emphasis> |
| 10244 | Specifies the <filename>gpg</filename> home |
| 10245 | directory used when the package is signed. |
| 10246 | </para></listitem> |
| 10247 | </itemizedlist> |
| 10248 | </para> |
| 10249 | </section> |
| 10250 | |
| 10251 | <section id='processing-package-feeds'> |
| 10252 | <title>Processing Package Feeds</title> |
| 10253 | |
| 10254 | <para> |
| 10255 | In addition to being able to sign RPM packages, you can |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 10256 | also enable signed package feeds for IPK and RPM packages. |
| 10257 | </para> |
| 10258 | |
| 10259 | <para> |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 10260 | The steps you need to take to enable signed package feed |
| 10261 | use are similar to the steps used to sign RPM packages. |
| 10262 | You must define the following in your |
| 10263 | <filename>local.config</filename> or |
| 10264 | <filename>distro.config</filename> file: |
| 10265 | <literallayout class='monospaced'> |
| 10266 | INHERIT += "sign_package_feed" |
| 10267 | PACKAGE_FEED_GPG_NAME = "<replaceable>key_name</replaceable>" |
| 10268 | PACKAGE_FEED_GPG_PASSPHRASE_FILE = "<replaceable>path_to_file_containing_passphrase</replaceable>" |
| 10269 | </literallayout> |
| 10270 | For signed package feeds, the passphrase must exist in a |
| 10271 | separate file, which is pointed to by the |
| 10272 | <filename>PACKAGE_FEED_GPG_PASSPHRASE_FILE</filename> |
| 10273 | variable. |
| 10274 | Regarding security, keeping a plain text passphrase out of |
| 10275 | the configuration is more secure. |
| 10276 | </para> |
| 10277 | |
| 10278 | <para> |
| 10279 | Aside from the |
| 10280 | <filename>PACKAGE_FEED_GPG_NAME</filename> and |
| 10281 | <filename>PACKAGE_FEED_GPG_PASSPHRASE_FILE</filename> |
| 10282 | variables, three optional variables related to signed |
| 10283 | package feeds exist: |
| 10284 | <itemizedlist> |
| 10285 | <listitem><para> |
| 10286 | <emphasis><filename>GPG_BIN</filename>:</emphasis> |
| 10287 | Specifies a <filename>gpg</filename> binary/wrapper |
| 10288 | that is executed when the package is signed. |
| 10289 | </para></listitem> |
| 10290 | <listitem><para> |
| 10291 | <emphasis><filename>GPG_PATH</filename>:</emphasis> |
| 10292 | Specifies the <filename>gpg</filename> home |
| 10293 | directory used when the package is signed. |
| 10294 | </para></listitem> |
| 10295 | <listitem><para> |
| 10296 | <emphasis><filename>PACKAGE_FEED_GPG_SIGNATURE_TYPE</filename>:</emphasis> |
| 10297 | Specifies the type of <filename>gpg</filename> |
| 10298 | signature. |
| 10299 | This variable applies only to RPM and IPK package |
| 10300 | feeds. |
| 10301 | Allowable values for the |
| 10302 | <filename>PACKAGE_FEED_GPG_SIGNATURE_TYPE</filename> |
| 10303 | are "ASC", which is the default and specifies ascii |
| 10304 | armored, and "BIN", which specifies binary. |
| 10305 | </para></listitem> |
| 10306 | </itemizedlist> |
| 10307 | </para> |
| 10308 | </section> |
| 10309 | </section> |
| 10310 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 10311 | <section id='testing-packages-with-ptest'> |
| 10312 | <title>Testing Packages With ptest</title> |
| 10313 | |
| 10314 | <para> |
| 10315 | A Package Test (ptest) runs tests against packages built |
| 10316 | by the OpenEmbedded build system on the target machine. |
| 10317 | A ptest contains at least two items: the actual test, and |
| 10318 | a shell script (<filename>run-ptest</filename>) that starts |
| 10319 | the test. |
| 10320 | The shell script that starts the test must not contain |
| 10321 | the actual test - the script only starts the test. |
| 10322 | On the other hand, the test can be anything from a simple |
| 10323 | shell script that runs a binary and checks the output to |
| 10324 | an elaborate system of test binaries and data files. |
| 10325 | </para> |
| 10326 | |
| 10327 | <para> |
| 10328 | The test generates output in the format used by |
| 10329 | Automake: |
| 10330 | <literallayout class='monospaced'> |
| 10331 | <replaceable>result</replaceable>: <replaceable>testname</replaceable> |
| 10332 | </literallayout> |
| 10333 | where the result can be <filename>PASS</filename>, |
| 10334 | <filename>FAIL</filename>, or <filename>SKIP</filename>, |
| 10335 | and the testname can be any identifying string. |
| 10336 | </para> |
| 10337 | |
| 10338 | <para> |
| 10339 | For a list of Yocto Project recipes that are already |
| 10340 | enabled with ptest, see the |
| 10341 | <ulink url='https://wiki.yoctoproject.org/wiki/Ptest'>Ptest</ulink> |
| 10342 | wiki page. |
| 10343 | <note> |
| 10344 | A recipe is "ptest-enabled" if it inherits the |
| 10345 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-ptest'><filename>ptest</filename></ulink> |
| 10346 | class. |
| 10347 | </note> |
| 10348 | </para> |
| 10349 | |
| 10350 | <section id='adding-ptest-to-your-build'> |
| 10351 | <title>Adding ptest to Your Build</title> |
| 10352 | |
| 10353 | <para> |
| 10354 | To add package testing to your build, add the |
| 10355 | <ulink url='&YOCTO_DOCS_REF_URL;#var-DISTRO_FEATURES'><filename>DISTRO_FEATURES</filename></ulink> |
| 10356 | and <ulink url='&YOCTO_DOCS_REF_URL;#var-EXTRA_IMAGE_FEATURES'><filename>EXTRA_IMAGE_FEATURES</filename></ulink> |
| 10357 | variables to your <filename>local.conf</filename> file, |
| 10358 | which is found in the |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 10359 | <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink>: |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 10360 | <literallayout class='monospaced'> |
| 10361 | DISTRO_FEATURES_append = " ptest" |
| 10362 | EXTRA_IMAGE_FEATURES += "ptest-pkgs" |
| 10363 | </literallayout> |
| 10364 | Once your build is complete, the ptest files are installed |
| 10365 | into the |
| 10366 | <filename>/usr/lib/<replaceable>package</replaceable>/ptest</filename> |
| 10367 | directory within the image, where |
| 10368 | <filename><replaceable>package</replaceable></filename> |
| 10369 | is the name of the package. |
| 10370 | </para> |
| 10371 | </section> |
| 10372 | |
| 10373 | <section id='running-ptest'> |
| 10374 | <title>Running ptest</title> |
| 10375 | |
| 10376 | <para> |
| 10377 | The <filename>ptest-runner</filename> package installs a |
| 10378 | shell script that loops through all installed ptest test |
| 10379 | suites and runs them in sequence. |
| 10380 | Consequently, you might want to add this package to |
| 10381 | your image. |
| 10382 | </para> |
| 10383 | </section> |
| 10384 | |
| 10385 | <section id='getting-your-package-ready'> |
| 10386 | <title>Getting Your Package Ready</title> |
| 10387 | |
| 10388 | <para> |
| 10389 | In order to enable a recipe to run installed ptests |
| 10390 | on target hardware, |
| 10391 | you need to prepare the recipes that build the packages |
| 10392 | you want to test. |
| 10393 | Here is what you have to do for each recipe: |
| 10394 | <itemizedlist> |
| 10395 | <listitem><para><emphasis>Be sure the recipe |
| 10396 | inherits the |
| 10397 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-ptest'><filename>ptest</filename></ulink> |
| 10398 | class:</emphasis> |
| 10399 | Include the following line in each recipe: |
| 10400 | <literallayout class='monospaced'> |
| 10401 | inherit ptest |
| 10402 | </literallayout> |
| 10403 | </para></listitem> |
| 10404 | <listitem><para><emphasis>Create <filename>run-ptest</filename>:</emphasis> |
| 10405 | This script starts your test. |
| 10406 | Locate the script where you will refer to it |
| 10407 | using |
| 10408 | <ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'><filename>SRC_URI</filename></ulink>. |
| 10409 | Here is an example that starts a test for |
| 10410 | <filename>dbus</filename>: |
| 10411 | <literallayout class='monospaced'> |
| 10412 | #!/bin/sh |
| 10413 | cd test |
| 10414 | make -k runtest-TESTS |
| 10415 | </literallayout> |
| 10416 | </para></listitem> |
| 10417 | <listitem><para><emphasis>Ensure dependencies are |
| 10418 | met:</emphasis> |
| 10419 | If the test adds build or runtime dependencies |
| 10420 | that normally do not exist for the package |
| 10421 | (such as requiring "make" to run the test suite), |
| 10422 | use the |
| 10423 | <ulink url='&YOCTO_DOCS_REF_URL;#var-DEPENDS'><filename>DEPENDS</filename></ulink> |
| 10424 | and |
| 10425 | <ulink url='&YOCTO_DOCS_REF_URL;#var-RDEPENDS'><filename>RDEPENDS</filename></ulink> |
| 10426 | variables in your recipe in order for the package |
| 10427 | to meet the dependencies. |
| 10428 | Here is an example where the package has a runtime |
| 10429 | dependency on "make": |
| 10430 | <literallayout class='monospaced'> |
| 10431 | RDEPENDS_${PN}-ptest += "make" |
| 10432 | </literallayout> |
| 10433 | </para></listitem> |
| 10434 | <listitem><para><emphasis>Add a function to build the |
| 10435 | test suite:</emphasis> |
| 10436 | Not many packages support cross-compilation of |
| 10437 | their test suites. |
| 10438 | Consequently, you usually need to add a |
| 10439 | cross-compilation function to the package. |
| 10440 | </para> |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 10441 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 10442 | <para>Many packages based on Automake compile and |
| 10443 | run the test suite by using a single command |
| 10444 | such as <filename>make check</filename>. |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 10445 | However, the host <filename>make check</filename> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 10446 | builds and runs on the same computer, while |
| 10447 | cross-compiling requires that the package is built |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 10448 | on the host but executed for the target |
| 10449 | architecture (though often, as in the case for |
| 10450 | ptest, the execution occurs on the host). |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 10451 | The built version of Automake that ships with the |
| 10452 | Yocto Project includes a patch that separates |
| 10453 | building and execution. |
| 10454 | Consequently, packages that use the unaltered, |
| 10455 | patched version of <filename>make check</filename> |
| 10456 | automatically cross-compiles.</para> |
| 10457 | <para>Regardless, you still must add a |
| 10458 | <filename>do_compile_ptest</filename> function to |
| 10459 | build the test suite. |
| 10460 | Add a function similar to the following to your |
| 10461 | recipe: |
| 10462 | <literallayout class='monospaced'> |
| 10463 | do_compile_ptest() { |
| 10464 | oe_runmake buildtest-TESTS |
| 10465 | } |
| 10466 | </literallayout> |
| 10467 | </para></listitem> |
| 10468 | <listitem><para><emphasis>Ensure special configurations |
| 10469 | are set:</emphasis> |
| 10470 | If the package requires special configurations |
| 10471 | prior to compiling the test code, you must |
| 10472 | insert a <filename>do_configure_ptest</filename> |
| 10473 | function into the recipe. |
| 10474 | </para></listitem> |
| 10475 | <listitem><para><emphasis>Install the test |
| 10476 | suite:</emphasis> |
| 10477 | The <filename>ptest</filename> class |
| 10478 | automatically copies the file |
| 10479 | <filename>run-ptest</filename> to the target and |
| 10480 | then runs make <filename>install-ptest</filename> |
| 10481 | to run the tests. |
| 10482 | If this is not enough, you need to create a |
| 10483 | <filename>do_install_ptest</filename> function and |
| 10484 | make sure it gets called after the |
| 10485 | "make install-ptest" completes. |
| 10486 | </para></listitem> |
| 10487 | </itemizedlist> |
| 10488 | </para> |
| 10489 | </section> |
| 10490 | </section> |
Brad Bishop | 15ae250 | 2019-06-18 21:44:24 -0400 | [diff] [blame] | 10491 | |
| 10492 | <section id='creating-node-package-manager-npm-packages'> |
| 10493 | <title>Creating Node Package Manager (NPM) Packages</title> |
| 10494 | |
| 10495 | <para> |
| 10496 | <ulink url='https://en.wikipedia.org/wiki/Npm_(software)'>NPM</ulink> |
| 10497 | is a package manager for the JavaScript programming |
| 10498 | language. |
| 10499 | The Yocto Project supports the NPM |
| 10500 | <ulink url='&YOCTO_DOCS_BB_URL;#bb-fetchers'>fetcher</ulink>. |
| 10501 | You can use this fetcher in combination with |
| 10502 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-devtool-reference'><filename>devtool</filename></ulink> |
| 10503 | to create recipes that produce NPM packages. |
| 10504 | </para> |
| 10505 | |
| 10506 | <para> |
| 10507 | Two workflows exist that allow you to create NPM packages |
| 10508 | using <filename>devtool</filename>: the NPM registry modules |
| 10509 | method and the NPM project code method. |
| 10510 | <note> |
| 10511 | While it is possible to create NPM recipes manually, |
| 10512 | using <filename>devtool</filename> is far simpler. |
| 10513 | </note> |
| 10514 | Additionally, some requirements and caveats exist. |
| 10515 | </para> |
| 10516 | |
| 10517 | <section id='npm-package-creation-requirements'> |
| 10518 | <title>Requirements and Caveats</title> |
| 10519 | |
| 10520 | <para> |
| 10521 | You need to be aware of the following before using |
| 10522 | <filename>devtool</filename> to create NPM packages: |
| 10523 | <itemizedlist> |
| 10524 | <listitem><para> |
| 10525 | Of the two methods that you can use |
| 10526 | <filename>devtool</filename> to create NPM |
| 10527 | packages, the registry approach is slightly |
| 10528 | simpler. |
| 10529 | However, you might consider the project |
| 10530 | approach because you do not have to publish |
| 10531 | your module in the NPM registry |
| 10532 | (<ulink url='https://docs.npmjs.com/misc/registry'><filename>npm-registry</filename></ulink>), |
| 10533 | which is NPM's public registry. |
| 10534 | </para></listitem> |
| 10535 | <listitem><para> |
| 10536 | Be familiar with |
| 10537 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-devtool-reference'><filename>devtool</filename></ulink>. |
| 10538 | </para></listitem> |
| 10539 | <listitem><para> |
| 10540 | The NPM host tools need the native |
| 10541 | <filename>nodejs-npm</filename> package, which |
| 10542 | is part of the OpenEmbedded environment. |
| 10543 | You need to get the package by cloning the |
| 10544 | <ulink url='https://github.com/openembedded/meta-openembedded'></ulink> |
| 10545 | repository out of GitHub. |
| 10546 | Be sure to add the path to your local copy to |
| 10547 | your <filename>bblayers.conf</filename> file. |
| 10548 | </para></listitem> |
| 10549 | <listitem><para> |
| 10550 | <filename>devtool</filename> cannot detect |
| 10551 | native libraries in module dependencies. |
| 10552 | Consequently, you must manually add packages |
| 10553 | to your recipe. |
| 10554 | </para></listitem> |
| 10555 | <listitem><para> |
| 10556 | While deploying NPM packages, |
| 10557 | <filename>devtool</filename> cannot determine |
| 10558 | which dependent packages are missing on the |
| 10559 | target (e.g. the node runtime |
| 10560 | <filename>nodejs</filename>). |
| 10561 | Consequently, you need to find out what |
| 10562 | files are missing and be sure they are on the |
| 10563 | target. |
| 10564 | </para></listitem> |
| 10565 | <listitem><para> |
| 10566 | Although you might not need NPM to run your |
| 10567 | node package, it is useful to have NPM on your |
| 10568 | target. |
| 10569 | The NPM package name is |
| 10570 | <filename>nodejs-npm</filename>. |
| 10571 | </para></listitem> |
| 10572 | </itemizedlist> |
| 10573 | </para> |
| 10574 | </section> |
| 10575 | |
| 10576 | <section id='npm-using-the-registry-modules-method'> |
| 10577 | <title>Using the Registry Modules Method</title> |
| 10578 | |
| 10579 | <para> |
| 10580 | This section presents an example that uses the |
| 10581 | <filename>cute-files</filename> module, which is a |
| 10582 | file browser web application. |
| 10583 | <note> |
| 10584 | You must know the <filename>cute-files</filename> |
| 10585 | module version. |
| 10586 | </note> |
| 10587 | </para> |
| 10588 | |
| 10589 | <para> |
| 10590 | The first thing you need to do is use |
| 10591 | <filename>devtool</filename> and the NPM fetcher to |
| 10592 | create the recipe: |
| 10593 | <literallayout class='monospaced'> |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 10594 | $ devtool add "npm://registry.npmjs.org;package=cute-files;version=1.0.2" |
Brad Bishop | 15ae250 | 2019-06-18 21:44:24 -0400 | [diff] [blame] | 10595 | </literallayout> |
| 10596 | The <filename>devtool add</filename> command runs |
| 10597 | <filename>recipetool create</filename> and uses the |
| 10598 | same fetch URI to download each dependency and capture |
| 10599 | license details where possible. |
| 10600 | The result is a generated recipe. |
| 10601 | </para> |
| 10602 | |
| 10603 | <para> |
| 10604 | The recipe file is fairly simple and contains every |
| 10605 | license that <filename>recipetool</filename> finds |
| 10606 | and includes the licenses in the recipe's |
| 10607 | <ulink url='&YOCTO_DOCS_REF_URL;#var-LIC_FILES_CHKSUM'><filename>LIC_FILES_CHKSUM</filename></ulink> |
| 10608 | variables. |
| 10609 | You need to examine the variables and look for those |
| 10610 | with "unknown" in the |
| 10611 | <ulink url='&YOCTO_DOCS_REF_URL;#var-LICENSE'><filename>LICENSE</filename></ulink> |
| 10612 | field. |
| 10613 | You need to track down the license information for |
| 10614 | "unknown" modules and manually add the information to the |
| 10615 | recipe. |
| 10616 | </para> |
| 10617 | |
| 10618 | <para> |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 10619 | <filename>recipetool</filename> creates a "shrinkwrap" file |
| 10620 | for your recipe. |
Brad Bishop | 15ae250 | 2019-06-18 21:44:24 -0400 | [diff] [blame] | 10621 | Shrinkwrap files capture the version of all dependent |
| 10622 | modules. |
| 10623 | Many packages do not provide shrinkwrap files. |
| 10624 | <filename>recipetool</filename> create a shrinkwrap |
| 10625 | file as it runs. |
Brad Bishop | 15ae250 | 2019-06-18 21:44:24 -0400 | [diff] [blame] | 10626 | <note> |
| 10627 | A package is created for each sub-module. |
| 10628 | This policy is the only practical way to have the |
| 10629 | licenses for all of the dependencies represented |
| 10630 | in the license manifest of the image. |
| 10631 | </note> |
| 10632 | </para> |
| 10633 | |
| 10634 | <para> |
| 10635 | The <filename>devtool edit-recipe</filename> command |
| 10636 | lets you take a look at the recipe: |
| 10637 | <literallayout class='monospaced'> |
| 10638 | $ devtool edit-recipe cute-files |
| 10639 | SUMMARY = "Turn any folder on your computer into a cute file browser, available on the local network." |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 10640 | LICENSE = "MIT & ISC & Unknown" |
Brad Bishop | 15ae250 | 2019-06-18 21:44:24 -0400 | [diff] [blame] | 10641 | LIC_FILES_CHKSUM = "file://LICENSE;md5=71d98c0a1db42956787b1909c74a86ca \ |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 10642 | file://node_modules/toidentifier/LICENSE;md5=1a261071a044d02eb6f2bb47f51a3502 \ |
| 10643 | file://node_modules/debug/LICENSE;md5=ddd815a475e7338b0be7a14d8ee35a99 \ |
Brad Bishop | 15ae250 | 2019-06-18 21:44:24 -0400 | [diff] [blame] | 10644 | ... |
| 10645 | |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 10646 | SRC_URI = " \ |
| 10647 | npm://registry.npmjs.org/;package=cute-files;version=${PV} \ |
| 10648 | npmsw://${THISDIR}/${BPN}/npm-shrinkwrap.json \ |
| 10649 | " |
Brad Bishop | 15ae250 | 2019-06-18 21:44:24 -0400 | [diff] [blame] | 10650 | |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 10651 | S = "${WORKDIR}/npm" |
| 10652 | |
| 10653 | inherit npm |
| 10654 | |
Brad Bishop | 15ae250 | 2019-06-18 21:44:24 -0400 | [diff] [blame] | 10655 | LICENSE_${PN} = "MIT" |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 10656 | LICENSE_${PN}-accepts = "MIT" |
| 10657 | LICENSE_${PN}-array-flatten = "MIT" |
| 10658 | ... |
| 10659 | LICENSE_${PN}-vary = "MIT" |
Brad Bishop | 15ae250 | 2019-06-18 21:44:24 -0400 | [diff] [blame] | 10660 | </literallayout> |
| 10661 | Three key points exist in the previous example: |
| 10662 | <itemizedlist> |
| 10663 | <listitem><para> |
| 10664 | <ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'><filename>SRC_URI</filename></ulink> |
| 10665 | uses the NPM scheme so that the NPM fetcher |
| 10666 | is used. |
| 10667 | </para></listitem> |
| 10668 | <listitem><para> |
| 10669 | <filename>recipetool</filename> collects all |
| 10670 | the license information. |
| 10671 | If a sub-module's license is unavailable, |
| 10672 | the sub-module's name appears in the comments. |
| 10673 | </para></listitem> |
| 10674 | <listitem><para> |
| 10675 | The <filename>inherit npm</filename> statement |
| 10676 | causes the |
| 10677 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-npm'><filename>npm</filename></ulink> |
| 10678 | class to package up all the modules. |
| 10679 | </para></listitem> |
| 10680 | </itemizedlist> |
| 10681 | </para> |
| 10682 | |
| 10683 | <para> |
| 10684 | You can run the following command to build the |
| 10685 | <filename>cute-files</filename> package: |
| 10686 | <literallayout class='monospaced'> |
| 10687 | $ devtool build cute-files |
| 10688 | </literallayout> |
| 10689 | Remember that <filename>nodejs</filename> must be |
| 10690 | installed on the target before your package. |
| 10691 | </para> |
| 10692 | |
| 10693 | <para> |
| 10694 | Assuming 192.168.7.2 for the target's IP address, use |
| 10695 | the following command to deploy your package: |
| 10696 | <literallayout class='monospaced'> |
| 10697 | $ devtool deploy-target -s cute-files root@192.168.7.2 |
| 10698 | </literallayout> |
| 10699 | Once the package is installed on the target, you can |
| 10700 | test the application: |
| 10701 | <note> |
| 10702 | Because of a know issue, you cannot simply run |
| 10703 | <filename>cute-files</filename> as you would if you |
| 10704 | had run <filename>npm install</filename>. |
| 10705 | </note> |
| 10706 | <literallayout class='monospaced'> |
| 10707 | $ cd /usr/lib/node_modules/cute-files |
| 10708 | $ node cute-files.js |
| 10709 | </literallayout> |
| 10710 | On a browser, go to |
| 10711 | <filename>http://192.168.7.2:3000</filename> and you |
| 10712 | see the following: |
| 10713 | <imagedata fileref="figures/cute-files-npm-example.png" align="center" width="6in" depth="4in" /> |
| 10714 | </para> |
| 10715 | |
| 10716 | <para> |
| 10717 | You can find the recipe in |
| 10718 | <filename>workspace/recipes/cute-files</filename>. |
| 10719 | You can use the recipe in any layer you choose. |
| 10720 | </para> |
| 10721 | </section> |
| 10722 | |
| 10723 | <section id='npm-using-the-npm-projects-method'> |
| 10724 | <title>Using the NPM Projects Code Method</title> |
| 10725 | |
| 10726 | <para> |
| 10727 | Although it is useful to package modules already in the |
| 10728 | NPM registry, adding <filename>node.js</filename> projects |
| 10729 | under development is a more common developer use case. |
| 10730 | </para> |
| 10731 | |
| 10732 | <para> |
| 10733 | This section covers the NPM projects code method, which is |
| 10734 | very similar to the "registry" approach described in the |
| 10735 | previous section. |
| 10736 | In the NPM projects method, you provide |
| 10737 | <filename>devtool</filename> with an URL that points to the |
| 10738 | source files. |
| 10739 | </para> |
| 10740 | |
| 10741 | <para> |
| 10742 | Replicating the same example, (i.e. |
| 10743 | <filename>cute-files</filename>) use the following command: |
| 10744 | <literallayout class='monospaced'> |
| 10745 | $ devtool add https://github.com/martinaglv/cute-files.git |
| 10746 | </literallayout> |
| 10747 | The recipe this command generates is very similar to the |
| 10748 | recipe created in the previous section. |
| 10749 | However, the <filename>SRC_URI</filename> looks like the |
| 10750 | following: |
| 10751 | <literallayout class='monospaced'> |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 10752 | SRC_URI = " \ |
| 10753 | git://github.com/martinaglv/cute-files.git;protocol=https \ |
| 10754 | npmsw://${THISDIR}/${BPN}/npm-shrinkwrap.json \ |
| 10755 | " |
Brad Bishop | 15ae250 | 2019-06-18 21:44:24 -0400 | [diff] [blame] | 10756 | </literallayout> |
| 10757 | In this example, the main module is taken from the Git |
| 10758 | repository and dependents are taken from the NPM registry. |
| 10759 | Other than those differences, the recipe is basically the |
| 10760 | same between the two methods. |
| 10761 | You can build and deploy the package exactly as described |
| 10762 | in the previous section that uses the registry modules |
| 10763 | method. |
| 10764 | </para> |
| 10765 | </section> |
| 10766 | </section> |
Andrew Geissler | 1e34c2d | 2020-05-29 16:02:59 -0500 | [diff] [blame^] | 10767 | |
| 10768 | <section id='adding-custom-metadata-to-packages'> |
| 10769 | <title>Adding custom metadata to packages</title> |
| 10770 | |
| 10771 | <para> |
| 10772 | The variable <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_ADD_METADATA'><filename>PACKAGE_ADD_METADATA</filename></ulink> |
| 10773 | can be used to add additional metadata to packages. This is |
| 10774 | reflected in the package control/spec file. To take the ipk |
| 10775 | format for example, the CONTROL file stored inside would |
| 10776 | contain the additional metadata as additional lines. |
| 10777 | </para> |
| 10778 | |
| 10779 | <para> |
| 10780 | The variable can be used in multiple ways, including using |
| 10781 | suffixes to set it for a specific package type and/or package. |
| 10782 | Note that the order of precedence is the same as this list: |
| 10783 | <itemizedlist> |
| 10784 | <listitem><para> |
| 10785 | <filename>PACKAGE_ADD_METADATA_<PKGTYPE>_<PN></filename> |
| 10786 | </para></listitem> |
| 10787 | <listitem><para> |
| 10788 | <filename>PACKAGE_ADD_METADATA_<PKGTYPE></filename> |
| 10789 | </para></listitem> |
| 10790 | <listitem><para> |
| 10791 | <filename>PACKAGE_ADD_METADATA_<PN></filename> |
| 10792 | </para></listitem> |
| 10793 | <listitem><para> |
| 10794 | <filename>PACKAGE_ADD_METADATA</filename> |
| 10795 | </para></listitem> |
| 10796 | </itemizedlist> |
| 10797 | <PKGTYPE> is a parameter and expected to be a |
| 10798 | distinct name of specific package type: |
| 10799 | <itemizedlist> |
| 10800 | <listitem><para>IPK for .ipk packages</para></listitem> |
| 10801 | <listitem><para>DEB for .deb packages</para></listitem> |
| 10802 | <listitem><para>RPM for .rpm packages</para></listitem> |
| 10803 | </itemizedlist> |
| 10804 | <PN> is a parameter and expected to be a package name. |
| 10805 | </para> |
| 10806 | |
| 10807 | <para> |
| 10808 | The variable can contain multiple [one-line] metadata fields |
| 10809 | separated by the literal sequence '\n'. The separator can be |
| 10810 | redefined using the variable flag <filename>separator</filename>. |
| 10811 | </para> |
| 10812 | |
| 10813 | <para> |
| 10814 | The following is an example that adds two custom fields for |
| 10815 | ipk packages: |
| 10816 | <literallayout class='monospaced'> |
| 10817 | PACKAGE_ADD_METADATA_IPK = "Vendor: CustomIpk\nGroup: Applications/Spreadsheets" |
| 10818 | </literallayout> |
| 10819 | </para> |
| 10820 | </section> |
| 10821 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 10822 | </section> |
| 10823 | |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 10824 | <section id='efficiently-fetching-source-files-during-a-build'> |
| 10825 | <title>Efficiently Fetching Source Files During a Build</title> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 10826 | |
| 10827 | <para> |
| 10828 | The OpenEmbedded build system works with source files located |
| 10829 | through the |
| 10830 | <ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'><filename>SRC_URI</filename></ulink> |
| 10831 | variable. |
| 10832 | When you build something using BitBake, a big part of the operation |
| 10833 | is locating and downloading all the source tarballs. |
| 10834 | For images, downloading all the source for various packages can |
| 10835 | take a significant amount of time. |
| 10836 | </para> |
| 10837 | |
| 10838 | <para> |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 10839 | This section shows you how you can use mirrors to speed up |
| 10840 | fetching source files and how you can pre-fetch files all of which |
| 10841 | leads to more efficient use of resources and time. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 10842 | </para> |
| 10843 | |
| 10844 | <section id='setting-up-effective-mirrors'> |
| 10845 | <title>Setting up Effective Mirrors</title> |
| 10846 | |
| 10847 | <para> |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 10848 | A good deal that goes into a Yocto Project |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 10849 | build is simply downloading all of the source tarballs. |
| 10850 | Maybe you have been working with another build system |
| 10851 | (OpenEmbedded or Angstrom) for which you have built up a |
| 10852 | sizable directory of source tarballs. |
| 10853 | Or, perhaps someone else has such a directory for which you |
| 10854 | have read access. |
| 10855 | If so, you can save time by adding statements to your |
| 10856 | configuration file so that the build process checks local |
| 10857 | directories first for existing tarballs before checking the |
| 10858 | Internet. |
| 10859 | </para> |
| 10860 | |
| 10861 | <para> |
| 10862 | Here is an efficient way to set it up in your |
| 10863 | <filename>local.conf</filename> file: |
| 10864 | <literallayout class='monospaced'> |
| 10865 | SOURCE_MIRROR_URL ?= "file:///home/you/your-download-dir/" |
| 10866 | INHERIT += "own-mirrors" |
| 10867 | BB_GENERATE_MIRROR_TARBALLS = "1" |
| 10868 | # BB_NO_NETWORK = "1" |
| 10869 | </literallayout> |
| 10870 | </para> |
| 10871 | |
| 10872 | <para> |
| 10873 | In the previous example, the |
| 10874 | <ulink url='&YOCTO_DOCS_REF_URL;#var-BB_GENERATE_MIRROR_TARBALLS'><filename>BB_GENERATE_MIRROR_TARBALLS</filename></ulink> |
| 10875 | variable causes the OpenEmbedded build system to generate |
| 10876 | tarballs of the Git repositories and store them in the |
| 10877 | <ulink url='&YOCTO_DOCS_REF_URL;#var-DL_DIR'><filename>DL_DIR</filename></ulink> |
| 10878 | directory. |
| 10879 | Due to performance reasons, generating and storing these |
| 10880 | tarballs is not the build system's default behavior. |
| 10881 | </para> |
| 10882 | |
| 10883 | <para> |
| 10884 | You can also use the |
| 10885 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PREMIRRORS'><filename>PREMIRRORS</filename></ulink> |
| 10886 | variable. |
| 10887 | For an example, see the variable's glossary entry in the |
| 10888 | Yocto Project Reference Manual. |
| 10889 | </para> |
| 10890 | </section> |
| 10891 | |
| 10892 | <section id='getting-source-files-and-suppressing-the-build'> |
| 10893 | <title>Getting Source Files and Suppressing the Build</title> |
| 10894 | |
| 10895 | <para> |
| 10896 | Another technique you can use to ready yourself for a |
| 10897 | successive string of build operations, is to pre-fetch |
| 10898 | all the source files without actually starting a build. |
| 10899 | This technique lets you work through any download issues |
| 10900 | and ultimately gathers all the source files into your |
| 10901 | download directory |
| 10902 | <ulink url='&YOCTO_DOCS_REF_URL;#structure-build-downloads'><filename>build/downloads</filename></ulink>, |
| 10903 | which is located with |
| 10904 | <ulink url='&YOCTO_DOCS_REF_URL;#var-DL_DIR'><filename>DL_DIR</filename></ulink>. |
| 10905 | </para> |
| 10906 | |
| 10907 | <para> |
| 10908 | Use the following BitBake command form to fetch all the |
| 10909 | necessary sources without starting the build: |
| 10910 | <literallayout class='monospaced'> |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 10911 | $ bitbake <replaceable>target</replaceable> --runall=fetch |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 10912 | </literallayout> |
| 10913 | This variation of the BitBake command guarantees that you |
| 10914 | have all the sources for that BitBake target should you |
| 10915 | disconnect from the Internet and want to do the build |
| 10916 | later offline. |
| 10917 | </para> |
| 10918 | </section> |
| 10919 | </section> |
| 10920 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 10921 | <section id="selecting-an-initialization-manager"> |
| 10922 | <title>Selecting an Initialization Manager</title> |
| 10923 | |
| 10924 | <para> |
| 10925 | By default, the Yocto Project uses SysVinit as the initialization |
| 10926 | manager. |
| 10927 | However, support also exists for systemd, |
| 10928 | which is a full replacement for init with |
| 10929 | parallel starting of services, reduced shell overhead and other |
| 10930 | features that are used by many distributions. |
| 10931 | </para> |
| 10932 | |
| 10933 | <para> |
Brad Bishop | 64c979e | 2019-11-04 13:55:29 -0500 | [diff] [blame] | 10934 | Within the system, SysVinit treats system components as services. |
| 10935 | These services are maintained as shell scripts stored in the |
| 10936 | <filename>/etc/init.d/</filename> directory. |
| 10937 | Services organize into different run levels. |
| 10938 | This organization is maintained by putting links to the services |
| 10939 | in the <filename>/etc/rcN.d/</filename> directories, where |
| 10940 | <replaceable>N/</replaceable> is one of the following options: |
| 10941 | "S", "0", "1", "2", "3", "4", "5", or "6". |
| 10942 | <note> |
| 10943 | Each runlevel has a dependency on the previous runlevel. |
| 10944 | This dependency allows the services to work properly. |
| 10945 | </note> |
| 10946 | </para> |
| 10947 | |
| 10948 | <para> |
| 10949 | In comparison, systemd treats components as units. |
| 10950 | Using units is a broader concept as compared to using a service. |
| 10951 | A unit includes several different types of entities. |
| 10952 | Service is one of the types of entities. |
| 10953 | The runlevel concept in SysVinit corresponds to the concept of a |
| 10954 | target in systemd, where target is also a type of supported unit. |
| 10955 | </para> |
| 10956 | |
| 10957 | <para> |
| 10958 | In a SysVinit-based system, services load sequentially (i.e. one |
| 10959 | by one) during and parallelization is not supported. |
| 10960 | With systemd, services start in parallel. |
| 10961 | Needless to say, the method can have an impact on system startup |
| 10962 | performance. |
| 10963 | </para> |
| 10964 | |
| 10965 | <para> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 10966 | If you want to use SysVinit, you do |
| 10967 | not have to do anything. |
| 10968 | But, if you want to use systemd, you must |
| 10969 | take some steps as described in the following sections. |
| 10970 | </para> |
| 10971 | |
| 10972 | <section id='using-systemd-exclusively'> |
| 10973 | <title>Using systemd Exclusively</title> |
| 10974 | |
| 10975 | <para> |
Brad Bishop | 15ae250 | 2019-06-18 21:44:24 -0400 | [diff] [blame] | 10976 | Set these variables in your distribution configuration |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 10977 | file as follows: |
| 10978 | <literallayout class='monospaced'> |
| 10979 | DISTRO_FEATURES_append = " systemd" |
| 10980 | VIRTUAL-RUNTIME_init_manager = "systemd" |
| 10981 | </literallayout> |
| 10982 | You can also prevent the SysVinit |
| 10983 | distribution feature from |
| 10984 | being automatically enabled as follows: |
| 10985 | <literallayout class='monospaced'> |
| 10986 | DISTRO_FEATURES_BACKFILL_CONSIDERED = "sysvinit" |
| 10987 | </literallayout> |
| 10988 | Doing so removes any redundant SysVinit scripts. |
| 10989 | </para> |
| 10990 | |
| 10991 | <para> |
| 10992 | To remove initscripts from your image altogether, |
| 10993 | set this variable also: |
| 10994 | <literallayout class='monospaced'> |
| 10995 | VIRTUAL-RUNTIME_initscripts = "" |
| 10996 | </literallayout> |
| 10997 | </para> |
| 10998 | |
| 10999 | <para> |
| 11000 | For information on the backfill variable, see |
| 11001 | <ulink url='&YOCTO_DOCS_REF_URL;#var-DISTRO_FEATURES_BACKFILL_CONSIDERED'><filename>DISTRO_FEATURES_BACKFILL_CONSIDERED</filename></ulink>. |
| 11002 | </para> |
| 11003 | </section> |
| 11004 | |
| 11005 | <section id='using-systemd-for-the-main-image-and-using-sysvinit-for-the-rescue-image'> |
| 11006 | <title>Using systemd for the Main Image and Using SysVinit for the Rescue Image</title> |
| 11007 | |
| 11008 | <para> |
| 11009 | Set these variables in your distribution configuration |
| 11010 | file as follows: |
| 11011 | <literallayout class='monospaced'> |
| 11012 | DISTRO_FEATURES_append = " systemd" |
| 11013 | VIRTUAL-RUNTIME_init_manager = "systemd" |
| 11014 | </literallayout> |
| 11015 | Doing so causes your main image to use the |
| 11016 | <filename>packagegroup-core-boot.bb</filename> recipe and |
| 11017 | systemd. |
| 11018 | The rescue/minimal image cannot use this package group. |
| 11019 | However, it can install SysVinit |
| 11020 | and the appropriate packages will have support for both |
| 11021 | systemd and SysVinit. |
| 11022 | </para> |
| 11023 | </section> |
| 11024 | </section> |
| 11025 | |
| 11026 | <section id="selecting-dev-manager"> |
| 11027 | <title>Selecting a Device Manager</title> |
| 11028 | |
| 11029 | <para> |
| 11030 | The Yocto Project provides multiple ways to manage the device |
| 11031 | manager (<filename>/dev</filename>): |
| 11032 | <itemizedlist> |
| 11033 | <listitem><para><emphasis>Persistent and Pre-Populated<filename>/dev</filename>:</emphasis> |
| 11034 | For this case, the <filename>/dev</filename> directory |
| 11035 | is persistent and the required device nodes are created |
| 11036 | during the build. |
| 11037 | </para></listitem> |
| 11038 | <listitem><para><emphasis>Use <filename>devtmpfs</filename> with a Device Manager:</emphasis> |
| 11039 | For this case, the <filename>/dev</filename> directory |
| 11040 | is provided by the kernel as an in-memory file system and |
| 11041 | is automatically populated by the kernel at runtime. |
| 11042 | Additional configuration of device nodes is done in user |
| 11043 | space by a device manager like |
| 11044 | <filename>udev</filename> or |
| 11045 | <filename>busybox-mdev</filename>. |
| 11046 | </para></listitem> |
| 11047 | </itemizedlist> |
| 11048 | </para> |
| 11049 | |
| 11050 | <section id="static-dev-management"> |
| 11051 | <title>Using Persistent and Pre-Populated<filename>/dev</filename></title> |
| 11052 | |
| 11053 | <para> |
| 11054 | To use the static method for device population, you need to |
| 11055 | set the |
| 11056 | <ulink url='&YOCTO_DOCS_REF_URL;#var-USE_DEVFS'><filename>USE_DEVFS</filename></ulink> |
| 11057 | variable to "0" as follows: |
| 11058 | <literallayout class='monospaced'> |
| 11059 | USE_DEVFS = "0" |
| 11060 | </literallayout> |
| 11061 | </para> |
| 11062 | |
| 11063 | <para> |
| 11064 | The content of the resulting <filename>/dev</filename> |
| 11065 | directory is defined in a Device Table file. |
| 11066 | The |
| 11067 | <ulink url='&YOCTO_DOCS_REF_URL;#var-IMAGE_DEVICE_TABLES'><filename>IMAGE_DEVICE_TABLES</filename></ulink> |
| 11068 | variable defines the Device Table to use and should be set |
| 11069 | in the machine or distro configuration file. |
| 11070 | Alternatively, you can set this variable in your |
| 11071 | <filename>local.conf</filename> configuration file. |
| 11072 | </para> |
| 11073 | |
| 11074 | <para> |
| 11075 | If you do not define the |
| 11076 | <filename>IMAGE_DEVICE_TABLES</filename> variable, the default |
| 11077 | <filename>device_table-minimal.txt</filename> is used: |
| 11078 | <literallayout class='monospaced'> |
| 11079 | IMAGE_DEVICE_TABLES = "device_table-mymachine.txt" |
| 11080 | </literallayout> |
| 11081 | </para> |
| 11082 | |
| 11083 | <para> |
| 11084 | The population is handled by the <filename>makedevs</filename> |
| 11085 | utility during image creation: |
| 11086 | </para> |
| 11087 | </section> |
| 11088 | |
| 11089 | <section id="devtmpfs-dev-management"> |
| 11090 | <title>Using <filename>devtmpfs</filename> and a Device Manager</title> |
| 11091 | |
| 11092 | <para> |
| 11093 | To use the dynamic method for device population, you need to |
| 11094 | use (or be sure to set) the |
| 11095 | <ulink url='&YOCTO_DOCS_REF_URL;#var-USE_DEVFS'><filename>USE_DEVFS</filename></ulink> |
| 11096 | variable to "1", which is the default: |
| 11097 | <literallayout class='monospaced'> |
| 11098 | USE_DEVFS = "1" |
| 11099 | </literallayout> |
| 11100 | With this setting, the resulting <filename>/dev</filename> |
| 11101 | directory is populated by the kernel using |
| 11102 | <filename>devtmpfs</filename>. |
| 11103 | Make sure the corresponding kernel configuration variable |
| 11104 | <filename>CONFIG_DEVTMPFS</filename> is set when building |
| 11105 | you build a Linux kernel. |
| 11106 | </para> |
| 11107 | |
| 11108 | <para> |
| 11109 | All devices created by <filename>devtmpfs</filename> will be |
| 11110 | owned by <filename>root</filename> and have permissions |
| 11111 | <filename>0600</filename>. |
| 11112 | </para> |
| 11113 | |
| 11114 | <para> |
| 11115 | To have more control over the device nodes, you can use a |
| 11116 | device manager like <filename>udev</filename> or |
| 11117 | <filename>busybox-mdev</filename>. |
| 11118 | You choose the device manager by defining the |
| 11119 | <filename>VIRTUAL-RUNTIME_dev_manager</filename> variable |
| 11120 | in your machine or distro configuration file. |
| 11121 | Alternatively, you can set this variable in your |
| 11122 | <filename>local.conf</filename> configuration file: |
| 11123 | <literallayout class='monospaced'> |
| 11124 | VIRTUAL-RUNTIME_dev_manager = "udev" |
| 11125 | |
| 11126 | # Some alternative values |
| 11127 | # VIRTUAL-RUNTIME_dev_manager = "busybox-mdev" |
| 11128 | # VIRTUAL-RUNTIME_dev_manager = "systemd" |
| 11129 | </literallayout> |
| 11130 | </para> |
| 11131 | </section> |
| 11132 | </section> |
| 11133 | |
| 11134 | <section id="platdev-appdev-srcrev"> |
| 11135 | <title>Using an External SCM</title> |
| 11136 | |
| 11137 | <para> |
| 11138 | If you're working on a recipe that pulls from an external Source |
| 11139 | Code Manager (SCM), it is possible to have the OpenEmbedded build |
| 11140 | system notice new recipe changes added to the SCM and then build |
| 11141 | the resulting packages that depend on the new recipes by using |
| 11142 | the latest versions. |
| 11143 | This only works for SCMs from which it is possible to get a |
| 11144 | sensible revision number for changes. |
| 11145 | Currently, you can do this with Apache Subversion (SVN), Git, and |
| 11146 | Bazaar (BZR) repositories. |
| 11147 | </para> |
| 11148 | |
| 11149 | <para> |
| 11150 | To enable this behavior, the |
| 11151 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PV'><filename>PV</filename></ulink> |
| 11152 | of the recipe needs to reference |
| 11153 | <ulink url='&YOCTO_DOCS_REF_URL;#var-SRCPV'><filename>SRCPV</filename></ulink>. |
| 11154 | Here is an example: |
| 11155 | <literallayout class='monospaced'> |
| 11156 | PV = "1.2.3+git${SRCPV}" |
| 11157 | </literallayout> |
| 11158 | Then, you can add the following to your |
| 11159 | <filename>local.conf</filename>: |
| 11160 | <literallayout class='monospaced'> |
| 11161 | SRCREV_pn-<replaceable>PN</replaceable> = "${AUTOREV}" |
| 11162 | </literallayout> |
| 11163 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PN'><filename>PN</filename></ulink> |
| 11164 | is the name of the recipe for which you want to enable automatic source |
| 11165 | revision updating. |
| 11166 | </para> |
| 11167 | |
| 11168 | <para> |
| 11169 | If you do not want to update your local configuration file, you can |
| 11170 | add the following directly to the recipe to finish enabling |
| 11171 | the feature: |
| 11172 | <literallayout class='monospaced'> |
| 11173 | SRCREV = "${AUTOREV}" |
| 11174 | </literallayout> |
| 11175 | </para> |
| 11176 | |
| 11177 | <para> |
| 11178 | The Yocto Project provides a distribution named |
| 11179 | <filename>poky-bleeding</filename>, whose configuration |
| 11180 | file contains the line: |
| 11181 | <literallayout class='monospaced'> |
| 11182 | require conf/distro/include/poky-floating-revisions.inc |
| 11183 | </literallayout> |
| 11184 | This line pulls in the listed include file that contains |
| 11185 | numerous lines of exactly that form: |
| 11186 | <literallayout class='monospaced'> |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 11187 | #SRCREV_pn-opkg-native ?= "${AUTOREV}" |
| 11188 | #SRCREV_pn-opkg-sdk ?= "${AUTOREV}" |
| 11189 | #SRCREV_pn-opkg ?= "${AUTOREV}" |
| 11190 | #SRCREV_pn-opkg-utils-native ?= "${AUTOREV}" |
| 11191 | #SRCREV_pn-opkg-utils ?= "${AUTOREV}" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 11192 | SRCREV_pn-gconf-dbus ?= "${AUTOREV}" |
| 11193 | SRCREV_pn-matchbox-common ?= "${AUTOREV}" |
| 11194 | SRCREV_pn-matchbox-config-gtk ?= "${AUTOREV}" |
| 11195 | SRCREV_pn-matchbox-desktop ?= "${AUTOREV}" |
| 11196 | SRCREV_pn-matchbox-keyboard ?= "${AUTOREV}" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 11197 | SRCREV_pn-matchbox-panel-2 ?= "${AUTOREV}" |
| 11198 | SRCREV_pn-matchbox-themes-extra ?= "${AUTOREV}" |
| 11199 | SRCREV_pn-matchbox-terminal ?= "${AUTOREV}" |
| 11200 | SRCREV_pn-matchbox-wm ?= "${AUTOREV}" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 11201 | SRCREV_pn-settings-daemon ?= "${AUTOREV}" |
| 11202 | SRCREV_pn-screenshot ?= "${AUTOREV}" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 11203 | . |
| 11204 | . |
| 11205 | . |
| 11206 | </literallayout> |
| 11207 | These lines allow you to experiment with building a |
| 11208 | distribution that tracks the latest development source |
| 11209 | for numerous packages. |
| 11210 | <note><title>Caution</title> |
| 11211 | The <filename>poky-bleeding</filename> distribution |
| 11212 | is not tested on a regular basis. |
| 11213 | Keep this in mind if you use it. |
| 11214 | </note> |
| 11215 | </para> |
| 11216 | </section> |
| 11217 | |
| 11218 | <section id='creating-a-read-only-root-filesystem'> |
| 11219 | <title>Creating a Read-Only Root Filesystem</title> |
| 11220 | |
| 11221 | <para> |
| 11222 | Suppose, for security reasons, you need to disable |
| 11223 | your target device's root filesystem's write permissions |
| 11224 | (i.e. you need a read-only root filesystem). |
| 11225 | Or, perhaps you are running the device's operating system |
| 11226 | from a read-only storage device. |
| 11227 | For either case, you can customize your image for |
| 11228 | that behavior. |
| 11229 | </para> |
| 11230 | |
| 11231 | <note> |
| 11232 | Supporting a read-only root filesystem requires that the system and |
| 11233 | applications do not try to write to the root filesystem. |
| 11234 | You must configure all parts of the target system to write |
| 11235 | elsewhere, or to gracefully fail in the event of attempting to |
| 11236 | write to the root filesystem. |
| 11237 | </note> |
| 11238 | |
| 11239 | <section id='creating-the-root-filesystem'> |
| 11240 | <title>Creating the Root Filesystem</title> |
| 11241 | |
| 11242 | <para> |
| 11243 | To create the read-only root filesystem, simply add the |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 11244 | "read-only-rootfs" feature to your image, normally in one of two ways. |
| 11245 | The first way is to add the "read-only-rootfs" image feature |
| 11246 | in the image's recipe file via the |
| 11247 | <filename>IMAGE_FEATURES</filename> variable: |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 11248 | <literallayout class='monospaced'> |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 11249 | IMAGE_FEATURES += "read-only-rootfs" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 11250 | </literallayout> |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 11251 | As an alternative, you can add the same feature from within your |
| 11252 | build directory's <filename>local.conf</filename> file with the |
| 11253 | associated <filename>EXTRA_IMAGE_FEATURES</filename> variable, as in: |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 11254 | <literallayout class='monospaced'> |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 11255 | EXTRA_IMAGE_FEATURES = "read-only-rootfs" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 11256 | </literallayout> |
| 11257 | </para> |
| 11258 | |
| 11259 | <para> |
| 11260 | For more information on how to use these variables, see the |
| 11261 | "<link linkend='usingpoky-extend-customimage-imagefeatures'>Customizing Images Using Custom <filename>IMAGE_FEATURES</filename> and <filename>EXTRA_IMAGE_FEATURES</filename></link>" |
| 11262 | section. |
| 11263 | For information on the variables, see |
| 11264 | <ulink url='&YOCTO_DOCS_REF_URL;#var-IMAGE_FEATURES'><filename>IMAGE_FEATURES</filename></ulink> |
| 11265 | and <ulink url='&YOCTO_DOCS_REF_URL;#var-EXTRA_IMAGE_FEATURES'><filename>EXTRA_IMAGE_FEATURES</filename></ulink>. |
| 11266 | </para> |
| 11267 | </section> |
| 11268 | |
| 11269 | <section id='post-installation-scripts'> |
| 11270 | <title>Post-Installation Scripts</title> |
| 11271 | |
| 11272 | <para> |
| 11273 | It is very important that you make sure all |
| 11274 | post-Installation (<filename>pkg_postinst</filename>) scripts |
| 11275 | for packages that are installed into the image can be run |
| 11276 | at the time when the root filesystem is created during the |
| 11277 | build on the host system. |
| 11278 | These scripts cannot attempt to run during first-boot on the |
| 11279 | target device. |
| 11280 | With the "read-only-rootfs" feature enabled, |
| 11281 | the build system checks during root filesystem creation to make |
| 11282 | sure all post-installation scripts succeed. |
| 11283 | If any of these scripts still need to be run after the root |
| 11284 | filesystem is created, the build immediately fails. |
| 11285 | These build-time checks ensure that the build fails |
| 11286 | rather than the target device fails later during its |
| 11287 | initial boot operation. |
| 11288 | </para> |
| 11289 | |
| 11290 | <para> |
| 11291 | Most of the common post-installation scripts generated by the |
| 11292 | build system for the out-of-the-box Yocto Project are engineered |
| 11293 | so that they can run during root filesystem creation |
| 11294 | (e.g. post-installation scripts for caching fonts). |
| 11295 | However, if you create and add custom scripts, you need |
| 11296 | to be sure they can be run during this file system creation. |
| 11297 | </para> |
| 11298 | |
| 11299 | <para> |
| 11300 | Here are some common problems that prevent |
| 11301 | post-installation scripts from running during root filesystem |
| 11302 | creation: |
| 11303 | <itemizedlist> |
| 11304 | <listitem><para> |
| 11305 | <emphasis>Not using $D in front of absolute |
| 11306 | paths:</emphasis> |
| 11307 | The build system defines |
| 11308 | <filename>$</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-D'><filename>D</filename></ulink> |
| 11309 | when the root filesystem is created. |
| 11310 | Furthermore, <filename>$D</filename> is blank when the |
| 11311 | script is run on the target device. |
| 11312 | This implies two purposes for <filename>$D</filename>: |
| 11313 | ensuring paths are valid in both the host and target |
| 11314 | environments, and checking to determine which |
| 11315 | environment is being used as a method for taking |
| 11316 | appropriate actions. |
| 11317 | </para></listitem> |
| 11318 | <listitem><para> |
| 11319 | <emphasis>Attempting to run processes that are |
| 11320 | specific to or dependent on the target |
| 11321 | architecture:</emphasis> |
| 11322 | You can work around these attempts by using native |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 11323 | tools, which run on the host system, |
| 11324 | to accomplish the same tasks, or |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 11325 | by alternatively running the processes under QEMU, |
| 11326 | which has the <filename>qemu_run_binary</filename> |
| 11327 | function. |
| 11328 | For more information, see the |
| 11329 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-qemu'><filename>qemu</filename></ulink> |
| 11330 | class.</para></listitem> |
| 11331 | </itemizedlist> |
| 11332 | </para> |
| 11333 | </section> |
| 11334 | |
| 11335 | <section id='areas-with-write-access'> |
| 11336 | <title>Areas With Write Access</title> |
| 11337 | |
| 11338 | <para> |
| 11339 | With the "read-only-rootfs" feature enabled, |
| 11340 | any attempt by the target to write to the root filesystem at |
| 11341 | runtime fails. |
| 11342 | Consequently, you must make sure that you configure processes |
| 11343 | and applications that attempt these types of writes do so |
| 11344 | to directories with write access (e.g. |
| 11345 | <filename>/tmp</filename> or <filename>/var/run</filename>). |
| 11346 | </para> |
| 11347 | </section> |
| 11348 | </section> |
| 11349 | |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 11350 | |
| 11351 | |
| 11352 | |
| 11353 | <section id='maintaining-build-output-quality'> |
| 11354 | <title>Maintaining Build Output Quality</title> |
| 11355 | |
| 11356 | <para> |
| 11357 | Many factors can influence the quality of a build. |
| 11358 | For example, if you upgrade a recipe to use a new version of an |
| 11359 | upstream software package or you experiment with some new |
| 11360 | configuration options, subtle changes can occur that you might |
| 11361 | not detect until later. |
| 11362 | Consider the case where your recipe is using a newer version of |
| 11363 | an upstream package. |
| 11364 | In this case, a new version of a piece of software might |
| 11365 | introduce an optional dependency on another library, which is |
| 11366 | auto-detected. |
| 11367 | If that library has already been built when the software is |
| 11368 | building, the software will link to the built library and that |
| 11369 | library will be pulled into your image along with the new |
| 11370 | software even if you did not want the library. |
| 11371 | </para> |
| 11372 | |
| 11373 | <para> |
| 11374 | The |
| 11375 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-buildhistory'><filename>buildhistory</filename></ulink> |
| 11376 | class exists to help you maintain the quality of your build |
| 11377 | output. |
| 11378 | You can use the class to highlight unexpected and possibly |
| 11379 | unwanted changes in the build output. |
| 11380 | When you enable build history, it records information about the |
| 11381 | contents of each package and image and then commits that |
| 11382 | information to a local Git repository where you can examine |
| 11383 | the information. |
| 11384 | </para> |
| 11385 | |
| 11386 | <para> |
| 11387 | The remainder of this section describes the following: |
| 11388 | <itemizedlist> |
| 11389 | <listitem><para> |
| 11390 | How you can enable and disable build history |
| 11391 | </para></listitem> |
| 11392 | <listitem><para> |
| 11393 | How to understand what the build history contains |
| 11394 | </para></listitem> |
| 11395 | <listitem><para> |
| 11396 | How to limit the information used for build history |
| 11397 | </para></listitem> |
| 11398 | <listitem><para> |
| 11399 | How to examine the build history from both a |
| 11400 | command-line and web interface |
| 11401 | </para></listitem> |
| 11402 | </itemizedlist> |
| 11403 | </para> |
| 11404 | |
| 11405 | <section id='enabling-and-disabling-build-history'> |
| 11406 | <title>Enabling and Disabling Build History</title> |
| 11407 | |
| 11408 | <para> |
| 11409 | Build history is disabled by default. |
| 11410 | To enable it, add the following <filename>INHERIT</filename> |
| 11411 | statement and set the |
| 11412 | <ulink url='&YOCTO_DOCS_REF_URL;#var-BUILDHISTORY_COMMIT'><filename>BUILDHISTORY_COMMIT</filename></ulink> |
| 11413 | variable to "1" at the end of your |
| 11414 | <filename>conf/local.conf</filename> file found in the |
| 11415 | <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink>: |
| 11416 | <literallayout class='monospaced'> |
| 11417 | INHERIT += "buildhistory" |
| 11418 | BUILDHISTORY_COMMIT = "1" |
| 11419 | </literallayout> |
| 11420 | Enabling build history as previously described causes the |
| 11421 | OpenEmbedded build system to collect build output information |
| 11422 | and commit it as a single commit to a local |
| 11423 | <ulink url='&YOCTO_DOCS_OM_URL;#git'>Git</ulink> |
| 11424 | repository. |
| 11425 | <note> |
| 11426 | Enabling build history increases your build times slightly, |
| 11427 | particularly for images, and increases the amount of disk |
| 11428 | space used during the build. |
| 11429 | </note> |
| 11430 | </para> |
| 11431 | |
| 11432 | <para> |
| 11433 | You can disable build history by removing the previous |
| 11434 | statements from your <filename>conf/local.conf</filename> |
| 11435 | file. |
| 11436 | </para> |
| 11437 | </section> |
| 11438 | |
| 11439 | <section id='understanding-what-the-build-history-contains'> |
| 11440 | <title>Understanding What the Build History Contains</title> |
| 11441 | |
| 11442 | <para> |
| 11443 | Build history information is kept in |
| 11444 | <filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-TOPDIR'><filename>TOPDIR</filename></ulink><filename>}/buildhistory</filename> |
| 11445 | in the Build Directory as defined by the |
| 11446 | <ulink url='&YOCTO_DOCS_REF_URL;#var-BUILDHISTORY_DIR'><filename>BUILDHISTORY_DIR</filename></ulink> |
| 11447 | variable. |
| 11448 | The following is an example abbreviated listing: |
| 11449 | <imagedata fileref="figures/buildhistory.png" align="center" width="6in" depth="4in" /> |
| 11450 | </para> |
| 11451 | |
| 11452 | <para> |
| 11453 | At the top level, a <filename>metadata-revs</filename> |
| 11454 | file exists that lists the revisions of the repositories for |
| 11455 | the enabled layers when the build was produced. |
| 11456 | The rest of the data splits into separate |
| 11457 | <filename>packages</filename>, <filename>images</filename> |
| 11458 | and <filename>sdk</filename> directories, the contents of |
| 11459 | which are described as follows. |
| 11460 | </para> |
| 11461 | |
| 11462 | <section id='build-history-package-information'> |
| 11463 | <title>Build History Package Information</title> |
| 11464 | |
| 11465 | <para> |
| 11466 | The history for each package contains a text file that has |
| 11467 | name-value pairs with information about the package. |
| 11468 | For example, |
| 11469 | <filename>buildhistory/packages/i586-poky-linux/busybox/busybox/latest</filename> |
| 11470 | contains the following: |
| 11471 | <literallayout class='monospaced'> |
| 11472 | PV = 1.22.1 |
| 11473 | PR = r32 |
| 11474 | RPROVIDES = |
| 11475 | RDEPENDS = glibc (>= 2.20) update-alternatives-opkg |
| 11476 | RRECOMMENDS = busybox-syslog busybox-udhcpc update-rc.d |
| 11477 | PKGSIZE = 540168 |
| 11478 | FILES = /usr/bin/* /usr/sbin/* /usr/lib/busybox/* /usr/lib/lib*.so.* \ |
| 11479 | /etc /com /var /bin/* /sbin/* /lib/*.so.* /lib/udev/rules.d \ |
| 11480 | /usr/lib/udev/rules.d /usr/share/busybox /usr/lib/busybox/* \ |
| 11481 | /usr/share/pixmaps /usr/share/applications /usr/share/idl \ |
| 11482 | /usr/share/omf /usr/share/sounds /usr/lib/bonobo/servers |
| 11483 | FILELIST = /bin/busybox /bin/busybox.nosuid /bin/busybox.suid /bin/sh \ |
| 11484 | /etc/busybox.links.nosuid /etc/busybox.links.suid |
| 11485 | </literallayout> |
| 11486 | Most of these name-value pairs correspond to variables |
| 11487 | used to produce the package. |
| 11488 | The exceptions are <filename>FILELIST</filename>, which |
| 11489 | is the actual list of files in the package, and |
| 11490 | <filename>PKGSIZE</filename>, which is the total size of |
| 11491 | files in the package in bytes. |
| 11492 | </para> |
| 11493 | |
| 11494 | <para> |
| 11495 | A file also exists that corresponds to the recipe from |
| 11496 | which the package came (e.g. |
| 11497 | <filename>buildhistory/packages/i586-poky-linux/busybox/latest</filename>): |
| 11498 | <literallayout class='monospaced'> |
| 11499 | PV = 1.22.1 |
| 11500 | PR = r32 |
| 11501 | DEPENDS = initscripts kern-tools-native update-rc.d-native \ |
| 11502 | virtual/i586-poky-linux-compilerlibs virtual/i586-poky-linux-gcc \ |
| 11503 | virtual/libc virtual/update-alternatives |
| 11504 | PACKAGES = busybox-ptest busybox-httpd busybox-udhcpd busybox-udhcpc \ |
| 11505 | busybox-syslog busybox-mdev busybox-hwclock busybox-dbg \ |
| 11506 | busybox-staticdev busybox-dev busybox-doc busybox-locale busybox |
| 11507 | </literallayout> |
| 11508 | </para> |
| 11509 | |
| 11510 | <para> |
| 11511 | Finally, for those recipes fetched from a version control |
| 11512 | system (e.g., Git), a file exists that lists source |
| 11513 | revisions that are specified in the recipe and lists |
| 11514 | the actual revisions used during the build. |
| 11515 | Listed and actual revisions might differ when |
| 11516 | <ulink url='&YOCTO_DOCS_REF_URL;#var-SRCREV'><filename>SRCREV</filename></ulink> |
| 11517 | is set to |
| 11518 | ${<ulink url='&YOCTO_DOCS_REF_URL;#var-AUTOREV'><filename>AUTOREV</filename></ulink>}. |
| 11519 | Here is an example assuming |
| 11520 | <filename>buildhistory/packages/qemux86-poky-linux/linux-yocto/latest_srcrev</filename>): |
| 11521 | <literallayout class='monospaced'> |
| 11522 | # SRCREV_machine = "38cd560d5022ed2dbd1ab0dca9642e47c98a0aa1" |
| 11523 | SRCREV_machine = "38cd560d5022ed2dbd1ab0dca9642e47c98a0aa1" |
| 11524 | # SRCREV_meta = "a227f20eff056e511d504b2e490f3774ab260d6f" |
| 11525 | SRCREV_meta = "a227f20eff056e511d504b2e490f3774ab260d6f" |
| 11526 | </literallayout> |
| 11527 | You can use the |
| 11528 | <filename>buildhistory-collect-srcrevs</filename> |
| 11529 | command with the <filename>-a</filename> option to |
| 11530 | collect the stored <filename>SRCREV</filename> values |
| 11531 | from build history and report them in a format suitable for |
| 11532 | use in global configuration (e.g., |
| 11533 | <filename>local.conf</filename> or a distro include file) |
| 11534 | to override floating <filename>AUTOREV</filename> values |
| 11535 | to a fixed set of revisions. |
| 11536 | Here is some example output from this command: |
| 11537 | <literallayout class='monospaced'> |
| 11538 | $ buildhistory-collect-srcrevs -a |
| 11539 | # i586-poky-linux |
| 11540 | SRCREV_pn-glibc = "b8079dd0d360648e4e8de48656c5c38972621072" |
| 11541 | SRCREV_pn-glibc-initial = "b8079dd0d360648e4e8de48656c5c38972621072" |
| 11542 | SRCREV_pn-opkg-utils = "53274f087565fd45d8452c5367997ba6a682a37a" |
| 11543 | SRCREV_pn-kmod = "fd56638aed3fe147015bfa10ed4a5f7491303cb4" |
| 11544 | # x86_64-linux |
| 11545 | SRCREV_pn-gtk-doc-stub-native = "1dea266593edb766d6d898c79451ef193eb17cfa" |
| 11546 | SRCREV_pn-dtc-native = "65cc4d2748a2c2e6f27f1cf39e07a5dbabd80ebf" |
| 11547 | SRCREV_pn-update-rc.d-native = "eca680ddf28d024954895f59a241a622dd575c11" |
| 11548 | SRCREV_glibc_pn-cross-localedef-native = "b8079dd0d360648e4e8de48656c5c38972621072" |
| 11549 | SRCREV_localedef_pn-cross-localedef-native = "c833367348d39dad7ba018990bfdaffaec8e9ed3" |
| 11550 | SRCREV_pn-prelink-native = "faa069deec99bf61418d0bab831c83d7c1b797ca" |
| 11551 | SRCREV_pn-opkg-utils-native = "53274f087565fd45d8452c5367997ba6a682a37a" |
| 11552 | SRCREV_pn-kern-tools-native = "23345b8846fe4bd167efdf1bd8a1224b2ba9a5ff" |
| 11553 | SRCREV_pn-kmod-native = "fd56638aed3fe147015bfa10ed4a5f7491303cb4" |
| 11554 | # qemux86-poky-linux |
| 11555 | SRCREV_machine_pn-linux-yocto = "38cd560d5022ed2dbd1ab0dca9642e47c98a0aa1" |
| 11556 | SRCREV_meta_pn-linux-yocto = "a227f20eff056e511d504b2e490f3774ab260d6f" |
| 11557 | # all-poky-linux |
| 11558 | SRCREV_pn-update-rc.d = "eca680ddf28d024954895f59a241a622dd575c11" |
| 11559 | </literallayout> |
| 11560 | <note> |
| 11561 | Here are some notes on using the |
| 11562 | <filename>buildhistory-collect-srcrevs</filename> |
| 11563 | command: |
| 11564 | <itemizedlist> |
| 11565 | <listitem><para> |
| 11566 | By default, only values where the |
| 11567 | <filename>SRCREV</filename> was not hardcoded |
| 11568 | (usually when <filename>AUTOREV</filename> |
| 11569 | is used) are reported. |
| 11570 | Use the <filename>-a</filename> option to |
| 11571 | see all <filename>SRCREV</filename> values. |
| 11572 | </para></listitem> |
| 11573 | <listitem><para> |
| 11574 | The output statements might not have any effect |
| 11575 | if overrides are applied elsewhere in the |
| 11576 | build system configuration. |
| 11577 | Use the <filename>-f</filename> option to add |
| 11578 | the <filename>forcevariable</filename> override |
| 11579 | to each output line if you need to work around |
| 11580 | this restriction. |
| 11581 | </para></listitem> |
| 11582 | <listitem><para> |
| 11583 | The script does apply special handling when |
| 11584 | building for multiple machines. |
| 11585 | However, the script does place a comment before |
| 11586 | each set of values that specifies which |
| 11587 | triplet to which they belong as previously |
| 11588 | shown (e.g., |
| 11589 | <filename>i586-poky-linux</filename>). |
| 11590 | </para></listitem> |
| 11591 | </itemizedlist> |
| 11592 | </note> |
| 11593 | </para> |
| 11594 | </section> |
| 11595 | |
| 11596 | <section id='build-history-image-information'> |
| 11597 | <title>Build History Image Information</title> |
| 11598 | |
| 11599 | <para> |
| 11600 | The files produced for each image are as follows: |
| 11601 | <itemizedlist> |
| 11602 | <listitem><para> |
| 11603 | <filename>image-files:</filename> |
| 11604 | A directory containing selected files from the root |
| 11605 | filesystem. |
| 11606 | The files are defined by |
| 11607 | <ulink url='&YOCTO_DOCS_REF_URL;#var-BUILDHISTORY_IMAGE_FILES'><filename>BUILDHISTORY_IMAGE_FILES</filename></ulink>. |
| 11608 | </para></listitem> |
| 11609 | <listitem><para> |
| 11610 | <filename>build-id.txt:</filename> |
| 11611 | Human-readable information about the build |
| 11612 | configuration and metadata source revisions. |
| 11613 | This file contains the full build header as printed |
| 11614 | by BitBake. |
| 11615 | </para></listitem> |
| 11616 | <listitem><para> |
| 11617 | <filename>*.dot:</filename> |
| 11618 | Dependency graphs for the image that are |
| 11619 | compatible with <filename>graphviz</filename>. |
| 11620 | </para></listitem> |
| 11621 | <listitem><para> |
| 11622 | <filename>files-in-image.txt:</filename> |
| 11623 | A list of files in the image with permissions, |
| 11624 | owner, group, size, and symlink information. |
| 11625 | </para></listitem> |
| 11626 | <listitem><para> |
| 11627 | <filename>image-info.txt:</filename> |
| 11628 | A text file containing name-value pairs with |
| 11629 | information about the image. |
| 11630 | See the following listing example for more |
| 11631 | information. |
| 11632 | </para></listitem> |
| 11633 | <listitem><para> |
| 11634 | <filename>installed-package-names.txt:</filename> |
| 11635 | A list of installed packages by name only. |
| 11636 | </para></listitem> |
| 11637 | <listitem><para> |
| 11638 | <filename>installed-package-sizes.txt:</filename> |
| 11639 | A list of installed packages ordered by size. |
| 11640 | </para></listitem> |
| 11641 | <listitem><para> |
| 11642 | <filename>installed-packages.txt:</filename> |
| 11643 | A list of installed packages with full package |
| 11644 | filenames. |
| 11645 | </para></listitem> |
| 11646 | </itemizedlist> |
| 11647 | <note> |
| 11648 | Installed package information is able to be gathered |
| 11649 | and produced even if package management is disabled |
| 11650 | for the final image. |
| 11651 | </note> |
| 11652 | </para> |
| 11653 | |
| 11654 | <para> |
| 11655 | Here is an example of <filename>image-info.txt</filename>: |
| 11656 | <literallayout class='monospaced'> |
| 11657 | DISTRO = poky |
| 11658 | DISTRO_VERSION = 1.7 |
| 11659 | USER_CLASSES = buildstats image-mklibs image-prelink |
| 11660 | IMAGE_CLASSES = image_types |
| 11661 | IMAGE_FEATURES = debug-tweaks |
| 11662 | IMAGE_LINGUAS = |
| 11663 | IMAGE_INSTALL = packagegroup-core-boot run-postinsts |
| 11664 | BAD_RECOMMENDATIONS = |
| 11665 | NO_RECOMMENDATIONS = |
| 11666 | PACKAGE_EXCLUDE = |
| 11667 | ROOTFS_POSTPROCESS_COMMAND = write_package_manifest; license_create_manifest; \ |
| 11668 | write_image_manifest ; buildhistory_list_installed_image ; \ |
| 11669 | buildhistory_get_image_installed ; ssh_allow_empty_password; \ |
| 11670 | postinst_enable_logging; rootfs_update_timestamp ; ssh_disable_dns_lookup ; |
| 11671 | IMAGE_POSTPROCESS_COMMAND = buildhistory_get_imageinfo ; |
| 11672 | IMAGESIZE = 6900 |
| 11673 | </literallayout> |
| 11674 | Other than <filename>IMAGESIZE</filename>, which is the |
| 11675 | total size of the files in the image in Kbytes, the |
| 11676 | name-value pairs are variables that may have influenced the |
| 11677 | content of the image. |
| 11678 | This information is often useful when you are trying to |
| 11679 | determine why a change in the package or file |
| 11680 | listings has occurred. |
| 11681 | </para> |
| 11682 | </section> |
| 11683 | |
| 11684 | <section id='using-build-history-to-gather-image-information-only'> |
| 11685 | <title>Using Build History to Gather Image Information Only</title> |
| 11686 | |
| 11687 | <para> |
| 11688 | As you can see, build history produces image information, |
| 11689 | including dependency graphs, so you can see why something |
| 11690 | was pulled into the image. |
| 11691 | If you are just interested in this information and not |
| 11692 | interested in collecting specific package or SDK |
| 11693 | information, you can enable writing only image information |
| 11694 | without any history by adding the following to your |
| 11695 | <filename>conf/local.conf</filename> file found in the |
| 11696 | <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink>: |
| 11697 | <literallayout class='monospaced'> |
| 11698 | INHERIT += "buildhistory" |
| 11699 | BUILDHISTORY_COMMIT = "0" |
| 11700 | BUILDHISTORY_FEATURES = "image" |
| 11701 | </literallayout> |
| 11702 | Here, you set the |
| 11703 | <ulink url='&YOCTO_DOCS_REF_URL;#var-BUILDHISTORY_FEATURES'><filename>BUILDHISTORY_FEATURES</filename></ulink> |
| 11704 | variable to use the image feature only. |
| 11705 | </para> |
| 11706 | </section> |
| 11707 | |
| 11708 | <section id='build-history-sdk-information'> |
| 11709 | <title>Build History SDK Information</title> |
| 11710 | |
| 11711 | <para> |
| 11712 | Build history collects similar information on the contents |
| 11713 | of SDKs |
| 11714 | (e.g. <filename>bitbake -c populate_sdk imagename</filename>) |
| 11715 | as compared to information it collects for images. |
| 11716 | Furthermore, this information differs depending on whether |
| 11717 | an extensible or standard SDK is being produced. |
| 11718 | </para> |
| 11719 | |
| 11720 | <para> |
| 11721 | The following list shows the files produced for SDKs: |
| 11722 | <itemizedlist> |
| 11723 | <listitem><para> |
| 11724 | <filename>files-in-sdk.txt:</filename> |
| 11725 | A list of files in the SDK with permissions, |
| 11726 | owner, group, size, and symlink information. |
| 11727 | This list includes both the host and target parts |
| 11728 | of the SDK. |
| 11729 | </para></listitem> |
| 11730 | <listitem><para> |
| 11731 | <filename>sdk-info.txt:</filename> |
| 11732 | A text file containing name-value pairs with |
| 11733 | information about the SDK. |
| 11734 | See the following listing example for more |
| 11735 | information. |
| 11736 | </para></listitem> |
| 11737 | <listitem><para> |
| 11738 | <filename>sstate-task-sizes.txt:</filename> |
| 11739 | A text file containing name-value pairs with |
| 11740 | information about task group sizes |
| 11741 | (e.g. <filename>do_populate_sysroot</filename> |
| 11742 | tasks have a total size). |
| 11743 | The <filename>sstate-task-sizes.txt</filename> file |
| 11744 | exists only when an extensible SDK is created. |
| 11745 | </para></listitem> |
| 11746 | <listitem><para> |
| 11747 | <filename>sstate-package-sizes.txt:</filename> |
| 11748 | A text file containing name-value pairs with |
| 11749 | information for the shared-state packages and |
| 11750 | sizes in the SDK. |
| 11751 | The <filename>sstate-package-sizes.txt</filename> |
| 11752 | file exists only when an extensible SDK is created. |
| 11753 | </para></listitem> |
| 11754 | <listitem><para> |
| 11755 | <filename>sdk-files:</filename> |
| 11756 | A folder that contains copies of the files |
| 11757 | mentioned in |
| 11758 | <filename>BUILDHISTORY_SDK_FILES</filename> if the |
| 11759 | files are present in the output. |
| 11760 | Additionally, the default value of |
| 11761 | <filename>BUILDHISTORY_SDK_FILES</filename> is |
| 11762 | specific to the extensible SDK although you can |
| 11763 | set it differently if you would like to pull in |
| 11764 | specific files from the standard SDK.</para> |
| 11765 | |
| 11766 | <para>The default files are |
| 11767 | <filename>conf/local.conf</filename>, |
| 11768 | <filename>conf/bblayers.conf</filename>, |
| 11769 | <filename>conf/auto.conf</filename>, |
| 11770 | <filename>conf/locked-sigs.inc</filename>, and |
| 11771 | <filename>conf/devtool.conf</filename>. |
| 11772 | Thus, for an extensible SDK, these files get |
| 11773 | copied into the <filename>sdk-files</filename> |
| 11774 | directory. |
| 11775 | </para></listitem> |
| 11776 | <listitem><para> |
| 11777 | The following information appears under |
| 11778 | each of the <filename>host</filename> |
| 11779 | and <filename>target</filename> directories |
| 11780 | for the portions of the SDK that run on the host |
| 11781 | and on the target, respectively: |
| 11782 | <note> |
| 11783 | The following files for the most part are empty |
| 11784 | when producing an extensible SDK because this |
| 11785 | type of SDK is not constructed from packages |
| 11786 | as is the standard SDK. |
| 11787 | </note> |
| 11788 | <itemizedlist> |
| 11789 | <listitem><para> |
| 11790 | <filename>depends.dot:</filename> |
| 11791 | Dependency graph for the SDK that is |
| 11792 | compatible with |
| 11793 | <filename>graphviz</filename>. |
| 11794 | </para></listitem> |
| 11795 | <listitem><para> |
| 11796 | <filename>installed-package-names.txt:</filename> |
| 11797 | A list of installed packages by name only. |
| 11798 | </para></listitem> |
| 11799 | <listitem><para> |
| 11800 | <filename>installed-package-sizes.txt:</filename> |
| 11801 | A list of installed packages ordered by size. |
| 11802 | </para></listitem> |
| 11803 | <listitem><para> |
| 11804 | <filename>installed-packages.txt:</filename> |
| 11805 | A list of installed packages with full |
| 11806 | package filenames. |
| 11807 | </para></listitem> |
| 11808 | </itemizedlist> |
| 11809 | </para></listitem> |
| 11810 | </itemizedlist> |
| 11811 | </para> |
| 11812 | |
| 11813 | <para> |
| 11814 | Here is an example of <filename>sdk-info.txt</filename>: |
| 11815 | <literallayout class='monospaced'> |
| 11816 | DISTRO = poky |
| 11817 | DISTRO_VERSION = 1.3+snapshot-20130327 |
| 11818 | SDK_NAME = poky-glibc-i686-arm |
| 11819 | SDK_VERSION = 1.3+snapshot |
| 11820 | SDKMACHINE = |
| 11821 | SDKIMAGE_FEATURES = dev-pkgs dbg-pkgs |
| 11822 | BAD_RECOMMENDATIONS = |
| 11823 | SDKSIZE = 352712 |
| 11824 | </literallayout> |
| 11825 | Other than <filename>SDKSIZE</filename>, which is the |
| 11826 | total size of the files in the SDK in Kbytes, the |
| 11827 | name-value pairs are variables that might have influenced |
| 11828 | the content of the SDK. |
| 11829 | This information is often useful when you are trying to |
| 11830 | determine why a change in the package or file listings |
| 11831 | has occurred. |
| 11832 | </para> |
| 11833 | </section> |
| 11834 | |
| 11835 | <section id='examining-build-history-information'> |
| 11836 | <title>Examining Build History Information</title> |
| 11837 | |
| 11838 | <para> |
| 11839 | You can examine build history output from the command |
| 11840 | line or from a web interface. |
| 11841 | </para> |
| 11842 | |
| 11843 | <para> |
| 11844 | To see any changes that have occurred (assuming you have |
| 11845 | <ulink url='&YOCTO_DOCS_REF_URL;#var-BUILDHISTORY_COMMIT'><filename>BUILDHISTORY_COMMIT</filename></ulink><filename> = "1"</filename>), |
| 11846 | you can simply use any Git command that allows you to |
| 11847 | view the history of a repository. |
| 11848 | Here is one method: |
| 11849 | <literallayout class='monospaced'> |
| 11850 | $ git log -p |
| 11851 | </literallayout> |
| 11852 | You need to realize, however, that this method does show |
| 11853 | changes that are not significant (e.g. a package's size |
| 11854 | changing by a few bytes). |
| 11855 | </para> |
| 11856 | |
| 11857 | <para> |
| 11858 | A command-line tool called |
| 11859 | <filename>buildhistory-diff</filename> does exist, though, |
| 11860 | that queries the Git repository and prints just the |
| 11861 | differences that might be significant in human-readable |
| 11862 | form. |
| 11863 | Here is an example: |
| 11864 | <literallayout class='monospaced'> |
| 11865 | $ ~/poky/poky/scripts/buildhistory-diff . HEAD^ |
| 11866 | Changes to images/qemux86_64/glibc/core-image-minimal (files-in-image.txt): |
| 11867 | /etc/anotherpkg.conf was added |
| 11868 | /sbin/anotherpkg was added |
| 11869 | * (installed-package-names.txt): |
| 11870 | * anotherpkg was added |
| 11871 | Changes to images/qemux86_64/glibc/core-image-minimal (installed-package-names.txt): |
| 11872 | anotherpkg was added |
| 11873 | packages/qemux86_64-poky-linux/v86d: PACKAGES: added "v86d-extras" |
| 11874 | * PR changed from "r0" to "r1" |
| 11875 | * PV changed from "0.1.10" to "0.1.12" |
| 11876 | packages/qemux86_64-poky-linux/v86d/v86d: PKGSIZE changed from 110579 to 144381 (+30%) |
| 11877 | * PR changed from "r0" to "r1" |
| 11878 | * PV changed from "0.1.10" to "0.1.12" |
| 11879 | </literallayout> |
| 11880 | <note> |
| 11881 | The <filename>buildhistory-diff</filename> tool |
| 11882 | requires the <filename>GitPython</filename> package. |
| 11883 | Be sure to install it using Pip3 as follows: |
| 11884 | <literallayout class='monospaced'> |
| 11885 | $ pip3 install GitPython --user |
| 11886 | </literallayout> |
| 11887 | Alternatively, you can install |
| 11888 | <filename>python3-git</filename> using the appropriate |
| 11889 | distribution package manager (e.g. |
| 11890 | <filename>apt-get</filename>, <filename>dnf</filename>, |
| 11891 | or <filename>zipper</filename>). |
| 11892 | </note> |
| 11893 | </para> |
| 11894 | |
| 11895 | <para> |
| 11896 | To see changes to the build history using a web interface, |
| 11897 | follow the instruction in the <filename>README</filename> |
| 11898 | file here. |
| 11899 | <ulink url='http://git.yoctoproject.org/cgit/cgit.cgi/buildhistory-web/'></ulink>. |
| 11900 | </para> |
| 11901 | |
| 11902 | <para> |
| 11903 | Here is a sample screenshot of the interface: |
| 11904 | <imagedata fileref="figures/buildhistory-web.png" align="center" scalefit="1" width="130%" contentdepth="130%" /> |
| 11905 | </para> |
| 11906 | </section> |
| 11907 | </section> |
| 11908 | </section> |
| 11909 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 11910 | <section id="performing-automated-runtime-testing"> |
| 11911 | <title>Performing Automated Runtime Testing</title> |
| 11912 | |
| 11913 | <para> |
| 11914 | The OpenEmbedded build system makes available a series of automated |
| 11915 | tests for images to verify runtime functionality. |
| 11916 | You can run these tests on either QEMU or actual target hardware. |
| 11917 | Tests are written in Python making use of the |
| 11918 | <filename>unittest</filename> module, and the majority of them |
| 11919 | run commands on the target system over SSH. |
| 11920 | This section describes how you set up the environment to use these |
| 11921 | tests, run available tests, and write and add your own tests. |
| 11922 | </para> |
| 11923 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 11924 | <para> |
| 11925 | For information on the test and QA infrastructure available |
| 11926 | within the Yocto Project, see the |
| 11927 | "<ulink url='&YOCTO_DOCS_REF_URL;#testing-and-quality-assurance'>Testing and Quality Assurance</ulink>" |
| 11928 | section in the Yocto Project Reference Manual. |
| 11929 | </para> |
| 11930 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 11931 | <section id='enabling-tests'> |
| 11932 | <title>Enabling Tests</title> |
| 11933 | |
| 11934 | <para> |
| 11935 | Depending on whether you are planning to run tests using |
| 11936 | QEMU or on the hardware, you have to take |
| 11937 | different steps to enable the tests. |
| 11938 | See the following subsections for information on how to |
| 11939 | enable both types of tests. |
| 11940 | </para> |
| 11941 | |
| 11942 | <section id='qemu-image-enabling-tests'> |
| 11943 | <title>Enabling Runtime Tests on QEMU</title> |
| 11944 | |
| 11945 | <para> |
| 11946 | In order to run tests, you need to do the following: |
| 11947 | <itemizedlist> |
| 11948 | <listitem><para><emphasis>Set up to avoid interaction |
| 11949 | with <filename>sudo</filename> for networking:</emphasis> |
| 11950 | To accomplish this, you must do one of the |
| 11951 | following: |
| 11952 | <itemizedlist> |
| 11953 | <listitem><para>Add |
| 11954 | <filename>NOPASSWD</filename> for your user |
| 11955 | in <filename>/etc/sudoers</filename> either for |
| 11956 | all commands or just for |
| 11957 | <filename>runqemu-ifup</filename>. |
| 11958 | You must provide the full path as that can |
| 11959 | change if you are using multiple clones of the |
| 11960 | source repository. |
| 11961 | <note> |
| 11962 | On some distributions, you also need to |
| 11963 | comment out "Defaults requiretty" in |
| 11964 | <filename>/etc/sudoers</filename>. |
| 11965 | </note></para></listitem> |
| 11966 | <listitem><para>Manually configure a tap interface |
| 11967 | for your system.</para></listitem> |
| 11968 | <listitem><para>Run as root the script in |
| 11969 | <filename>scripts/runqemu-gen-tapdevs</filename>, |
| 11970 | which should generate a list of tap devices. |
| 11971 | This is the option typically chosen for |
| 11972 | Autobuilder-type environments. |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 11973 | <note><title>Notes</title> |
| 11974 | <itemizedlist> |
| 11975 | <listitem><para> |
| 11976 | Be sure to use an absolute path |
| 11977 | when calling this script |
| 11978 | with sudo. |
| 11979 | </para></listitem> |
| 11980 | <listitem><para> |
| 11981 | The package recipe |
| 11982 | <filename>qemu-helper-native</filename> |
| 11983 | is required to run this script. |
| 11984 | Build the package using the |
| 11985 | following command: |
| 11986 | <literallayout class='monospaced'> |
| 11987 | $ bitbake qemu-helper-native |
| 11988 | </literallayout> |
| 11989 | </para></listitem> |
| 11990 | </itemizedlist> |
| 11991 | </note> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 11992 | </para></listitem> |
| 11993 | </itemizedlist></para></listitem> |
| 11994 | <listitem><para><emphasis>Set the |
| 11995 | <filename>DISPLAY</filename> variable:</emphasis> |
| 11996 | You need to set this variable so that you have an X |
| 11997 | server available (e.g. start |
| 11998 | <filename>vncserver</filename> for a headless machine). |
| 11999 | </para></listitem> |
| 12000 | <listitem><para><emphasis>Be sure your host's firewall |
| 12001 | accepts incoming connections from |
| 12002 | 192.168.7.0/24:</emphasis> |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 12003 | Some of the tests (in particular DNF tests) start |
| 12004 | an HTTP server on a random high number port, |
| 12005 | which is used to serve files to the target. |
| 12006 | The DNF module serves |
| 12007 | <filename>${WORKDIR}/oe-rootfs-repo</filename> |
| 12008 | so it can run DNF channel commands. |
| 12009 | That means your host's firewall |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 12010 | must accept incoming connections from 192.168.7.0/24, |
| 12011 | which is the default IP range used for tap devices |
| 12012 | by <filename>runqemu</filename>.</para></listitem> |
Patrick Williams | f1e5d69 | 2016-03-30 15:21:19 -0500 | [diff] [blame] | 12013 | <listitem><para><emphasis>Be sure your host has the |
| 12014 | correct packages installed:</emphasis> |
| 12015 | Depending your host's distribution, you need |
| 12016 | to have the following packages installed: |
| 12017 | <itemizedlist> |
| 12018 | <listitem><para>Ubuntu and Debian: |
| 12019 | <filename>sysstat</filename> and |
| 12020 | <filename>iproute2</filename> |
| 12021 | </para></listitem> |
| 12022 | <listitem><para>OpenSUSE: |
| 12023 | <filename>sysstat</filename> and |
| 12024 | <filename>iproute2</filename> |
| 12025 | </para></listitem> |
| 12026 | <listitem><para>Fedora: |
| 12027 | <filename>sysstat</filename> and |
| 12028 | <filename>iproute</filename> |
| 12029 | </para></listitem> |
| 12030 | <listitem><para>CentOS: |
| 12031 | <filename>sysstat</filename> and |
| 12032 | <filename>iproute</filename> |
| 12033 | </para></listitem> |
| 12034 | </itemizedlist> |
| 12035 | </para></listitem> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 12036 | </itemizedlist> |
| 12037 | </para> |
| 12038 | |
| 12039 | <para> |
| 12040 | Once you start running the tests, the following happens: |
| 12041 | <orderedlist> |
| 12042 | <listitem><para>A copy of the root filesystem is written |
| 12043 | to <filename>${WORKDIR}/testimage</filename>. |
| 12044 | </para></listitem> |
| 12045 | <listitem><para>The image is booted under QEMU using the |
| 12046 | standard <filename>runqemu</filename> script. |
| 12047 | </para></listitem> |
| 12048 | <listitem><para>A default timeout of 500 seconds occurs |
| 12049 | to allow for the boot process to reach the login prompt. |
| 12050 | You can change the timeout period by setting |
| 12051 | <ulink url='&YOCTO_DOCS_REF_URL;#var-TEST_QEMUBOOT_TIMEOUT'><filename>TEST_QEMUBOOT_TIMEOUT</filename></ulink> |
| 12052 | in the <filename>local.conf</filename> file. |
| 12053 | </para></listitem> |
| 12054 | <listitem><para>Once the boot process is reached and the |
| 12055 | login prompt appears, the tests run. |
| 12056 | The full boot log is written to |
| 12057 | <filename>${WORKDIR}/testimage/qemu_boot_log</filename>. |
| 12058 | </para></listitem> |
| 12059 | <listitem><para>Each test module loads in the order found |
| 12060 | in <filename>TEST_SUITES</filename>. |
| 12061 | You can find the full output of the commands run over |
| 12062 | SSH in |
| 12063 | <filename>${WORKDIR}/testimgage/ssh_target_log</filename>. |
| 12064 | </para></listitem> |
| 12065 | <listitem><para>If no failures occur, the task running the |
| 12066 | tests ends successfully. |
| 12067 | You can find the output from the |
| 12068 | <filename>unittest</filename> in the task log at |
| 12069 | <filename>${WORKDIR}/temp/log.do_testimage</filename>. |
| 12070 | </para></listitem> |
| 12071 | </orderedlist> |
| 12072 | </para> |
| 12073 | </section> |
| 12074 | |
| 12075 | <section id='hardware-image-enabling-tests'> |
| 12076 | <title>Enabling Runtime Tests on Hardware</title> |
| 12077 | |
| 12078 | <para> |
| 12079 | The OpenEmbedded build system can run tests on real |
| 12080 | hardware, and for certain devices it can also deploy |
| 12081 | the image to be tested onto the device beforehand. |
| 12082 | </para> |
| 12083 | |
| 12084 | <para> |
| 12085 | For automated deployment, a "master image" is installed |
| 12086 | onto the hardware once as part of setup. |
| 12087 | Then, each time tests are to be run, the following |
| 12088 | occurs: |
| 12089 | <orderedlist> |
| 12090 | <listitem><para>The master image is booted into and |
| 12091 | used to write the image to be tested to |
| 12092 | a second partition. |
| 12093 | </para></listitem> |
| 12094 | <listitem><para>The device is then rebooted using an |
| 12095 | external script that you need to provide. |
| 12096 | </para></listitem> |
| 12097 | <listitem><para>The device boots into the image to be |
| 12098 | tested. |
| 12099 | </para></listitem> |
| 12100 | </orderedlist> |
| 12101 | </para> |
| 12102 | |
| 12103 | <para> |
| 12104 | When running tests (independent of whether the image |
| 12105 | has been deployed automatically or not), the device is |
| 12106 | expected to be connected to a network on a |
| 12107 | pre-determined IP address. |
| 12108 | You can either use static IP addresses written into |
| 12109 | the image, or set the image to use DHCP and have your |
| 12110 | DHCP server on the test network assign a known IP address |
| 12111 | based on the MAC address of the device. |
| 12112 | </para> |
| 12113 | |
| 12114 | <para> |
| 12115 | In order to run tests on hardware, you need to set |
| 12116 | <filename>TEST_TARGET</filename> to an appropriate value. |
| 12117 | For QEMU, you do not have to change anything, the default |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 12118 | value is "qemu". |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 12119 | For running tests on hardware, the following options exist: |
| 12120 | <itemizedlist> |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 12121 | <listitem><para><emphasis>"simpleremote":</emphasis> |
| 12122 | Choose "simpleremote" if you are going to |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 12123 | run tests on a target system that is already |
| 12124 | running the image to be tested and is available |
| 12125 | on the network. |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 12126 | You can use "simpleremote" in conjunction |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 12127 | with either real hardware or an image running |
| 12128 | within a separately started QEMU or any |
| 12129 | other virtual machine manager. |
| 12130 | </para></listitem> |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 12131 | <listitem><para><emphasis>"SystemdbootTarget":</emphasis> |
| 12132 | Choose "SystemdbootTarget" if your hardware is |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 12133 | an EFI-based machine with |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 12134 | <filename>systemd-boot</filename> as bootloader and |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 12135 | <filename>core-image-testmaster</filename> |
| 12136 | (or something similar) is installed. |
| 12137 | Also, your hardware under test must be in a |
| 12138 | DHCP-enabled network that gives it the same IP |
| 12139 | address for each reboot.</para> |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 12140 | <para>If you choose "SystemdbootTarget", there are |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 12141 | additional requirements and considerations. |
| 12142 | See the |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 12143 | "<link linkend='selecting-systemdboottarget'>Selecting SystemdbootTarget</link>" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 12144 | section, which follows, for more information. |
| 12145 | </para></listitem> |
| 12146 | <listitem><para><emphasis>"BeagleBoneTarget":</emphasis> |
| 12147 | Choose "BeagleBoneTarget" if you are deploying |
| 12148 | images and running tests on the BeagleBone |
| 12149 | "Black" or original "White" hardware. |
| 12150 | For information on how to use these tests, see the |
| 12151 | comments at the top of the BeagleBoneTarget |
| 12152 | <filename>meta-yocto-bsp/lib/oeqa/controllers/beaglebonetarget.py</filename> |
| 12153 | file. |
| 12154 | </para></listitem> |
| 12155 | <listitem><para><emphasis>"EdgeRouterTarget":</emphasis> |
| 12156 | Choose "EdgeRouterTarget" is you are deploying |
| 12157 | images and running tests on the Ubiquiti Networks |
| 12158 | EdgeRouter Lite. |
| 12159 | For information on how to use these tests, see the |
| 12160 | comments at the top of the EdgeRouterTarget |
| 12161 | <filename>meta-yocto-bsp/lib/oeqa/controllers/edgeroutertarget.py</filename> |
| 12162 | file. |
| 12163 | </para></listitem> |
| 12164 | <listitem><para><emphasis>"GrubTarget":</emphasis> |
| 12165 | Choose the "supports deploying images and running |
| 12166 | tests on any generic PC that boots using GRUB. |
| 12167 | For information on how to use these tests, see the |
| 12168 | comments at the top of the GrubTarget |
| 12169 | <filename>meta-yocto-bsp/lib/oeqa/controllers/grubtarget.py</filename> |
| 12170 | file. |
| 12171 | </para></listitem> |
| 12172 | <listitem><para><emphasis>"<replaceable>your-target</replaceable>":</emphasis> |
| 12173 | Create your own custom target if you want to run |
| 12174 | tests when you are deploying images and running |
| 12175 | tests on a custom machine within your BSP layer. |
| 12176 | To do this, you need to add a Python unit that |
| 12177 | defines the target class under |
| 12178 | <filename>lib/oeqa/controllers/</filename> within |
| 12179 | your layer. |
| 12180 | You must also provide an empty |
| 12181 | <filename>__init__.py</filename>. |
| 12182 | For examples, see files in |
| 12183 | <filename>meta-yocto-bsp/lib/oeqa/controllers/</filename>. |
| 12184 | </para></listitem> |
| 12185 | </itemizedlist> |
| 12186 | </para> |
| 12187 | </section> |
| 12188 | |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 12189 | <section id='selecting-systemdboottarget'> |
| 12190 | <title>Selecting SystemdbootTarget</title> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 12191 | |
| 12192 | <para> |
| 12193 | If you did not set <filename>TEST_TARGET</filename> to |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 12194 | "SystemdbootTarget", then you do not need any information |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 12195 | in this section. |
| 12196 | You can skip down to the |
| 12197 | "<link linkend='qemu-image-running-tests'>Running Tests</link>" |
| 12198 | section. |
| 12199 | </para> |
| 12200 | |
| 12201 | <para> |
| 12202 | If you did set <filename>TEST_TARGET</filename> to |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 12203 | "SystemdbootTarget", you also need to perform a one-time |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 12204 | setup of your master image by doing the following: |
| 12205 | <orderedlist> |
| 12206 | <listitem><para><emphasis>Set <filename>EFI_PROVIDER</filename>:</emphasis> |
| 12207 | Be sure that <filename>EFI_PROVIDER</filename> |
| 12208 | is as follows: |
| 12209 | <literallayout class='monospaced'> |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 12210 | EFI_PROVIDER = "systemd-boot" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 12211 | </literallayout> |
| 12212 | </para></listitem> |
| 12213 | <listitem><para><emphasis>Build the master image:</emphasis> |
| 12214 | Build the <filename>core-image-testmaster</filename> |
| 12215 | image. |
| 12216 | The <filename>core-image-testmaster</filename> |
| 12217 | recipe is provided as an example for a |
| 12218 | "master" image and you can customize the image |
| 12219 | recipe as you would any other recipe. |
| 12220 | </para> |
| 12221 | <para>Here are the image recipe requirements: |
| 12222 | <itemizedlist> |
| 12223 | <listitem><para>Inherits |
| 12224 | <filename>core-image</filename> |
| 12225 | so that kernel modules are installed. |
| 12226 | </para></listitem> |
| 12227 | <listitem><para>Installs normal linux utilities |
| 12228 | not busybox ones (e.g. |
| 12229 | <filename>bash</filename>, |
| 12230 | <filename>coreutils</filename>, |
| 12231 | <filename>tar</filename>, |
| 12232 | <filename>gzip</filename>, and |
| 12233 | <filename>kmod</filename>). |
| 12234 | </para></listitem> |
| 12235 | <listitem><para>Uses a custom |
| 12236 | Initial RAM Disk (initramfs) image with a |
| 12237 | custom installer. |
| 12238 | A normal image that you can install usually |
| 12239 | creates a single rootfs partition. |
| 12240 | This image uses another installer that |
| 12241 | creates a specific partition layout. |
| 12242 | Not all Board Support Packages (BSPs) |
| 12243 | can use an installer. |
| 12244 | For such cases, you need to manually create |
| 12245 | the following partition layout on the |
| 12246 | target: |
| 12247 | <itemizedlist> |
| 12248 | <listitem><para>First partition mounted |
| 12249 | under <filename>/boot</filename>, |
| 12250 | labeled "boot". |
| 12251 | </para></listitem> |
| 12252 | <listitem><para>The main rootfs |
| 12253 | partition where this image gets |
| 12254 | installed, which is mounted under |
| 12255 | <filename>/</filename>. |
| 12256 | </para></listitem> |
| 12257 | <listitem><para>Another partition |
| 12258 | labeled "testrootfs" where test |
| 12259 | images get deployed. |
| 12260 | </para></listitem> |
| 12261 | </itemizedlist> |
| 12262 | </para></listitem> |
| 12263 | </itemizedlist> |
| 12264 | </para></listitem> |
| 12265 | <listitem><para><emphasis>Install image:</emphasis> |
| 12266 | Install the image that you just built on the target |
| 12267 | system. |
| 12268 | </para></listitem> |
| 12269 | </orderedlist> |
| 12270 | </para> |
| 12271 | |
| 12272 | <para> |
| 12273 | The final thing you need to do when setting |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 12274 | <filename>TEST_TARGET</filename> to "SystemdbootTarget" is |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 12275 | to set up the test image: |
| 12276 | <orderedlist> |
| 12277 | <listitem><para><emphasis>Set up your <filename>local.conf</filename> file:</emphasis> |
| 12278 | Make sure you have the following statements in |
| 12279 | your <filename>local.conf</filename> file: |
| 12280 | <literallayout class='monospaced'> |
| 12281 | IMAGE_FSTYPES += "tar.gz" |
| 12282 | INHERIT += "testimage" |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 12283 | TEST_TARGET = "SystemdbootTarget" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 12284 | TEST_TARGET_IP = "192.168.2.3" |
| 12285 | </literallayout> |
| 12286 | </para></listitem> |
| 12287 | <listitem><para><emphasis>Build your test image:</emphasis> |
| 12288 | Use BitBake to build the image: |
| 12289 | <literallayout class='monospaced'> |
| 12290 | $ bitbake core-image-sato |
| 12291 | </literallayout> |
| 12292 | </para></listitem> |
| 12293 | </orderedlist> |
| 12294 | </para> |
| 12295 | </section> |
| 12296 | |
| 12297 | <section id='power-control'> |
| 12298 | <title>Power Control</title> |
| 12299 | |
| 12300 | <para> |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 12301 | For most hardware targets other than "simpleremote", |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 12302 | you can control power: |
| 12303 | <itemizedlist> |
| 12304 | <listitem><para> |
| 12305 | You can use |
| 12306 | <filename>TEST_POWERCONTROL_CMD</filename> |
| 12307 | together with |
| 12308 | <filename>TEST_POWERCONTROL_EXTRA_ARGS</filename> |
| 12309 | as a command that runs on the host and does power |
| 12310 | cycling. |
| 12311 | The test code passes one argument to that command: |
| 12312 | off, on or cycle (off then on). |
| 12313 | Here is an example that could appear in your |
| 12314 | <filename>local.conf</filename> file: |
| 12315 | <literallayout class='monospaced'> |
| 12316 | TEST_POWERCONTROL_CMD = "powercontrol.exp test 10.11.12.1 nuc1" |
| 12317 | </literallayout> |
| 12318 | In this example, the expect script does the |
| 12319 | following: |
| 12320 | <literallayout class='monospaced'> |
| 12321 | ssh test@10.11.12.1 "pyctl nuc1 <replaceable>arg</replaceable>" |
| 12322 | </literallayout> |
| 12323 | It then runs a Python script that controls power |
| 12324 | for a label called <filename>nuc1</filename>. |
| 12325 | <note> |
| 12326 | You need to customize |
| 12327 | <filename>TEST_POWERCONTROL_CMD</filename> |
| 12328 | and |
| 12329 | <filename>TEST_POWERCONTROL_EXTRA_ARGS</filename> |
| 12330 | for your own setup. |
| 12331 | The one requirement is that it accepts |
| 12332 | "on", "off", and "cycle" as the last argument. |
| 12333 | </note> |
| 12334 | </para></listitem> |
| 12335 | <listitem><para> |
| 12336 | When no command is defined, it connects to the |
| 12337 | device over SSH and uses the classic reboot command |
| 12338 | to reboot the device. |
| 12339 | Classic reboot is fine as long as the machine |
| 12340 | actually reboots (i.e. the SSH test has not |
| 12341 | failed). |
| 12342 | It is useful for scenarios where you have a simple |
| 12343 | setup, typically with a single board, and where |
| 12344 | some manual interaction is okay from time to time. |
| 12345 | </para></listitem> |
| 12346 | </itemizedlist> |
| 12347 | If you have no hardware to automatically perform power |
| 12348 | control but still wish to experiment with automated |
| 12349 | hardware testing, you can use the dialog-power-control |
| 12350 | script that shows a dialog prompting you to perform the |
| 12351 | required power action. |
| 12352 | This script requires either KDialog or Zenity to be |
| 12353 | installed. |
| 12354 | To use this script, set the |
| 12355 | <ulink url='&YOCTO_DOCS_REF_URL;#var-TEST_POWERCONTROL_CMD'><filename>TEST_POWERCONTROL_CMD</filename></ulink> |
| 12356 | variable as follows: |
| 12357 | <literallayout class='monospaced'> |
| 12358 | TEST_POWERCONTROL_CMD = "${COREBASE}/scripts/contrib/dialog-power-control" |
| 12359 | </literallayout> |
| 12360 | </para> |
| 12361 | </section> |
| 12362 | |
| 12363 | <section id='serial-console-connection'> |
| 12364 | <title>Serial Console Connection</title> |
| 12365 | |
| 12366 | <para> |
| 12367 | For test target classes requiring a serial console |
| 12368 | to interact with the bootloader (e.g. BeagleBoneTarget, |
| 12369 | EdgeRouterTarget, and GrubTarget), you need to |
| 12370 | specify a command to use to connect to the serial console |
| 12371 | of the target machine by using the |
| 12372 | <ulink url='&YOCTO_DOCS_REF_URL;#var-TEST_SERIALCONTROL_CMD'><filename>TEST_SERIALCONTROL_CMD</filename></ulink> |
| 12373 | variable and optionally the |
| 12374 | <ulink url='&YOCTO_DOCS_REF_URL;#var-TEST_SERIALCONTROL_EXTRA_ARGS'><filename>TEST_SERIALCONTROL_EXTRA_ARGS</filename></ulink> |
| 12375 | variable. |
| 12376 | </para> |
| 12377 | |
| 12378 | <para> |
| 12379 | These cases could be a serial terminal program if the |
| 12380 | machine is connected to a local serial port, or a |
| 12381 | <filename>telnet</filename> or |
| 12382 | <filename>ssh</filename> command connecting to a remote |
| 12383 | console server. |
| 12384 | Regardless of the case, the command simply needs to |
| 12385 | connect to the serial console and forward that connection |
| 12386 | to standard input and output as any normal terminal |
| 12387 | program does. |
| 12388 | For example, to use the picocom terminal program on |
| 12389 | serial device <filename>/dev/ttyUSB0</filename> |
| 12390 | at 115200bps, you would set the variable as follows: |
| 12391 | <literallayout class='monospaced'> |
| 12392 | TEST_SERIALCONTROL_CMD = "picocom /dev/ttyUSB0 -b 115200" |
| 12393 | </literallayout> |
| 12394 | For local devices where the serial port device disappears |
| 12395 | when the device reboots, an additional "serdevtry" wrapper |
| 12396 | script is provided. |
| 12397 | To use this wrapper, simply prefix the terminal command |
| 12398 | with |
| 12399 | <filename>${COREBASE}/scripts/contrib/serdevtry</filename>: |
| 12400 | <literallayout class='monospaced'> |
| 12401 | TEST_SERIALCONTROL_CMD = "${COREBASE}/scripts/contrib/serdevtry picocom -b |
| 12402 | 115200 /dev/ttyUSB0" |
| 12403 | </literallayout> |
| 12404 | </para> |
| 12405 | </section> |
| 12406 | </section> |
| 12407 | |
| 12408 | <section id="qemu-image-running-tests"> |
| 12409 | <title>Running Tests</title> |
| 12410 | |
| 12411 | <para> |
| 12412 | You can start the tests automatically or manually: |
| 12413 | <itemizedlist> |
| 12414 | <listitem><para><emphasis>Automatically running tests:</emphasis> |
| 12415 | To run the tests automatically after the |
| 12416 | OpenEmbedded build system successfully creates an image, |
| 12417 | first set the |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 12418 | <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] | 12419 | variable to "1" in your <filename>local.conf</filename> |
| 12420 | file in the |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 12421 | <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink>: |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 12422 | <literallayout class='monospaced'> |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 12423 | TESTIMAGE_AUTO = "1" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 12424 | </literallayout> |
| 12425 | Next, build your image. |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 12426 | If the image successfully builds, the tests run: |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 12427 | <literallayout class='monospaced'> |
| 12428 | bitbake core-image-sato |
| 12429 | </literallayout></para></listitem> |
| 12430 | <listitem><para><emphasis>Manually running tests:</emphasis> |
| 12431 | To manually run the tests, first globally inherit the |
Patrick Williams | f1e5d69 | 2016-03-30 15:21:19 -0500 | [diff] [blame] | 12432 | <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] | 12433 | class by editing your <filename>local.conf</filename> |
| 12434 | file: |
| 12435 | <literallayout class='monospaced'> |
| 12436 | INHERIT += "testimage" |
| 12437 | </literallayout> |
| 12438 | Next, use BitBake to run the tests: |
| 12439 | <literallayout class='monospaced'> |
| 12440 | bitbake -c testimage <replaceable>image</replaceable> |
| 12441 | </literallayout></para></listitem> |
| 12442 | </itemizedlist> |
| 12443 | </para> |
| 12444 | |
| 12445 | <para> |
| 12446 | All test files reside in |
| 12447 | <filename>meta/lib/oeqa/runtime</filename> in the |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 12448 | <ulink url='&YOCTO_DOCS_REF_URL;#source-directory'>Source Directory</ulink>. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 12449 | A test name maps directly to a Python module. |
| 12450 | Each test module may contain a number of individual tests. |
| 12451 | Tests are usually grouped together by the area |
| 12452 | tested (e.g tests for systemd reside in |
| 12453 | <filename>meta/lib/oeqa/runtime/systemd.py</filename>). |
| 12454 | </para> |
| 12455 | |
| 12456 | <para> |
| 12457 | You can add tests to any layer provided you place them in the |
| 12458 | proper area and you extend |
| 12459 | <ulink url='&YOCTO_DOCS_REF_URL;#var-BBPATH'><filename>BBPATH</filename></ulink> |
| 12460 | in the <filename>local.conf</filename> file as normal. |
| 12461 | Be sure that tests reside in |
| 12462 | <filename><replaceable>layer</replaceable>/lib/oeqa/runtime</filename>. |
| 12463 | <note> |
| 12464 | Be sure that module names do not collide with module names |
| 12465 | used in the default set of test modules in |
| 12466 | <filename>meta/lib/oeqa/runtime</filename>. |
| 12467 | </note> |
| 12468 | </para> |
| 12469 | |
| 12470 | <para> |
| 12471 | You can change the set of tests run by appending or overriding |
| 12472 | <ulink url='&YOCTO_DOCS_REF_URL;#var-TEST_SUITES'><filename>TEST_SUITES</filename></ulink> |
| 12473 | variable in <filename>local.conf</filename>. |
| 12474 | Each name in <filename>TEST_SUITES</filename> represents a |
| 12475 | required test for the image. |
| 12476 | Test modules named within <filename>TEST_SUITES</filename> |
| 12477 | cannot be skipped even if a test is not suitable for an image |
| 12478 | (e.g. running the RPM tests on an image without |
| 12479 | <filename>rpm</filename>). |
| 12480 | Appending "auto" to <filename>TEST_SUITES</filename> causes the |
| 12481 | build system to try to run all tests that are suitable for the |
| 12482 | image (i.e. each test module may elect to skip itself). |
| 12483 | </para> |
| 12484 | |
| 12485 | <para> |
| 12486 | The order you list tests in <filename>TEST_SUITES</filename> |
| 12487 | is important and influences test dependencies. |
| 12488 | Consequently, tests that depend on other tests should be added |
| 12489 | after the test on which they depend. |
| 12490 | For example, since the <filename>ssh</filename> test |
| 12491 | depends on the |
| 12492 | <filename>ping</filename> test, "ssh" needs to come after |
| 12493 | "ping" in the list. |
| 12494 | The test class provides no re-ordering or dependency handling. |
| 12495 | <note> |
| 12496 | Each module can have multiple classes with multiple test |
| 12497 | methods. |
| 12498 | And, Python <filename>unittest</filename> rules apply. |
| 12499 | </note> |
| 12500 | </para> |
| 12501 | |
| 12502 | <para> |
| 12503 | Here are some things to keep in mind when running tests: |
| 12504 | <itemizedlist> |
| 12505 | <listitem><para>The default tests for the image are defined |
| 12506 | as: |
| 12507 | <literallayout class='monospaced'> |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 12508 | 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] | 12509 | </literallayout></para></listitem> |
| 12510 | <listitem><para>Add your own test to the list of the |
| 12511 | by using the following: |
| 12512 | <literallayout class='monospaced'> |
| 12513 | TEST_SUITES_append = " mytest" |
| 12514 | </literallayout></para></listitem> |
| 12515 | <listitem><para>Run a specific list of tests as follows: |
| 12516 | <literallayout class='monospaced'> |
| 12517 | TEST_SUITES = "test1 test2 test3" |
| 12518 | </literallayout> |
| 12519 | Remember, order is important. |
| 12520 | Be sure to place a test that is dependent on another test |
| 12521 | later in the order.</para></listitem> |
| 12522 | </itemizedlist> |
| 12523 | </para> |
| 12524 | </section> |
| 12525 | |
| 12526 | <section id="exporting-tests"> |
| 12527 | <title>Exporting Tests</title> |
| 12528 | |
| 12529 | <para> |
| 12530 | You can export tests so that they can run independently of |
| 12531 | the build system. |
| 12532 | Exporting tests is required if you want to be able to hand |
| 12533 | the test execution off to a scheduler. |
| 12534 | You can only export tests that are defined in |
| 12535 | <ulink url='&YOCTO_DOCS_REF_URL;#var-TEST_SUITES'><filename>TEST_SUITES</filename></ulink>. |
| 12536 | </para> |
| 12537 | |
| 12538 | <para> |
| 12539 | If your image is already built, make sure the following are set |
Brad Bishop | 37a0e4d | 2017-12-04 01:01:44 -0500 | [diff] [blame] | 12540 | in your <filename>local.conf</filename> file: |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 12541 | <literallayout class='monospaced'> |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 12542 | INHERIT +="testexport" |
Brad Bishop | 37a0e4d | 2017-12-04 01:01:44 -0500 | [diff] [blame] | 12543 | TEST_TARGET_IP = "<replaceable>IP-address-for-the-test-target</replaceable>" |
| 12544 | TEST_SERVER_IP = "<replaceable>IP-address-for-the-test-server</replaceable>" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 12545 | </literallayout> |
Brad Bishop | 37a0e4d | 2017-12-04 01:01:44 -0500 | [diff] [blame] | 12546 | You can then export the tests with the following BitBake |
| 12547 | command form: |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 12548 | <literallayout class='monospaced'> |
Brad Bishop | 37a0e4d | 2017-12-04 01:01:44 -0500 | [diff] [blame] | 12549 | $ bitbake <replaceable>image</replaceable> -c testexport |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 12550 | </literallayout> |
| 12551 | Exporting the tests places them in the |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 12552 | <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink> |
| 12553 | in |
Brad Bishop | 37a0e4d | 2017-12-04 01:01:44 -0500 | [diff] [blame] | 12554 | <filename>tmp/testexport/</filename><replaceable>image</replaceable>, |
| 12555 | which is controlled by the |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 12556 | <filename>TEST_EXPORT_DIR</filename> variable. |
| 12557 | </para> |
| 12558 | |
| 12559 | <para> |
| 12560 | You can now run the tests outside of the build environment: |
| 12561 | <literallayout class='monospaced'> |
Brad Bishop | 37a0e4d | 2017-12-04 01:01:44 -0500 | [diff] [blame] | 12562 | $ cd tmp/testexport/<replaceable>image</replaceable> |
| 12563 | $ ./runexported.py testdata.json |
| 12564 | </literallayout> |
| 12565 | </para> |
| 12566 | |
| 12567 | <para> |
| 12568 | Here is a complete example that shows IP addresses and uses |
| 12569 | the <filename>core-image-sato</filename> image: |
| 12570 | <literallayout class='monospaced'> |
| 12571 | INHERIT +="testexport" |
| 12572 | TEST_TARGET_IP = "192.168.7.2" |
| 12573 | TEST_SERVER_IP = "192.168.7.1" |
| 12574 | </literallayout> |
| 12575 | Use BitBake to export the tests: |
| 12576 | <literallayout class='monospaced'> |
| 12577 | $ bitbake core-image-sato -c testexport |
| 12578 | </literallayout> |
| 12579 | Run the tests outside of the build environment using the |
| 12580 | following: |
| 12581 | <literallayout class='monospaced'> |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 12582 | $ cd tmp/testexport/core-image-sato |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 12583 | $ ./runexported.py testdata.json |
| 12584 | </literallayout> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 12585 | </para> |
| 12586 | </section> |
| 12587 | |
| 12588 | <section id="qemu-image-writing-new-tests"> |
| 12589 | <title>Writing New Tests</title> |
| 12590 | |
| 12591 | <para> |
| 12592 | As mentioned previously, all new test files need to be in the |
| 12593 | proper place for the build system to find them. |
| 12594 | New tests for additional functionality outside of the core |
| 12595 | should be added to the layer that adds the functionality, in |
| 12596 | <filename><replaceable>layer</replaceable>/lib/oeqa/runtime</filename> |
| 12597 | (as long as |
| 12598 | <ulink url='&YOCTO_DOCS_REF_URL;#var-BBPATH'><filename>BBPATH</filename></ulink> |
| 12599 | is extended in the layer's |
| 12600 | <filename>layer.conf</filename> file as normal). |
| 12601 | Just remember the following: |
| 12602 | <itemizedlist> |
| 12603 | <listitem><para>Filenames need to map directly to test |
| 12604 | (module) names. |
| 12605 | </para></listitem> |
| 12606 | <listitem><para>Do not use module names that |
| 12607 | collide with existing core tests. |
| 12608 | </para></listitem> |
| 12609 | <listitem><para>Minimally, an empty |
| 12610 | <filename>__init__.py</filename> file must exist |
| 12611 | in the runtime directory. |
| 12612 | </para></listitem> |
| 12613 | </itemizedlist> |
| 12614 | </para> |
| 12615 | |
| 12616 | <para> |
| 12617 | To create a new test, start by copying an existing module |
| 12618 | (e.g. <filename>syslog.py</filename> or |
| 12619 | <filename>gcc.py</filename> are good ones to use). |
| 12620 | Test modules can use code from |
| 12621 | <filename>meta/lib/oeqa/utils</filename>, which are helper |
| 12622 | classes. |
| 12623 | </para> |
| 12624 | |
| 12625 | <note> |
| 12626 | Structure shell commands such that you rely on them and they |
| 12627 | return a single code for success. |
| 12628 | Be aware that sometimes you will need to parse the output. |
| 12629 | See the <filename>df.py</filename> and |
| 12630 | <filename>date.py</filename> modules for examples. |
| 12631 | </note> |
| 12632 | |
| 12633 | <para> |
| 12634 | You will notice that all test classes inherit |
| 12635 | <filename>oeRuntimeTest</filename>, which is found in |
| 12636 | <filename>meta/lib/oetest.py</filename>. |
| 12637 | This base class offers some helper attributes, which are |
| 12638 | described in the following sections: |
| 12639 | </para> |
| 12640 | |
| 12641 | <section id='qemu-image-writing-tests-class-methods'> |
| 12642 | <title>Class Methods</title> |
| 12643 | |
| 12644 | <para> |
| 12645 | Class methods are as follows: |
| 12646 | <itemizedlist> |
| 12647 | <listitem><para><emphasis><filename>hasPackage(pkg)</filename>:</emphasis> |
| 12648 | Returns "True" if <filename>pkg</filename> is in the |
| 12649 | installed package list of the image, which is based |
| 12650 | on the manifest file that is generated during the |
| 12651 | <filename>do_rootfs</filename> task. |
| 12652 | </para></listitem> |
| 12653 | <listitem><para><emphasis><filename>hasFeature(feature)</filename>:</emphasis> |
| 12654 | Returns "True" if the feature is in |
| 12655 | <ulink url='&YOCTO_DOCS_REF_URL;#var-IMAGE_FEATURES'><filename>IMAGE_FEATURES</filename></ulink> |
| 12656 | or |
| 12657 | <ulink url='&YOCTO_DOCS_REF_URL;#var-DISTRO_FEATURES'><filename>DISTRO_FEATURES</filename></ulink>. |
| 12658 | </para></listitem> |
| 12659 | </itemizedlist> |
| 12660 | </para> |
| 12661 | </section> |
| 12662 | |
| 12663 | <section id='qemu-image-writing-tests-class-attributes'> |
| 12664 | <title>Class Attributes</title> |
| 12665 | |
| 12666 | <para> |
| 12667 | Class attributes are as follows: |
| 12668 | <itemizedlist> |
| 12669 | <listitem><para><emphasis><filename>pscmd</filename>:</emphasis> |
| 12670 | Equals "ps -ef" if <filename>procps</filename> is |
| 12671 | installed in the image. |
| 12672 | Otherwise, <filename>pscmd</filename> equals |
| 12673 | "ps" (busybox). |
| 12674 | </para></listitem> |
| 12675 | <listitem><para><emphasis><filename>tc</filename>:</emphasis> |
| 12676 | The called test context, which gives access to the |
| 12677 | following attributes: |
| 12678 | <itemizedlist> |
| 12679 | <listitem><para><emphasis><filename>d</filename>:</emphasis> |
| 12680 | The BitBake datastore, which allows you to |
| 12681 | use stuff such as |
| 12682 | <filename>oeRuntimeTest.tc.d.getVar("VIRTUAL-RUNTIME_init_manager")</filename>. |
| 12683 | </para></listitem> |
| 12684 | <listitem><para><emphasis><filename>testslist</filename> and <filename>testsrequired</filename>:</emphasis> |
| 12685 | Used internally. |
| 12686 | The tests do not need these. |
| 12687 | </para></listitem> |
| 12688 | <listitem><para><emphasis><filename>filesdir</filename>:</emphasis> |
| 12689 | The absolute path to |
| 12690 | <filename>meta/lib/oeqa/runtime/files</filename>, |
| 12691 | which contains helper files for tests meant |
| 12692 | for copying on the target such as small |
| 12693 | files written in C for compilation. |
| 12694 | </para></listitem> |
| 12695 | <listitem><para><emphasis><filename>target</filename>:</emphasis> |
| 12696 | The target controller object used to deploy |
| 12697 | and start an image on a particular target |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 12698 | (e.g. Qemu, SimpleRemote, and |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 12699 | SystemdbootTarget). |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 12700 | Tests usually use the following: |
| 12701 | <itemizedlist> |
| 12702 | <listitem><para><emphasis><filename>ip</filename>:</emphasis> |
| 12703 | The target's IP address. |
| 12704 | </para></listitem> |
| 12705 | <listitem><para><emphasis><filename>server_ip</filename>:</emphasis> |
| 12706 | The host's IP address, which is |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 12707 | usually used by the DNF test |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 12708 | suite. |
| 12709 | </para></listitem> |
| 12710 | <listitem><para><emphasis><filename>run(cmd, timeout=None)</filename>:</emphasis> |
| 12711 | The single, most used method. |
| 12712 | This command is a wrapper for: |
| 12713 | <filename>ssh root@host "cmd"</filename>. |
| 12714 | The command returns a tuple: |
| 12715 | (status, output), which are what |
| 12716 | their names imply - the return code |
| 12717 | of "cmd" and whatever output |
| 12718 | it produces. |
| 12719 | The optional timeout argument |
| 12720 | represents the number of seconds the |
| 12721 | test should wait for "cmd" to |
| 12722 | return. |
| 12723 | If the argument is "None", the |
| 12724 | test uses the default instance's |
| 12725 | timeout period, which is 300 |
| 12726 | seconds. |
| 12727 | If the argument is "0", the test |
| 12728 | runs until the command returns. |
| 12729 | </para></listitem> |
| 12730 | <listitem><para><emphasis><filename>copy_to(localpath, remotepath)</filename>:</emphasis> |
| 12731 | <filename>scp localpath root@ip:remotepath</filename>. |
| 12732 | </para></listitem> |
| 12733 | <listitem><para><emphasis><filename>copy_from(remotepath, localpath)</filename>:</emphasis> |
| 12734 | <filename>scp root@host:remotepath localpath</filename>. |
| 12735 | </para></listitem> |
| 12736 | </itemizedlist></para></listitem> |
| 12737 | </itemizedlist></para></listitem> |
| 12738 | </itemizedlist> |
| 12739 | </para> |
| 12740 | </section> |
| 12741 | |
| 12742 | <section id='qemu-image-writing-tests-instance-attributes'> |
| 12743 | <title>Instance Attributes</title> |
| 12744 | |
| 12745 | <para> |
| 12746 | A single instance attribute exists, which is |
| 12747 | <filename>target</filename>. |
| 12748 | The <filename>target</filename> instance attribute is |
| 12749 | identical to the class attribute of the same name, which |
| 12750 | is described in the previous section. |
| 12751 | This attribute exists as both an instance and class |
| 12752 | attribute so tests can use |
| 12753 | <filename>self.target.run(cmd)</filename> in instance |
| 12754 | methods instead of |
| 12755 | <filename>oeRuntimeTest.tc.target.run(cmd)</filename>. |
| 12756 | </para> |
| 12757 | </section> |
| 12758 | </section> |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 12759 | |
| 12760 | <section id='installing-packages-in-the-dut-without-the-package-manager'> |
| 12761 | <title>Installing Packages in the DUT Without the Package Manager</title> |
| 12762 | |
| 12763 | <para> |
| 12764 | When a test requires a package built by BitBake, it is possible |
| 12765 | to install that package. |
| 12766 | Installing the package does not require a package manager be |
| 12767 | installed in the device under test (DUT). |
| 12768 | It does, however, require an SSH connection and the target must |
| 12769 | be using the <filename>sshcontrol</filename> class. |
| 12770 | <note> |
| 12771 | This method uses <filename>scp</filename> to copy files |
| 12772 | from the host to the target, which causes permissions and |
| 12773 | special attributes to be lost. |
| 12774 | </note> |
| 12775 | </para> |
| 12776 | |
| 12777 | <para> |
| 12778 | A JSON file is used to define the packages needed by a test. |
| 12779 | This file must be in the same path as the file used to define |
| 12780 | the tests. |
| 12781 | Furthermore, the filename must map directly to the test |
| 12782 | module name with a <filename>.json</filename> extension. |
| 12783 | </para> |
| 12784 | |
| 12785 | <para> |
| 12786 | The JSON file must include an object with the test name as |
| 12787 | keys of an object or an array. |
| 12788 | This object (or array of objects) uses the following data: |
| 12789 | <itemizedlist> |
| 12790 | <listitem><para>"pkg" - A mandatory string that is the |
| 12791 | name of the package to be installed. |
| 12792 | </para></listitem> |
| 12793 | <listitem><para>"rm" - An optional boolean, which defaults |
| 12794 | to "false", that specifies to remove the package after |
| 12795 | the test. |
| 12796 | </para></listitem> |
| 12797 | <listitem><para>"extract" - An optional boolean, which |
| 12798 | defaults to "false", that specifies if the package must |
| 12799 | be extracted from the package format. |
| 12800 | When set to "true", the package is not automatically |
| 12801 | installed into the DUT. |
| 12802 | </para></listitem> |
| 12803 | </itemizedlist> |
| 12804 | </para> |
| 12805 | |
| 12806 | <para> |
| 12807 | Following is an example JSON file that handles test "foo" |
| 12808 | installing package "bar" and test "foobar" installing |
| 12809 | packages "foo" and "bar". |
| 12810 | Once the test is complete, the packages are removed from the |
| 12811 | DUT. |
| 12812 | <literallayout class='monospaced'> |
| 12813 | { |
| 12814 | "foo": { |
| 12815 | "pkg": "bar" |
| 12816 | }, |
| 12817 | "foobar": [ |
| 12818 | { |
| 12819 | "pkg": "foo", |
| 12820 | "rm": true |
| 12821 | }, |
| 12822 | { |
| 12823 | "pkg": "bar", |
| 12824 | "rm": true |
| 12825 | } |
| 12826 | ] |
| 12827 | } |
| 12828 | </literallayout> |
| 12829 | </para> |
| 12830 | </section> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 12831 | </section> |
| 12832 | |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 12833 | <section id='usingpoky-debugging-tools-and-techniques'> |
| 12834 | <title>Debugging Tools and Techniques</title> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 12835 | |
| 12836 | <para> |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 12837 | The exact method for debugging build failures depends on the nature |
| 12838 | of the problem and on the system's area from which the bug |
| 12839 | originates. |
| 12840 | Standard debugging practices such as comparison against the last |
| 12841 | known working version with examination of the changes and the |
| 12842 | re-application of steps to identify the one causing the problem are |
| 12843 | valid for the Yocto Project just as they are for any other system. |
| 12844 | Even though it is impossible to detail every possible potential |
| 12845 | failure, this section provides some general tips to aid in |
| 12846 | debugging given a variety of situations. |
| 12847 | <note><title>Tip</title> |
| 12848 | A useful feature for debugging is the error reporting tool. |
| 12849 | Configuring the Yocto Project to use this tool causes the |
| 12850 | OpenEmbedded build system to produce error reporting commands as |
| 12851 | part of the console output. |
| 12852 | You can enter the commands after the build completes to log |
| 12853 | error information into a common database, that can help you |
| 12854 | figure out what might be going wrong. |
| 12855 | For information on how to enable and use this feature, see the |
| 12856 | "<link linkend='using-the-error-reporting-tool'>Using the Error Reporting Tool</link>" |
| 12857 | section. |
| 12858 | </note> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 12859 | </para> |
| 12860 | |
| 12861 | <para> |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 12862 | The following list shows the debugging topics in the remainder of |
| 12863 | this section: |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 12864 | <itemizedlist> |
| 12865 | <listitem><para> |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 12866 | "<link linkend='dev-debugging-viewing-logs-from-failed-tasks'>Viewing Logs from Failed Tasks</link>" |
| 12867 | describes how to find and view logs from tasks that |
| 12868 | failed during the build process. |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 12869 | </para></listitem> |
| 12870 | <listitem><para> |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 12871 | "<link linkend='dev-debugging-viewing-variable-values'>Viewing Variable Values</link>" |
| 12872 | describes how to use the BitBake <filename>-e</filename> |
| 12873 | option to examine variable values after a recipe has been |
| 12874 | parsed. |
| 12875 | </para></listitem> |
| 12876 | <listitem><para> |
| 12877 | "<link linkend='viewing-package-information-with-oe-pkgdata-util'>Viewing Package Information with <filename>oe-pkgdata-util</filename></link>" |
| 12878 | describes how to use the |
| 12879 | <filename>oe-pkgdata-util</filename> utility to query |
| 12880 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PKGDATA_DIR'><filename>PKGDATA_DIR</filename></ulink> |
| 12881 | and display package-related information for built |
| 12882 | packages. |
| 12883 | </para></listitem> |
| 12884 | <listitem><para> |
| 12885 | "<link linkend='dev-viewing-dependencies-between-recipes-and-tasks'>Viewing Dependencies Between Recipes and Tasks</link>" |
| 12886 | describes how to use the BitBake <filename>-g</filename> |
| 12887 | option to display recipe dependency information used |
| 12888 | during the build. |
| 12889 | </para></listitem> |
| 12890 | <listitem><para> |
| 12891 | "<link linkend='dev-viewing-task-variable-dependencies'>Viewing Task Variable Dependencies</link>" |
| 12892 | describes how to use the |
| 12893 | <filename>bitbake-dumpsig</filename> command in |
| 12894 | conjunction with key subdirectories in the |
| 12895 | <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink> |
| 12896 | to determine variable dependencies. |
| 12897 | </para></listitem> |
| 12898 | <listitem><para> |
| 12899 | "<link linkend='dev-debugging-taskrunning'>Running Specific Tasks</link>" |
| 12900 | describes how to use several BitBake options (e.g. |
| 12901 | <filename>-c</filename>, <filename>-C</filename>, and |
| 12902 | <filename>-f</filename>) to run specific tasks in the |
| 12903 | build chain. |
| 12904 | It can be useful to run tasks "out-of-order" when trying |
| 12905 | isolate build issues. |
| 12906 | </para></listitem> |
| 12907 | <listitem><para> |
| 12908 | "<link linkend='dev-debugging-bitbake'>General BitBake Problems</link>" |
| 12909 | describes how to use BitBake's <filename>-D</filename> |
| 12910 | debug output option to reveal more about what BitBake is |
| 12911 | doing during the build. |
| 12912 | </para></listitem> |
| 12913 | <listitem><para> |
| 12914 | "<link linkend='dev-debugging-buildfile'>Building with No Dependencies</link>" |
| 12915 | describes how to use the BitBake <filename>-b</filename> |
| 12916 | option to build a recipe while ignoring dependencies. |
| 12917 | </para></listitem> |
| 12918 | <listitem><para> |
| 12919 | "<link linkend='recipe-logging-mechanisms'>Recipe Logging Mechanisms</link>" |
| 12920 | describes how to use the many recipe logging functions |
| 12921 | to produce debugging output and report errors and warnings. |
| 12922 | </para></listitem> |
| 12923 | <listitem><para> |
| 12924 | "<link linkend='debugging-parallel-make-races'>Debugging Parallel Make Races</link>" |
| 12925 | describes how to debug situations where the build consists |
| 12926 | of several parts that are run simultaneously and when the |
| 12927 | output or result of one part is not ready for use with a |
| 12928 | different part of the build that depends on that output. |
| 12929 | </para></listitem> |
| 12930 | <listitem><para> |
| 12931 | "<link linkend='platdev-gdb-remotedebug'>Debugging With the GNU Project Debugger (GDB) Remotely</link>" |
| 12932 | describes how to use GDB to allow you to examine running |
| 12933 | programs, which can help you fix problems. |
| 12934 | </para></listitem> |
| 12935 | <listitem><para> |
| 12936 | "<link linkend='debugging-with-the-gnu-project-debugger-gdb-on-the-target'>Debugging with the GNU Project Debugger (GDB) on the Target</link>" |
| 12937 | describes how to use GDB directly on target hardware for |
| 12938 | debugging. |
| 12939 | </para></listitem> |
| 12940 | <listitem><para> |
| 12941 | "<link linkend='dev-other-debugging-others'>Other Debugging Tips</link>" |
| 12942 | describes miscellaneous debugging tips that can be useful. |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 12943 | </para></listitem> |
| 12944 | </itemizedlist> |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 12945 | </para> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 12946 | |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 12947 | <section id='dev-debugging-viewing-logs-from-failed-tasks'> |
| 12948 | <title>Viewing Logs from Failed Tasks</title> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 12949 | |
| 12950 | <para> |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 12951 | You can find the log for a task in the file |
| 12952 | <filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-WORKDIR'><filename>WORKDIR</filename></ulink><filename>}/temp/log.do_</filename><replaceable>taskname</replaceable>. |
| 12953 | For example, the log for the |
| 12954 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-compile'><filename>do_compile</filename></ulink> |
| 12955 | task of the QEMU minimal image for the x86 machine |
| 12956 | (<filename>qemux86</filename>) might be in |
| 12957 | <filename>tmp/work/qemux86-poky-linux/core-image-minimal/1.0-r0/temp/log.do_compile</filename>. |
| 12958 | To see the commands |
| 12959 | <ulink url='&YOCTO_DOCS_REF_URL;#bitbake-term'>BitBake</ulink> |
| 12960 | ran to generate a log, look at the corresponding |
| 12961 | <filename>run.do_</filename><replaceable>taskname</replaceable> |
| 12962 | file in the same directory. |
| 12963 | </para> |
| 12964 | |
| 12965 | <para> |
| 12966 | <filename>log.do_</filename><replaceable>taskname</replaceable> |
| 12967 | and |
| 12968 | <filename>run.do_</filename><replaceable>taskname</replaceable> |
| 12969 | are actually symbolic links to |
| 12970 | <filename>log.do_</filename><replaceable>taskname</replaceable><filename>.</filename><replaceable>pid</replaceable> |
| 12971 | and |
| 12972 | <filename>log.run_</filename><replaceable>taskname</replaceable><filename>.</filename><replaceable>pid</replaceable>, |
| 12973 | where <replaceable>pid</replaceable> is the PID the task had |
| 12974 | when it ran. |
| 12975 | The symlinks always point to the files corresponding to the most |
| 12976 | recent run. |
| 12977 | </para> |
| 12978 | </section> |
| 12979 | |
| 12980 | <section id='dev-debugging-viewing-variable-values'> |
| 12981 | <title>Viewing Variable Values</title> |
| 12982 | |
| 12983 | <para> |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 12984 | Sometimes you need to know the value of a variable as a |
| 12985 | result of BitBake's parsing step. |
| 12986 | This could be because some unexpected behavior occurred |
| 12987 | in your project. |
| 12988 | Perhaps an attempt to |
| 12989 | <ulink url='&YOCTO_DOCS_BB_URL;#modifying-existing-variables'>modify a variable</ulink> |
| 12990 | did not work out as expected. |
| 12991 | </para> |
| 12992 | |
| 12993 | <para> |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 12994 | BitBake's <filename>-e</filename> option is used to display |
| 12995 | variable values after parsing. |
| 12996 | The following command displays the variable values after the |
| 12997 | configuration files (i.e. <filename>local.conf</filename>, |
| 12998 | <filename>bblayers.conf</filename>, |
| 12999 | <filename>bitbake.conf</filename> and so forth) have been |
| 13000 | parsed: |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 13001 | <literallayout class='monospaced'> |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 13002 | $ bitbake -e |
| 13003 | </literallayout> |
| 13004 | The following command displays variable values after a specific |
| 13005 | recipe has been parsed. |
| 13006 | The variables include those from the configuration as well: |
| 13007 | <literallayout class='monospaced'> |
| 13008 | $ bitbake -e recipename |
| 13009 | </literallayout> |
| 13010 | <note><para> |
| 13011 | Each recipe has its own private set of variables |
| 13012 | (datastore). |
| 13013 | Internally, after parsing the configuration, a copy of the |
| 13014 | resulting datastore is made prior to parsing each recipe. |
| 13015 | This copying implies that variables set in one recipe will |
| 13016 | not be visible to other recipes.</para> |
| 13017 | |
| 13018 | <para>Likewise, each task within a recipe gets a private |
| 13019 | datastore based on the recipe datastore, which means that |
| 13020 | variables set within one task will not be visible to |
| 13021 | other tasks.</para> |
| 13022 | </note> |
| 13023 | </para> |
| 13024 | |
| 13025 | <para> |
| 13026 | In the output of <filename>bitbake -e</filename>, each |
| 13027 | variable is preceded by a description of how the variable |
| 13028 | got its value, including temporary values that were later |
| 13029 | overriden. |
| 13030 | This description also includes variable flags (varflags) set on |
| 13031 | the variable. |
| 13032 | The output can be very helpful during debugging. |
| 13033 | </para> |
| 13034 | |
| 13035 | <para> |
| 13036 | Variables that are exported to the environment are preceded by |
| 13037 | <filename>export</filename> in the output of |
| 13038 | <filename>bitbake -e</filename>. |
| 13039 | See the following example: |
| 13040 | <literallayout class='monospaced'> |
| 13041 | export CC="i586-poky-linux-gcc -m32 -march=i586 --sysroot=/home/ulf/poky/build/tmp/sysroots/qemux86" |
| 13042 | </literallayout> |
| 13043 | </para> |
| 13044 | |
| 13045 | <para> |
| 13046 | In addition to variable values, the output of the |
| 13047 | <filename>bitbake -e</filename> and |
| 13048 | <filename>bitbake -e</filename> <replaceable>recipe</replaceable> |
| 13049 | commands includes the following information: |
| 13050 | <itemizedlist> |
| 13051 | <listitem><para> |
| 13052 | The output starts with a tree listing all configuration |
| 13053 | files and classes included globally, recursively listing |
| 13054 | the files they include or inherit in turn. |
| 13055 | Much of the behavior of the OpenEmbedded build system |
| 13056 | (including the behavior of the |
| 13057 | <ulink url='&YOCTO_DOCS_REF_URL;#normal-recipe-build-tasks'>normal recipe build tasks</ulink>) |
| 13058 | is implemented in the |
| 13059 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-base'><filename>base</filename></ulink> |
| 13060 | class and the classes it inherits, rather than being |
| 13061 | built into BitBake itself. |
| 13062 | </para></listitem> |
| 13063 | <listitem><para> |
| 13064 | After the variable values, all functions appear in the |
| 13065 | output. |
| 13066 | For shell functions, variables referenced within the |
| 13067 | function body are expanded. |
| 13068 | If a function has been modified using overrides or |
| 13069 | using override-style operators like |
| 13070 | <filename>_append</filename> and |
| 13071 | <filename>_prepend</filename>, then the final assembled |
| 13072 | function body appears in the output. |
| 13073 | </para></listitem> |
| 13074 | </itemizedlist> |
| 13075 | </para> |
| 13076 | </section> |
| 13077 | |
| 13078 | <section id='viewing-package-information-with-oe-pkgdata-util'> |
| 13079 | <title>Viewing Package Information with <filename>oe-pkgdata-util</filename></title> |
| 13080 | |
| 13081 | <para> |
| 13082 | You can use the <filename>oe-pkgdata-util</filename> |
| 13083 | command-line utility to query |
| 13084 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PKGDATA_DIR'><filename>PKGDATA_DIR</filename></ulink> |
| 13085 | and display various package-related information. |
| 13086 | When you use the utility, you must use it to view information |
| 13087 | on packages that have already been built. |
| 13088 | </para> |
| 13089 | |
| 13090 | <para> |
| 13091 | Following are a few of the available |
| 13092 | <filename>oe-pkgdata-util</filename> subcommands. |
| 13093 | <note> |
| 13094 | You can use the standard * and ? globbing wildcards as part |
| 13095 | of package names and paths. |
| 13096 | </note> |
| 13097 | <itemizedlist> |
| 13098 | <listitem><para> |
| 13099 | <filename>oe-pkgdata-util list-pkgs [</filename><replaceable>pattern</replaceable><filename>]</filename>: |
| 13100 | Lists all packages that have been built, optionally |
| 13101 | limiting the match to packages that match |
| 13102 | <replaceable>pattern</replaceable>. |
| 13103 | </para></listitem> |
| 13104 | <listitem><para> |
| 13105 | <filename>oe-pkgdata-util list-pkg-files </filename><replaceable>package</replaceable><filename> ...</filename>: |
| 13106 | Lists the files and directories contained in the given |
| 13107 | packages. |
| 13108 | <note> |
| 13109 | <para> |
| 13110 | A different way to view the contents of a package is |
| 13111 | to look at the |
| 13112 | <filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-WORKDIR'><filename>WORKDIR</filename></ulink><filename>}/packages-split</filename> |
| 13113 | directory of the recipe that generates the |
| 13114 | package. |
| 13115 | This directory is created by the |
| 13116 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-package'><filename>do_package</filename></ulink> |
| 13117 | task and has one subdirectory for each package the |
| 13118 | recipe generates, which contains the files stored in |
| 13119 | that package.</para> |
| 13120 | <para> |
| 13121 | If you want to inspect the |
| 13122 | <filename>${WORKDIR}/packages-split</filename> |
| 13123 | directory, make sure that |
| 13124 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-rm-work'><filename>rm_work</filename></ulink> |
| 13125 | is not enabled when you build the recipe. |
| 13126 | </para> |
| 13127 | </note> |
| 13128 | </para></listitem> |
| 13129 | <listitem><para> |
| 13130 | <filename>oe-pkgdata-util find-path </filename><replaceable>path</replaceable><filename> ...</filename>: |
| 13131 | Lists the names of the packages that contain the given |
| 13132 | paths. |
| 13133 | For example, the following tells us that |
| 13134 | <filename>/usr/share/man/man1/make.1</filename> |
| 13135 | is contained in the <filename>make-doc</filename> |
| 13136 | package: |
| 13137 | <literallayout class='monospaced'> |
| 13138 | $ oe-pkgdata-util find-path /usr/share/man/man1/make.1 |
| 13139 | make-doc: /usr/share/man/man1/make.1 |
| 13140 | </literallayout> |
| 13141 | </para></listitem> |
| 13142 | <listitem><para> |
| 13143 | <filename>oe-pkgdata-util lookup-recipe </filename><replaceable>package</replaceable><filename> ...</filename>: |
| 13144 | Lists the name of the recipes that |
| 13145 | produce the given packages. |
| 13146 | </para></listitem> |
| 13147 | </itemizedlist> |
| 13148 | </para> |
| 13149 | |
| 13150 | <para> |
| 13151 | For more information on the <filename>oe-pkgdata-util</filename> |
| 13152 | command, use the help facility: |
| 13153 | <literallayout class='monospaced'> |
| 13154 | $ oe-pkgdata-util ‐‐help |
| 13155 | $ oe-pkgdata-util <replaceable>subcommand</replaceable> --help |
| 13156 | </literallayout> |
| 13157 | </para> |
| 13158 | </section> |
| 13159 | |
| 13160 | <section id='dev-viewing-dependencies-between-recipes-and-tasks'> |
| 13161 | <title>Viewing Dependencies Between Recipes and Tasks</title> |
| 13162 | |
| 13163 | <para> |
| 13164 | Sometimes it can be hard to see why BitBake wants to build other |
| 13165 | recipes before the one you have specified. |
| 13166 | Dependency information can help you understand why a recipe is |
| 13167 | built. |
| 13168 | </para> |
| 13169 | |
| 13170 | <para> |
| 13171 | To generate dependency information for a recipe, run the |
| 13172 | following command: |
| 13173 | <literallayout class='monospaced'> |
| 13174 | $ bitbake -g <replaceable>recipename</replaceable> |
| 13175 | </literallayout> |
| 13176 | This command writes the following files in the current |
| 13177 | directory: |
| 13178 | <itemizedlist> |
| 13179 | <listitem><para> |
| 13180 | <filename>pn-buildlist</filename>: A list of |
| 13181 | recipes/targets involved in building |
| 13182 | <replaceable>recipename</replaceable>. |
| 13183 | "Involved" here means that at least one task from the |
| 13184 | recipe needs to run when building |
| 13185 | <replaceable>recipename</replaceable> from scratch. |
| 13186 | Targets that are in |
| 13187 | <ulink url='&YOCTO_DOCS_REF_URL;#var-ASSUME_PROVIDED'><filename>ASSUME_PROVIDED</filename></ulink> |
| 13188 | are not listed. |
| 13189 | </para></listitem> |
| 13190 | <listitem><para> |
| 13191 | <filename>task-depends.dot</filename>: A graph showing |
| 13192 | dependencies between tasks. |
| 13193 | </para></listitem> |
| 13194 | </itemizedlist> |
| 13195 | </para> |
| 13196 | |
| 13197 | <para> |
| 13198 | The graphs are in |
| 13199 | <ulink url='https://en.wikipedia.org/wiki/DOT_%28graph_description_language%29'>DOT</ulink> |
| 13200 | format and can be converted to images (e.g. using the |
| 13201 | <filename>dot</filename> tool from |
| 13202 | <ulink url='http://www.graphviz.org/'>Graphviz</ulink>). |
| 13203 | <note><title>Notes</title> |
| 13204 | <itemizedlist> |
| 13205 | <listitem><para> |
| 13206 | DOT files use a plain text format. |
| 13207 | The graphs generated using the |
| 13208 | <filename>bitbake -g</filename> command are often so |
| 13209 | large as to be difficult to read without special |
| 13210 | pruning (e.g. with Bitbake's |
| 13211 | <filename>-I</filename> option) and processing. |
| 13212 | Despite the form and size of the graphs, the |
| 13213 | corresponding <filename>.dot</filename> files can |
| 13214 | still be possible to read and provide useful |
| 13215 | information. |
| 13216 | </para> |
| 13217 | |
| 13218 | <para>As an example, the |
| 13219 | <filename>task-depends.dot</filename> file contains |
| 13220 | lines such as the following: |
| 13221 | <literallayout class='monospaced'> |
| 13222 | "libxslt.do_configure" -> "libxml2.do_populate_sysroot" |
| 13223 | </literallayout> |
| 13224 | The above example line reveals that the |
| 13225 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-configure'><filename>do_configure</filename></ulink> |
| 13226 | task in <filename>libxslt</filename> depends on the |
| 13227 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-populate_sysroot'><filename>do_populate_sysroot</filename></ulink> |
| 13228 | task in <filename>libxml2</filename>, which is a |
| 13229 | normal |
| 13230 | <ulink url='&YOCTO_DOCS_REF_URL;#var-DEPENDS'><filename>DEPENDS</filename></ulink> |
| 13231 | dependency between the two recipes. |
| 13232 | </para></listitem> |
| 13233 | <listitem><para> |
| 13234 | For an example of how <filename>.dot</filename> |
| 13235 | files can be processed, see the |
| 13236 | <filename>scripts/contrib/graph-tool</filename> |
| 13237 | Python script, which finds and displays paths |
| 13238 | between graph nodes. |
| 13239 | </para></listitem> |
| 13240 | </itemizedlist> |
| 13241 | </note> |
| 13242 | </para> |
| 13243 | |
| 13244 | <para> |
| 13245 | You can use a different method to view dependency information |
| 13246 | by using the following command: |
| 13247 | <literallayout class='monospaced'> |
| 13248 | $ bitbake -g -u taskexp <replaceable>recipename</replaceable> |
| 13249 | </literallayout> |
| 13250 | This command displays a GUI window from which you can view |
| 13251 | build-time and runtime dependencies for the recipes involved in |
| 13252 | building <replaceable>recipename</replaceable>. |
| 13253 | </para> |
| 13254 | </section> |
| 13255 | |
| 13256 | <section id='dev-viewing-task-variable-dependencies'> |
| 13257 | <title>Viewing Task Variable Dependencies</title> |
| 13258 | |
| 13259 | <para> |
| 13260 | As mentioned in the |
| 13261 | "<ulink url='&YOCTO_DOCS_BB_URL;#checksums'>Checksums (Signatures)</ulink>" |
| 13262 | section of the BitBake User Manual, BitBake tries to |
| 13263 | automatically determine what variables a task depends on so |
| 13264 | that it can rerun the task if any values of the variables |
| 13265 | change. |
| 13266 | This determination is usually reliable. |
| 13267 | However, if you do things like construct variable names at |
| 13268 | runtime, then you might have to manually declare dependencies |
| 13269 | on those variables using <filename>vardeps</filename> as |
| 13270 | described in the |
| 13271 | "<ulink url='&YOCTO_DOCS_BB_URL;#variable-flags'>Variable Flags</ulink>" |
| 13272 | section of the BitBake User Manual. |
| 13273 | </para> |
| 13274 | |
| 13275 | <para> |
| 13276 | If you are unsure whether a variable dependency is being |
| 13277 | picked up automatically for a given task, you can list the |
| 13278 | variable dependencies BitBake has determined by doing the |
| 13279 | following: |
| 13280 | <orderedlist> |
| 13281 | <listitem><para> |
| 13282 | Build the recipe containing the task: |
| 13283 | <literallayout class='monospaced'> |
| 13284 | $ bitbake <replaceable>recipename</replaceable> |
| 13285 | </literallayout> |
| 13286 | </para></listitem> |
| 13287 | <listitem><para> |
| 13288 | Inside the |
| 13289 | <ulink url='&YOCTO_DOCS_REF_URL;#var-STAMPS_DIR'><filename>STAMPS_DIR</filename></ulink> |
| 13290 | directory, find the signature data |
| 13291 | (<filename>sigdata</filename>) file that corresponds |
| 13292 | to the task. |
| 13293 | The <filename>sigdata</filename> files contain a pickled |
| 13294 | Python database of all the metadata that went into |
| 13295 | creating the input checksum for the task. |
| 13296 | As an example, for the |
| 13297 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-fetch'><filename>do_fetch</filename></ulink> |
| 13298 | task of the <filename>db</filename> recipe, the |
| 13299 | <filename>sigdata</filename> file might be found in the |
| 13300 | following location: |
| 13301 | <literallayout class='monospaced'> |
| 13302 | ${BUILDDIR}/tmp/stamps/i586-poky-linux/db/6.0.30-r1.do_fetch.sigdata.7c048c18222b16ff0bcee2000ef648b1 |
| 13303 | </literallayout> |
| 13304 | For tasks that are accelerated through the shared state |
| 13305 | (<ulink url='&YOCTO_DOCS_OM_URL;#shared-state-cache'>sstate</ulink>) |
| 13306 | cache, an additional <filename>siginfo</filename> file |
| 13307 | is written into |
| 13308 | <ulink url='&YOCTO_DOCS_REF_URL;#var-SSTATE_DIR'><filename>SSTATE_DIR</filename></ulink> |
| 13309 | along with the cached task output. |
| 13310 | The <filename>siginfo</filename> files contain exactly |
| 13311 | the same information as <filename>sigdata</filename> |
| 13312 | files. |
| 13313 | </para></listitem> |
| 13314 | <listitem><para> |
| 13315 | Run <filename>bitbake-dumpsig</filename> on the |
| 13316 | <filename>sigdata</filename> or |
| 13317 | <filename>siginfo</filename> file. |
| 13318 | Here is an example: |
| 13319 | <literallayout class='monospaced'> |
| 13320 | $ bitbake-dumpsig ${BUILDDIR}/tmp/stamps/i586-poky-linux/db/6.0.30-r1.do_fetch.sigdata.7c048c18222b16ff0bcee2000ef648b1 |
| 13321 | </literallayout> |
| 13322 | In the output of the above command, you will find a |
| 13323 | line like the following, which lists all the (inferred) |
| 13324 | variable dependencies for the task. |
| 13325 | This list also includes indirect dependencies from |
| 13326 | variables depending on other variables, recursively. |
| 13327 | <literallayout class='monospaced'> |
| 13328 | Task dependencies: ['PV', 'SRCREV', 'SRC_URI', 'SRC_URI[md5sum]', 'SRC_URI[sha256sum]', 'base_do_fetch'] |
| 13329 | </literallayout> |
| 13330 | <note> |
| 13331 | Functions (e.g. <filename>base_do_fetch</filename>) |
| 13332 | also count as variable dependencies. |
| 13333 | These functions in turn depend on the variables they |
| 13334 | reference. |
| 13335 | </note> |
| 13336 | The output of <filename>bitbake-dumpsig</filename> also |
| 13337 | includes the value each variable had, a list of |
| 13338 | dependencies for each variable, and |
| 13339 | <ulink url='&YOCTO_DOCS_BB_URL;#var-BB_HASHBASE_WHITELIST'><filename>BB_HASHBASE_WHITELIST</filename></ulink> |
| 13340 | information. |
| 13341 | </para></listitem> |
| 13342 | </orderedlist> |
| 13343 | </para> |
| 13344 | |
| 13345 | <para> |
| 13346 | There is also a <filename>bitbake-diffsigs</filename> command |
| 13347 | for comparing two <filename>siginfo</filename> or |
| 13348 | <filename>sigdata</filename> files. |
| 13349 | This command can be helpful when trying to figure out what |
| 13350 | changed between two versions of a task. |
| 13351 | If you call <filename>bitbake-diffsigs</filename> with just one |
| 13352 | file, the command behaves like |
| 13353 | <filename>bitbake-dumpsig</filename>. |
| 13354 | </para> |
| 13355 | |
| 13356 | <para> |
| 13357 | You can also use BitBake to dump out the signature construction |
| 13358 | information without executing tasks by using either of the |
| 13359 | following BitBake command-line options: |
| 13360 | <literallayout class='monospaced'> |
| 13361 | ‐‐dump-signatures=<replaceable>SIGNATURE_HANDLER</replaceable> |
| 13362 | -S <replaceable>SIGNATURE_HANDLER</replaceable> |
| 13363 | </literallayout> |
| 13364 | <note> |
| 13365 | Two common values for |
| 13366 | <replaceable>SIGNATURE_HANDLER</replaceable> are "none" and |
| 13367 | "printdiff", which dump only the signature or compare the |
| 13368 | dumped signature with the cached one, respectively. |
| 13369 | </note> |
| 13370 | Using BitBake with either of these options causes BitBake to |
| 13371 | dump out <filename>sigdata</filename> files in the |
| 13372 | <filename>stamps</filename> directory for every task it would |
| 13373 | have executed instead of building the specified target package. |
| 13374 | </para> |
| 13375 | </section> |
| 13376 | |
| 13377 | <section id='dev-viewing-metadata-used-to-create-the-input-signature-of-a-shared-state-task'> |
| 13378 | <title>Viewing Metadata Used to Create the Input Signature of a Shared State Task</title> |
| 13379 | |
| 13380 | <para> |
| 13381 | Seeing what metadata went into creating the input signature |
| 13382 | of a shared state (sstate) task can be a useful debugging |
| 13383 | aid. |
| 13384 | This information is available in signature information |
| 13385 | (<filename>siginfo</filename>) files in |
| 13386 | <ulink url='&YOCTO_DOCS_REF_URL;#var-SSTATE_DIR'><filename>SSTATE_DIR</filename></ulink>. |
| 13387 | For information on how to view and interpret information in |
| 13388 | <filename>siginfo</filename> files, see the |
| 13389 | "<link linkend='dev-viewing-task-variable-dependencies'>Viewing Task Variable Dependencies</link>" |
| 13390 | section. |
| 13391 | </para> |
| 13392 | |
| 13393 | <para> |
| 13394 | For conceptual information on shared state, see the |
| 13395 | "<ulink url='&YOCTO_DOCS_OM_URL;#shared-state'>Shared State</ulink>" |
| 13396 | section in the Yocto Project Overview and Concepts Manual. |
| 13397 | </para> |
| 13398 | </section> |
| 13399 | |
| 13400 | <section id='dev-invalidating-shared-state-to-force-a-task-to-run'> |
| 13401 | <title>Invalidating Shared State to Force a Task to Run</title> |
| 13402 | |
| 13403 | <para> |
| 13404 | The OpenEmbedded build system uses |
| 13405 | <ulink url='&YOCTO_DOCS_OM_URL;#overview-checksums'>checksums</ulink> |
| 13406 | and |
| 13407 | <ulink url='&YOCTO_DOCS_OM_URL;#shared-state'>shared state</ulink> |
| 13408 | cache to avoid unnecessarily rebuilding tasks. |
| 13409 | Collectively, this scheme is known as "shared state code." |
| 13410 | </para> |
| 13411 | |
| 13412 | <para> |
| 13413 | As with all schemes, this one has some drawbacks. |
| 13414 | It is possible that you could make implicit changes to your |
| 13415 | code that the checksum calculations do not take into |
| 13416 | account. |
| 13417 | These implicit changes affect a task's output but do not |
| 13418 | trigger the shared state code into rebuilding a recipe. |
| 13419 | Consider an example during which a tool changes its output. |
| 13420 | Assume that the output of <filename>rpmdeps</filename> |
| 13421 | changes. |
| 13422 | The result of the change should be that all the |
| 13423 | <filename>package</filename> and |
| 13424 | <filename>package_write_rpm</filename> shared state cache |
| 13425 | items become invalid. |
| 13426 | However, because the change to the output is |
| 13427 | external to the code and therefore implicit, |
| 13428 | the associated shared state cache items do not become |
| 13429 | invalidated. |
| 13430 | In this case, the build process uses the cached items |
| 13431 | rather than running the task again. |
| 13432 | Obviously, these types of implicit changes can cause |
| 13433 | problems. |
| 13434 | </para> |
| 13435 | |
| 13436 | <para> |
| 13437 | To avoid these problems during the build, you need to |
| 13438 | understand the effects of any changes you make. |
| 13439 | Realize that changes you make directly to a function |
| 13440 | are automatically factored into the checksum calculation. |
| 13441 | Thus, these explicit changes invalidate the associated |
| 13442 | area of shared state cache. |
| 13443 | However, you need to be aware of any implicit changes that |
| 13444 | are not obvious changes to the code and could affect |
| 13445 | the output of a given task. |
| 13446 | </para> |
| 13447 | |
| 13448 | <para> |
| 13449 | When you identify an implicit change, you can easily |
| 13450 | take steps to invalidate the cache and force the tasks |
| 13451 | to run. |
| 13452 | The steps you can take are as simple as changing a |
| 13453 | function's comments in the source code. |
| 13454 | For example, to invalidate package shared state files, |
| 13455 | change the comment statements of |
| 13456 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-package'><filename>do_package</filename></ulink> |
| 13457 | or the comments of one of the functions it calls. |
| 13458 | Even though the change is purely cosmetic, it causes the |
| 13459 | checksum to be recalculated and forces the build system to |
| 13460 | run the task again. |
| 13461 | <note> |
| 13462 | For an example of a commit that makes a cosmetic |
| 13463 | change to invalidate shared state, see this |
| 13464 | <ulink url='&YOCTO_GIT_URL;/cgit.cgi/poky/commit/meta/classes/package.bbclass?id=737f8bbb4f27b4837047cb9b4fbfe01dfde36d54'>commit</ulink>. |
| 13465 | </note> |
| 13466 | </para> |
| 13467 | </section> |
| 13468 | |
| 13469 | <section id='dev-debugging-taskrunning'> |
| 13470 | <title>Running Specific Tasks</title> |
| 13471 | |
| 13472 | <para> |
| 13473 | Any given recipe consists of a set of tasks. |
| 13474 | The standard BitBake behavior in most cases is: |
| 13475 | <filename>do_fetch</filename>, |
| 13476 | <filename>do_unpack</filename>, |
| 13477 | <filename>do_patch</filename>, |
| 13478 | <filename>do_configure</filename>, |
| 13479 | <filename>do_compile</filename>, |
| 13480 | <filename>do_install</filename>, |
| 13481 | <filename>do_package</filename>, |
| 13482 | <filename>do_package_write_*</filename>, and |
| 13483 | <filename>do_build</filename>. |
| 13484 | The default task is <filename>do_build</filename> and any tasks |
| 13485 | on which it depends build first. |
| 13486 | Some tasks, such as <filename>do_devshell</filename>, are not |
| 13487 | part of the default build chain. |
| 13488 | If you wish to run a task that is not part of the default build |
| 13489 | chain, you can use the <filename>-c</filename> option in |
| 13490 | BitBake. |
| 13491 | Here is an example: |
| 13492 | <literallayout class='monospaced'> |
| 13493 | $ bitbake matchbox-desktop -c devshell |
| 13494 | </literallayout> |
| 13495 | </para> |
| 13496 | |
| 13497 | <para> |
| 13498 | The <filename>-c</filename> option respects task dependencies, |
| 13499 | which means that all other tasks (including tasks from other |
| 13500 | recipes) that the specified task depends on will be run before |
| 13501 | the task. |
| 13502 | Even when you manually specify a task to run with |
| 13503 | <filename>-c</filename>, BitBake will only run the task if it |
| 13504 | considers it "out of date". |
| 13505 | See the |
| 13506 | "<ulink url='&YOCTO_DOCS_OM_URL;#stamp-files-and-the-rerunning-of-tasks'>Stamp Files and the Rerunning of Tasks</ulink>" |
| 13507 | section in the Yocto Project Overview and Concepts Manual for |
| 13508 | how BitBake determines whether a task is "out of date". |
| 13509 | </para> |
| 13510 | |
| 13511 | <para> |
| 13512 | If you want to force an up-to-date task to be rerun (e.g. |
| 13513 | because you made manual modifications to the recipe's |
| 13514 | <ulink url='&YOCTO_DOCS_REF_URL;#var-WORKDIR'><filename>WORKDIR</filename></ulink> |
| 13515 | that you want to try out), then you can use the |
| 13516 | <filename>-f</filename> option. |
| 13517 | <note> |
| 13518 | The reason <filename>-f</filename> is never required when |
| 13519 | running the |
| 13520 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-devshell'><filename>do_devshell</filename></ulink> |
| 13521 | task is because the |
| 13522 | <filename>[</filename><ulink url='&YOCTO_DOCS_BB_URL;#variable-flags'><filename>nostamp</filename></ulink><filename>]</filename> |
| 13523 | variable flag is already set for the task. |
| 13524 | </note> |
| 13525 | The following example shows one way you can use the |
| 13526 | <filename>-f</filename> option: |
| 13527 | <literallayout class='monospaced'> |
| 13528 | $ bitbake matchbox-desktop |
| 13529 | . |
| 13530 | . |
| 13531 | make some changes to the source code in the work directory |
| 13532 | . |
| 13533 | . |
| 13534 | $ bitbake matchbox-desktop -c compile -f |
| 13535 | $ bitbake matchbox-desktop |
| 13536 | </literallayout> |
| 13537 | </para> |
| 13538 | |
| 13539 | <para> |
| 13540 | This sequence first builds and then recompiles |
| 13541 | <filename>matchbox-desktop</filename>. |
| 13542 | The last command reruns all tasks (basically the packaging |
| 13543 | tasks) after the compile. |
| 13544 | BitBake recognizes that the <filename>do_compile</filename> |
| 13545 | task was rerun and therefore understands that the other tasks |
| 13546 | also need to be run again. |
| 13547 | </para> |
| 13548 | |
| 13549 | <para> |
| 13550 | Another, shorter way to rerun a task and all |
| 13551 | <ulink url='&YOCTO_DOCS_REF_URL;#normal-recipe-build-tasks'>normal recipe build tasks</ulink> |
| 13552 | that depend on it is to use the <filename>-C</filename> |
| 13553 | option. |
| 13554 | <note> |
| 13555 | This option is upper-cased and is separate from the |
| 13556 | <filename>-c</filename> option, which is lower-cased. |
| 13557 | </note> |
| 13558 | Using this option invalidates the given task and then runs the |
| 13559 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-build'><filename>do_build</filename></ulink> |
| 13560 | task, which is the default task if no task is given, and the |
| 13561 | tasks on which it depends. |
| 13562 | You could replace the final two commands in the previous example |
| 13563 | with the following single command: |
| 13564 | <literallayout class='monospaced'> |
| 13565 | $ bitbake matchbox-desktop -C compile |
| 13566 | </literallayout> |
| 13567 | Internally, the <filename>-f</filename> and |
| 13568 | <filename>-C</filename> options work by tainting (modifying) the |
| 13569 | input checksum of the specified task. |
| 13570 | This tainting indirectly causes the task and its |
| 13571 | dependent tasks to be rerun through the normal task dependency |
| 13572 | mechanisms. |
| 13573 | <note> |
| 13574 | BitBake explicitly keeps track of which tasks have been |
| 13575 | tainted in this fashion, and will print warnings such as the |
| 13576 | following for builds involving such tasks: |
| 13577 | <literallayout class='monospaced'> |
| 13578 | WARNING: /home/ulf/poky/meta/recipes-sato/matchbox-desktop/matchbox-desktop_2.1.bb.do_compile is tainted from a forced run |
| 13579 | </literallayout> |
| 13580 | The purpose of the warning is to let you know that the work |
| 13581 | directory and build output might not be in the clean state |
| 13582 | they would be in for a "normal" build, depending on what |
| 13583 | actions you took. |
| 13584 | To get rid of such warnings, you can remove the work |
| 13585 | directory and rebuild the recipe, as follows: |
| 13586 | <literallayout class='monospaced'> |
| 13587 | $ bitbake matchbox-desktop -c clean |
| 13588 | $ bitbake matchbox-desktop |
| 13589 | </literallayout> |
| 13590 | </note> |
| 13591 | </para> |
| 13592 | |
| 13593 | <para> |
| 13594 | You can view a list of tasks in a given package by running the |
| 13595 | <filename>do_listtasks</filename> task as follows: |
| 13596 | <literallayout class='monospaced'> |
| 13597 | $ bitbake matchbox-desktop -c listtasks |
| 13598 | </literallayout> |
| 13599 | The results appear as output to the console and are also in the |
| 13600 | file <filename>${WORKDIR}/temp/log.do_listtasks</filename>. |
| 13601 | </para> |
| 13602 | </section> |
| 13603 | |
| 13604 | <section id='dev-debugging-bitbake'> |
| 13605 | <title>General BitBake Problems</title> |
| 13606 | |
| 13607 | <para> |
| 13608 | You can see debug output from BitBake by using the |
| 13609 | <filename>-D</filename> option. |
| 13610 | The debug output gives more information about what BitBake |
| 13611 | is doing and the reason behind it. |
| 13612 | Each <filename>-D</filename> option you use increases the |
| 13613 | logging level. |
| 13614 | The most common usage is <filename>-DDD</filename>. |
| 13615 | </para> |
| 13616 | |
| 13617 | <para> |
| 13618 | The output from |
| 13619 | <filename>bitbake -DDD -v</filename> <replaceable>targetname</replaceable> |
| 13620 | can reveal why BitBake chose a certain version of a package or |
| 13621 | why BitBake picked a certain provider. |
| 13622 | This command could also help you in a situation where you think |
| 13623 | BitBake did something unexpected. |
| 13624 | </para> |
| 13625 | </section> |
| 13626 | |
| 13627 | <section id='dev-debugging-buildfile'> |
| 13628 | <title>Building with No Dependencies</title> |
| 13629 | |
| 13630 | <para> |
| 13631 | To build a specific recipe (<filename>.bb</filename> file), |
| 13632 | you can use the following command form: |
| 13633 | <literallayout class='monospaced'> |
| 13634 | $ bitbake -b <replaceable>somepath</replaceable>/<replaceable>somerecipe</replaceable>.bb |
| 13635 | </literallayout> |
| 13636 | This command form does not check for dependencies. |
| 13637 | Consequently, you should use it only when you know existing |
| 13638 | dependencies have been met. |
| 13639 | <note> |
| 13640 | You can also specify fragments of the filename. |
| 13641 | In this case, BitBake checks for a unique match. |
| 13642 | </note> |
| 13643 | </para> |
| 13644 | </section> |
| 13645 | |
| 13646 | <section id='recipe-logging-mechanisms'> |
| 13647 | <title>Recipe Logging Mechanisms</title> |
| 13648 | |
| 13649 | <para> |
| 13650 | The Yocto Project provides several logging functions for |
| 13651 | producing debugging output and reporting errors and warnings. |
| 13652 | For Python functions, the following logging functions exist. |
| 13653 | All of these functions log to |
| 13654 | <filename>${T}/log.do_</filename><replaceable>task</replaceable>, |
| 13655 | and can also log to standard output (stdout) with the right |
| 13656 | settings: |
| 13657 | <itemizedlist> |
| 13658 | <listitem><para> |
| 13659 | <filename>bb.plain(</filename><replaceable>msg</replaceable><filename>)</filename>: |
| 13660 | Writes <replaceable>msg</replaceable> as is to the |
| 13661 | log while also logging to stdout. |
| 13662 | </para></listitem> |
| 13663 | <listitem><para> |
| 13664 | <filename>bb.note(</filename><replaceable>msg</replaceable><filename>)</filename>: |
| 13665 | Writes "NOTE: <replaceable>msg</replaceable>" to the |
| 13666 | log. |
| 13667 | Also logs to stdout if BitBake is called with "-v". |
| 13668 | </para></listitem> |
| 13669 | <listitem><para> |
| 13670 | <filename>bb.debug(</filename><replaceable>level</replaceable><filename>, </filename><replaceable>msg</replaceable><filename>)</filename>: |
| 13671 | Writes "DEBUG: <replaceable>msg</replaceable>" to the |
| 13672 | log. |
| 13673 | Also logs to stdout if the log level is greater than or |
| 13674 | equal to <replaceable>level</replaceable>. |
| 13675 | See the |
| 13676 | "<ulink url='&YOCTO_DOCS_BB_URL;#usage-and-syntax'>-D</ulink>" |
| 13677 | option in the BitBake User Manual for more information. |
| 13678 | </para></listitem> |
| 13679 | <listitem><para> |
| 13680 | <filename>bb.warn(</filename><replaceable>msg</replaceable><filename>)</filename>: |
| 13681 | Writes "WARNING: <replaceable>msg</replaceable>" to the |
| 13682 | log while also logging to stdout. |
| 13683 | </para></listitem> |
| 13684 | <listitem><para> |
| 13685 | <filename>bb.error(</filename><replaceable>msg</replaceable><filename>)</filename>: |
| 13686 | Writes "ERROR: <replaceable>msg</replaceable>" to the |
| 13687 | log while also logging to standard out (stdout). |
| 13688 | <note> |
| 13689 | Calling this function does not cause the task to fail. |
| 13690 | </note> |
| 13691 | </para></listitem> |
| 13692 | <listitem><para> |
| 13693 | <filename>bb.fatal(</filename><replaceable>msg</replaceable><filename>)</filename>: |
| 13694 | This logging function is similar to |
| 13695 | <filename>bb.error(</filename><replaceable>msg</replaceable><filename>)</filename> |
| 13696 | but also causes the calling task to fail. |
| 13697 | <note> |
| 13698 | <filename>bb.fatal()</filename> raises an exception, |
| 13699 | which means you do not need to put a "return" |
| 13700 | statement after the function. |
| 13701 | </note> |
| 13702 | </para></listitem> |
| 13703 | </itemizedlist> |
| 13704 | </para> |
| 13705 | |
| 13706 | <para> |
| 13707 | The same logging functions are also available in shell |
| 13708 | functions, under the names |
| 13709 | <filename>bbplain</filename>, <filename>bbnote</filename>, |
| 13710 | <filename>bbdebug</filename>, <filename>bbwarn</filename>, |
| 13711 | <filename>bberror</filename>, and <filename>bbfatal</filename>. |
| 13712 | The |
| 13713 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-logging'><filename>logging</filename></ulink> |
| 13714 | class implements these functions. |
| 13715 | See that class in the |
| 13716 | <filename>meta/classes</filename> folder of the |
| 13717 | <ulink url='&YOCTO_DOCS_REF_URL;#source-directory'>Source Directory</ulink> |
| 13718 | for information. |
| 13719 | </para> |
| 13720 | |
| 13721 | <section id='logging-with-python'> |
| 13722 | <title>Logging With Python</title> |
| 13723 | |
| 13724 | <para> |
| 13725 | When creating recipes using Python and inserting code that |
| 13726 | handles build logs, keep in mind the goal is to have |
| 13727 | informative logs while keeping the console as "silent" as |
| 13728 | possible. |
| 13729 | Also, if you want status messages in the log, use the |
| 13730 | "debug" loglevel. |
| 13731 | </para> |
| 13732 | |
| 13733 | <para> |
| 13734 | Following is an example written in Python. |
| 13735 | The code handles logging for a function that determines the |
| 13736 | number of tasks needed to be run. |
| 13737 | See the |
| 13738 | "<ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-listtasks'><filename>do_listtasks</filename></ulink>" |
| 13739 | section for additional information: |
| 13740 | <literallayout class='monospaced'> |
| 13741 | python do_listtasks() { |
| 13742 | bb.debug(2, "Starting to figure out the task list") |
| 13743 | if noteworthy_condition: |
| 13744 | bb.note("There are 47 tasks to run") |
| 13745 | bb.debug(2, "Got to point xyz") |
| 13746 | if warning_trigger: |
| 13747 | bb.warn("Detected warning_trigger, this might be a problem later.") |
| 13748 | if recoverable_error: |
| 13749 | bb.error("Hit recoverable_error, you really need to fix this!") |
| 13750 | if fatal_error: |
| 13751 | bb.fatal("fatal_error detected, unable to print the task list") |
| 13752 | bb.plain("The tasks present are abc") |
| 13753 | bb.debug(2, "Finished figuring out the tasklist") |
| 13754 | } |
| 13755 | </literallayout> |
| 13756 | </para> |
| 13757 | </section> |
| 13758 | |
| 13759 | <section id='logging-with-bash'> |
| 13760 | <title>Logging With Bash</title> |
| 13761 | |
| 13762 | <para> |
| 13763 | When creating recipes using Bash and inserting code that |
| 13764 | handles build logs, you have the same goals - informative |
| 13765 | with minimal console output. |
| 13766 | The syntax you use for recipes written in Bash is similar |
| 13767 | to that of recipes written in Python described in the |
| 13768 | previous section. |
| 13769 | </para> |
| 13770 | |
| 13771 | <para> |
| 13772 | Following is an example written in Bash. |
| 13773 | The code logs the progress of the <filename>do_my_function</filename> function. |
| 13774 | <literallayout class='monospaced'> |
| 13775 | do_my_function() { |
| 13776 | bbdebug 2 "Running do_my_function" |
| 13777 | if [ exceptional_condition ]; then |
| 13778 | bbnote "Hit exceptional_condition" |
| 13779 | fi |
| 13780 | bbdebug 2 "Got to point xyz" |
| 13781 | if [ warning_trigger ]; then |
| 13782 | bbwarn "Detected warning_trigger, this might cause a problem later." |
| 13783 | fi |
| 13784 | if [ recoverable_error ]; then |
| 13785 | bberror "Hit recoverable_error, correcting" |
| 13786 | fi |
| 13787 | if [ fatal_error ]; then |
| 13788 | bbfatal "fatal_error detected" |
| 13789 | fi |
| 13790 | bbdebug 2 "Completed do_my_function" |
| 13791 | } |
| 13792 | </literallayout> |
| 13793 | </para> |
| 13794 | </section> |
| 13795 | </section> |
| 13796 | |
| 13797 | <section id='debugging-parallel-make-races'> |
| 13798 | <title>Debugging Parallel Make Races</title> |
| 13799 | |
| 13800 | <para> |
| 13801 | A parallel <filename>make</filename> race occurs when the build |
| 13802 | consists of several parts that are run simultaneously and |
| 13803 | a situation occurs when the output or result of one |
| 13804 | part is not ready for use with a different part of the build |
| 13805 | that depends on that output. |
| 13806 | Parallel make races are annoying and can sometimes be difficult |
| 13807 | to reproduce and fix. |
| 13808 | However, some simple tips and tricks exist that can help |
| 13809 | you debug and fix them. |
| 13810 | This section presents a real-world example of an error |
| 13811 | encountered on the Yocto Project autobuilder and the process |
| 13812 | used to fix it. |
| 13813 | <note> |
| 13814 | If you cannot properly fix a <filename>make</filename> race |
| 13815 | condition, you can work around it by clearing either the |
| 13816 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PARALLEL_MAKE'><filename>PARALLEL_MAKE</filename></ulink> |
| 13817 | or |
| 13818 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PARALLEL_MAKEINST'><filename>PARALLEL_MAKEINST</filename></ulink> |
| 13819 | variables. |
| 13820 | </note> |
| 13821 | </para> |
| 13822 | |
| 13823 | <section id='the-failure'> |
| 13824 | <title>The Failure</title> |
| 13825 | |
| 13826 | <para> |
| 13827 | For this example, assume that you are building an image that |
| 13828 | depends on the "neard" package. |
| 13829 | And, during the build, BitBake runs into problems and |
| 13830 | creates the following output. |
| 13831 | <note> |
| 13832 | This example log file has longer lines artificially |
| 13833 | broken to make the listing easier to read. |
| 13834 | </note> |
| 13835 | If you examine the output or the log file, you see the |
| 13836 | failure during <filename>make</filename>: |
| 13837 | <literallayout class='monospaced'> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 13838 | | DEBUG: SITE files ['endian-little', 'bit-32', 'ix86-common', 'common-linux', 'common-glibc', 'i586-linux', 'common'] |
| 13839 | | DEBUG: Executing shell function do_compile |
| 13840 | | NOTE: make -j 16 |
| 13841 | | make --no-print-directory all-am |
| 13842 | | /bin/mkdir -p include/near |
| 13843 | | /bin/mkdir -p include/near |
| 13844 | | /bin/mkdir -p include/near |
| 13845 | | ln -s /home/pokybuild/yocto-autobuilder/yocto-slave/nightly-x86/build/build/tmp/work/i586-poky-linux/neard/ |
| 13846 | 0.14-r0/neard-0.14/include/types.h include/near/types.h |
| 13847 | | ln -s /home/pokybuild/yocto-autobuilder/yocto-slave/nightly-x86/build/build/tmp/work/i586-poky-linux/neard/ |
| 13848 | 0.14-r0/neard-0.14/include/log.h include/near/log.h |
| 13849 | | ln -s /home/pokybuild/yocto-autobuilder/yocto-slave/nightly-x86/build/build/tmp/work/i586-poky-linux/neard/ |
| 13850 | 0.14-r0/neard-0.14/include/plugin.h include/near/plugin.h |
| 13851 | | /bin/mkdir -p include/near |
| 13852 | | /bin/mkdir -p include/near |
| 13853 | | /bin/mkdir -p include/near |
| 13854 | | ln -s /home/pokybuild/yocto-autobuilder/yocto-slave/nightly-x86/build/build/tmp/work/i586-poky-linux/neard/ |
| 13855 | 0.14-r0/neard-0.14/include/tag.h include/near/tag.h |
| 13856 | | /bin/mkdir -p include/near |
| 13857 | | ln -s /home/pokybuild/yocto-autobuilder/yocto-slave/nightly-x86/build/build/tmp/work/i586-poky-linux/neard/ |
| 13858 | 0.14-r0/neard-0.14/include/adapter.h include/near/adapter.h |
| 13859 | | /bin/mkdir -p include/near |
| 13860 | | ln -s /home/pokybuild/yocto-autobuilder/yocto-slave/nightly-x86/build/build/tmp/work/i586-poky-linux/neard/ |
| 13861 | 0.14-r0/neard-0.14/include/ndef.h include/near/ndef.h |
| 13862 | | ln -s /home/pokybuild/yocto-autobuilder/yocto-slave/nightly-x86/build/build/tmp/work/i586-poky-linux/neard/ |
| 13863 | 0.14-r0/neard-0.14/include/tlv.h include/near/tlv.h |
| 13864 | | /bin/mkdir -p include/near |
| 13865 | | /bin/mkdir -p include/near |
| 13866 | | ln -s /home/pokybuild/yocto-autobuilder/yocto-slave/nightly-x86/build/build/tmp/work/i586-poky-linux/neard/ |
| 13867 | 0.14-r0/neard-0.14/include/setting.h include/near/setting.h |
| 13868 | | /bin/mkdir -p include/near |
| 13869 | | /bin/mkdir -p include/near |
| 13870 | | /bin/mkdir -p include/near |
| 13871 | | ln -s /home/pokybuild/yocto-autobuilder/yocto-slave/nightly-x86/build/build/tmp/work/i586-poky-linux/neard/ |
| 13872 | 0.14-r0/neard-0.14/include/device.h include/near/device.h |
| 13873 | | ln -s /home/pokybuild/yocto-autobuilder/yocto-slave/nightly-x86/build/build/tmp/work/i586-poky-linux/neard/ |
| 13874 | 0.14-r0/neard-0.14/include/nfc_copy.h include/near/nfc_copy.h |
| 13875 | | ln -s /home/pokybuild/yocto-autobuilder/yocto-slave/nightly-x86/build/build/tmp/work/i586-poky-linux/neard/ |
| 13876 | 0.14-r0/neard-0.14/include/snep.h include/near/snep.h |
| 13877 | | ln -s /home/pokybuild/yocto-autobuilder/yocto-slave/nightly-x86/build/build/tmp/work/i586-poky-linux/neard/ |
| 13878 | 0.14-r0/neard-0.14/include/version.h include/near/version.h |
| 13879 | | ln -s /home/pokybuild/yocto-autobuilder/yocto-slave/nightly-x86/build/build/tmp/work/i586-poky-linux/neard/ |
| 13880 | 0.14-r0/neard-0.14/include/dbus.h include/near/dbus.h |
| 13881 | | ./src/genbuiltin nfctype1 nfctype2 nfctype3 nfctype4 p2p > src/builtin.h |
| 13882 | | i586-poky-linux-gcc -m32 -march=i586 --sysroot=/home/pokybuild/yocto-autobuilder/yocto-slave/nightly-x86/ |
| 13883 | build/build/tmp/sysroots/qemux86 -DHAVE_CONFIG_H -I. -I./include -I./src -I./gdbus -I/home/pokybuild/ |
| 13884 | yocto-autobuilder/yocto-slave/nightly-x86/build/build/tmp/sysroots/qemux86/usr/include/glib-2.0 |
| 13885 | -I/home/pokybuild/yocto-autobuilder/yocto-slave/nightly-x86/build/build/tmp/sysroots/qemux86/usr/ |
| 13886 | lib/glib-2.0/include -I/home/pokybuild/yocto-autobuilder/yocto-slave/nightly-x86/build/build/ |
| 13887 | tmp/sysroots/qemux86/usr/include/dbus-1.0 -I/home/pokybuild/yocto-autobuilder/yocto-slave/ |
| 13888 | nightly-x86/build/build/tmp/sysroots/qemux86/usr/lib/dbus-1.0/include -I/home/pokybuild/yocto-autobuilder/ |
| 13889 | yocto-slave/nightly-x86/build/build/tmp/sysroots/qemux86/usr/include/libnl3 |
| 13890 | -DNEAR_PLUGIN_BUILTIN -DPLUGINDIR=\""/usr/lib/near/plugins"\" |
| 13891 | -DCONFIGDIR=\""/etc/neard\"" -O2 -pipe -g -feliminate-unused-debug-types -c |
| 13892 | -o tools/snep-send.o tools/snep-send.c |
| 13893 | | In file included from tools/snep-send.c:16:0: |
| 13894 | | tools/../src/near.h:41:23: fatal error: near/dbus.h: No such file or directory |
| 13895 | | #include <near/dbus.h> |
| 13896 | | ^ |
| 13897 | | compilation terminated. |
| 13898 | | make[1]: *** [tools/snep-send.o] Error 1 |
| 13899 | | make[1]: *** Waiting for unfinished jobs.... |
| 13900 | | make: *** [all] Error 2 |
| 13901 | | ERROR: oe_runmake failed |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 13902 | </literallayout> |
| 13903 | </para> |
| 13904 | </section> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 13905 | |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 13906 | <section id='reproducing-the-error'> |
| 13907 | <title>Reproducing the Error</title> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 13908 | |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 13909 | <para> |
| 13910 | Because race conditions are intermittent, they do not |
| 13911 | manifest themselves every time you do the build. |
| 13912 | In fact, most times the build will complete without problems |
| 13913 | even though the potential race condition exists. |
| 13914 | Thus, once the error surfaces, you need a way to reproduce |
| 13915 | it. |
| 13916 | </para> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 13917 | |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 13918 | <para> |
| 13919 | In this example, compiling the "neard" package is causing |
| 13920 | the problem. |
| 13921 | So the first thing to do is build "neard" locally. |
| 13922 | Before you start the build, set the |
| 13923 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PARALLEL_MAKE'><filename>PARALLEL_MAKE</filename></ulink> |
| 13924 | variable in your <filename>local.conf</filename> file to |
| 13925 | a high number (e.g. "-j 20"). |
| 13926 | Using a high value for <filename>PARALLEL_MAKE</filename> |
| 13927 | increases the chances of the race condition showing up: |
| 13928 | <literallayout class='monospaced'> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 13929 | $ bitbake neard |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 13930 | </literallayout> |
| 13931 | </para> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 13932 | |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 13933 | <para> |
| 13934 | Once the local build for "neard" completes, start a |
| 13935 | <filename>devshell</filename> build: |
| 13936 | <literallayout class='monospaced'> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 13937 | $ bitbake neard -c devshell |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 13938 | </literallayout> |
| 13939 | For information on how to use a |
| 13940 | <filename>devshell</filename>, see the |
| 13941 | "<link linkend='platdev-appdev-devshell'>Using a Development Shell</link>" |
| 13942 | section. |
| 13943 | </para> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 13944 | |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 13945 | <para> |
| 13946 | In the <filename>devshell</filename>, do the following: |
| 13947 | <literallayout class='monospaced'> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 13948 | $ make clean |
| 13949 | $ make tools/snep-send.o |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 13950 | </literallayout> |
| 13951 | The <filename>devshell</filename> commands cause the failure |
| 13952 | to clearly be visible. |
| 13953 | In this case, a missing dependency exists for the "neard" |
| 13954 | Makefile target. |
| 13955 | Here is some abbreviated, sample output with the |
| 13956 | missing dependency clearly visible at the end: |
| 13957 | <literallayout class='monospaced'> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 13958 | i586-poky-linux-gcc -m32 -march=i586 --sysroot=/home/scott-lenovo/...... |
| 13959 | . |
| 13960 | . |
| 13961 | . |
| 13962 | tools/snep-send.c |
| 13963 | In file included from tools/snep-send.c:16:0: |
| 13964 | tools/../src/near.h:41:23: fatal error: near/dbus.h: No such file or directory |
| 13965 | #include <near/dbus.h> |
| 13966 | ^ |
| 13967 | compilation terminated. |
| 13968 | make: *** [tools/snep-send.o] Error 1 |
| 13969 | $ |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 13970 | </literallayout> |
| 13971 | </para> |
| 13972 | </section> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 13973 | |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 13974 | <section id='creating-a-patch-for-the-fix'> |
| 13975 | <title>Creating a Patch for the Fix</title> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 13976 | |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 13977 | <para> |
| 13978 | Because there is a missing dependency for the Makefile |
| 13979 | target, you need to patch the |
| 13980 | <filename>Makefile.am</filename> file, which is generated |
| 13981 | from <filename>Makefile.in</filename>. |
| 13982 | You can use Quilt to create the patch: |
| 13983 | <literallayout class='monospaced'> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 13984 | $ quilt new parallelmake.patch |
| 13985 | Patch patches/parallelmake.patch is now on top |
| 13986 | $ quilt add Makefile.am |
| 13987 | File Makefile.am added to patch patches/parallelmake.patch |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 13988 | </literallayout> |
| 13989 | For more information on using Quilt, see the |
| 13990 | "<link linkend='using-a-quilt-workflow'>Using Quilt in Your Workflow</link>" |
| 13991 | section. |
| 13992 | </para> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 13993 | |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 13994 | <para> |
| 13995 | At this point you need to make the edits to |
| 13996 | <filename>Makefile.am</filename> to add the missing |
| 13997 | dependency. |
| 13998 | For our example, you have to add the following line |
| 13999 | to the file: |
| 14000 | <literallayout class='monospaced'> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 14001 | tools/snep-send.$(OBJEXT): include/near/dbus.h |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 14002 | </literallayout> |
| 14003 | </para> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 14004 | |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 14005 | <para> |
| 14006 | Once you have edited the file, use the |
| 14007 | <filename>refresh</filename> command to create the patch: |
| 14008 | <literallayout class='monospaced'> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 14009 | $ quilt refresh |
| 14010 | Refreshed patch patches/parallelmake.patch |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 14011 | </literallayout> |
| 14012 | Once the patch file exists, you need to add it back to the |
| 14013 | originating recipe folder. |
| 14014 | Here is an example assuming a top-level |
| 14015 | <ulink url='&YOCTO_DOCS_REF_URL;#source-directory'>Source Directory</ulink> |
| 14016 | named <filename>poky</filename>: |
| 14017 | <literallayout class='monospaced'> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 14018 | $ cp patches/parallelmake.patch poky/meta/recipes-connectivity/neard/neard |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 14019 | </literallayout> |
| 14020 | The final thing you need to do to implement the fix in the |
| 14021 | build is to update the "neard" recipe (i.e. |
| 14022 | <filename>neard-0.14.bb</filename>) so that the |
| 14023 | <ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'><filename>SRC_URI</filename></ulink> |
| 14024 | statement includes the patch file. |
| 14025 | The recipe file is in the folder above the patch. |
| 14026 | Here is what the edited <filename>SRC_URI</filename> |
| 14027 | statement would look like: |
| 14028 | <literallayout class='monospaced'> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 14029 | SRC_URI = "${KERNELORG_MIRROR}/linux/network/nfc/${BPN}-${PV}.tar.xz \ |
| 14030 | file://neard.in \ |
| 14031 | file://neard.service.in \ |
| 14032 | file://parallelmake.patch \ |
| 14033 | " |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 14034 | </literallayout> |
| 14035 | </para> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 14036 | |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 14037 | <para> |
| 14038 | With the patch complete and moved to the correct folder and |
| 14039 | the <filename>SRC_URI</filename> statement updated, you can |
| 14040 | exit the <filename>devshell</filename>: |
| 14041 | <literallayout class='monospaced'> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 14042 | $ exit |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 14043 | </literallayout> |
| 14044 | </para> |
| 14045 | </section> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 14046 | |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 14047 | <section id='testing-the-build'> |
| 14048 | <title>Testing the Build</title> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 14049 | |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 14050 | <para> |
| 14051 | With everything in place, you can get back to trying the |
| 14052 | build again locally: |
| 14053 | <literallayout class='monospaced'> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 14054 | $ bitbake neard |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 14055 | </literallayout> |
| 14056 | This build should succeed. |
| 14057 | </para> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 14058 | |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 14059 | <para> |
| 14060 | Now you can open up a <filename>devshell</filename> again |
| 14061 | and repeat the clean and make operations as follows: |
| 14062 | <literallayout class='monospaced'> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 14063 | $ bitbake neard -c devshell |
| 14064 | $ make clean |
| 14065 | $ make tools/snep-send.o |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 14066 | </literallayout> |
| 14067 | The build should work without issue. |
| 14068 | </para> |
| 14069 | |
| 14070 | <para> |
| 14071 | As with all solved problems, if they originated upstream, |
| 14072 | you need to submit the fix for the recipe in OE-Core and |
| 14073 | upstream so that the problem is taken care of at its |
| 14074 | source. |
| 14075 | See the |
| 14076 | "<link linkend='how-to-submit-a-change'>Submitting a Change to the Yocto Project</link>" |
| 14077 | section for more information. |
| 14078 | </para> |
| 14079 | </section> |
| 14080 | </section> |
| 14081 | |
| 14082 | <section id="platdev-gdb-remotedebug"> |
| 14083 | <title>Debugging With the GNU Project Debugger (GDB) Remotely</title> |
| 14084 | |
| 14085 | <para> |
| 14086 | GDB allows you to examine running programs, which in turn helps |
| 14087 | you to understand and fix problems. |
| 14088 | It also allows you to perform post-mortem style analysis of |
| 14089 | program crashes. |
| 14090 | GDB is available as a package within the Yocto Project and is |
| 14091 | installed in SDK images by default. |
| 14092 | See the |
| 14093 | "<ulink url='&YOCTO_DOCS_REF_URL;#ref-images'>Images</ulink>" |
| 14094 | chapter in the Yocto Project Reference Manual for a description of |
| 14095 | these images. |
| 14096 | You can find information on GDB at |
| 14097 | <ulink url="http://sourceware.org/gdb/"/>. |
| 14098 | <note><title>Tip</title> |
| 14099 | For best results, install debug (<filename>-dbg</filename>) |
| 14100 | packages for the applications you are going to debug. |
| 14101 | Doing so makes extra debug symbols available that give you |
| 14102 | more meaningful output. |
| 14103 | </note> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 14104 | </para> |
| 14105 | |
| 14106 | <para> |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 14107 | Sometimes, due to memory or disk space constraints, it is not |
| 14108 | possible to use GDB directly on the remote target to debug |
| 14109 | applications. |
| 14110 | These constraints arise because GDB needs to load the debugging |
| 14111 | information and the binaries of the process being debugged. |
| 14112 | Additionally, GDB needs to perform many computations to locate |
| 14113 | information such as function names, variable names and values, |
| 14114 | stack traces and so forth - even before starting the debugging |
| 14115 | process. |
| 14116 | These extra computations place more load on the target system |
| 14117 | and can alter the characteristics of the program being debugged. |
| 14118 | </para> |
| 14119 | |
| 14120 | <para> |
| 14121 | To help get past the previously mentioned constraints, you can |
| 14122 | use gdbserver, which runs on the remote target and does not |
| 14123 | load any debugging information from the debugged process. |
| 14124 | Instead, a GDB instance processes the debugging information that |
| 14125 | is run on a remote computer - the host GDB. |
| 14126 | The host GDB then sends control commands to gdbserver to make |
| 14127 | it stop or start the debugged program, as well as read or write |
| 14128 | memory regions of that debugged program. |
| 14129 | All the debugging information loaded and processed as well |
| 14130 | as all the heavy debugging is done by the host GDB. |
| 14131 | Offloading these processes gives the gdbserver running on the |
| 14132 | target a chance to remain small and fast. |
| 14133 | </para> |
| 14134 | |
| 14135 | <para> |
| 14136 | Because the host GDB is responsible for loading the debugging |
| 14137 | information and for doing the necessary processing to make |
| 14138 | actual debugging happen, you have to make sure the host can |
| 14139 | access the unstripped binaries complete with their debugging |
| 14140 | information and also be sure the target is compiled with no |
| 14141 | optimizations. |
| 14142 | The host GDB must also have local access to all the libraries |
| 14143 | used by the debugged program. |
| 14144 | Because gdbserver does not need any local debugging information, |
| 14145 | the binaries on the remote target can remain stripped. |
| 14146 | However, the binaries must also be compiled without optimization |
| 14147 | so they match the host's binaries. |
| 14148 | </para> |
| 14149 | |
| 14150 | <para> |
| 14151 | To remain consistent with GDB documentation and terminology, |
| 14152 | the binary being debugged on the remote target machine is |
| 14153 | referred to as the "inferior" binary. |
| 14154 | For documentation on GDB see the |
| 14155 | <ulink url="http://sourceware.org/gdb/documentation/">GDB site</ulink>. |
| 14156 | </para> |
| 14157 | |
| 14158 | <para> |
| 14159 | The following steps show you how to debug using the GNU project |
| 14160 | debugger. |
| 14161 | <orderedlist> |
| 14162 | <listitem><para> |
| 14163 | <emphasis>Configure your build system to construct the |
| 14164 | companion debug filesystem:</emphasis></para> |
| 14165 | |
| 14166 | <para>In your <filename>local.conf</filename> file, set |
| 14167 | the following: |
| 14168 | <literallayout class='monospaced'> |
| 14169 | IMAGE_GEN_DEBUGFS = "1" |
| 14170 | IMAGE_FSTYPES_DEBUGFS = "tar.bz2" |
| 14171 | </literallayout> |
| 14172 | These options cause the OpenEmbedded build system |
| 14173 | to generate a special companion filesystem fragment, |
| 14174 | which contains the matching source and debug symbols to |
| 14175 | your deployable filesystem. |
| 14176 | The build system does this by looking at what is in the |
| 14177 | deployed filesystem, and pulling the corresponding |
| 14178 | <filename>-dbg</filename> packages.</para> |
| 14179 | |
| 14180 | <para>The companion debug filesystem is not a complete |
| 14181 | filesystem, but only contains the debug fragments. |
| 14182 | This filesystem must be combined with the full filesystem |
| 14183 | for debugging. |
| 14184 | Subsequent steps in this procedure show how to combine |
| 14185 | the partial filesystem with the full filesystem. |
| 14186 | </para></listitem> |
| 14187 | <listitem><para> |
| 14188 | <emphasis>Configure the system to include gdbserver in |
| 14189 | the target filesystem:</emphasis></para> |
| 14190 | |
| 14191 | <para>Make the following addition in either your |
| 14192 | <filename>local.conf</filename> file or in an image |
| 14193 | recipe: |
| 14194 | <literallayout class='monospaced'> |
| 14195 | IMAGE_INSTALL_append = “ gdbserver" |
| 14196 | </literallayout> |
| 14197 | The change makes sure the <filename>gdbserver</filename> |
| 14198 | package is included. |
| 14199 | </para></listitem> |
| 14200 | <listitem><para> |
| 14201 | <emphasis>Build the environment:</emphasis></para> |
| 14202 | |
| 14203 | <para>Use the following command to construct the image |
| 14204 | and the companion Debug Filesystem: |
| 14205 | <literallayout class='monospaced'> |
| 14206 | $ bitbake <replaceable>image</replaceable> |
| 14207 | </literallayout> |
| 14208 | Build the cross GDB component and make it available |
| 14209 | for debugging. |
| 14210 | Build the SDK that matches the image. |
| 14211 | Building the SDK is best for a production build |
| 14212 | that can be used later for debugging, especially |
| 14213 | during long term maintenance: |
| 14214 | <literallayout class='monospaced'> |
| 14215 | $ bitbake -c populate_sdk <replaceable>image</replaceable> |
| 14216 | </literallayout></para> |
| 14217 | |
| 14218 | <para>Alternatively, you can build the minimal |
| 14219 | toolchain components that match the target. |
| 14220 | Doing so creates a smaller than typical SDK and only |
| 14221 | contains a minimal set of components with which to |
| 14222 | build simple test applications, as well as run the |
| 14223 | debugger: |
| 14224 | <literallayout class='monospaced'> |
| 14225 | $ bitbake meta-toolchain |
| 14226 | </literallayout></para> |
| 14227 | |
| 14228 | <para>A final method is to build Gdb itself within |
| 14229 | the build system: |
| 14230 | <literallayout class='monospaced'> |
| 14231 | $ bitbake gdb-cross-<replaceable>architecture</replaceable> |
| 14232 | </literallayout> |
| 14233 | Doing so produces a temporary copy of |
| 14234 | <filename>cross-gdb</filename> you can use for |
| 14235 | debugging during development. |
| 14236 | While this is the quickest approach, the two previous |
| 14237 | methods in this step are better when considering |
| 14238 | long-term maintenance strategies. |
| 14239 | <note> |
| 14240 | If you run |
| 14241 | <filename>bitbake gdb-cross</filename>, the |
| 14242 | OpenEmbedded build system suggests the actual |
| 14243 | image (e.g. <filename>gdb-cross-i586</filename>). |
| 14244 | The suggestion is usually the actual name you want |
| 14245 | to use. |
| 14246 | </note> |
| 14247 | </para></listitem> |
| 14248 | <listitem><para> |
| 14249 | <emphasis>Set up the</emphasis> <filename>debugfs</filename></para> |
| 14250 | |
| 14251 | <para>Run the following commands to set up the |
| 14252 | <filename>debugfs</filename>: |
| 14253 | <literallayout class='monospaced'> |
| 14254 | $ mkdir debugfs |
| 14255 | $ cd debugfs |
| 14256 | $ tar xvfj <replaceable>build-dir</replaceable>/tmp-glibc/deploy/images/<replaceable>machine</replaceable>/<replaceable>image</replaceable>.rootfs.tar.bz2 |
| 14257 | $ tar xvfj <replaceable>build-dir</replaceable>/tmp-glibc/deploy/images/<replaceable>machine</replaceable>/<replaceable>image</replaceable>-dbg.rootfs.tar.bz2 |
| 14258 | </literallayout> |
| 14259 | </para></listitem> |
| 14260 | <listitem><para> |
| 14261 | <emphasis>Set up GDB</emphasis></para> |
| 14262 | |
| 14263 | <para>Install the SDK (if you built one) and then |
| 14264 | source the correct environment file. |
| 14265 | Sourcing the environment file puts the SDK in your |
| 14266 | <filename>PATH</filename> environment variable.</para> |
| 14267 | |
| 14268 | <para>If you are using the build system, Gdb is |
| 14269 | located in |
| 14270 | <replaceable>build-dir</replaceable>/tmp/sysroots/<replaceable>host</replaceable>/usr/bin/<replaceable>architecture</replaceable>/<replaceable>architecture</replaceable>-gdb |
| 14271 | </para></listitem> |
| 14272 | <listitem><para> |
| 14273 | <emphasis>Boot the target:</emphasis></para> |
| 14274 | |
| 14275 | <para>For information on how to run QEMU, see the |
| 14276 | <ulink url='http://wiki.qemu.org/Documentation/GettingStartedDevelopers'>QEMU Documentation</ulink>. |
| 14277 | <note> |
| 14278 | Be sure to verify that your host can access the |
| 14279 | target via TCP. |
| 14280 | </note> |
| 14281 | </para></listitem> |
| 14282 | <listitem><para> |
| 14283 | <emphasis>Debug a program:</emphasis></para> |
| 14284 | |
| 14285 | <para>Debugging a program involves running gdbserver |
| 14286 | on the target and then running Gdb on the host. |
| 14287 | The example in this step debugs |
| 14288 | <filename>gzip</filename>: |
| 14289 | <literallayout class='monospaced'> |
| 14290 | root@qemux86:~# gdbserver localhost:1234 /bin/gzip —help |
| 14291 | </literallayout> |
| 14292 | For additional gdbserver options, see the |
| 14293 | <ulink url='https://www.gnu.org/software/gdb/documentation/'>GDB Server Documentation</ulink>. |
| 14294 | </para> |
| 14295 | |
| 14296 | <para>After running gdbserver on the target, you need |
| 14297 | to run Gdb on the host and configure it and connect to |
| 14298 | the target. |
| 14299 | Use these commands: |
| 14300 | <literallayout class='monospaced'> |
| 14301 | $ cd <replaceable>directory-holding-the-debugfs-directory</replaceable> |
| 14302 | $ <replaceable>arch</replaceable>-gdb |
| 14303 | |
| 14304 | (gdb) set sysroot debugfs |
| 14305 | (gdb) set substitute-path /usr/src/debug debugfs/usr/src/debug |
| 14306 | (gdb) target remote <replaceable>IP-of-target</replaceable>:1234 |
| 14307 | </literallayout> |
| 14308 | At this point, everything should automatically load |
| 14309 | (i.e. matching binaries, symbols and headers). |
| 14310 | <note> |
| 14311 | The Gdb <filename>set</filename> commands in the |
| 14312 | previous example can be placed into the users |
| 14313 | <filename>~/.gdbinit</filename> file. |
| 14314 | Upon starting, Gdb automatically runs whatever |
| 14315 | commands are in that file. |
| 14316 | </note> |
| 14317 | </para></listitem> |
| 14318 | <listitem><para> |
| 14319 | <emphasis>Deploying without a full image |
| 14320 | rebuild:</emphasis></para> |
| 14321 | |
| 14322 | <para>In many cases, during development you want a |
| 14323 | quick method to deploy a new binary to the target and |
| 14324 | debug it, without waiting for a full image build. |
| 14325 | </para> |
| 14326 | |
| 14327 | <para>One approach to solving this situation is to |
| 14328 | just build the component you want to debug. |
| 14329 | Once you have built the component, copy the |
| 14330 | executable directly to both the target and the |
| 14331 | host <filename>debugfs</filename>.</para> |
| 14332 | |
| 14333 | <para>If the binary is processed through the debug |
| 14334 | splitting in OpenEmbedded, you should also |
| 14335 | copy the debug items (i.e. <filename>.debug</filename> |
| 14336 | contents and corresponding |
| 14337 | <filename>/usr/src/debug</filename> files) |
| 14338 | from the work directory. |
| 14339 | Here is an example: |
| 14340 | <literallayout class='monospaced'> |
| 14341 | $ bitbake bash |
| 14342 | $ bitbake -c devshell bash |
| 14343 | $ cd .. |
| 14344 | $ scp packages-split/bash/bin/bash <replaceable>target</replaceable>:/bin/bash |
| 14345 | $ cp -a packages-split/bash-dbg/* <replaceable>path</replaceable>/debugfs |
| 14346 | </literallayout> |
| 14347 | </para></listitem> |
| 14348 | </orderedlist> |
| 14349 | </para> |
| 14350 | </section> |
| 14351 | |
| 14352 | <section id='debugging-with-the-gnu-project-debugger-gdb-on-the-target'> |
| 14353 | <title>Debugging with the GNU Project Debugger (GDB) on the Target</title> |
| 14354 | |
| 14355 | <para> |
| 14356 | The previous section addressed using GDB remotely for debugging |
| 14357 | purposes, which is the most usual case due to the inherent |
| 14358 | hardware limitations on many embedded devices. |
| 14359 | However, debugging in the target hardware itself is also |
| 14360 | possible with more powerful devices. |
| 14361 | This section describes what you need to do in order to support |
| 14362 | using GDB to debug on the target hardware. |
| 14363 | </para> |
| 14364 | |
| 14365 | <para> |
| 14366 | To support this kind of debugging, you need do the following: |
| 14367 | <itemizedlist> |
| 14368 | <listitem><para> |
| 14369 | Ensure that GDB is on the target. |
| 14370 | You can do this by adding "gdb" to |
| 14371 | <ulink url='&YOCTO_DOCS_REF_URL;#var-IMAGE_INSTALL'><filename>IMAGE_INSTALL</filename></ulink>: |
| 14372 | <literallayout class='monospaced'> |
| 14373 | IMAGE_INSTALL_append = " gdb" |
| 14374 | </literallayout> |
| 14375 | Alternatively, you can add "tools-debug" to |
| 14376 | <ulink url='&YOCTO_DOCS_REF_URL;#var-IMAGE_FEATURES'><filename>IMAGE_FEATURES</filename></ulink>: |
| 14377 | <literallayout class='monospaced'> |
| 14378 | IMAGE_FEATURES_append = " tools-debug" |
| 14379 | </literallayout> |
| 14380 | </para></listitem> |
| 14381 | <listitem><para> |
| 14382 | Ensure that debug symbols are present. |
| 14383 | You can make sure these symbols are present by |
| 14384 | installing <filename>-dbg</filename>: |
| 14385 | <literallayout class='monospaced'> |
| 14386 | IMAGE_INSTALL_append = " <replaceable>packagename</replaceable>-dbg" |
| 14387 | </literallayout> |
| 14388 | Alternatively, you can do the following to include all |
| 14389 | the debug symbols: |
| 14390 | <literallayout class='monospaced'> |
| 14391 | IMAGE_FEATURES_append = " dbg-pkgs" |
| 14392 | </literallayout> |
| 14393 | </para></listitem> |
| 14394 | </itemizedlist> |
| 14395 | <note> |
| 14396 | To improve the debug information accuracy, you can reduce |
| 14397 | the level of optimization used by the compiler. |
| 14398 | For example, when adding the following line to your |
| 14399 | <filename>local.conf</filename> file, you will reduce |
| 14400 | optimization from |
| 14401 | <ulink url='&YOCTO_DOCS_REF_URL;#var-FULL_OPTIMIZATION'><filename>FULL_OPTIMIZATION</filename></ulink> |
| 14402 | of "-O2" to |
| 14403 | <ulink url='&YOCTO_DOCS_REF_URL;#var-DEBUG_OPTIMIZATION'><filename>DEBUG_OPTIMIZATION</filename></ulink> |
| 14404 | of "-O -fno-omit-frame-pointer": |
| 14405 | <literallayout class='monospaced'> |
| 14406 | DEBUG_BUILD = "1" |
| 14407 | </literallayout> |
| 14408 | Consider that this will reduce the application's performance |
| 14409 | and is recommended only for debugging purposes. |
| 14410 | </note> |
| 14411 | </para> |
| 14412 | </section> |
| 14413 | |
| 14414 | <section id='dev-other-debugging-others'> |
| 14415 | <title>Other Debugging Tips</title> |
| 14416 | |
| 14417 | <para> |
| 14418 | Here are some other tips that you might find useful: |
| 14419 | <itemizedlist> |
| 14420 | <listitem><para> |
| 14421 | When adding new packages, it is worth watching for |
| 14422 | undesirable items making their way into compiler command |
| 14423 | lines. |
| 14424 | For example, you do not want references to local system |
| 14425 | files like |
| 14426 | <filename>/usr/lib/</filename> or |
| 14427 | <filename>/usr/include/</filename>. |
| 14428 | </para></listitem> |
| 14429 | <listitem><para> |
| 14430 | If you want to remove the <filename>psplash</filename> |
| 14431 | boot splashscreen, |
| 14432 | add <filename>psplash=false</filename> to the kernel |
| 14433 | command line. |
| 14434 | Doing so prevents <filename>psplash</filename> from |
| 14435 | loading and thus allows you to see the console. |
| 14436 | It is also possible to switch out of the splashscreen by |
| 14437 | switching the virtual console (e.g. Fn+Left or Fn+Right |
| 14438 | on a Zaurus). |
| 14439 | </para></listitem> |
| 14440 | <listitem><para> |
| 14441 | Removing |
| 14442 | <ulink url='&YOCTO_DOCS_REF_URL;#var-TMPDIR'><filename>TMPDIR</filename></ulink> |
| 14443 | (usually <filename>tmp/</filename>, within the |
| 14444 | <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink>) |
| 14445 | can often fix temporary build issues. |
| 14446 | Removing <filename>TMPDIR</filename> is usually a |
| 14447 | relatively cheap operation, because task output will be |
| 14448 | cached in |
| 14449 | <ulink url='&YOCTO_DOCS_REF_URL;#var-SSTATE_DIR'><filename>SSTATE_DIR</filename></ulink> |
| 14450 | (usually <filename>sstate-cache/</filename>, which is |
| 14451 | also in the Build Directory). |
| 14452 | <note> |
| 14453 | Removing <filename>TMPDIR</filename> might be a |
| 14454 | workaround rather than a fix. |
| 14455 | Consequently, trying to determine the underlying |
| 14456 | cause of an issue before removing the directory is |
| 14457 | a good idea. |
| 14458 | </note> |
| 14459 | </para></listitem> |
| 14460 | <listitem><para> |
| 14461 | Understanding how a feature is used in practice within |
| 14462 | existing recipes can be very helpful. |
| 14463 | It is recommended that you configure some method that |
| 14464 | allows you to quickly search through files.</para> |
| 14465 | |
| 14466 | <para>Using GNU Grep, you can use the following shell |
| 14467 | function to recursively search through common |
| 14468 | recipe-related files, skipping binary files, |
| 14469 | <filename>.git</filename> directories, and the |
| 14470 | Build Directory (assuming its name starts with |
| 14471 | "build"): |
| 14472 | <literallayout class='monospaced'> |
| 14473 | g() { |
| 14474 | grep -Ir \ |
| 14475 | --exclude-dir=.git \ |
| 14476 | --exclude-dir='build*' \ |
| 14477 | --include='*.bb*' \ |
| 14478 | --include='*.inc*' \ |
| 14479 | --include='*.conf*' \ |
| 14480 | --include='*.py*' \ |
| 14481 | "$@" |
| 14482 | } |
| 14483 | </literallayout> |
| 14484 | Following are some usage examples: |
| 14485 | <literallayout class='monospaced'> |
| 14486 | $ g FOO # Search recursively for "FOO" |
| 14487 | $ g -i foo # Search recursively for "foo", ignoring case |
| 14488 | $ g -w FOO # Search recursively for "FOO" as a word, ignoring e.g. "FOOBAR" |
| 14489 | </literallayout> |
| 14490 | If figuring out how some feature works requires a lot of |
| 14491 | searching, it might indicate that the documentation |
| 14492 | should be extended or improved. |
| 14493 | In such cases, consider filing a documentation bug using |
| 14494 | the Yocto Project implementation of |
| 14495 | <ulink url='https://bugzilla.yoctoproject.org/'>Bugzilla</ulink>. |
| 14496 | For information on how to submit a bug against |
| 14497 | the Yocto Project, see the Yocto Project Bugzilla |
| 14498 | <ulink url='&YOCTO_WIKI_URL;/wiki/Bugzilla_Configuration_and_Bug_Tracking'>wiki page</ulink> |
| 14499 | and the |
| 14500 | "<link linkend='submitting-a-defect-against-the-yocto-project'>Submitting a Defect Against the Yocto Project</link>" |
| 14501 | section. |
| 14502 | <note> |
| 14503 | The manuals might not be the right place to document |
| 14504 | variables that are purely internal and have a |
| 14505 | limited scope (e.g. internal variables used to |
| 14506 | implement a single <filename>.bbclass</filename> |
| 14507 | file). |
| 14508 | </note> |
| 14509 | </para></listitem> |
| 14510 | </itemizedlist> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 14511 | </para> |
| 14512 | </section> |
| 14513 | </section> |
| 14514 | |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 14515 | <section id='making-changes-to-the-yocto-project'> |
| 14516 | <title>Making Changes to the Yocto Project</title> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 14517 | |
| 14518 | <para> |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 14519 | Because the Yocto Project is an open-source, community-based |
| 14520 | project, you can effect changes to the project. |
| 14521 | This section presents procedures that show you how to submit |
| 14522 | a defect against the project and how to submit a change. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 14523 | </para> |
| 14524 | |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 14525 | <section id='submitting-a-defect-against-the-yocto-project'> |
| 14526 | <title>Submitting a Defect Against the Yocto Project</title> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 14527 | |
| 14528 | <para> |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 14529 | Use the Yocto Project implementation of |
| 14530 | <ulink url='http://www.bugzilla.org/about/'>Bugzilla</ulink> |
| 14531 | to submit a defect (bug) against the Yocto Project. |
| 14532 | For additional information on this implementation of Bugzilla see the |
| 14533 | "<ulink url='&YOCTO_DOCS_REF_URL;#resources-bugtracker'>Yocto Project Bugzilla</ulink>" |
| 14534 | section in the Yocto Project Reference Manual. |
| 14535 | For more detail on any of the following steps, see the Yocto Project |
| 14536 | <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] | 14537 | </para> |
| 14538 | |
| 14539 | <para> |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 14540 | Use the following general steps to submit a bug" |
| 14541 | |
| 14542 | <orderedlist> |
| 14543 | <listitem><para> |
| 14544 | Open the Yocto Project implementation of |
| 14545 | <ulink url='&YOCTO_BUGZILLA_URL;'>Bugzilla</ulink>. |
| 14546 | </para></listitem> |
| 14547 | <listitem><para> |
| 14548 | Click "File a Bug" to enter a new bug. |
| 14549 | </para></listitem> |
| 14550 | <listitem><para> |
| 14551 | Choose the appropriate "Classification", "Product", and |
| 14552 | "Component" for which the bug was found. |
| 14553 | Bugs for the Yocto Project fall into one of several |
| 14554 | classifications, which in turn break down into several |
| 14555 | products and components. |
| 14556 | For example, for a bug against the |
| 14557 | <filename>meta-intel</filename> layer, you would choose |
| 14558 | "Build System, Metadata & Runtime", "BSPs", and |
| 14559 | "bsps-meta-intel", respectively. |
| 14560 | </para></listitem> |
| 14561 | <listitem><para> |
| 14562 | Choose the "Version" of the Yocto Project for which you found |
| 14563 | the bug (e.g. &DISTRO;). |
| 14564 | </para></listitem> |
| 14565 | <listitem><para> |
| 14566 | Determine and select the "Severity" of the bug. |
| 14567 | The severity indicates how the bug impacted your work. |
| 14568 | </para></listitem> |
| 14569 | <listitem><para> |
| 14570 | Choose the "Hardware" that the bug impacts. |
| 14571 | </para></listitem> |
| 14572 | <listitem><para> |
| 14573 | Choose the "Architecture" that the bug impacts. |
| 14574 | </para></listitem> |
| 14575 | <listitem><para> |
| 14576 | Choose a "Documentation change" item for the bug. |
| 14577 | Fixing a bug might or might not affect the Yocto Project |
| 14578 | documentation. |
| 14579 | If you are unsure of the impact to the documentation, select |
| 14580 | "Don't Know". |
| 14581 | </para></listitem> |
| 14582 | <listitem><para> |
| 14583 | Provide a brief "Summary" of the bug. |
| 14584 | Try to limit your summary to just a line or two and be sure |
| 14585 | to capture the essence of the bug. |
| 14586 | </para></listitem> |
| 14587 | <listitem><para> |
| 14588 | Provide a detailed "Description" of the bug. |
| 14589 | You should provide as much detail as you can about the context, |
| 14590 | behavior, output, and so forth that surrounds the bug. |
| 14591 | You can even attach supporting files for output from logs by |
| 14592 | using the "Add an attachment" button. |
| 14593 | </para></listitem> |
| 14594 | <listitem><para> |
| 14595 | Click the "Submit Bug" button submit the bug. |
| 14596 | A new Bugzilla number is assigned to the bug and the defect |
| 14597 | is logged in the bug tracking system. |
| 14598 | </para></listitem> |
| 14599 | </orderedlist> |
| 14600 | Once you file a bug, the bug is processed by the Yocto Project Bug |
| 14601 | Triage Team and further details concerning the bug are assigned |
| 14602 | (e.g. priority and owner). |
| 14603 | You are the "Submitter" of the bug and any further categorization, |
| 14604 | progress, or comments on the bug result in Bugzilla sending you an |
| 14605 | automated email concerning the particular change or progress to the |
| 14606 | bug. |
| 14607 | </para> |
| 14608 | </section> |
| 14609 | |
| 14610 | <section id='how-to-submit-a-change'> |
| 14611 | <title>Submitting a Change to the Yocto Project</title> |
| 14612 | |
| 14613 | <para> |
| 14614 | Contributions to the Yocto Project and OpenEmbedded are very welcome. |
| 14615 | Because the system is extremely configurable and flexible, we recognize |
| 14616 | that developers will want to extend, configure or optimize it for |
| 14617 | their specific uses. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 14618 | </para> |
| 14619 | |
| 14620 | <para> |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 14621 | The Yocto Project uses a mailing list and a patch-based workflow |
| 14622 | that is similar to the Linux kernel but contains important |
| 14623 | differences. |
| 14624 | In general, a mailing list exists through which you can submit |
| 14625 | patches. |
| 14626 | You should send patches to the appropriate mailing list so that they |
| 14627 | can be reviewed and merged by the appropriate maintainer. |
| 14628 | The specific mailing list you need to use depends on the |
| 14629 | location of the code you are changing. |
| 14630 | Each component (e.g. layer) should have a |
| 14631 | <filename>README</filename> file that indicates where to send |
| 14632 | the changes and which process to follow. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 14633 | </para> |
| 14634 | |
| 14635 | <para> |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 14636 | You can send the patch to the mailing list using whichever approach |
| 14637 | you feel comfortable with to generate the patch. |
| 14638 | Once sent, the patch is usually reviewed by the community at large. |
| 14639 | If somebody has concerns with the patch, they will usually voice |
| 14640 | their concern over the mailing list. |
| 14641 | If a patch does not receive any negative reviews, the maintainer of |
| 14642 | the affected layer typically takes the patch, tests it, and then |
| 14643 | based on successful testing, merges the patch. |
| 14644 | </para> |
| 14645 | |
| 14646 | <para id='figuring-out-the-mailing-list-to-use'> |
| 14647 | The "poky" repository, which is the Yocto Project's reference build |
| 14648 | environment, is a hybrid repository that contains several |
| 14649 | individual pieces (e.g. BitBake, Metadata, documentation, |
| 14650 | and so forth) built using the combo-layer tool. |
| 14651 | The upstream location used for submitting changes varies by |
| 14652 | component: |
| 14653 | <itemizedlist> |
| 14654 | <listitem><para> |
| 14655 | <emphasis>Core Metadata:</emphasis> |
| 14656 | Send your patch to the |
| 14657 | <ulink url='http://lists.openembedded.org/mailman/listinfo/openembedded-core'>openembedded-core</ulink> |
| 14658 | mailing list. For example, a change to anything under |
| 14659 | the <filename>meta</filename> or |
| 14660 | <filename>scripts</filename> directories should be sent |
| 14661 | to this mailing list. |
| 14662 | </para></listitem> |
| 14663 | <listitem><para> |
| 14664 | <emphasis>BitBake:</emphasis> |
| 14665 | For changes to BitBake (i.e. anything under the |
| 14666 | <filename>bitbake</filename> directory), send your patch |
| 14667 | to the |
| 14668 | <ulink url='http://lists.openembedded.org/mailman/listinfo/bitbake-devel'>bitbake-devel</ulink> |
| 14669 | mailing list. |
| 14670 | </para></listitem> |
| 14671 | <listitem><para> |
| 14672 | <emphasis>"meta-*" trees:</emphasis> |
| 14673 | These trees contain Metadata. |
| 14674 | Use the |
| 14675 | <ulink url='https://lists.yoctoproject.org/listinfo/poky'>poky</ulink> |
| 14676 | mailing list. |
| 14677 | </para></listitem> |
| 14678 | </itemizedlist> |
| 14679 | </para> |
| 14680 | |
| 14681 | <para> |
| 14682 | For changes to other layers hosted in the Yocto Project source |
| 14683 | repositories (i.e. <filename>yoctoproject.org</filename>), tools, |
| 14684 | and the Yocto Project documentation, use the |
| 14685 | <ulink url='https://lists.yoctoproject.org/listinfo/yocto'>Yocto Project</ulink> |
| 14686 | general mailing list. |
| 14687 | <note> |
| 14688 | Sometimes a layer's documentation specifies to use a |
| 14689 | particular mailing list. |
| 14690 | If so, use that list. |
| 14691 | </note> |
| 14692 | For additional recipes that do not fit into the core Metadata, you |
| 14693 | should determine which layer the recipe should go into and submit |
| 14694 | the change in the manner recommended by the documentation (e.g. |
| 14695 | the <filename>README</filename> file) supplied with the layer. |
| 14696 | If in doubt, please ask on the Yocto general mailing list or on |
| 14697 | the openembedded-devel mailing list. |
| 14698 | </para> |
| 14699 | |
| 14700 | <para> |
| 14701 | You can also push a change upstream and request a maintainer to |
| 14702 | pull the change into the component's upstream repository. |
| 14703 | You do this by pushing to a contribution repository that is upstream. |
| 14704 | See the |
| 14705 | "<ulink url='&YOCTO_DOCS_OM_URL;#gs-git-workflows-and-the-yocto-project'>Git Workflows and the Yocto Project</ulink>" |
| 14706 | section in the Yocto Project Overview and Concepts Manual for additional |
| 14707 | concepts on working in the Yocto Project development environment. |
| 14708 | </para> |
| 14709 | |
| 14710 | <para> |
| 14711 | Two commonly used testing repositories exist for |
| 14712 | OpenEmbedded-Core: |
| 14713 | <itemizedlist> |
| 14714 | <listitem><para> |
| 14715 | <emphasis>"ross/mut" branch:</emphasis> |
| 14716 | The "mut" (master-under-test) tree |
| 14717 | exists in the <filename>poky-contrib</filename> repository |
| 14718 | in the |
| 14719 | <ulink url='&YOCTO_GIT_URL;'>Yocto Project source repositories</ulink>. |
| 14720 | </para></listitem> |
| 14721 | <listitem><para> |
| 14722 | <emphasis>"master-next" branch:</emphasis> |
| 14723 | This branch is part of the main |
| 14724 | "poky" repository in the Yocto Project source repositories. |
| 14725 | </para></listitem> |
| 14726 | </itemizedlist> |
| 14727 | Maintainers use these branches to test submissions prior to merging |
| 14728 | patches. |
| 14729 | Thus, you can get an idea of the status of a patch based on |
| 14730 | whether the patch has been merged into one of these branches. |
| 14731 | <note> |
| 14732 | This system is imperfect and changes can sometimes get lost in the |
| 14733 | flow. |
| 14734 | Asking about the status of a patch or change is reasonable if the |
| 14735 | change has been idle for a while with no feedback. |
| 14736 | The Yocto Project does have plans to use |
| 14737 | <ulink url='https://en.wikipedia.org/wiki/Patchwork_(software)'>Patchwork</ulink> |
| 14738 | to track the status of patches and also to automatically preview |
| 14739 | patches. |
| 14740 | </note> |
| 14741 | </para> |
| 14742 | |
| 14743 | <para> |
| 14744 | The following sections provide procedures for submitting a change. |
| 14745 | </para> |
| 14746 | |
| 14747 | <section id='pushing-a-change-upstream'> |
| 14748 | <title>Using Scripts to Push a Change Upstream and Request a Pull</title> |
| 14749 | |
| 14750 | <para> |
| 14751 | Follow this procedure to push a change to an upstream "contrib" |
| 14752 | Git repository: |
| 14753 | <note> |
| 14754 | You can find general Git information on how to push a change |
| 14755 | upstream in the |
| 14756 | <ulink url='http://git-scm.com/book/en/v2/Distributed-Git-Distributed-Workflows'>Git Community Book</ulink>. |
| 14757 | </note> |
| 14758 | <orderedlist> |
| 14759 | <listitem><para> |
| 14760 | <emphasis>Make Your Changes Locally:</emphasis> |
| 14761 | Make your changes in your local Git repository. |
| 14762 | You should make small, controlled, isolated changes. |
| 14763 | Keeping changes small and isolated aids review, |
| 14764 | makes merging/rebasing easier and keeps the change |
| 14765 | history clean should anyone need to refer to it in |
| 14766 | future. |
| 14767 | </para></listitem> |
| 14768 | <listitem><para> |
| 14769 | <emphasis>Stage Your Changes:</emphasis> |
| 14770 | Stage your changes by using the <filename>git add</filename> |
| 14771 | command on each file you changed. |
| 14772 | </para></listitem> |
| 14773 | <listitem><para id='making-sure-you-have-correct-commit-information'> |
| 14774 | <emphasis>Commit Your Changes:</emphasis> |
| 14775 | Commit the change by using the |
| 14776 | <filename>git commit</filename> command. |
| 14777 | Make sure your commit information follows standards by |
| 14778 | following these accepted conventions: |
| 14779 | <itemizedlist> |
| 14780 | <listitem><para> |
| 14781 | Be sure to include a "Signed-off-by:" line in the |
| 14782 | same style as required by the Linux kernel. |
| 14783 | Adding this line signifies that you, the submitter, |
| 14784 | have agreed to the Developer's Certificate of |
| 14785 | Origin 1.1 as follows: |
| 14786 | <literallayout class='monospaced'> |
| 14787 | Developer's Certificate of Origin 1.1 |
| 14788 | |
| 14789 | By making a contribution to this project, I certify that: |
| 14790 | |
| 14791 | (a) The contribution was created in whole or in part by me and I |
| 14792 | have the right to submit it under the open source license |
| 14793 | indicated in the file; or |
| 14794 | |
| 14795 | (b) The contribution is based upon previous work that, to the best |
| 14796 | of my knowledge, is covered under an appropriate open source |
| 14797 | license and I have the right under that license to submit that |
| 14798 | work with modifications, whether created in whole or in part |
| 14799 | by me, under the same open source license (unless I am |
| 14800 | permitted to submit under a different license), as indicated |
| 14801 | in the file; or |
| 14802 | |
| 14803 | (c) The contribution was provided directly to me by some other |
| 14804 | person who certified (a), (b) or (c) and I have not modified |
| 14805 | it. |
| 14806 | |
| 14807 | (d) I understand and agree that this project and the contribution |
| 14808 | are public and that a record of the contribution (including all |
| 14809 | personal information I submit with it, including my sign-off) is |
| 14810 | maintained indefinitely and may be redistributed consistent with |
| 14811 | this project or the open source license(s) involved. |
| 14812 | </literallayout> |
| 14813 | </para></listitem> |
| 14814 | <listitem><para> |
| 14815 | Provide a single-line summary of the change. |
| 14816 | and, |
| 14817 | if more explanation is needed, provide more |
| 14818 | detail in the body of the commit. |
| 14819 | This summary is typically viewable in the |
| 14820 | "shortlist" of changes. |
| 14821 | Thus, providing something short and descriptive |
| 14822 | that gives the reader a summary of the change is |
| 14823 | useful when viewing a list of many commits. |
| 14824 | You should prefix this short description with the |
| 14825 | recipe name (if changing a recipe), or else with |
| 14826 | the short form path to the file being changed. |
| 14827 | </para></listitem> |
| 14828 | <listitem><para> |
| 14829 | For the body of the commit message, provide |
| 14830 | detailed information that describes what you |
| 14831 | changed, why you made the change, and the approach |
| 14832 | you used. |
| 14833 | It might also be helpful if you mention how you |
| 14834 | tested the change. |
| 14835 | Provide as much detail as you can in the body of |
| 14836 | the commit message. |
| 14837 | <note> |
| 14838 | You do not need to provide a more detailed |
| 14839 | explanation of a change if the change is |
| 14840 | minor to the point of the single line |
| 14841 | summary providing all the information. |
| 14842 | </note> |
| 14843 | </para></listitem> |
| 14844 | <listitem><para> |
| 14845 | If the change addresses a specific bug or issue |
| 14846 | that is associated with a bug-tracking ID, |
| 14847 | include a reference to that ID in your detailed |
| 14848 | description. |
| 14849 | For example, the Yocto Project uses a specific |
| 14850 | convention for bug references - any commit that |
| 14851 | addresses a specific bug should use the following |
| 14852 | form for the detailed description. |
| 14853 | Be sure to use the actual bug-tracking ID from |
| 14854 | Bugzilla for |
| 14855 | <replaceable>bug-id</replaceable>: |
| 14856 | <literallayout class='monospaced'> |
| 14857 | Fixes [YOCTO #<replaceable>bug-id</replaceable>] |
| 14858 | |
| 14859 | <replaceable>detailed description of change</replaceable> |
| 14860 | </literallayout> |
| 14861 | </para></listitem> |
| 14862 | </itemizedlist> |
| 14863 | </para></listitem> |
| 14864 | <listitem><para> |
| 14865 | <emphasis>Push Your Commits to a "Contrib" Upstream:</emphasis> |
| 14866 | If you have arranged for permissions to push to an |
| 14867 | upstream contrib repository, push the change to that |
| 14868 | repository: |
| 14869 | <literallayout class='monospaced'> |
| 14870 | $ git push <replaceable>upstream_remote_repo</replaceable> <replaceable>local_branch_name</replaceable> |
| 14871 | </literallayout> |
| 14872 | For example, suppose you have permissions to push into the |
| 14873 | upstream <filename>meta-intel-contrib</filename> |
| 14874 | repository and you are working in a local branch named |
| 14875 | <replaceable>your_name</replaceable><filename>/README</filename>. |
| 14876 | The following command pushes your local commits to the |
| 14877 | <filename>meta-intel-contrib</filename> upstream |
| 14878 | repository and puts the commit in a branch named |
| 14879 | <replaceable>your_name</replaceable><filename>/README</filename>: |
| 14880 | <literallayout class='monospaced'> |
| 14881 | $ git push meta-intel-contrib <replaceable>your_name</replaceable>/README |
| 14882 | </literallayout> |
| 14883 | </para></listitem> |
| 14884 | <listitem><para id='push-determine-who-to-notify'> |
| 14885 | <emphasis>Determine Who to Notify:</emphasis> |
| 14886 | Determine the maintainer or the mailing list |
| 14887 | that you need to notify for the change.</para> |
| 14888 | |
| 14889 | <para>Before submitting any change, you need to be sure |
| 14890 | who the maintainer is or what mailing list that you need |
| 14891 | to notify. |
| 14892 | Use either these methods to find out: |
| 14893 | <itemizedlist> |
| 14894 | <listitem><para> |
| 14895 | <emphasis>Maintenance File:</emphasis> |
| 14896 | Examine the <filename>maintainers.inc</filename> |
| 14897 | file, which is located in the |
| 14898 | <ulink url='&YOCTO_DOCS_REF_URL;#source-directory'>Source Directory</ulink> |
| 14899 | at |
| 14900 | <filename>meta/conf/distro/include</filename>, |
| 14901 | to see who is responsible for code. |
| 14902 | </para></listitem> |
| 14903 | <listitem><para> |
| 14904 | <emphasis>Search by File:</emphasis> |
| 14905 | Using <ulink url='&YOCTO_DOCS_OM_URL;#git'>Git</ulink>, |
| 14906 | you can enter the following command to bring up a |
| 14907 | short list of all commits against a specific file: |
| 14908 | <literallayout class='monospaced'> |
| 14909 | git shortlog -- <replaceable>filename</replaceable> |
| 14910 | </literallayout> |
| 14911 | Just provide the name of the file for which you |
| 14912 | are interested. |
| 14913 | The information returned is not ordered by history |
| 14914 | but does include a list of everyone who has |
| 14915 | committed grouped by name. |
| 14916 | From the list, you can see who is responsible for |
| 14917 | the bulk of the changes against the file. |
| 14918 | </para></listitem> |
| 14919 | <listitem><para> |
| 14920 | <emphasis>Examine the List of Mailing Lists:</emphasis> |
| 14921 | For a list of the Yocto Project and related mailing |
| 14922 | lists, see the |
| 14923 | "<ulink url='&YOCTO_DOCS_REF_URL;#resources-mailinglist'>Mailing lists</ulink>" |
| 14924 | section in the Yocto Project Reference Manual. |
| 14925 | </para></listitem> |
| 14926 | </itemizedlist> |
| 14927 | </para></listitem> |
| 14928 | <listitem><para> |
| 14929 | <emphasis>Make a Pull Request:</emphasis> |
| 14930 | Notify the maintainer or the mailing list that you have |
| 14931 | pushed a change by making a pull request.</para> |
| 14932 | |
| 14933 | <para>The Yocto Project provides two scripts that |
| 14934 | conveniently let you generate and send pull requests to the |
| 14935 | Yocto Project. |
| 14936 | These scripts are <filename>create-pull-request</filename> |
| 14937 | and <filename>send-pull-request</filename>. |
| 14938 | You can find these scripts in the |
| 14939 | <filename>scripts</filename> directory within the |
| 14940 | <ulink url='&YOCTO_DOCS_REF_URL;#source-directory'>Source Directory</ulink> |
| 14941 | (e.g. <filename>~/poky/scripts</filename>). |
| 14942 | </para> |
| 14943 | |
| 14944 | <para>Using these scripts correctly formats the requests |
| 14945 | without introducing any whitespace or HTML formatting. |
| 14946 | The maintainer that receives your patches either directly |
| 14947 | or through the mailing list needs to be able to save and |
| 14948 | apply them directly from your emails. |
| 14949 | Using these scripts is the preferred method for sending |
| 14950 | patches.</para> |
| 14951 | |
| 14952 | <para>First, create the pull request. |
| 14953 | For example, the following command runs the script, |
| 14954 | specifies the upstream repository in the contrib directory |
| 14955 | into which you pushed the change, and provides a subject |
| 14956 | line in the created patch files: |
| 14957 | <literallayout class='monospaced'> |
| 14958 | $ ~/poky/scripts/create-pull-request -u meta-intel-contrib -s "Updated Manual Section Reference in README" |
| 14959 | </literallayout> |
| 14960 | Running this script forms |
| 14961 | <filename>*.patch</filename> files in a folder named |
| 14962 | <filename>pull-</filename><replaceable>PID</replaceable> |
| 14963 | in the current directory. |
| 14964 | One of the patch files is a cover letter.</para> |
| 14965 | |
| 14966 | <para>Before running the |
| 14967 | <filename>send-pull-request</filename> script, you must |
| 14968 | edit the cover letter patch to insert information about |
| 14969 | your change. |
| 14970 | After editing the cover letter, send the pull request. |
| 14971 | For example, the following command runs the script and |
| 14972 | specifies the patch directory and email address. |
| 14973 | In this example, the email address is a mailing list: |
| 14974 | <literallayout class='monospaced'> |
| 14975 | $ ~/poky/scripts/send-pull-request -p ~/meta-intel/pull-10565 -t meta-intel@yoctoproject.org |
| 14976 | </literallayout> |
| 14977 | You need to follow the prompts as the script is |
| 14978 | interactive. |
| 14979 | <note> |
| 14980 | For help on using these scripts, simply provide the |
| 14981 | <filename>-h</filename> argument as follows: |
| 14982 | <literallayout class='monospaced'> |
| 14983 | $ poky/scripts/create-pull-request -h |
| 14984 | $ poky/scripts/send-pull-request -h |
| 14985 | </literallayout> |
| 14986 | </note> |
| 14987 | </para></listitem> |
| 14988 | </orderedlist> |
| 14989 | </para> |
| 14990 | </section> |
| 14991 | |
| 14992 | <section id='submitting-a-patch'> |
| 14993 | <title>Using Email to Submit a Patch</title> |
| 14994 | |
| 14995 | <para> |
| 14996 | You can submit patches without using the |
| 14997 | <filename>create-pull-request</filename> and |
| 14998 | <filename>send-pull-request</filename> scripts described in the |
| 14999 | previous section. |
| 15000 | However, keep in mind, the preferred method is to use the scripts. |
| 15001 | </para> |
| 15002 | |
| 15003 | <para> |
| 15004 | Depending on the components changed, you need to submit the email |
| 15005 | to a specific mailing list. |
| 15006 | For some guidance on which mailing list to use, see the |
| 15007 | <link linkend='figuring-out-the-mailing-list-to-use'>list</link> |
| 15008 | at the beginning of this section. |
| 15009 | For a description of all the available mailing lists, see the |
| 15010 | "<ulink url='&YOCTO_DOCS_REF_URL;#resources-mailinglist'>Mailing Lists</ulink>" |
| 15011 | section in the Yocto Project Reference Manual. |
| 15012 | </para> |
| 15013 | |
| 15014 | <para> |
| 15015 | Here is the general procedure on how to submit a patch through |
| 15016 | email without using the scripts: |
| 15017 | <orderedlist> |
| 15018 | <listitem><para> |
| 15019 | <emphasis>Make Your Changes Locally:</emphasis> |
| 15020 | Make your changes in your local Git repository. |
| 15021 | You should make small, controlled, isolated changes. |
| 15022 | Keeping changes small and isolated aids review, |
| 15023 | makes merging/rebasing easier and keeps the change |
| 15024 | history clean should anyone need to refer to it in |
| 15025 | future. |
| 15026 | </para></listitem> |
| 15027 | <listitem><para> |
| 15028 | <emphasis>Stage Your Changes:</emphasis> |
| 15029 | Stage your changes by using the <filename>git add</filename> |
| 15030 | command on each file you changed. |
| 15031 | </para></listitem> |
| 15032 | <listitem><para> |
| 15033 | <emphasis>Commit Your Changes:</emphasis> |
| 15034 | Commit the change by using the |
| 15035 | <filename>git commit --signoff</filename> command. |
| 15036 | Using the <filename>--signoff</filename> option identifies |
| 15037 | you as the person making the change and also satisfies |
| 15038 | the Developer's Certificate of Origin (DCO) shown earlier. |
| 15039 | </para> |
| 15040 | |
| 15041 | <para>When you form a commit, you must follow certain |
| 15042 | standards established by the Yocto Project development |
| 15043 | team. |
| 15044 | See |
| 15045 | <link linkend='making-sure-you-have-correct-commit-information'>Step 3</link> |
| 15046 | in the previous section for information on how to |
| 15047 | provide commit information that meets Yocto Project |
| 15048 | commit message standards. |
| 15049 | </para></listitem> |
| 15050 | <listitem><para> |
| 15051 | <emphasis>Format the Commit:</emphasis> |
| 15052 | Format the commit into an email message. |
| 15053 | To format commits, use the |
| 15054 | <filename>git format-patch</filename> command. |
| 15055 | When you provide the command, you must include a revision |
| 15056 | list or a number of patches as part of the command. |
| 15057 | For example, either of these two commands takes your most |
| 15058 | recent single commit and formats it as an email message in |
| 15059 | the current directory: |
| 15060 | <literallayout class='monospaced'> |
| 15061 | $ git format-patch -1 |
| 15062 | </literallayout> |
| 15063 | or |
| 15064 | <literallayout class='monospaced'> |
| 15065 | $ git format-patch HEAD~ |
| 15066 | </literallayout></para> |
| 15067 | |
| 15068 | <para>After the command is run, the current directory |
| 15069 | contains a numbered <filename>.patch</filename> file for |
| 15070 | the commit.</para> |
| 15071 | |
| 15072 | <para>If you provide several commits as part of the |
| 15073 | command, the <filename>git format-patch</filename> command |
| 15074 | produces a series of numbered files in the current |
| 15075 | directory – one for each commit. |
| 15076 | If you have more than one patch, you should also use the |
| 15077 | <filename>--cover</filename> option with the command, |
| 15078 | which generates a cover letter as the first "patch" in |
| 15079 | the series. |
| 15080 | You can then edit the cover letter to provide a |
| 15081 | description for the series of patches. |
| 15082 | For information on the |
| 15083 | <filename>git format-patch</filename> command, |
| 15084 | see <filename>GIT_FORMAT_PATCH(1)</filename> displayed |
| 15085 | using the <filename>man git-format-patch</filename> |
| 15086 | command. |
| 15087 | <note> |
| 15088 | If you are or will be a frequent contributor to the |
| 15089 | Yocto Project or to OpenEmbedded, you might consider |
| 15090 | requesting a contrib area and the necessary associated |
| 15091 | rights. |
| 15092 | </note> |
| 15093 | </para></listitem> |
| 15094 | <listitem><para> |
| 15095 | <emphasis>Import the Files Into Your Mail Client:</emphasis> |
| 15096 | Import the files into your mail client by using the |
| 15097 | <filename>git send-email</filename> command. |
| 15098 | <note> |
| 15099 | In order to use <filename>git send-email</filename>, |
| 15100 | you must have the proper Git packages installed on |
| 15101 | your host. |
| 15102 | For Ubuntu, Debian, and Fedora the package is |
| 15103 | <filename>git-email</filename>. |
| 15104 | </note></para> |
| 15105 | |
| 15106 | <para>The <filename>git send-email</filename> command |
| 15107 | sends email by using a local or remote Mail Transport Agent |
| 15108 | (MTA) such as <filename>msmtp</filename>, |
| 15109 | <filename>sendmail</filename>, or through a direct |
| 15110 | <filename>smtp</filename> configuration in your Git |
| 15111 | <filename>~/.gitconfig</filename> file. |
| 15112 | If you are submitting patches through email only, it is |
| 15113 | very important that you submit them without any whitespace |
| 15114 | or HTML formatting that either you or your mailer |
| 15115 | introduces. |
| 15116 | The maintainer that receives your patches needs to be able |
| 15117 | to save and apply them directly from your emails. |
| 15118 | A good way to verify that what you are sending will be |
| 15119 | applicable by the maintainer is to do a dry run and send |
| 15120 | them to yourself and then save and apply them as the |
| 15121 | maintainer would.</para> |
| 15122 | |
| 15123 | <para>The <filename>git send-email</filename> command is |
| 15124 | the preferred method for sending your patches using |
| 15125 | email since there is no risk of compromising whitespace |
| 15126 | in the body of the message, which can occur when you use |
| 15127 | your own mail client. |
| 15128 | The command also has several options that let you |
| 15129 | specify recipients and perform further editing of the |
| 15130 | email message. |
| 15131 | For information on how to use the |
| 15132 | <filename>git send-email</filename> command, |
| 15133 | see <filename>GIT-SEND-EMAIL(1)</filename> displayed using |
| 15134 | the <filename>man git-send-email</filename> command. |
| 15135 | </para></listitem> |
| 15136 | </orderedlist> |
| 15137 | </para> |
| 15138 | </section> |
| 15139 | </section> |
| 15140 | </section> |
| 15141 | |
| 15142 | <section id='working-with-licenses'> |
| 15143 | <title>Working With Licenses</title> |
| 15144 | |
| 15145 | <para> |
| 15146 | As mentioned in the |
| 15147 | "<ulink url='&YOCTO_DOCS_OM_URL;#licensing'>Licensing</ulink>" |
| 15148 | section in the Yocto Project Overview and Concepts Manual, |
| 15149 | open source projects are open to the public and they |
| 15150 | consequently have different licensing structures in place. |
| 15151 | This section describes the mechanism by which the |
| 15152 | <ulink url='&YOCTO_DOCS_REF_URL;#build-system-term'>OpenEmbedded build system</ulink> |
| 15153 | tracks changes to licensing text and covers how to maintain open |
| 15154 | source license compliance during your project's lifecycle. |
| 15155 | The section also describes how to enable commercially licensed |
| 15156 | recipes, which by default are disabled. |
| 15157 | </para> |
| 15158 | |
| 15159 | <section id="usingpoky-configuring-LIC_FILES_CHKSUM"> |
| 15160 | <title>Tracking License Changes</title> |
| 15161 | |
| 15162 | <para> |
| 15163 | The license of an upstream project might change in the future. |
| 15164 | In order to prevent these changes going unnoticed, the |
| 15165 | <ulink url='&YOCTO_DOCS_REF_URL;#var-LIC_FILES_CHKSUM'><filename>LIC_FILES_CHKSUM</filename></ulink> |
| 15166 | variable tracks changes to the license text. The checksums are |
| 15167 | validated at the end of the configure step, and if the |
| 15168 | checksums do not match, the build will fail. |
| 15169 | </para> |
| 15170 | |
| 15171 | <section id="usingpoky-specifying-LIC_FILES_CHKSUM"> |
| 15172 | <title>Specifying the <filename>LIC_FILES_CHKSUM</filename> Variable</title> |
| 15173 | |
| 15174 | <para> |
| 15175 | The <filename>LIC_FILES_CHKSUM</filename> |
| 15176 | variable contains checksums of the license text in the |
| 15177 | source code for the recipe. |
| 15178 | Following is an example of how to specify |
| 15179 | <filename>LIC_FILES_CHKSUM</filename>: |
| 15180 | <literallayout class='monospaced'> |
| 15181 | LIC_FILES_CHKSUM = "file://COPYING;md5=xxxx \ |
| 15182 | file://licfile1.txt;beginline=5;endline=29;md5=yyyy \ |
| 15183 | file://licfile2.txt;endline=50;md5=zzzz \ |
| 15184 | ..." |
| 15185 | </literallayout> |
| 15186 | <note><title>Notes</title> |
| 15187 | <itemizedlist> |
| 15188 | <listitem><para> |
| 15189 | When using "beginline" and "endline", realize |
| 15190 | that line numbering begins with one and not |
| 15191 | zero. |
| 15192 | Also, the included lines are inclusive (i.e. |
| 15193 | lines five through and including 29 in the |
| 15194 | previous example for |
| 15195 | <filename>licfile1.txt</filename>). |
| 15196 | </para></listitem> |
| 15197 | <listitem><para> |
| 15198 | When a license check fails, the selected license |
| 15199 | text is included as part of the QA message. |
| 15200 | Using this output, you can determine the exact |
| 15201 | start and finish for the needed license text. |
| 15202 | </para></listitem> |
| 15203 | </itemizedlist> |
| 15204 | </note> |
| 15205 | </para> |
| 15206 | |
| 15207 | <para> |
| 15208 | The build system uses the |
| 15209 | <ulink url='&YOCTO_DOCS_REF_URL;#var-S'><filename>S</filename></ulink> |
| 15210 | variable as the default directory when searching files |
| 15211 | listed in <filename>LIC_FILES_CHKSUM</filename>. |
| 15212 | The previous example employs the default directory. |
| 15213 | </para> |
| 15214 | |
| 15215 | <para> |
| 15216 | Consider this next example: |
| 15217 | <literallayout class='monospaced'> |
| 15218 | LIC_FILES_CHKSUM = "file://src/ls.c;beginline=5;endline=16;\ |
| 15219 | md5=bb14ed3c4cda583abc85401304b5cd4e" |
| 15220 | LIC_FILES_CHKSUM = "file://${WORKDIR}/license.html;md5=5c94767cedb5d6987c902ac850ded2c6" |
| 15221 | </literallayout> |
| 15222 | </para> |
| 15223 | |
| 15224 | <para> |
| 15225 | The first line locates a file in |
| 15226 | <filename>${S}/src/ls.c</filename> and isolates lines five |
| 15227 | through 16 as license text. |
| 15228 | The second line refers to a file in |
| 15229 | <ulink url='&YOCTO_DOCS_REF_URL;#var-WORKDIR'><filename>WORKDIR</filename></ulink>. |
| 15230 | </para> |
| 15231 | |
| 15232 | <para> |
| 15233 | Note that <filename>LIC_FILES_CHKSUM</filename> variable is |
| 15234 | mandatory for all recipes, unless the |
| 15235 | <filename>LICENSE</filename> variable is set to "CLOSED". |
| 15236 | </para> |
| 15237 | </section> |
| 15238 | |
| 15239 | <section id="usingpoky-LIC_FILES_CHKSUM-explanation-of-syntax"> |
| 15240 | <title>Explanation of Syntax</title> |
| 15241 | |
| 15242 | <para> |
| 15243 | As mentioned in the previous section, the |
| 15244 | <filename>LIC_FILES_CHKSUM</filename> variable lists all |
| 15245 | the important files that contain the license text for the |
| 15246 | source code. |
| 15247 | It is possible to specify a checksum for an entire file, |
| 15248 | or a specific section of a file (specified by beginning and |
| 15249 | ending line numbers with the "beginline" and "endline" |
| 15250 | parameters, respectively). |
| 15251 | The latter is useful for source files with a license |
| 15252 | notice header, README documents, and so forth. |
| 15253 | If you do not use the "beginline" parameter, then it is |
| 15254 | assumed that the text begins on the first line of the file. |
| 15255 | Similarly, if you do not use the "endline" parameter, |
| 15256 | it is assumed that the license text ends with the last |
| 15257 | line of the file. |
| 15258 | </para> |
| 15259 | |
| 15260 | <para> |
| 15261 | The "md5" parameter stores the md5 checksum of the license |
| 15262 | text. |
| 15263 | If the license text changes in any way as compared to |
| 15264 | this parameter then a mismatch occurs. |
| 15265 | This mismatch triggers a build failure and notifies |
| 15266 | the developer. |
| 15267 | Notification allows the developer to review and address |
| 15268 | the license text changes. |
| 15269 | Also note that if a mismatch occurs during the build, |
| 15270 | the correct md5 checksum is placed in the build log and |
| 15271 | can be easily copied to the recipe. |
| 15272 | </para> |
| 15273 | |
| 15274 | <para> |
| 15275 | There is no limit to how many files you can specify using |
| 15276 | the <filename>LIC_FILES_CHKSUM</filename> variable. |
| 15277 | Generally, however, every project requires a few |
| 15278 | specifications for license tracking. |
| 15279 | Many projects have a "COPYING" file that stores the |
| 15280 | license information for all the source code files. |
| 15281 | This practice allows you to just track the "COPYING" |
| 15282 | file as long as it is kept up to date. |
| 15283 | <note><title>Tips</title> |
| 15284 | <itemizedlist> |
| 15285 | <listitem><para> |
| 15286 | If you specify an empty or invalid "md5" |
| 15287 | parameter, |
| 15288 | <ulink url='&YOCTO_DOCS_REF_URL;#bitbake-term'>BitBake</ulink> |
| 15289 | returns an md5 mis-match |
| 15290 | error and displays the correct "md5" parameter |
| 15291 | value during the build. |
| 15292 | The correct parameter is also captured in |
| 15293 | the build log. |
| 15294 | </para></listitem> |
| 15295 | <listitem><para> |
| 15296 | If the whole file contains only license text, |
| 15297 | you do not need to use the "beginline" and |
| 15298 | "endline" parameters. |
| 15299 | </para></listitem> |
| 15300 | </itemizedlist> |
| 15301 | </note> |
| 15302 | </para> |
| 15303 | </section> |
| 15304 | </section> |
| 15305 | |
| 15306 | <section id="enabling-commercially-licensed-recipes"> |
| 15307 | <title>Enabling Commercially Licensed Recipes</title> |
| 15308 | |
| 15309 | <para> |
| 15310 | By default, the OpenEmbedded build system disables |
| 15311 | components that have commercial or other special licensing |
| 15312 | requirements. |
| 15313 | Such requirements are defined on a |
| 15314 | recipe-by-recipe basis through the |
| 15315 | <ulink url='&YOCTO_DOCS_REF_URL;#var-LICENSE_FLAGS'><filename>LICENSE_FLAGS</filename></ulink> |
| 15316 | variable definition in the affected recipe. |
| 15317 | For instance, the |
| 15318 | <filename>poky/meta/recipes-multimedia/gstreamer/gst-plugins-ugly</filename> |
| 15319 | recipe contains the following statement: |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 15320 | <literallayout class='monospaced'> |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 15321 | LICENSE_FLAGS = "commercial" |
| 15322 | </literallayout> |
| 15323 | Here is a slightly more complicated example that contains both |
| 15324 | an explicit recipe name and version (after variable expansion): |
| 15325 | <literallayout class='monospaced'> |
| 15326 | LICENSE_FLAGS = "license_${PN}_${PV}" |
| 15327 | </literallayout> |
| 15328 | In order for a component restricted by a |
| 15329 | <filename>LICENSE_FLAGS</filename> definition to be enabled and |
| 15330 | included in an image, it needs to have a matching entry in the |
| 15331 | global |
| 15332 | <ulink url='&YOCTO_DOCS_REF_URL;#var-LICENSE_FLAGS_WHITELIST'><filename>LICENSE_FLAGS_WHITELIST</filename></ulink> |
| 15333 | variable, which is a variable typically defined in your |
| 15334 | <filename>local.conf</filename> file. |
| 15335 | For example, to enable the |
| 15336 | <filename>poky/meta/recipes-multimedia/gstreamer/gst-plugins-ugly</filename> |
| 15337 | package, you could add either the string |
| 15338 | "commercial_gst-plugins-ugly" or the more general string |
| 15339 | "commercial" to <filename>LICENSE_FLAGS_WHITELIST</filename>. |
| 15340 | See the |
| 15341 | "<link linkend='license-flag-matching'>License Flag Matching</link>" |
| 15342 | section for a full |
| 15343 | explanation of how <filename>LICENSE_FLAGS</filename> matching |
| 15344 | works. |
| 15345 | Here is the example: |
| 15346 | <literallayout class='monospaced'> |
| 15347 | LICENSE_FLAGS_WHITELIST = "commercial_gst-plugins-ugly" |
| 15348 | </literallayout> |
| 15349 | Likewise, to additionally enable the package built from the |
| 15350 | recipe containing |
| 15351 | <filename>LICENSE_FLAGS = "license_${PN}_${PV}"</filename>, |
| 15352 | and assuming that the actual recipe name was |
| 15353 | <filename>emgd_1.10.bb</filename>, the following string would |
| 15354 | enable that package as well as the original |
| 15355 | <filename>gst-plugins-ugly</filename> package: |
| 15356 | <literallayout class='monospaced'> |
| 15357 | LICENSE_FLAGS_WHITELIST = "commercial_gst-plugins-ugly license_emgd_1.10" |
| 15358 | </literallayout> |
| 15359 | As a convenience, you do not need to specify the complete |
| 15360 | license string in the whitelist for every package. |
| 15361 | You can use an abbreviated form, which consists |
| 15362 | of just the first portion or portions of the license |
| 15363 | string before the initial underscore character or characters. |
| 15364 | A partial string will match any license that contains the |
| 15365 | given string as the first portion of its license. |
| 15366 | For example, the following whitelist string will also match |
| 15367 | both of the packages previously mentioned as well as any other |
| 15368 | packages that have licenses starting with "commercial" or |
| 15369 | "license". |
| 15370 | <literallayout class='monospaced'> |
| 15371 | LICENSE_FLAGS_WHITELIST = "commercial license" |
| 15372 | </literallayout> |
| 15373 | </para> |
| 15374 | |
| 15375 | <section id="license-flag-matching"> |
| 15376 | <title>License Flag Matching</title> |
| 15377 | |
| 15378 | <para> |
| 15379 | License flag matching allows you to control what recipes |
| 15380 | the OpenEmbedded build system includes in the build. |
| 15381 | Fundamentally, the build system attempts to match |
| 15382 | <filename>LICENSE_FLAGS</filename> strings found in recipes |
| 15383 | against <filename>LICENSE_FLAGS_WHITELIST</filename> |
| 15384 | strings found in the whitelist. |
| 15385 | A match causes the build system to include a recipe in the |
| 15386 | build, while failure to find a match causes the build |
| 15387 | system to exclude a recipe. |
| 15388 | </para> |
| 15389 | |
| 15390 | <para> |
| 15391 | In general, license flag matching is simple. |
| 15392 | However, understanding some concepts will help you |
| 15393 | correctly and effectively use matching. |
| 15394 | </para> |
| 15395 | |
| 15396 | <para> |
| 15397 | Before a flag |
| 15398 | defined by a particular recipe is tested against the |
| 15399 | contents of the whitelist, the expanded string |
| 15400 | <filename>_${PN}</filename> is appended to the flag. |
| 15401 | This expansion makes each |
| 15402 | <filename>LICENSE_FLAGS</filename> value recipe-specific. |
| 15403 | After expansion, the string is then matched against the |
| 15404 | whitelist. |
| 15405 | Thus, specifying |
| 15406 | <filename>LICENSE_FLAGS = "commercial"</filename> |
| 15407 | in recipe "foo", for example, results in the string |
| 15408 | <filename>"commercial_foo"</filename>. |
| 15409 | And, to create a match, that string must appear in the |
| 15410 | whitelist. |
| 15411 | </para> |
| 15412 | |
| 15413 | <para> |
| 15414 | Judicious use of the <filename>LICENSE_FLAGS</filename> |
| 15415 | strings and the contents of the |
| 15416 | <filename>LICENSE_FLAGS_WHITELIST</filename> variable |
| 15417 | allows you a lot of flexibility for including or excluding |
| 15418 | recipes based on licensing. |
| 15419 | For example, you can broaden the matching capabilities by |
| 15420 | using license flags string subsets in the whitelist. |
| 15421 | <note> |
| 15422 | When using a string subset, be sure to use the part of |
| 15423 | the expanded string that precedes the appended |
| 15424 | underscore character (e.g. |
| 15425 | <filename>usethispart_1.3</filename>, |
| 15426 | <filename>usethispart_1.4</filename>, and so forth). |
| 15427 | </note> |
| 15428 | For example, simply specifying the string "commercial" in |
| 15429 | the whitelist matches any expanded |
| 15430 | <filename>LICENSE_FLAGS</filename> definition that starts |
| 15431 | with the string "commercial" such as "commercial_foo" and |
| 15432 | "commercial_bar", which are the strings the build system |
| 15433 | automatically generates for hypothetical recipes named |
| 15434 | "foo" and "bar" assuming those recipes simply specify the |
| 15435 | following: |
| 15436 | <literallayout class='monospaced'> |
| 15437 | LICENSE_FLAGS = "commercial" |
| 15438 | </literallayout> |
| 15439 | Thus, you can choose to exhaustively |
| 15440 | enumerate each license flag in the whitelist and |
| 15441 | allow only specific recipes into the image, or |
| 15442 | you can use a string subset that causes a broader range of |
| 15443 | matches to allow a range of recipes into the image. |
| 15444 | </para> |
| 15445 | |
| 15446 | <para> |
| 15447 | This scheme works even if the |
| 15448 | <filename>LICENSE_FLAGS</filename> string already |
| 15449 | has <filename>_${PN}</filename> appended. |
| 15450 | For example, the build system turns the license flag |
| 15451 | "commercial_1.2_foo" into "commercial_1.2_foo_foo" and |
| 15452 | would match both the general "commercial" and the specific |
| 15453 | "commercial_1.2_foo" strings found in the whitelist, as |
| 15454 | expected. |
| 15455 | </para> |
| 15456 | |
| 15457 | <para> |
| 15458 | Here are some other scenarios: |
| 15459 | <itemizedlist> |
| 15460 | <listitem><para> |
| 15461 | You can specify a versioned string in the recipe |
| 15462 | such as "commercial_foo_1.2" in a "foo" recipe. |
| 15463 | The build system expands this string to |
| 15464 | "commercial_foo_1.2_foo". |
| 15465 | Combine this license flag with a whitelist that has |
| 15466 | the string "commercial" and you match the flag |
| 15467 | along with any other flag that starts with the |
| 15468 | string "commercial". |
| 15469 | </para></listitem> |
| 15470 | <listitem><para> |
| 15471 | Under the same circumstances, you can use |
| 15472 | "commercial_foo" in the whitelist and the build |
| 15473 | system not only matches "commercial_foo_1.2" but |
| 15474 | also matches any license flag with the string |
| 15475 | "commercial_foo", regardless of the version. |
| 15476 | </para></listitem> |
| 15477 | <listitem><para> |
| 15478 | You can be very specific and use both the |
| 15479 | package and version parts in the whitelist (e.g. |
| 15480 | "commercial_foo_1.2") to specifically match a |
| 15481 | versioned recipe. |
| 15482 | </para></listitem> |
| 15483 | </itemizedlist> |
| 15484 | </para> |
| 15485 | </section> |
| 15486 | |
| 15487 | <section id="other-variables-related-to-commercial-licenses"> |
| 15488 | <title>Other Variables Related to Commercial Licenses</title> |
| 15489 | |
| 15490 | <para> |
| 15491 | Other helpful variables related to commercial |
| 15492 | license handling exist and are defined in the |
| 15493 | <filename>poky/meta/conf/distro/include/default-distrovars.inc</filename> file: |
| 15494 | <literallayout class='monospaced'> |
| 15495 | COMMERCIAL_AUDIO_PLUGINS ?= "" |
| 15496 | COMMERCIAL_VIDEO_PLUGINS ?= "" |
| 15497 | </literallayout> |
| 15498 | If you want to enable these components, you can do so by |
| 15499 | making sure you have statements similar to the following |
| 15500 | in your <filename>local.conf</filename> configuration file: |
| 15501 | <literallayout class='monospaced'> |
| 15502 | COMMERCIAL_AUDIO_PLUGINS = "gst-plugins-ugly-mad \ |
| 15503 | gst-plugins-ugly-mpegaudioparse" |
| 15504 | COMMERCIAL_VIDEO_PLUGINS = "gst-plugins-ugly-mpeg2dec \ |
| 15505 | gst-plugins-ugly-mpegstream gst-plugins-bad-mpegvideoparse" |
| 15506 | LICENSE_FLAGS_WHITELIST = "commercial_gst-plugins-ugly commercial_gst-plugins-bad commercial_qmmp" |
| 15507 | </literallayout> |
| 15508 | Of course, you could also create a matching whitelist |
| 15509 | for those components using the more general "commercial" |
| 15510 | in the whitelist, but that would also enable all the |
| 15511 | other packages with <filename>LICENSE_FLAGS</filename> |
| 15512 | containing "commercial", which you may or may not want: |
| 15513 | <literallayout class='monospaced'> |
| 15514 | LICENSE_FLAGS_WHITELIST = "commercial" |
| 15515 | </literallayout> |
| 15516 | </para> |
| 15517 | |
| 15518 | <para> |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 15519 | Specifying audio and video plugins as part of the |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 15520 | <filename>COMMERCIAL_AUDIO_PLUGINS</filename> and |
| 15521 | <filename>COMMERCIAL_VIDEO_PLUGINS</filename> statements |
| 15522 | (along with the enabling |
| 15523 | <filename>LICENSE_FLAGS_WHITELIST</filename>) includes the |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 15524 | plugins or components into built images, thus adding |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 15525 | support for media formats or components. |
| 15526 | </para> |
| 15527 | </section> |
| 15528 | </section> |
| 15529 | |
| 15530 | <section id='maintaining-open-source-license-compliance-during-your-products-lifecycle'> |
| 15531 | <title>Maintaining Open Source License Compliance During Your Product's Lifecycle</title> |
| 15532 | |
| 15533 | <para> |
| 15534 | One of the concerns for a development organization using open source |
| 15535 | software is how to maintain compliance with various open source |
| 15536 | licensing during the lifecycle of the product. |
| 15537 | While this section does not provide legal advice or |
| 15538 | comprehensively cover all scenarios, it does |
| 15539 | present methods that you can use to |
| 15540 | assist you in meeting the compliance requirements during a software |
| 15541 | release. |
| 15542 | </para> |
| 15543 | |
| 15544 | <para> |
| 15545 | With hundreds of different open source licenses that the Yocto |
| 15546 | Project tracks, it is difficult to know the requirements of each |
| 15547 | and every license. |
| 15548 | However, the requirements of the major FLOSS licenses can begin |
| 15549 | to be covered by |
| 15550 | assuming that three main areas of concern exist: |
| 15551 | <itemizedlist> |
| 15552 | <listitem><para>Source code must be provided.</para></listitem> |
| 15553 | <listitem><para>License text for the software must be |
| 15554 | provided.</para></listitem> |
| 15555 | <listitem><para>Compilation scripts and modifications to the |
| 15556 | source code must be provided. |
| 15557 | </para></listitem> |
| 15558 | </itemizedlist> |
| 15559 | There are other requirements beyond the scope of these |
| 15560 | three and the methods described in this section |
| 15561 | (e.g. the mechanism through which source code is distributed). |
| 15562 | </para> |
| 15563 | |
| 15564 | <para> |
| 15565 | As different organizations have different methods of complying with |
| 15566 | open source licensing, this section is not meant to imply that |
| 15567 | there is only one single way to meet your compliance obligations, |
| 15568 | but rather to describe one method of achieving compliance. |
| 15569 | The remainder of this section describes methods supported to meet the |
| 15570 | previously mentioned three requirements. |
| 15571 | Once you take steps to meet these requirements, |
| 15572 | and prior to releasing images, sources, and the build system, |
| 15573 | you should audit all artifacts to ensure completeness. |
| 15574 | <note> |
| 15575 | The Yocto Project generates a license manifest during |
| 15576 | image creation that is located |
| 15577 | in <filename>${DEPLOY_DIR}/licenses/<replaceable>image_name-datestamp</replaceable></filename> |
| 15578 | to assist with any audits. |
| 15579 | </note> |
| 15580 | </para> |
| 15581 | |
| 15582 | <section id='providing-the-source-code'> |
| 15583 | <title>Providing the Source Code</title> |
| 15584 | |
| 15585 | <para> |
| 15586 | Compliance activities should begin before you generate the |
| 15587 | final image. |
| 15588 | The first thing you should look at is the requirement that |
| 15589 | tops the list for most compliance groups - providing |
| 15590 | the source. |
| 15591 | The Yocto Project has a few ways of meeting this |
| 15592 | requirement. |
| 15593 | </para> |
| 15594 | |
| 15595 | <para> |
| 15596 | One of the easiest ways to meet this requirement is |
| 15597 | to provide the entire |
| 15598 | <ulink url='&YOCTO_DOCS_REF_URL;#var-DL_DIR'><filename>DL_DIR</filename></ulink> |
| 15599 | used by the build. |
| 15600 | This method, however, has a few issues. |
| 15601 | The most obvious is the size of the directory since it includes |
| 15602 | all sources used in the build and not just the source used in |
| 15603 | the released image. |
| 15604 | It will include toolchain source, and other artifacts, which |
| 15605 | you would not generally release. |
| 15606 | However, the more serious issue for most companies is accidental |
| 15607 | release of proprietary software. |
| 15608 | The Yocto Project provides an |
| 15609 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-archiver'><filename>archiver</filename></ulink> |
| 15610 | class to help avoid some of these concerns. |
| 15611 | </para> |
| 15612 | |
| 15613 | <para> |
| 15614 | Before you employ <filename>DL_DIR</filename> or the |
| 15615 | <filename>archiver</filename> class, you need to decide how |
| 15616 | you choose to provide source. |
| 15617 | The source <filename>archiver</filename> class can generate |
| 15618 | tarballs and SRPMs and can create them with various levels of |
| 15619 | compliance in mind. |
| 15620 | </para> |
| 15621 | |
| 15622 | <para> |
| 15623 | One way of doing this (but certainly not the only way) is to |
| 15624 | release just the source as a tarball. |
| 15625 | You can do this by adding the following to the |
| 15626 | <filename>local.conf</filename> file found in the |
| 15627 | <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink>: |
| 15628 | <literallayout class='monospaced'> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 15629 | INHERIT += "archiver" |
| 15630 | ARCHIVER_MODE[src] = "original" |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 15631 | </literallayout> |
| 15632 | During the creation of your image, the source from all |
| 15633 | recipes that deploy packages to the image is placed within |
| 15634 | subdirectories of |
| 15635 | <filename>DEPLOY_DIR/sources</filename> based on the |
| 15636 | <ulink url='&YOCTO_DOCS_REF_URL;#var-LICENSE'><filename>LICENSE</filename></ulink> |
| 15637 | for each recipe. |
| 15638 | Releasing the entire directory enables you to comply with |
| 15639 | requirements concerning providing the unmodified source. |
| 15640 | It is important to note that the size of the directory can |
| 15641 | get large. |
| 15642 | </para> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 15643 | |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 15644 | <para> |
| 15645 | A way to help mitigate the size issue is to only release |
| 15646 | tarballs for licenses that require the release of |
| 15647 | source. |
| 15648 | Let us assume you are only concerned with GPL code as |
| 15649 | identified by running the following script: |
| 15650 | <literallayout class='monospaced'> |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 15651 | # Script to archive a subset of packages matching specific license(s) |
| 15652 | # Source and license files are copied into sub folders of package folder |
| 15653 | # Must be run from build folder |
| 15654 | #!/bin/bash |
| 15655 | src_release_dir="source-release" |
| 15656 | mkdir -p $src_release_dir |
| 15657 | for a in tmp/deploy/sources/*; do |
| 15658 | for d in $a/*; do |
| 15659 | # Get package name from path |
| 15660 | p=`basename $d` |
| 15661 | p=${p%-*} |
| 15662 | p=${p%-*} |
| 15663 | # Only archive GPL packages (update *GPL* regex for your license check) |
| 15664 | numfiles=`ls tmp/deploy/licenses/$p/*GPL* 2> /dev/null | wc -l` |
| 15665 | if [ $numfiles -gt 1 ]; then |
| 15666 | echo Archiving $p |
| 15667 | mkdir -p $src_release_dir/$p/source |
| 15668 | cp $d/* $src_release_dir/$p/source 2> /dev/null |
| 15669 | mkdir -p $src_release_dir/$p/license |
| 15670 | cp tmp/deploy/licenses/$p/* $src_release_dir/$p/license 2> /dev/null |
| 15671 | fi |
| 15672 | done |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 15673 | done |
| 15674 | </literallayout> |
| 15675 | At this point, you could create a tarball from the |
| 15676 | <filename>gpl_source_release</filename> directory and |
| 15677 | provide that to the end user. |
| 15678 | This method would be a step toward achieving compliance |
| 15679 | with section 3a of GPLv2 and with section 6 of GPLv3. |
| 15680 | </para> |
| 15681 | </section> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 15682 | |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 15683 | <section id='providing-license-text'> |
| 15684 | <title>Providing License Text</title> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 15685 | |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 15686 | <para> |
| 15687 | One requirement that is often overlooked is inclusion |
| 15688 | of license text. |
| 15689 | This requirement also needs to be dealt with prior to |
| 15690 | generating the final image. |
| 15691 | Some licenses require the license text to accompany |
| 15692 | the binary. |
| 15693 | You can achieve this by adding the following to your |
| 15694 | <filename>local.conf</filename> file: |
| 15695 | <literallayout class='monospaced'> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 15696 | COPY_LIC_MANIFEST = "1" |
| 15697 | COPY_LIC_DIRS = "1" |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 15698 | LICENSE_CREATE_PACKAGE = "1" |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 15699 | </literallayout> |
| 15700 | Adding these statements to the configuration file ensures |
| 15701 | that the licenses collected during package generation |
| 15702 | are included on your image. |
| 15703 | <note> |
| 15704 | <para>Setting all three variables to "1" results in the |
| 15705 | image having two copies of the same license file. |
| 15706 | One copy resides in |
| 15707 | <filename>/usr/share/common-licenses</filename> and |
| 15708 | the other resides in |
| 15709 | <filename>/usr/share/license</filename>.</para> |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 15710 | |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 15711 | <para>The reason for this behavior is because |
| 15712 | <ulink url='&YOCTO_DOCS_REF_URL;#var-COPY_LIC_DIRS'><filename>COPY_LIC_DIRS</filename></ulink> |
| 15713 | and |
| 15714 | <ulink url='&YOCTO_DOCS_REF_URL;#var-COPY_LIC_MANIFEST'><filename>COPY_LIC_MANIFEST</filename></ulink> |
| 15715 | add a copy of the license when the image is built but do |
| 15716 | not offer a path for adding licenses for newly installed |
| 15717 | packages to an image. |
| 15718 | <ulink url='&YOCTO_DOCS_REF_URL;#var-LICENSE_CREATE_PACKAGE'><filename>LICENSE_CREATE_PACKAGE</filename></ulink> |
| 15719 | adds a separate package and an upgrade path for adding |
| 15720 | licenses to an image.</para> |
| 15721 | </note> |
| 15722 | </para> |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 15723 | |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 15724 | <para> |
| 15725 | As the source <filename>archiver</filename> class has already |
| 15726 | archived the original |
| 15727 | unmodified source that contains the license files, |
| 15728 | you would have already met the requirements for inclusion |
| 15729 | of the license information with source as defined by the GPL |
| 15730 | and other open source licenses. |
| 15731 | </para> |
| 15732 | </section> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 15733 | |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 15734 | <section id='providing-compilation-scripts-and-source-code-modifications'> |
| 15735 | <title>Providing Compilation Scripts and Source Code Modifications</title> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 15736 | |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 15737 | <para> |
| 15738 | At this point, we have addressed all we need to |
| 15739 | prior to generating the image. |
| 15740 | The next two requirements are addressed during the final |
| 15741 | packaging of the release. |
| 15742 | </para> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 15743 | |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 15744 | <para> |
| 15745 | By releasing the version of the OpenEmbedded build system |
| 15746 | and the layers used during the build, you will be providing both |
| 15747 | compilation scripts and the source code modifications in one |
| 15748 | step. |
| 15749 | </para> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 15750 | |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 15751 | <para> |
| 15752 | If the deployment team has a |
| 15753 | <ulink url='&YOCTO_DOCS_BSP_URL;#bsp-layers'>BSP layer</ulink> |
| 15754 | and a distro layer, and those those layers are used to patch, |
| 15755 | compile, package, or modify (in any way) any open source |
| 15756 | software included in your released images, you |
| 15757 | might be required to release those layers under section 3 of |
| 15758 | GPLv2 or section 1 of GPLv3. |
| 15759 | One way of doing that is with a clean |
| 15760 | checkout of the version of the Yocto Project and layers used |
| 15761 | during your build. |
| 15762 | Here is an example: |
| 15763 | <literallayout class='monospaced'> |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 15764 | # We built using the &DISTRO_NAME_NO_CAP; branch of the poky repo |
| 15765 | $ git clone -b &DISTRO_NAME_NO_CAP; git://git.yoctoproject.org/poky |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 15766 | $ cd poky |
| 15767 | # We built using the release_branch for our layers |
| 15768 | $ git clone -b release_branch git://git.mycompany.com/meta-my-bsp-layer |
| 15769 | $ git clone -b release_branch git://git.mycompany.com/meta-my-software-layer |
| 15770 | # clean up the .git repos |
| 15771 | $ find . -name ".git" -type d -exec rm -rf {} \; |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 15772 | </literallayout> |
| 15773 | One thing a development organization might want to consider |
| 15774 | for end-user convenience is to modify |
| 15775 | <filename>meta-poky/conf/bblayers.conf.sample</filename> to |
| 15776 | ensure that when the end user utilizes the released build |
| 15777 | system to build an image, the development organization's |
| 15778 | layers are included in the <filename>bblayers.conf</filename> |
| 15779 | file automatically: |
| 15780 | <literallayout class='monospaced'> |
| 15781 | # POKY_BBLAYERS_CONF_VERSION is increased each time build/conf/bblayers.conf |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 15782 | # changes incompatibly |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 15783 | POKY_BBLAYERS_CONF_VERSION = "2" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 15784 | |
| 15785 | BBPATH = "${TOPDIR}" |
| 15786 | BBFILES ?= "" |
| 15787 | |
| 15788 | BBLAYERS ?= " \ |
| 15789 | ##OEROOT##/meta \ |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 15790 | ##OEROOT##/meta-poky \ |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 15791 | ##OEROOT##/meta-yocto-bsp \ |
| 15792 | ##OEROOT##/meta-mylayer \ |
| 15793 | " |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 15794 | </literallayout> |
| 15795 | Creating and providing an archive of the |
| 15796 | <ulink url='&YOCTO_DOCS_REF_URL;#metadata'>Metadata</ulink> |
| 15797 | layers (recipes, configuration files, and so forth) |
| 15798 | enables you to meet your |
| 15799 | requirements to include the scripts to control compilation |
| 15800 | as well as any modifications to the original source. |
| 15801 | </para> |
| 15802 | </section> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 15803 | </section> |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 15804 | |
| 15805 | <section id='copying-licenses-that-do-not-exist'> |
| 15806 | <title>Copying Licenses that Do Not Exist</title> |
| 15807 | |
| 15808 | <para> |
| 15809 | Some packages, such as the linux-firmware package, have many |
| 15810 | licenses that are not in any way common. |
| 15811 | You can avoid adding a lot of these types of common license |
| 15812 | files, which are only applicable to a specific package, by using |
| 15813 | the |
| 15814 | <ulink url='&YOCTO_DOCS_REF_URL;#var-NO_GENERIC_LICENSE'><filename>NO_GENERIC_LICENSE</filename></ulink> |
| 15815 | variable. |
| 15816 | Using this variable also avoids QA errors when you use a |
| 15817 | non-common, non-CLOSED license in a recipe. |
| 15818 | </para> |
| 15819 | |
| 15820 | <para> |
| 15821 | The following is an example that uses the |
| 15822 | <filename>LICENSE.Abilis.txt</filename> |
| 15823 | file as the license from the fetched source: |
| 15824 | <literallayout class='monospaced'> |
| 15825 | NO_GENERIC_LICENSE[Firmware-Abilis] = "LICENSE.Abilis.txt" |
| 15826 | </literallayout> |
| 15827 | </para> |
| 15828 | </section> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 15829 | </section> |
| 15830 | |
| 15831 | <section id='using-the-error-reporting-tool'> |
| 15832 | <title>Using the Error Reporting Tool</title> |
| 15833 | |
| 15834 | <para> |
| 15835 | The error reporting tool allows you to |
| 15836 | submit errors encountered during builds to a central database. |
| 15837 | Outside of the build environment, you can use a web interface to |
| 15838 | browse errors, view statistics, and query for errors. |
| 15839 | The tool works using a client-server system where the client |
| 15840 | portion is integrated with the installed Yocto Project |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 15841 | <ulink url='&YOCTO_DOCS_REF_URL;#source-directory'>Source Directory</ulink> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 15842 | (e.g. <filename>poky</filename>). |
| 15843 | The server receives the information collected and saves it in a |
| 15844 | database. |
| 15845 | </para> |
| 15846 | |
| 15847 | <para> |
| 15848 | A live instance of the error reporting server exists at |
| 15849 | <ulink url='http://errors.yoctoproject.org'></ulink>. |
| 15850 | This server exists so that when you want to get help with |
| 15851 | build failures, you can submit all of the information on the |
| 15852 | failure easily and then point to the URL in your bug report |
| 15853 | or send an email to the mailing list. |
| 15854 | <note> |
| 15855 | If you send error reports to this server, the reports become |
| 15856 | publicly visible. |
| 15857 | </note> |
| 15858 | </para> |
| 15859 | |
| 15860 | <section id='enabling-and-using-the-tool'> |
| 15861 | <title>Enabling and Using the Tool</title> |
| 15862 | |
| 15863 | <para> |
| 15864 | By default, the error reporting tool is disabled. |
| 15865 | You can enable it by inheriting the |
| 15866 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-report-error'><filename>report-error</filename></ulink> |
| 15867 | class by adding the following statement to the end of |
| 15868 | your <filename>local.conf</filename> file in your |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 15869 | <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink>. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 15870 | <literallayout class='monospaced'> |
| 15871 | INHERIT += "report-error" |
| 15872 | </literallayout> |
| 15873 | </para> |
| 15874 | |
| 15875 | <para> |
| 15876 | By default, the error reporting feature stores information in |
| 15877 | <filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-LOG_DIR'><filename>LOG_DIR</filename></ulink><filename>}/error-report</filename>. |
| 15878 | However, you can specify a directory to use by adding the following |
| 15879 | to your <filename>local.conf</filename> file: |
| 15880 | <literallayout class='monospaced'> |
| 15881 | ERR_REPORT_DIR = "path" |
| 15882 | </literallayout> |
| 15883 | Enabling error reporting causes the build process to collect |
| 15884 | the errors and store them in a file as previously described. |
| 15885 | When the build system encounters an error, it includes a |
| 15886 | command as part of the console output. |
| 15887 | You can run the command to send the error file to the server. |
| 15888 | For example, the following command sends the errors to an |
| 15889 | upstream server: |
| 15890 | <literallayout class='monospaced'> |
| 15891 | $ send-error-report /home/brandusa/project/poky/build/tmp/log/error-report/error_report_201403141617.txt |
| 15892 | </literallayout> |
| 15893 | In the previous example, the errors are sent to a public |
| 15894 | database available at |
| 15895 | <ulink url='http://errors.yoctoproject.org'></ulink>, which is |
| 15896 | used by the entire community. |
| 15897 | If you specify a particular server, you can send the errors |
| 15898 | to a different database. |
| 15899 | Use the following command for more information on available |
| 15900 | options: |
| 15901 | <literallayout class='monospaced'> |
| 15902 | $ send-error-report --help |
| 15903 | </literallayout> |
| 15904 | </para> |
| 15905 | |
| 15906 | <para> |
| 15907 | When sending the error file, you are prompted to review the |
| 15908 | data being sent as well as to provide a name and optional |
| 15909 | email address. |
| 15910 | Once you satisfy these prompts, the command returns a link |
| 15911 | from the server that corresponds to your entry in the database. |
| 15912 | For example, here is a typical link: |
| 15913 | <literallayout class='monospaced'> |
| 15914 | http://errors.yoctoproject.org/Errors/Details/9522/ |
| 15915 | </literallayout> |
| 15916 | Following the link takes you to a web interface where you can |
| 15917 | browse, query the errors, and view statistics. |
| 15918 | </para> |
| 15919 | </section> |
| 15920 | |
| 15921 | <section id='disabling-the-tool'> |
| 15922 | <title>Disabling the Tool</title> |
| 15923 | |
| 15924 | <para> |
| 15925 | To disable the error reporting feature, simply remove or comment |
| 15926 | out the following statement from the end of your |
| 15927 | <filename>local.conf</filename> file in your |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 15928 | <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink>. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 15929 | <literallayout class='monospaced'> |
| 15930 | INHERIT += "report-error" |
| 15931 | </literallayout> |
| 15932 | </para> |
| 15933 | </section> |
| 15934 | |
| 15935 | <section id='setting-up-your-own-error-reporting-server'> |
| 15936 | <title>Setting Up Your Own Error Reporting Server</title> |
| 15937 | |
| 15938 | <para> |
| 15939 | If you want to set up your own error reporting server, you |
| 15940 | can obtain the code from the Git repository at |
| 15941 | <ulink url='http://git.yoctoproject.org/cgit/cgit.cgi/error-report-web/'></ulink>. |
| 15942 | Instructions on how to set it up are in the README document. |
| 15943 | </para> |
| 15944 | </section> |
| 15945 | </section> |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 15946 | |
| 15947 | <section id="dev-using-wayland-and-weston"> |
| 15948 | <title>Using Wayland and Weston</title> |
| 15949 | |
| 15950 | <para> |
| 15951 | <ulink url='http://en.wikipedia.org/wiki/Wayland_(display_server_protocol)'>Wayland</ulink> |
| 15952 | is a computer display server protocol that |
| 15953 | provides a method for compositing window managers to communicate |
| 15954 | directly with applications and video hardware and expects them to |
| 15955 | communicate with input hardware using other libraries. |
| 15956 | Using Wayland with supporting targets can result in better control |
| 15957 | over graphics frame rendering than an application might otherwise |
| 15958 | achieve. |
| 15959 | </para> |
| 15960 | |
| 15961 | <para> |
| 15962 | The Yocto Project provides the Wayland protocol libraries and the |
| 15963 | reference |
| 15964 | <ulink url='http://en.wikipedia.org/wiki/Wayland_(display_server_protocol)#Weston'>Weston</ulink> |
| 15965 | compositor as part of its release. |
| 15966 | You can find the integrated packages in the |
| 15967 | <filename>meta</filename> layer of the |
| 15968 | <ulink url='&YOCTO_DOCS_REF_URL;#source-directory'>Source Directory</ulink>. |
| 15969 | Specifically, you can find the recipes that build both Wayland |
| 15970 | and Weston at <filename>meta/recipes-graphics/wayland</filename>. |
| 15971 | </para> |
| 15972 | |
| 15973 | <para> |
| 15974 | You can build both the Wayland and Weston packages for use only |
| 15975 | with targets that accept the |
| 15976 | <ulink url='https://en.wikipedia.org/wiki/Mesa_(computer_graphics)'>Mesa 3D and Direct Rendering Infrastructure</ulink>, |
| 15977 | which is also known as Mesa DRI. |
| 15978 | This implies that you cannot build and use the packages if your |
| 15979 | target uses, for example, the |
| 15980 | <trademark class='registered'>Intel</trademark> Embedded Media |
| 15981 | and Graphics Driver |
| 15982 | (<trademark class='registered'>Intel</trademark> EMGD) that |
| 15983 | overrides Mesa DRI. |
| 15984 | <note> |
| 15985 | Due to lack of EGL support, Weston 1.0.3 will not run |
| 15986 | directly on the emulated QEMU hardware. |
| 15987 | However, this version of Weston will run under X emulation |
| 15988 | without issues. |
| 15989 | </note> |
| 15990 | </para> |
| 15991 | |
| 15992 | <para> |
| 15993 | This section describes what you need to do to implement Wayland and |
| 15994 | use the Weston compositor when building an image for a supporting |
| 15995 | target. |
| 15996 | </para> |
| 15997 | |
| 15998 | <section id="enabling-wayland-in-an-image"> |
| 15999 | <title>Enabling Wayland in an Image</title> |
| 16000 | |
| 16001 | <para> |
| 16002 | To enable Wayland, you need to enable it to be built and enable |
| 16003 | it to be included (installed) in the image. |
| 16004 | </para> |
| 16005 | |
| 16006 | <section id="enable-building"> |
| 16007 | <title>Building</title> |
| 16008 | |
| 16009 | <para> |
| 16010 | To cause Mesa to build the <filename>wayland-egl</filename> |
| 16011 | platform and Weston to build Wayland with Kernel Mode |
| 16012 | Setting |
| 16013 | (<ulink url='https://wiki.archlinux.org/index.php/Kernel_Mode_Setting'>KMS</ulink>) |
| 16014 | support, include the "wayland" flag in the |
| 16015 | <ulink url="&YOCTO_DOCS_REF_URL;#var-DISTRO_FEATURES"><filename>DISTRO_FEATURES</filename></ulink> |
| 16016 | statement in your <filename>local.conf</filename> file: |
| 16017 | <literallayout class='monospaced'> |
| 16018 | DISTRO_FEATURES_append = " wayland" |
| 16019 | </literallayout> |
| 16020 | <note> |
| 16021 | If X11 has been enabled elsewhere, Weston will build |
| 16022 | Wayland with X11 support |
| 16023 | </note> |
| 16024 | </para> |
| 16025 | </section> |
| 16026 | |
| 16027 | <section id="enable-installation-in-an-image"> |
| 16028 | <title>Installing</title> |
| 16029 | |
| 16030 | <para> |
| 16031 | To install the Wayland feature into an image, you must |
| 16032 | include the following |
| 16033 | <ulink url='&YOCTO_DOCS_REF_URL;#var-CORE_IMAGE_EXTRA_INSTALL'><filename>CORE_IMAGE_EXTRA_INSTALL</filename></ulink> |
| 16034 | statement in your <filename>local.conf</filename> file: |
| 16035 | <literallayout class='monospaced'> |
| 16036 | CORE_IMAGE_EXTRA_INSTALL += "wayland weston" |
| 16037 | </literallayout> |
| 16038 | </para> |
| 16039 | </section> |
| 16040 | </section> |
| 16041 | |
| 16042 | <section id="running-weston"> |
| 16043 | <title>Running Weston</title> |
| 16044 | |
| 16045 | <para> |
| 16046 | To run Weston inside X11, enabling it as described earlier and |
| 16047 | building a Sato image is sufficient. |
| 16048 | If you are running your image under Sato, a Weston Launcher |
| 16049 | appears in the "Utility" category. |
| 16050 | </para> |
| 16051 | |
| 16052 | <para> |
| 16053 | Alternatively, you can run Weston through the command-line |
| 16054 | interpretor (CLI), which is better suited for development work. |
| 16055 | To run Weston under the CLI, you need to do the following after |
| 16056 | your image is built: |
| 16057 | <orderedlist> |
| 16058 | <listitem><para> |
| 16059 | Run these commands to export |
| 16060 | <filename>XDG_RUNTIME_DIR</filename>: |
| 16061 | <literallayout class='monospaced'> |
| 16062 | mkdir -p /tmp/$USER-weston |
| 16063 | chmod 0700 /tmp/$USER-weston |
| 16064 | export XDG_RUNTIME_DIR=/tmp/$USER-weston |
| 16065 | </literallayout> |
| 16066 | </para></listitem> |
| 16067 | <listitem><para> |
| 16068 | Launch Weston in the shell: |
| 16069 | <literallayout class='monospaced'> |
| 16070 | weston |
| 16071 | </literallayout></para></listitem> |
| 16072 | </orderedlist> |
| 16073 | </para> |
| 16074 | </section> |
| 16075 | </section> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 16076 | </chapter> |
| 16077 | |
| 16078 | <!-- |
| 16079 | vim: expandtab tw=80 ts=4 |
| 16080 | --> |