blob: 5e49613b2fdb2ea794433c0a06f3b2679de8e763 [file] [log] [blame]
Andrew Geisslerf0343792020-11-18 10:42:21 -06001.. SPDX-License-Identifier: CC-BY-SA-2.0-UK
Andrew Geisslerc9f78652020-09-18 14:11:35 -05002
3*******
4Classes
5*******
6
7Class files are used to abstract common functionality and share it
8amongst multiple recipe (``.bb``) files. To use a class file, you simply
9make sure the recipe inherits the class. In most cases, when a recipe
10inherits a class it is enough to enable its features. There are cases,
11however, where in the recipe you might need to set variables or override
12some default behavior.
13
14Any :term:`Metadata` usually found in a recipe can also be
15placed in a class file. Class files are identified by the extension
16``.bbclass`` and are usually placed in a ``classes/`` directory beneath
17the ``meta*/`` directory found in the :term:`Source Directory`.
18Class files can also be pointed to by
19:term:`BUILDDIR` (e.g. ``build/``) in the same way as
20``.conf`` files in the ``conf`` directory. Class files are searched for
21in :term:`BBPATH` using the same method by which ``.conf``
22files are searched.
23
24This chapter discusses only the most useful and important classes. Other
25classes do exist within the ``meta/classes`` directory in the Source
26Directory. You can reference the ``.bbclass`` files directly for more
27information.
28
29.. _ref-classes-allarch:
30
31``allarch.bbclass``
32===================
33
34The ``allarch`` class is inherited by recipes that do not produce
35architecture-specific output. The class disables functionality that is
36normally needed for recipes that produce executable binaries (such as
37building the cross-compiler and a C library as pre-requisites, and
38splitting out of debug symbols during packaging).
39
40.. note::
41
42 Unlike some distro recipes (e.g. Debian), OpenEmbedded recipes that
43 produce packages that depend on tunings through use of the
44 :term:`RDEPENDS` and
45 :term:`TUNE_PKGARCH` variables, should never be
46 configured for all architectures using ``allarch``. This is the case
47 even if the recipes do not produce architecture-specific output.
48
49 Configuring such recipes for all architectures causes the
Patrick Williams2194f502022-10-16 14:26:09 -050050 :ref:`do_package_write_* <ref-tasks-package_write_deb>` tasks to
Andrew Geisslerc9f78652020-09-18 14:11:35 -050051 have different signatures for the machines with different tunings.
52 Additionally, unnecessary rebuilds occur every time an image for a
Andrew Geissler09036742021-06-25 14:25:14 -050053 different :term:`MACHINE` is built even when the recipe never changes.
Andrew Geisslerc9f78652020-09-18 14:11:35 -050054
55By default, all recipes inherit the :ref:`base <ref-classes-base>` and
56:ref:`package <ref-classes-package>` classes, which enable
57functionality needed for recipes that produce executable output. If your
58recipe, for example, only produces packages that contain configuration
59files, media files, or scripts (e.g. Python and Perl), then it should
60inherit the ``allarch`` class.
61
62.. _ref-classes-archiver:
63
64``archiver.bbclass``
65====================
66
67The ``archiver`` class supports releasing source code and other
68materials with the binaries.
69
70For more details on the source archiver, see the
Andrew Geissler09209ee2020-12-13 08:44:15 -060071":ref:`dev-manual/common-tasks:maintaining open source license compliance during your product's lifecycle`"
Andrew Geisslerc9f78652020-09-18 14:11:35 -050072section in the Yocto Project Development Tasks Manual. You can also see
73the :term:`ARCHIVER_MODE` variable for information
74about the variable flags (varflags) that help control archive creation.
75
76.. _ref-classes-autotools:
77
78``autotools*.bbclass``
79======================
80
Patrick Williams03907ee2022-05-01 06:28:52 -050081The ``autotools*`` classes support packages built with the
82`GNU Autotools <https://en.wikipedia.org/wiki/GNU_Autotools>`__.
Andrew Geisslerc9f78652020-09-18 14:11:35 -050083
84The ``autoconf``, ``automake``, and ``libtool`` packages bring
85standardization. This class defines a set of tasks (e.g. ``configure``,
86``compile`` and so forth) that work for all Autotooled packages. It
87should usually be enough to define a few standard variables and then
88simply ``inherit autotools``. These classes can also work with software
89that emulates Autotools. For more information, see the
Andrew Geissler09209ee2020-12-13 08:44:15 -060090":ref:`dev-manual/common-tasks:autotooled package`" section
Andrew Geisslerc9f78652020-09-18 14:11:35 -050091in the Yocto Project Development Tasks Manual.
92
93By default, the ``autotools*`` classes use out-of-tree builds (i.e.
94``autotools.bbclass`` building with ``B != S``).
95
96If the software being built by a recipe does not support using
97out-of-tree builds, you should have the recipe inherit the
98``autotools-brokensep`` class. The ``autotools-brokensep`` class behaves
99the same as the ``autotools`` class but builds with :term:`B`
100== :term:`S`. This method is useful when out-of-tree build
101support is either not present or is broken.
102
103.. note::
104
105 It is recommended that out-of-tree support be fixed and used if at
106 all possible.
107
108It's useful to have some idea of how the tasks defined by the
109``autotools*`` classes work and what they do behind the scenes.
110
Andrew Geissler615f2f12022-07-15 14:00:58 -0500111- :ref:`ref-tasks-configure` --- regenerates the
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500112 configure script (using ``autoreconf``) and then launches it with a
113 standard set of arguments used during cross-compilation. You can pass
Andrew Geissler09036742021-06-25 14:25:14 -0500114 additional parameters to ``configure`` through the :term:`EXTRA_OECONF`
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500115 or :term:`PACKAGECONFIG_CONFARGS`
116 variables.
117
Andrew Geissler615f2f12022-07-15 14:00:58 -0500118- :ref:`ref-tasks-compile` --- runs ``make`` with
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500119 arguments that specify the compiler and linker. You can pass
Andrew Geissler5f350902021-07-23 13:09:54 -0400120 additional arguments through the :term:`EXTRA_OEMAKE` variable.
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500121
Andrew Geissler615f2f12022-07-15 14:00:58 -0500122- :ref:`ref-tasks-install` --- runs ``make install`` and
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500123 passes in ``${``\ :term:`D`\ ``}`` as ``DESTDIR``.
124
125.. _ref-classes-base:
126
127``base.bbclass``
128================
129
130The ``base`` class is special in that every ``.bb`` file implicitly
131inherits the class. This class contains definitions for standard basic
132tasks such as fetching, unpacking, configuring (empty by default),
133compiling (runs any ``Makefile`` present), installing (empty by default)
134and packaging (empty by default). These classes are often overridden or
135extended by other classes such as the
136:ref:`autotools <ref-classes-autotools>` class or the
137:ref:`package <ref-classes-package>` class.
138
139The class also contains some commonly used functions such as
140``oe_runmake``, which runs ``make`` with the arguments specified in
141:term:`EXTRA_OEMAKE` variable as well as the
142arguments passed directly to ``oe_runmake``.
143
144.. _ref-classes-bash-completion:
145
146``bash-completion.bbclass``
147===========================
148
149Sets up packaging and dependencies appropriate for recipes that build
150software that includes bash-completion data.
151
152.. _ref-classes-bin-package:
153
154``bin_package.bbclass``
155=======================
156
157The ``bin_package`` class is a helper class for recipes that extract the
158contents of a binary package (e.g. an RPM) and install those contents
159rather than building the binary from source. The binary package is
160extracted and new packages in the configured output package format are
161created. Extraction and installation of proprietary binaries is a good
162example use for this class.
163
164.. note::
165
166 For RPMs and other packages that do not contain a subdirectory, you
167 should specify an appropriate fetcher parameter to point to the
Andrew Geissler4c19ea12020-10-27 13:52:24 -0500168 subdirectory. For example, if BitBake is using the Git fetcher (``git://``),
169 the "subpath" parameter limits the checkout to a specific subpath
170 of the tree. Here is an example where ``${BP}`` is used so that the files
171 are extracted into the subdirectory expected by the default value of
Andrew Geissler09036742021-06-25 14:25:14 -0500172 :term:`S`::
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500173
Andrew Geissler9aee5002022-03-30 16:27:02 +0000174 SRC_URI = "git://example.com/downloads/somepackage.rpm;branch=main;subpath=${BP}"
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500175
Andrew Geissler4c19ea12020-10-27 13:52:24 -0500176 See the ":ref:`bitbake-user-manual/bitbake-user-manual-fetching:fetchers`" section in the BitBake User Manual for
177 more information on supported BitBake Fetchers.
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500178
179.. _ref-classes-binconfig:
180
181``binconfig.bbclass``
182=====================
183
184The ``binconfig`` class helps to correct paths in shell scripts.
185
186Before ``pkg-config`` had become widespread, libraries shipped shell
187scripts to give information about the libraries and include paths needed
188to build software (usually named ``LIBNAME-config``). This class assists
189any recipe using such scripts.
190
191During staging, the OpenEmbedded build system installs such scripts into
192the ``sysroots/`` directory. Inheriting this class results in all paths
193in these scripts being changed to point into the ``sysroots/`` directory
194so that all builds that use the script use the correct directories for
195the cross compiling layout. See the
196:term:`BINCONFIG_GLOB` variable for more
197information.
198
199.. _ref-classes-binconfig-disabled:
200
201``binconfig-disabled.bbclass``
202==============================
203
204An alternative version of the :ref:`binconfig <ref-classes-binconfig>`
205class, which disables binary configuration scripts by making them return
206an error in favor of using ``pkg-config`` to query the information. The
207scripts to be disabled should be specified using the
208:term:`BINCONFIG` variable within the recipe inheriting
209the class.
210
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500211.. _ref-classes-buildhistory:
212
213``buildhistory.bbclass``
214========================
215
216The ``buildhistory`` class records a history of build output metadata,
217which can be used to detect possible regressions as well as used for
218analysis of the build output. For more information on using Build
219History, see the
Andrew Geissler09209ee2020-12-13 08:44:15 -0600220":ref:`dev-manual/common-tasks:maintaining build output quality`"
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500221section in the Yocto Project Development Tasks Manual.
222
223.. _ref-classes-buildstats:
224
225``buildstats.bbclass``
226======================
227
228The ``buildstats`` class records performance statistics about each task
229executed during the build (e.g. elapsed time, CPU usage, and I/O usage).
230
231When you use this class, the output goes into the
232:term:`BUILDSTATS_BASE` directory, which defaults
233to ``${TMPDIR}/buildstats/``. You can analyze the elapsed time using
234``scripts/pybootchartgui/pybootchartgui.py``, which produces a cascading
235chart of the entire build process and can be useful for highlighting
236bottlenecks.
237
238Collecting build statistics is enabled by default through the
239:term:`USER_CLASSES` variable from your
240``local.conf`` file. Consequently, you do not have to do anything to
241enable the class. However, if you want to disable the class, simply
Andrew Geissler09036742021-06-25 14:25:14 -0500242remove "buildstats" from the :term:`USER_CLASSES` list.
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500243
244.. _ref-classes-buildstats-summary:
245
246``buildstats-summary.bbclass``
247==============================
248
249When inherited globally, prints statistics at the end of the build on
250sstate re-use. In order to function, this class requires the
251:ref:`buildstats <ref-classes-buildstats>` class be enabled.
252
253.. _ref-classes-ccache:
254
255``ccache.bbclass``
256==================
257
258The ``ccache`` class enables the C/C++ Compiler Cache for the build.
259This class is used to give a minor performance boost during the build.
Andrew Geissler7e0e3c02022-02-25 20:34:39 +0000260
261See https://ccache.samba.org/ for information on the C/C++ Compiler
262Cache, and the :oe_git:`ccache.bbclass </openembedded-core/tree/meta/classes/ccache.bbclass>`
263file for details about how to enable this mechanism in your configuration
264file, how to disable it for specific recipes, and how to share ``ccache``
265files between builds.
266
267However, using the class can lead to unexpected side-effects. Thus, using
268this class is not recommended.
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500269
270.. _ref-classes-chrpath:
271
272``chrpath.bbclass``
273===================
274
275The ``chrpath`` class is a wrapper around the "chrpath" utility, which
276is used during the build process for ``nativesdk``, ``cross``, and
277``cross-canadian`` recipes to change ``RPATH`` records within binaries
278in order to make them relocatable.
279
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500280.. _ref-classes-cmake:
281
282``cmake.bbclass``
283=================
284
285The ``cmake`` class allows for recipes that need to build software using
286the `CMake <https://cmake.org/overview/>`__ build system. You can use
287the :term:`EXTRA_OECMAKE` variable to specify
288additional configuration options to be passed using the ``cmake``
289command line.
290
291On the occasion that you would be installing custom CMake toolchain
292files supplied by the application being built, you should install them
293to the preferred CMake Module directory: ``${D}${datadir}/cmake/``
294Modules during
295:ref:`ref-tasks-install`.
296
297.. _ref-classes-cml1:
298
299``cml1.bbclass``
300================
301
302The ``cml1`` class provides basic support for the Linux kernel style
303build configuration system.
304
305.. _ref-classes-compress_doc:
306
307``compress_doc.bbclass``
308========================
309
310Enables compression for man pages and info pages. This class is intended
311to be inherited globally. The default compression mechanism is gz (gzip)
312but you can select an alternative mechanism by setting the
313:term:`DOC_COMPRESS` variable.
314
315.. _ref-classes-copyleft_compliance:
316
317``copyleft_compliance.bbclass``
318===============================
319
320The ``copyleft_compliance`` class preserves source code for the purposes
321of license compliance. This class is an alternative to the ``archiver``
322class and is still used by some users even though it has been deprecated
323in favor of the :ref:`archiver <ref-classes-archiver>` class.
324
325.. _ref-classes-copyleft_filter:
326
327``copyleft_filter.bbclass``
328===========================
329
330A class used by the :ref:`archiver <ref-classes-archiver>` and
331:ref:`copyleft_compliance <ref-classes-copyleft_compliance>` classes
332for filtering licenses. The ``copyleft_filter`` class is an internal
333class and is not intended to be used directly.
334
335.. _ref-classes-core-image:
336
337``core-image.bbclass``
338======================
339
340The ``core-image`` class provides common definitions for the
341``core-image-*`` image recipes, such as support for additional
342:term:`IMAGE_FEATURES`.
343
344.. _ref-classes-cpan:
345
346``cpan*.bbclass``
347=================
348
349The ``cpan*`` classes support Perl modules.
350
351Recipes for Perl modules are simple. These recipes usually only need to
352point to the source's archive and then inherit the proper class file.
353Building is split into two methods depending on which method the module
354authors used.
355
356- Modules that use old ``Makefile.PL``-based build system require
357 ``cpan.bbclass`` in their recipes.
358
359- Modules that use ``Build.PL``-based build system require using
360 ``cpan_build.bbclass`` in their recipes.
361
362Both build methods inherit the ``cpan-base`` class for basic Perl
363support.
364
365.. _ref-classes-cross:
366
367``cross.bbclass``
368=================
369
370The ``cross`` class provides support for the recipes that build the
371cross-compilation tools.
372
373.. _ref-classes-cross-canadian:
374
375``cross-canadian.bbclass``
376==========================
377
378The ``cross-canadian`` class provides support for the recipes that build
379the Canadian Cross-compilation tools for SDKs. See the
Andrew Geissler09209ee2020-12-13 08:44:15 -0600380":ref:`overview-manual/concepts:cross-development toolchain generation`"
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500381section in the Yocto Project Overview and Concepts Manual for more
382discussion on these cross-compilation tools.
383
384.. _ref-classes-crosssdk:
385
386``crosssdk.bbclass``
387====================
388
389The ``crosssdk`` class provides support for the recipes that build the
390cross-compilation tools used for building SDKs. See the
Andrew Geissler09209ee2020-12-13 08:44:15 -0600391":ref:`overview-manual/concepts:cross-development toolchain generation`"
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500392section in the Yocto Project Overview and Concepts Manual for more
393discussion on these cross-compilation tools.
394
Patrick Williams0ca19cc2021-08-16 14:03:13 -0500395.. _ref-classes-cve-check:
396
397``cve-check.bbclass``
398=====================
399
400The ``cve-check`` class looks for known CVEs (Common Vulnerabilities
401and Exposures) while building an image. This class is meant to be
402inherited globally from a configuration file::
403
404 INHERIT += "cve-check"
405
406You can also look for vulnerabilities in specific packages by passing
407``-c cve_check`` to BitBake. You will find details in the
408":ref:`dev-manual/common-tasks:checking for vulnerabilities`"
409section in the Development Tasks Manual.
410
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500411.. _ref-classes-debian:
412
413``debian.bbclass``
414==================
415
416The ``debian`` class renames output packages so that they follow the
417Debian naming policy (i.e. ``glibc`` becomes ``libc6`` and
418``glibc-devel`` becomes ``libc6-dev``.) Renaming includes the library
419name and version as part of the package name.
420
421If a recipe creates packages for multiple libraries (shared object files
422of ``.so`` type), use the :term:`LEAD_SONAME`
423variable in the recipe to specify the library on which to apply the
424naming scheme.
425
426.. _ref-classes-deploy:
427
428``deploy.bbclass``
429==================
430
431The ``deploy`` class handles deploying files to the
432:term:`DEPLOY_DIR_IMAGE` directory. The main
433function of this class is to allow the deploy step to be accelerated by
434shared state. Recipes that inherit this class should define their own
435:ref:`ref-tasks-deploy` function to copy the files to be
436deployed to :term:`DEPLOYDIR`, and use ``addtask`` to
437add the task at the appropriate place, which is usually after
438:ref:`ref-tasks-compile` or
439:ref:`ref-tasks-install`. The class then takes care of
Andrew Geissler09036742021-06-25 14:25:14 -0500440staging the files from :term:`DEPLOYDIR` to :term:`DEPLOY_DIR_IMAGE`.
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500441
442.. _ref-classes-devshell:
443
444``devshell.bbclass``
445====================
446
Patrick Williams2194f502022-10-16 14:26:09 -0500447The ``devshell`` class adds the :ref:`ref-tasks-devshell` task. Distribution
Andrew Geissler09209ee2020-12-13 08:44:15 -0600448policy dictates whether to include this class. See the ":ref:`dev-manual/common-tasks:using a development shell`"
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500449section in the Yocto Project Development Tasks Manual for more
450information about using ``devshell``.
451
452.. _ref-classes-devupstream:
453
454``devupstream.bbclass``
455=======================
456
457The ``devupstream`` class uses
458:term:`BBCLASSEXTEND` to add a variant of the
459recipe that fetches from an alternative URI (e.g. Git) instead of a
Andrew Geisslerc926e172021-05-07 16:11:35 -0500460tarball. Following is an example::
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500461
462 BBCLASSEXTEND = "devupstream:target"
Andrew Geissler9aee5002022-03-30 16:27:02 +0000463 SRC_URI:class-devupstream = "git://git.example.com/example;branch=main"
Patrick Williams0ca19cc2021-08-16 14:03:13 -0500464 SRCREV:class-devupstream = "abcd1234"
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500465
466Adding the above statements to your recipe creates a variant that has
467:term:`DEFAULT_PREFERENCE` set to "-1".
468Consequently, you need to select the variant of the recipe to use it.
469Any development-specific adjustments can be done by using the
Andrew Geisslerc926e172021-05-07 16:11:35 -0500470``class-devupstream`` override. Here is an example::
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500471
Patrick Williams0ca19cc2021-08-16 14:03:13 -0500472 DEPENDS:append:class-devupstream = " gperf-native"
473 do_configure:prepend:class-devupstream() {
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500474 touch ${S}/README
475 }
476
477The class
478currently only supports creating a development variant of the target
479recipe, not ``native`` or ``nativesdk`` variants.
480
Andrew Geissler09036742021-06-25 14:25:14 -0500481The :term:`BBCLASSEXTEND` syntax (i.e. ``devupstream:target``) provides
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500482support for ``native`` and ``nativesdk`` variants. Consequently, this
483functionality can be added in a future release.
484
485Support for other version control systems such as Subversion is limited
486due to BitBake's automatic fetch dependencies (e.g.
487``subversion-native``).
488
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500489.. _ref-classes-externalsrc:
490
491``externalsrc.bbclass``
492=======================
493
494The ``externalsrc`` class supports building software from source code
495that is external to the OpenEmbedded build system. Building software
496from an external source tree means that the build system's normal fetch,
497unpack, and patch process is not used.
498
499By default, the OpenEmbedded build system uses the :term:`S`
500and :term:`B` variables to locate unpacked recipe source code
501and to build it, respectively. When your recipe inherits the
502``externalsrc`` class, you use the
503:term:`EXTERNALSRC` and
504:term:`EXTERNALSRC_BUILD` variables to
Andrew Geissler09036742021-06-25 14:25:14 -0500505ultimately define :term:`S` and :term:`B`.
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500506
507By default, this class expects the source code to support recipe builds
508that use the :term:`B` variable to point to the directory in
509which the OpenEmbedded build system places the generated objects built
Andrew Geissler09036742021-06-25 14:25:14 -0500510from the recipes. By default, the :term:`B` directory is set to the
511following, which is separate from the source directory (:term:`S`)::
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500512
Andrew Geissler5199d832021-09-24 16:47:35 -0500513 ${WORKDIR}/${BPN}-{PV}/
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500514
515See these variables for more information:
516:term:`WORKDIR`, :term:`BPN`, and
517:term:`PV`,
518
519For more information on the ``externalsrc`` class, see the comments in
520``meta/classes/externalsrc.bbclass`` in the :term:`Source Directory`.
521For information on how to use the
522``externalsrc`` class, see the
Andrew Geissler09209ee2020-12-13 08:44:15 -0600523":ref:`dev-manual/common-tasks:building software from an external source`"
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500524section in the Yocto Project Development Tasks Manual.
525
526.. _ref-classes-extrausers:
527
528``extrausers.bbclass``
529======================
530
531The ``extrausers`` class allows additional user and group configuration
532to be applied at the image level. Inheriting this class either globally
533or from an image recipe allows additional user and group operations to
534be performed using the
535:term:`EXTRA_USERS_PARAMS` variable.
536
537.. note::
538
539 The user and group operations added using the
Andrew Geissler595f6302022-01-24 19:11:47 +0000540 :ref:`extrausers <ref-classes-extrausers>`
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500541 class are not tied to a specific recipe outside of the recipe for the
542 image. Thus, the operations can be performed across the image as a
543 whole. Use the
Andrew Geissler595f6302022-01-24 19:11:47 +0000544 :ref:`useradd <ref-classes-useradd>`
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500545 class to add user and group configuration to a specific recipe.
546
Andrew Geisslerc926e172021-05-07 16:11:35 -0500547Here is an example that uses this class in an image recipe::
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500548
549 inherit extrausers
550 EXTRA_USERS_PARAMS = "\
551 useradd -p '' tester; \
552 groupadd developers; \
553 userdel nobody; \
554 groupdel -g video; \
555 groupmod -g 1020 developers; \
556 usermod -s /bin/sh tester; \
557 "
558
559Here is an example that adds two users named "tester-jim" and "tester-sue" and assigns
Andrew Geissler9aee5002022-03-30 16:27:02 +0000560passwords. First on host, create the (escaped) password hash::
Andrew Geisslereff27472021-10-29 15:35:00 -0500561
Andrew Geissler9aee5002022-03-30 16:27:02 +0000562 printf "%q" $(mkpasswd -m sha256crypt tester01)
Andrew Geisslereff27472021-10-29 15:35:00 -0500563
Andrew Geissler9aee5002022-03-30 16:27:02 +0000564The resulting hash is set to a variable and used in ``useradd`` command parameters::
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500565
566 inherit extrausers
Andrew Geisslereff27472021-10-29 15:35:00 -0500567 PASSWD = "\$X\$ABC123\$A-Long-Hash"
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500568 EXTRA_USERS_PARAMS = "\
Andrew Geisslereff27472021-10-29 15:35:00 -0500569 useradd -p '${PASSWD}' tester-jim; \
570 useradd -p '${PASSWD}' tester-sue; \
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500571 "
572
Andrew Geisslereff27472021-10-29 15:35:00 -0500573Finally, here is an example that sets the root password::
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500574
575 inherit extrausers
576 EXTRA_USERS_PARAMS = "\
Andrew Geisslereff27472021-10-29 15:35:00 -0500577 usermod -p '${PASSWD}' root; \
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500578 "
579
Patrick Williams03907ee2022-05-01 06:28:52 -0500580.. note::
581
582 From a security perspective, hardcoding a default password is not
Andrew Geissler87f5cff2022-09-30 13:13:31 -0500583 generally a good idea or even legal in some jurisdictions. It is
584 recommended that you do not do this if you are building a production
Patrick Williams03907ee2022-05-01 06:28:52 -0500585 image.
586
587
Andrew Geissler6ce62a22020-11-30 19:58:47 -0600588.. _ref-classes-features_check:
589
590``features_check.bbclass``
591=================================
592
593The ``features_check`` class allows individual recipes to check
594for required and conflicting
595:term:`DISTRO_FEATURES`, :term:`MACHINE_FEATURES` or :term:`COMBINED_FEATURES`.
596
597This class provides support for the following variables:
598
599- :term:`REQUIRED_DISTRO_FEATURES`
600- :term:`CONFLICT_DISTRO_FEATURES`
601- :term:`ANY_OF_DISTRO_FEATURES`
602- ``REQUIRED_MACHINE_FEATURES``
603- ``CONFLICT_MACHINE_FEATURES``
604- ``ANY_OF_MACHINE_FEATURES``
605- ``REQUIRED_COMBINED_FEATURES``
606- ``CONFLICT_COMBINED_FEATURES``
607- ``ANY_OF_COMBINED_FEATURES``
608
609If any conditions specified in the recipe using the above
610variables are not met, the recipe will be skipped, and if the
611build system attempts to build the recipe then an error will be
612triggered.
613
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500614.. _ref-classes-fontcache:
615
616``fontcache.bbclass``
617=====================
618
619The ``fontcache`` class generates the proper post-install and
620post-remove (postinst and postrm) scriptlets for font packages. These
621scriptlets call ``fc-cache`` (part of ``Fontconfig``) to add the fonts
622to the font information cache. Since the cache files are
623architecture-specific, ``fc-cache`` runs using QEMU if the postinst
624scriptlets need to be run on the build host during image creation.
625
626If the fonts being installed are in packages other than the main
627package, set :term:`FONT_PACKAGES` to specify the
628packages containing the fonts.
629
630.. _ref-classes-fs-uuid:
631
632``fs-uuid.bbclass``
633===================
634
635The ``fs-uuid`` class extracts UUID from
636``${``\ :term:`ROOTFS`\ ``}``, which must have been built
637by the time that this function gets called. The ``fs-uuid`` class only
638works on ``ext`` file systems and depends on ``tune2fs``.
639
640.. _ref-classes-gconf:
641
642``gconf.bbclass``
643=================
644
645The ``gconf`` class provides common functionality for recipes that need
646to install GConf schemas. The schemas will be put into a separate
647package (``${``\ :term:`PN`\ ``}-gconf``) that is created
648automatically when this class is inherited. This package uses the
649appropriate post-install and post-remove (postinst/postrm) scriptlets to
650register and unregister the schemas in the target image.
651
652.. _ref-classes-gettext:
653
654``gettext.bbclass``
655===================
656
657The ``gettext`` class provides support for building software that uses
658the GNU ``gettext`` internationalization and localization system. All
659recipes building software that use ``gettext`` should inherit this
660class.
661
662.. _ref-classes-gnomebase:
663
664``gnomebase.bbclass``
665=====================
666
667The ``gnomebase`` class is the base class for recipes that build
668software from the GNOME stack. This class sets
669:term:`SRC_URI` to download the source from the GNOME
670mirrors as well as extending :term:`FILES` with the typical
671GNOME installation paths.
672
673.. _ref-classes-gobject-introspection:
674
675``gobject-introspection.bbclass``
676=================================
677
678Provides support for recipes building software that supports GObject
679introspection. This functionality is only enabled if the
680"gobject-introspection-data" feature is in
681:term:`DISTRO_FEATURES` as well as
682"qemu-usermode" being in
683:term:`MACHINE_FEATURES`.
684
685.. note::
686
687 This functionality is backfilled by default and, if not applicable,
Andrew Geissler09036742021-06-25 14:25:14 -0500688 should be disabled through :term:`DISTRO_FEATURES_BACKFILL_CONSIDERED` or
689 :term:`MACHINE_FEATURES_BACKFILL_CONSIDERED`, respectively.
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500690
691.. _ref-classes-grub-efi:
692
693``grub-efi.bbclass``
694====================
695
696The ``grub-efi`` class provides ``grub-efi``-specific functions for
697building bootable images.
698
699This class supports several variables:
700
701- :term:`INITRD`: Indicates list of filesystem images to
702 concatenate and use as an initial RAM disk (initrd) (optional).
703
704- :term:`ROOTFS`: Indicates a filesystem image to include
705 as the root filesystem (optional).
706
707- :term:`GRUB_GFXSERIAL`: Set this to "1" to have
708 graphics and serial in the boot menu.
709
710- :term:`LABELS`: A list of targets for the automatic
711 configuration.
712
713- :term:`APPEND`: An override list of append strings for
714 each ``LABEL``.
715
716- :term:`GRUB_OPTS`: Additional options to add to the
717 configuration (optional). Options are delimited using semi-colon
718 characters (``;``).
719
720- :term:`GRUB_TIMEOUT`: Timeout before executing
721 the default ``LABEL`` (optional).
722
723.. _ref-classes-gsettings:
724
725``gsettings.bbclass``
726=====================
727
728The ``gsettings`` class provides common functionality for recipes that
729need to install GSettings (glib) schemas. The schemas are assumed to be
730part of the main package. Appropriate post-install and post-remove
731(postinst/postrm) scriptlets are added to register and unregister the
732schemas in the target image.
733
734.. _ref-classes-gtk-doc:
735
736``gtk-doc.bbclass``
737===================
738
739The ``gtk-doc`` class is a helper class to pull in the appropriate
740``gtk-doc`` dependencies and disable ``gtk-doc``.
741
742.. _ref-classes-gtk-icon-cache:
743
744``gtk-icon-cache.bbclass``
745==========================
746
747The ``gtk-icon-cache`` class generates the proper post-install and
748post-remove (postinst/postrm) scriptlets for packages that use GTK+ and
749install icons. These scriptlets call ``gtk-update-icon-cache`` to add
750the fonts to GTK+'s icon cache. Since the cache files are
751architecture-specific, ``gtk-update-icon-cache`` is run using QEMU if
752the postinst scriptlets need to be run on the build host during image
753creation.
754
755.. _ref-classes-gtk-immodules-cache:
756
757``gtk-immodules-cache.bbclass``
758===============================
759
760The ``gtk-immodules-cache`` class generates the proper post-install and
761post-remove (postinst/postrm) scriptlets for packages that install GTK+
762input method modules for virtual keyboards. These scriptlets call
763``gtk-update-icon-cache`` to add the input method modules to the cache.
764Since the cache files are architecture-specific,
765``gtk-update-icon-cache`` is run using QEMU if the postinst scriptlets
766need to be run on the build host during image creation.
767
768If the input method modules being installed are in packages other than
769the main package, set
770:term:`GTKIMMODULES_PACKAGES` to specify
771the packages containing the modules.
772
773.. _ref-classes-gzipnative:
774
775``gzipnative.bbclass``
776======================
777
778The ``gzipnative`` class enables the use of different native versions of
779``gzip`` and ``pigz`` rather than the versions of these tools from the
780build host.
781
782.. _ref-classes-icecc:
783
784``icecc.bbclass``
785=================
786
787The ``icecc`` class supports
788`Icecream <https://github.com/icecc/icecream>`__, which facilitates
789taking compile jobs and distributing them among remote machines.
790
791The class stages directories with symlinks from ``gcc`` and ``g++`` to
792``icecc``, for both native and cross compilers. Depending on each
793configure or compile, the OpenEmbedded build system adds the directories
794at the head of the ``PATH`` list and then sets the ``ICECC_CXX`` and
Andrew Geissler87f5cff2022-09-30 13:13:31 -0500795``ICECC_CC`` variables, which are the paths to the ``g++`` and ``gcc``
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500796compilers, respectively.
797
798For the cross compiler, the class creates a ``tar.gz`` file that
799contains the Yocto Project toolchain and sets ``ICECC_VERSION``, which
800is the version of the cross-compiler used in the cross-development
801toolchain, accordingly.
802
Andrew Geissler87f5cff2022-09-30 13:13:31 -0500803The class handles all three different compile stages (i.e native,
804cross-kernel and target) and creates the necessary environment
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500805``tar.gz`` file to be used by the remote machines. The class also
806supports SDK generation.
807
808If :term:`ICECC_PATH` is not set in your
809``local.conf`` file, then the class tries to locate the ``icecc`` binary
810using ``which``. If :term:`ICECC_ENV_EXEC` is set
811in your ``local.conf`` file, the variable should point to the
812``icecc-create-env`` script provided by the user. If you do not point to
813a user-provided script, the build system uses the default script
Andrew Geissler87f5cff2022-09-30 13:13:31 -0500814provided by the recipe :oe_git:`icecc-create-env_0.1.bb
815</openembedded-core/tree/meta/recipes-devtools/icecc-create-env/icecc-create-env_0.1.bb>`.
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500816
817.. note::
818
819 This script is a modified version and not the one that comes with
Andrew Geissler87f5cff2022-09-30 13:13:31 -0500820 ``icecream``.
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500821
822If you do not want the Icecream distributed compile support to apply to
Andrew Geissler595f6302022-01-24 19:11:47 +0000823specific recipes or classes, you can ask them to be ignored by Icecream
824by listing the recipes and classes using the
Andrew Geissler9aee5002022-03-30 16:27:02 +0000825:term:`ICECC_RECIPE_DISABLE` and
826:term:`ICECC_CLASS_DISABLE` variables,
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500827respectively, in your ``local.conf`` file. Doing so causes the
828OpenEmbedded build system to handle these compilations locally.
829
830Additionally, you can list recipes using the
Andrew Geissler9aee5002022-03-30 16:27:02 +0000831:term:`ICECC_RECIPE_ENABLE` variable in
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500832your ``local.conf`` file to force ``icecc`` to be enabled for recipes
833using an empty :term:`PARALLEL_MAKE` variable.
834
835Inheriting the ``icecc`` class changes all sstate signatures.
836Consequently, if a development team has a dedicated build system that
837populates :term:`SSTATE_MIRRORS` and they want to
Andrew Geissler09036742021-06-25 14:25:14 -0500838reuse sstate from :term:`SSTATE_MIRRORS`, then all developers and the build
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500839system need to either inherit the ``icecc`` class or nobody should.
840
841At the distribution level, you can inherit the ``icecc`` class to be
842sure that all builders start with the same sstate signatures. After
843inheriting the class, you can then disable the feature by setting the
Andrew Geisslerc926e172021-05-07 16:11:35 -0500844:term:`ICECC_DISABLED` variable to "1" as follows::
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500845
Patrick Williams0ca19cc2021-08-16 14:03:13 -0500846 INHERIT_DISTRO:append = " icecc"
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500847 ICECC_DISABLED ??= "1"
848
849This practice
850makes sure everyone is using the same signatures but also requires
851individuals that do want to use Icecream to enable the feature
Andrew Geisslerc926e172021-05-07 16:11:35 -0500852individually as follows in your ``local.conf`` file::
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500853
854 ICECC_DISABLED = ""
855
856.. _ref-classes-image:
857
858``image.bbclass``
859=================
860
861The ``image`` class helps support creating images in different formats.
862First, the root filesystem is created from packages using one of the
863``rootfs*.bbclass`` files (depending on the package format used) and
864then one or more image files are created.
865
Andrew Geissler09036742021-06-25 14:25:14 -0500866- The :term:`IMAGE_FSTYPES` variable controls the types of images to
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500867 generate.
868
Andrew Geissler09036742021-06-25 14:25:14 -0500869- The :term:`IMAGE_INSTALL` variable controls the list of packages to
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500870 install into the image.
871
872For information on customizing images, see the
Andrew Geissler09209ee2020-12-13 08:44:15 -0600873":ref:`dev-manual/common-tasks:customizing images`" section
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500874in the Yocto Project Development Tasks Manual. For information on how
875images are created, see the
Andrew Geissler09209ee2020-12-13 08:44:15 -0600876":ref:`overview-manual/concepts:images`" section in the
Andrew Geisslerd1e89492021-02-12 15:35:20 -0600877Yocto Project Overview and Concepts Manual.
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500878
879.. _ref-classes-image-buildinfo:
880
881``image-buildinfo.bbclass``
882===========================
883
884The ``image-buildinfo`` class writes information to the target
885filesystem on ``/etc/build``.
886
887.. _ref-classes-image_types:
888
889``image_types.bbclass``
890=======================
891
892The ``image_types`` class defines all of the standard image output types
893that you can enable through the
894:term:`IMAGE_FSTYPES` variable. You can use this
895class as a reference on how to add support for custom image output
896types.
897
898By default, the :ref:`image <ref-classes-image>` class automatically
899enables the ``image_types`` class. The ``image`` class uses the
Andrew Geisslerc926e172021-05-07 16:11:35 -0500900``IMGCLASSES`` variable as follows::
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500901
902 IMGCLASSES = "rootfs_${IMAGE_PKGTYPE} image_types ${IMAGE_CLASSES}"
903 IMGCLASSES += "${@['populate_sdk_base', 'populate_sdk_ext']['linux' in d.getVar("SDK_OS")]}"
904 IMGCLASSES += "${@bb.utils.contains_any('IMAGE_FSTYPES', 'live iso hddimg', 'image-live', '', d)}"
905 IMGCLASSES += "${@bb.utils.contains('IMAGE_FSTYPES', 'container', 'image-container', '', d)}"
906 IMGCLASSES += "image_types_wic"
907 IMGCLASSES += "rootfs-postcommands"
908 IMGCLASSES += "image-postinst-intercepts"
909 inherit ${IMGCLASSES}
910
911The ``image_types`` class also handles conversion and compression of images.
912
913.. note::
914
915 To build a VMware VMDK image, you need to add "wic.vmdk" to
Andrew Geissler09036742021-06-25 14:25:14 -0500916 :term:`IMAGE_FSTYPES`. This would also be similar for Virtual Box Virtual Disk
Andrew Geissler4c19ea12020-10-27 13:52:24 -0500917 Image ("vdi") and QEMU Copy On Write Version 2 ("qcow2") images.
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500918
919.. _ref-classes-image-live:
920
921``image-live.bbclass``
922======================
923
924This class controls building "live" (i.e. HDDIMG and ISO) images. Live
925images contain syslinux for legacy booting, as well as the bootloader
926specified by :term:`EFI_PROVIDER` if
927:term:`MACHINE_FEATURES` contains "efi".
928
929Normally, you do not use this class directly. Instead, you add "live" to
930:term:`IMAGE_FSTYPES`.
931
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500932.. _ref-classes-insane:
933
934``insane.bbclass``
935==================
936
937The ``insane`` class adds a step to the package generation process so
938that output quality assurance checks are generated by the OpenEmbedded
939build system. A range of checks are performed that check the build's
940output for common problems that show up during runtime. Distribution
941policy usually dictates whether to include this class.
942
943You can configure the sanity checks so that specific test failures
944either raise a warning or an error message. Typically, failures for new
945tests generate a warning. Subsequent failures for the same test would
946then generate an error message once the metadata is in a known and good
Andrew Geissler09209ee2020-12-13 08:44:15 -0600947condition. See the ":doc:`/ref-manual/qa-checks`" Chapter for a list of all the warning
Andrew Geissler4c19ea12020-10-27 13:52:24 -0500948and error messages you might encounter using a default configuration.
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500949
950Use the :term:`WARN_QA` and
951:term:`ERROR_QA` variables to control the behavior of
952these checks at the global level (i.e. in your custom distro
953configuration). However, to skip one or more checks in recipes, you
954should use :term:`INSANE_SKIP`. For example, to skip
955the check for symbolic link ``.so`` files in the main package of a
956recipe, add the following to the recipe. You need to realize that the
Andrew Geisslerc926e172021-05-07 16:11:35 -0500957package name override, in this example ``${PN}``, must be used::
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500958
Patrick Williams0ca19cc2021-08-16 14:03:13 -0500959 INSANE_SKIP:${PN} += "dev-so"
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500960
961Please keep in mind that the QA checks
William A. Kennington IIIac69b482021-06-02 12:28:27 -0700962are meant to detect real or potential problems in the packaged
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500963output. So exercise caution when disabling these checks.
964
Andrew Geissler09036742021-06-25 14:25:14 -0500965Here are the tests you can list with the :term:`WARN_QA` and
Andrew Geissler5f350902021-07-23 13:09:54 -0400966:term:`ERROR_QA` variables:
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500967
968- ``already-stripped:`` Checks that produced binaries have not
969 already been stripped prior to the build system extracting debug
970 symbols. It is common for upstream software projects to default to
971 stripping debug symbols for output binaries. In order for debugging
972 to work on the target using ``-dbg`` packages, this stripping must be
973 disabled.
974
975- ``arch:`` Checks the Executable and Linkable Format (ELF) type, bit
976 size, and endianness of any binaries to ensure they match the target
977 architecture. This test fails if any binaries do not match the type
978 since there would be an incompatibility. The test could indicate that
979 the wrong compiler or compiler options have been used. Sometimes
980 software, like bootloaders, might need to bypass this check.
981
982- ``buildpaths:`` Checks for paths to locations on the build host
983 inside the output files. Currently, this test triggers too many false
984 positives and thus is not normally enabled.
985
986- ``build-deps:`` Determines if a build-time dependency that is
987 specified through :term:`DEPENDS`, explicit
988 :term:`RDEPENDS`, or task-level dependencies exists
989 to match any runtime dependency. This determination is particularly
990 useful to discover where runtime dependencies are detected and added
991 during packaging. If no explicit dependency has been specified within
992 the metadata, at the packaging stage it is too late to ensure that
993 the dependency is built, and thus you can end up with an error when
994 the package is installed into the image during the
995 :ref:`ref-tasks-rootfs` task because the auto-detected
996 dependency was not satisfied. An example of this would be where the
997 :ref:`update-rc.d <ref-classes-update-rc.d>` class automatically
998 adds a dependency on the ``initscripts-functions`` package to
999 packages that install an initscript that refers to
1000 ``/etc/init.d/functions``. The recipe should really have an explicit
Andrew Geissler5f350902021-07-23 13:09:54 -04001001 :term:`RDEPENDS` for the package in question on ``initscripts-functions``
Andrew Geisslerc9f78652020-09-18 14:11:35 -05001002 so that the OpenEmbedded build system is able to ensure that the
1003 ``initscripts`` recipe is actually built and thus the
1004 ``initscripts-functions`` package is made available.
1005
1006- ``compile-host-path:`` Checks the
1007 :ref:`ref-tasks-compile` log for indications that
1008 paths to locations on the build host were used. Using such paths
1009 might result in host contamination of the build output.
1010
1011- ``debug-deps:`` Checks that all packages except ``-dbg`` packages
1012 do not depend on ``-dbg`` packages, which would cause a packaging
1013 bug.
1014
1015- ``debug-files:`` Checks for ``.debug`` directories in anything but
1016 the ``-dbg`` package. The debug files should all be in the ``-dbg``
1017 package. Thus, anything packaged elsewhere is incorrect packaging.
1018
1019- ``dep-cmp:`` Checks for invalid version comparison statements in
1020 runtime dependency relationships between packages (i.e. in
1021 :term:`RDEPENDS`,
1022 :term:`RRECOMMENDS`,
1023 :term:`RSUGGESTS`,
1024 :term:`RPROVIDES`,
1025 :term:`RREPLACES`, and
1026 :term:`RCONFLICTS` variable values). Any invalid
1027 comparisons might trigger failures or undesirable behavior when
1028 passed to the package manager.
1029
1030- ``desktop:`` Runs the ``desktop-file-validate`` program against any
1031 ``.desktop`` files to validate their contents against the
1032 specification for ``.desktop`` files.
1033
1034- ``dev-deps:`` Checks that all packages except ``-dev`` or
1035 ``-staticdev`` packages do not depend on ``-dev`` packages, which
1036 would be a packaging bug.
1037
1038- ``dev-so:`` Checks that the ``.so`` symbolic links are in the
1039 ``-dev`` package and not in any of the other packages. In general,
1040 these symlinks are only useful for development purposes. Thus, the
William A. Kennington IIIac69b482021-06-02 12:28:27 -07001041 ``-dev`` package is the correct location for them. In very rare
1042 cases, such as dynamically loaded modules, these symlinks
Andrew Geisslerc9f78652020-09-18 14:11:35 -05001043 are needed instead in the main package.
1044
Patrick Williams03907ee2022-05-01 06:28:52 -05001045- ``empty-dirs:`` Checks that packages are not installing files to
1046 directories that are normally expected to be empty (such as ``/tmp``)
1047 The list of directories that are checked is specified by the
1048 :term:`QA_EMPTY_DIRS` variable.
1049
Andrew Geisslerc9f78652020-09-18 14:11:35 -05001050- ``file-rdeps:`` Checks that file-level dependencies identified by
1051 the OpenEmbedded build system at packaging time are satisfied. For
1052 example, a shell script might start with the line ``#!/bin/bash``.
1053 This line would translate to a file dependency on ``/bin/bash``. Of
1054 the three package managers that the OpenEmbedded build system
1055 supports, only RPM directly handles file-level dependencies,
1056 resolving them automatically to packages providing the files.
1057 However, the lack of that functionality in the other two package
1058 managers does not mean the dependencies do not still need resolving.
1059 This QA check attempts to ensure that explicitly declared
1060 :term:`RDEPENDS` exist to handle any file-level
1061 dependency detected in packaged files.
1062
1063- ``files-invalid:`` Checks for :term:`FILES` variable
1064 values that contain "//", which is invalid.
1065
1066- ``host-user-contaminated:`` Checks that no package produced by the
1067 recipe contains any files outside of ``/home`` with a user or group
1068 ID that matches the user running BitBake. A match usually indicates
1069 that the files are being installed with an incorrect UID/GID, since
1070 target IDs are independent from host IDs. For additional information,
1071 see the section describing the
1072 :ref:`ref-tasks-install` task.
1073
1074- ``incompatible-license:`` Report when packages are excluded from
1075 being created due to being marked with a license that is in
1076 :term:`INCOMPATIBLE_LICENSE`.
1077
1078- ``install-host-path:`` Checks the
1079 :ref:`ref-tasks-install` log for indications that
1080 paths to locations on the build host were used. Using such paths
1081 might result in host contamination of the build output.
1082
1083- ``installed-vs-shipped:`` Reports when files have been installed
Patrick Williams2194f502022-10-16 14:26:09 -05001084 within :ref:`ref-tasks-install` but have not been included in any package by
Andrew Geisslerc9f78652020-09-18 14:11:35 -05001085 way of the :term:`FILES` variable. Files that do not
1086 appear in any package cannot be present in an image later on in the
1087 build process. Ideally, all installed files should be packaged or not
1088 installed at all. These files can be deleted at the end of
Patrick Williams2194f502022-10-16 14:26:09 -05001089 :ref:`ref-tasks-install` if the files are not needed in any package.
Andrew Geisslerc9f78652020-09-18 14:11:35 -05001090
1091- ``invalid-chars:`` Checks that the recipe metadata variables
1092 :term:`DESCRIPTION`,
1093 :term:`SUMMARY`, :term:`LICENSE`, and
1094 :term:`SECTION` do not contain non-UTF-8 characters.
1095 Some package managers do not support such characters.
1096
1097- ``invalid-packageconfig:`` Checks that no undefined features are
1098 being added to :term:`PACKAGECONFIG`. For
Andrew Geisslerc926e172021-05-07 16:11:35 -05001099 example, any name "foo" for which the following form does not exist::
Andrew Geisslerc9f78652020-09-18 14:11:35 -05001100
1101 PACKAGECONFIG[foo] = "..."
1102
Andrew Geissler09036742021-06-25 14:25:14 -05001103- ``la:`` Checks ``.la`` files for any :term:`TMPDIR` paths. Any ``.la``
Andrew Geisslerc9f78652020-09-18 14:11:35 -05001104 file containing these paths is incorrect since ``libtool`` adds the
1105 correct sysroot prefix when using the files automatically itself.
1106
1107- ``ldflags:`` Ensures that the binaries were linked with the
1108 :term:`LDFLAGS` options provided by the build system.
Andrew Geissler09036742021-06-25 14:25:14 -05001109 If this test fails, check that the :term:`LDFLAGS` variable is being
Andrew Geisslerc9f78652020-09-18 14:11:35 -05001110 passed to the linker command.
1111
1112- ``libdir:`` Checks for libraries being installed into incorrect
1113 (possibly hardcoded) installation paths. For example, this test will
1114 catch recipes that install ``/lib/bar.so`` when ``${base_libdir}`` is
1115 "lib32". Another example is when recipes install
1116 ``/usr/lib64/foo.so`` when ``${libdir}`` is "/usr/lib".
1117
1118- ``libexec:`` Checks if a package contains files in
1119 ``/usr/libexec``. This check is not performed if the ``libexecdir``
1120 variable has been set explicitly to ``/usr/libexec``.
1121
1122- ``packages-list:`` Checks for the same package being listed
1123 multiple times through the :term:`PACKAGES` variable
1124 value. Installing the package in this manner can cause errors during
1125 packaging.
1126
1127- ``perm-config:`` Reports lines in ``fs-perms.txt`` that have an
1128 invalid format.
1129
1130- ``perm-line:`` Reports lines in ``fs-perms.txt`` that have an
1131 invalid format.
1132
1133- ``perm-link:`` Reports lines in ``fs-perms.txt`` that specify
1134 'link' where the specified target already exists.
1135
1136- ``perms:`` Currently, this check is unused but reserved.
1137
1138- ``pkgconfig:`` Checks ``.pc`` files for any
1139 :term:`TMPDIR`/:term:`WORKDIR` paths.
1140 Any ``.pc`` file containing these paths is incorrect since
1141 ``pkg-config`` itself adds the correct sysroot prefix when the files
1142 are accessed.
1143
1144- ``pkgname:`` Checks that all packages in
1145 :term:`PACKAGES` have names that do not contain
1146 invalid characters (i.e. characters other than 0-9, a-z, ., +, and
1147 -).
1148
Andrew Geissler09036742021-06-25 14:25:14 -05001149- ``pkgv-undefined:`` Checks to see if the :term:`PKGV` variable is
Andrew Geisslerc9f78652020-09-18 14:11:35 -05001150 undefined during :ref:`ref-tasks-package`.
1151
1152- ``pkgvarcheck:`` Checks through the variables
1153 :term:`RDEPENDS`,
1154 :term:`RRECOMMENDS`,
1155 :term:`RSUGGESTS`,
1156 :term:`RCONFLICTS`,
1157 :term:`RPROVIDES`,
1158 :term:`RREPLACES`, :term:`FILES`,
1159 :term:`ALLOW_EMPTY`, ``pkg_preinst``,
1160 ``pkg_postinst``, ``pkg_prerm`` and ``pkg_postrm``, and reports if
1161 there are variable sets that are not package-specific. Using these
1162 variables without a package suffix is bad practice, and might
1163 unnecessarily complicate dependencies of other packages within the
1164 same recipe or have other unintended consequences.
1165
1166- ``pn-overrides:`` Checks that a recipe does not have a name
1167 (:term:`PN`) value that appears in
1168 :term:`OVERRIDES`. If a recipe is named such that
Andrew Geissler09036742021-06-25 14:25:14 -05001169 its :term:`PN` value matches something already in :term:`OVERRIDES` (e.g.
1170 :term:`PN` happens to be the same as :term:`MACHINE` or
Andrew Geisslerc9f78652020-09-18 14:11:35 -05001171 :term:`DISTRO`), it can have unexpected consequences.
Patrick Williams0ca19cc2021-08-16 14:03:13 -05001172 For example, assignments such as ``FILES:${PN} = "xyz"`` effectively
Andrew Geisslerc9f78652020-09-18 14:11:35 -05001173 turn into ``FILES = "xyz"``.
1174
1175- ``rpaths:`` Checks for rpaths in the binaries that contain build
Andrew Geissler5f350902021-07-23 13:09:54 -04001176 system paths such as :term:`TMPDIR`. If this test fails, bad ``-rpath``
Andrew Geisslerc9f78652020-09-18 14:11:35 -05001177 options are being passed to the linker commands and your binaries
1178 have potential security issues.
1179
1180- ``split-strip:`` Reports that splitting or stripping debug symbols
1181 from binaries has failed.
1182
1183- ``staticdev:`` Checks for static library files (``*.a``) in
1184 non-``staticdev`` packages.
1185
1186- ``symlink-to-sysroot:`` Checks for symlinks in packages that point
1187 into :term:`TMPDIR` on the host. Such symlinks will
1188 work on the host, but are clearly invalid when running on the target.
1189
1190- ``textrel:`` Checks for ELF binaries that contain relocations in
1191 their ``.text`` sections, which can result in a performance impact at
Andrew Geissler4c19ea12020-10-27 13:52:24 -05001192 runtime. See the explanation for the ``ELF binary`` message in
Andrew Geissler09209ee2020-12-13 08:44:15 -06001193 ":doc:`/ref-manual/qa-checks`" for more information regarding runtime performance
Andrew Geissler4c19ea12020-10-27 13:52:24 -05001194 issues.
Andrew Geisslerc9f78652020-09-18 14:11:35 -05001195
1196- ``unlisted-pkg-lics:`` Checks that all declared licenses applying
1197 for a package are also declared on the recipe level (i.e. any license
Patrick Williams0ca19cc2021-08-16 14:03:13 -05001198 in ``LICENSE:*`` should appear in :term:`LICENSE`).
Andrew Geisslerc9f78652020-09-18 14:11:35 -05001199
1200- ``useless-rpaths:`` Checks for dynamic library load paths (rpaths)
1201 in the binaries that by default on a standard system are searched by
1202 the linker (e.g. ``/lib`` and ``/usr/lib``). While these paths will
1203 not cause any breakage, they do waste space and are unnecessary.
1204
1205- ``var-undefined:`` Reports when variables fundamental to packaging
1206 (i.e. :term:`WORKDIR`,
1207 :term:`DEPLOY_DIR`, :term:`D`,
1208 :term:`PN`, and :term:`PKGD`) are undefined
1209 during :ref:`ref-tasks-package`.
1210
1211- ``version-going-backwards:`` If Build History is enabled, reports
1212 when a package being written out has a lower version than the
1213 previously written package under the same name. If you are placing
1214 output packages into a feed and upgrading packages on a target system
1215 using that feed, the version of a package going backwards can result
1216 in the target system not correctly upgrading to the "new" version of
1217 the package.
1218
1219 .. note::
1220
William A. Kennington IIIac69b482021-06-02 12:28:27 -07001221 This is only relevant when you are using runtime package management
1222 on your target system.
Andrew Geisslerc9f78652020-09-18 14:11:35 -05001223
1224- ``xorg-driver-abi:`` Checks that all packages containing Xorg
1225 drivers have ABI dependencies. The ``xserver-xorg`` recipe provides
1226 driver ABI names. All drivers should depend on the ABI versions that
1227 they have been built against. Driver recipes that include
1228 ``xorg-driver-input.inc`` or ``xorg-driver-video.inc`` will
1229 automatically get these versions. Consequently, you should only need
1230 to explicitly add dependencies to binary driver recipes.
1231
1232.. _ref-classes-insserv:
1233
1234``insserv.bbclass``
1235===================
1236
1237The ``insserv`` class uses the ``insserv`` utility to update the order
1238of symbolic links in ``/etc/rc?.d/`` within an image based on
1239dependencies specified by LSB headers in the ``init.d`` scripts
1240themselves.
1241
1242.. _ref-classes-kernel:
1243
1244``kernel.bbclass``
1245==================
1246
1247The ``kernel`` class handles building Linux kernels. The class contains
1248code to build all kernel trees. All needed headers are staged into the
Andrew Geissler5f350902021-07-23 13:09:54 -04001249:term:`STAGING_KERNEL_DIR` directory to allow out-of-tree module builds
Andrew Geisslerc9f78652020-09-18 14:11:35 -05001250using the :ref:`module <ref-classes-module>` class.
1251
1252This means that each built kernel module is packaged separately and
1253inter-module dependencies are created by parsing the ``modinfo`` output.
1254If all modules are required, then installing the ``kernel-modules``
1255package installs all packages with modules and various other kernel
1256packages such as ``kernel-vmlinux``.
1257
1258The ``kernel`` class contains logic that allows you to embed an initial
Patrick Williams2194f502022-10-16 14:26:09 -05001259RAM filesystem (:term:`Initramfs`) image when you build the kernel image. For
1260information on how to build an :term:`Initramfs`, see the
1261":ref:`dev-manual/common-tasks:building an initial ram filesystem (Initramfs) image`" section in
Andrew Geisslerc9f78652020-09-18 14:11:35 -05001262the Yocto Project Development Tasks Manual.
1263
1264Various other classes are used by the ``kernel`` and ``module`` classes
1265internally including the :ref:`kernel-arch <ref-classes-kernel-arch>`,
1266:ref:`module-base <ref-classes-module-base>`, and
1267:ref:`linux-kernel-base <ref-classes-linux-kernel-base>` classes.
1268
1269.. _ref-classes-kernel-arch:
1270
1271``kernel-arch.bbclass``
1272=======================
1273
1274The ``kernel-arch`` class sets the ``ARCH`` environment variable for
1275Linux kernel compilation (including modules).
1276
1277.. _ref-classes-kernel-devicetree:
1278
1279``kernel-devicetree.bbclass``
1280=============================
1281
1282The ``kernel-devicetree`` class, which is inherited by the
1283:ref:`kernel <ref-classes-kernel>` class, supports device tree
1284generation.
1285
1286.. _ref-classes-kernel-fitimage:
1287
1288``kernel-fitimage.bbclass``
1289===========================
1290
Andrew Geisslerd1e89492021-02-12 15:35:20 -06001291The ``kernel-fitimage`` class provides support to pack a kernel image,
1292device trees, a U-boot script, a Initramfs bundle and a RAM disk
1293into a single FIT image. In theory, a FIT image can support any number
1294of kernels, U-boot scripts, Initramfs bundles, RAM disks and device-trees.
Andrew Geisslerc9f78652020-09-18 14:11:35 -05001295However, ``kernel-fitimage`` currently only supports
Andrew Geisslerd1e89492021-02-12 15:35:20 -06001296limited usescases: just one kernel image, an optional U-boot script,
1297an optional Initramfs bundle, an optional RAM disk, and any number of
1298device tree.
Andrew Geisslerc9f78652020-09-18 14:11:35 -05001299
1300To create a FIT image, it is required that :term:`KERNEL_CLASSES`
Andrew Geisslerd1e89492021-02-12 15:35:20 -06001301is set to include "kernel-fitimage" and :term:`KERNEL_IMAGETYPE`
Andrew Geisslerc9f78652020-09-18 14:11:35 -05001302is set to "fitImage".
1303
Andrew Geisslerd1e89492021-02-12 15:35:20 -06001304The options for the device tree compiler passed to ``mkimage -D``
Andrew Geisslerc9f78652020-09-18 14:11:35 -05001305when creating the FIT image are specified using the
1306:term:`UBOOT_MKIMAGE_DTCOPTS` variable.
1307
1308Only a single kernel can be added to the FIT image created by
1309``kernel-fitimage`` and the kernel image in FIT is mandatory. The
Andrew Geisslerd1e89492021-02-12 15:35:20 -06001310address where the kernel image is to be loaded by U-Boot is
Andrew Geisslerc9f78652020-09-18 14:11:35 -05001311specified by :term:`UBOOT_LOADADDRESS` and the entrypoint by
1312:term:`UBOOT_ENTRYPOINT`.
1313
1314Multiple device trees can be added to the FIT image created by
1315``kernel-fitimage`` and the device tree is optional.
Andrew Geisslerd1e89492021-02-12 15:35:20 -06001316The address where the device tree is to be loaded by U-Boot is
Andrew Geisslerc9f78652020-09-18 14:11:35 -05001317specified by :term:`UBOOT_DTBO_LOADADDRESS` for device tree overlays
Andrew Geissler4c19ea12020-10-27 13:52:24 -05001318and by :term:`UBOOT_DTB_LOADADDRESS` for device tree binaries.
Andrew Geisslerc9f78652020-09-18 14:11:35 -05001319
1320Only a single RAM disk can be added to the FIT image created by
1321``kernel-fitimage`` and the RAM disk in FIT is optional.
Andrew Geisslerd1e89492021-02-12 15:35:20 -06001322The address where the RAM disk image is to be loaded by U-Boot
Andrew Geisslerc9f78652020-09-18 14:11:35 -05001323is specified by :term:`UBOOT_RD_LOADADDRESS` and the entrypoint by
1324:term:`UBOOT_RD_ENTRYPOINT`. The ramdisk is added to FIT image when
Andrew Geisslerd1e89492021-02-12 15:35:20 -06001325:term:`INITRAMFS_IMAGE` is specified and that :term:`INITRAMFS_IMAGE_BUNDLE`
1326is set to 0.
1327
1328Only a single Initramfs bundle can be added to the FIT image created by
1329``kernel-fitimage`` and the Initramfs bundle in FIT is optional.
Andrew Geissler595f6302022-01-24 19:11:47 +00001330In case of Initramfs, the kernel is configured to be bundled with the root filesystem
Andrew Geisslerd1e89492021-02-12 15:35:20 -06001331in the same binary (example: zImage-initramfs-:term:`MACHINE`.bin).
Andrew Geissler595f6302022-01-24 19:11:47 +00001332When the kernel is copied to RAM and executed, it unpacks the Initramfs root filesystem.
Andrew Geisslerd1e89492021-02-12 15:35:20 -06001333The Initramfs bundle can be enabled when :term:`INITRAMFS_IMAGE`
1334is specified and that :term:`INITRAMFS_IMAGE_BUNDLE` is set to 1.
1335The address where the Initramfs bundle is to be loaded by U-boot is specified
1336by :term:`UBOOT_LOADADDRESS` and the entrypoint by :term:`UBOOT_ENTRYPOINT`.
1337
1338Only a single U-boot boot script can be added to the FIT image created by
1339``kernel-fitimage`` and the boot script is optional.
1340The boot script is specified in the ITS file as a text file containing
1341U-boot commands. When using a boot script the user should configure the
Patrick Williams2194f502022-10-16 14:26:09 -05001342U-boot :ref:`ref-tasks-install` task to copy the script to sysroot.
Andrew Geissler3b8a17c2021-04-15 15:55:55 -05001343So the script can be included in the FIT image by the ``kernel-fitimage``
Andrew Geisslerd1e89492021-02-12 15:35:20 -06001344class. At run-time, U-boot CONFIG_BOOTCOMMAND define can be configured to
1345load the boot script from the FIT image and executes it.
Andrew Geisslerc9f78652020-09-18 14:11:35 -05001346
1347The FIT image generated by ``kernel-fitimage`` class is signed when the
1348variables :term:`UBOOT_SIGN_ENABLE`, :term:`UBOOT_MKIMAGE_DTCOPTS`,
1349:term:`UBOOT_SIGN_KEYDIR` and :term:`UBOOT_SIGN_KEYNAME` are set
1350appropriately. The default values used for :term:`FIT_HASH_ALG` and
1351:term:`FIT_SIGN_ALG` in ``kernel-fitimage`` are "sha256" and
Andrew Geisslerc3d88e42020-10-02 09:45:00 -05001352"rsa2048" respectively. The keys for signing fitImage can be generated using
1353the ``kernel-fitimage`` class when both :term:`FIT_GENERATE_KEYS` and
1354:term:`UBOOT_SIGN_ENABLE` are set to "1".
Andrew Geisslerc9f78652020-09-18 14:11:35 -05001355
1356
1357.. _ref-classes-kernel-grub:
1358
1359``kernel-grub.bbclass``
1360=======================
1361
1362The ``kernel-grub`` class updates the boot area and the boot menu with
1363the kernel as the priority boot mechanism while installing a RPM to
1364update the kernel on a deployed target.
1365
1366.. _ref-classes-kernel-module-split:
1367
1368``kernel-module-split.bbclass``
1369===============================
1370
1371The ``kernel-module-split`` class provides common functionality for
1372splitting Linux kernel modules into separate packages.
1373
1374.. _ref-classes-kernel-uboot:
1375
1376``kernel-uboot.bbclass``
1377========================
1378
1379The ``kernel-uboot`` class provides support for building from
1380vmlinux-style kernel sources.
1381
1382.. _ref-classes-kernel-uimage:
1383
1384``kernel-uimage.bbclass``
1385=========================
1386
1387The ``kernel-uimage`` class provides support to pack uImage.
1388
1389.. _ref-classes-kernel-yocto:
1390
1391``kernel-yocto.bbclass``
1392========================
1393
1394The ``kernel-yocto`` class provides common functionality for building
1395from linux-yocto style kernel source repositories.
1396
1397.. _ref-classes-kernelsrc:
1398
1399``kernelsrc.bbclass``
1400=====================
1401
1402The ``kernelsrc`` class sets the Linux kernel source and version.
1403
1404.. _ref-classes-lib_package:
1405
1406``lib_package.bbclass``
1407=======================
1408
1409The ``lib_package`` class supports recipes that build libraries and
1410produce executable binaries, where those binaries should not be
1411installed by default along with the library. Instead, the binaries are
1412added to a separate ``${``\ :term:`PN`\ ``}-bin`` package to
1413make their installation optional.
1414
1415.. _ref-classes-libc*:
1416
1417``libc*.bbclass``
1418=================
1419
1420The ``libc*`` classes support recipes that build packages with ``libc``:
1421
1422- The ``libc-common`` class provides common support for building with
1423 ``libc``.
1424
1425- The ``libc-package`` class supports packaging up ``glibc`` and
1426 ``eglibc``.
1427
1428.. _ref-classes-license:
1429
1430``license.bbclass``
1431===================
1432
1433The ``license`` class provides license manifest creation and license
1434exclusion. This class is enabled by default using the default value for
1435the :term:`INHERIT_DISTRO` variable.
1436
1437.. _ref-classes-linux-kernel-base:
1438
1439``linux-kernel-base.bbclass``
1440=============================
1441
1442The ``linux-kernel-base`` class provides common functionality for
1443recipes that build out of the Linux kernel source tree. These builds
1444goes beyond the kernel itself. For example, the Perf recipe also
1445inherits this class.
1446
1447.. _ref-classes-linuxloader:
1448
1449``linuxloader.bbclass``
1450=======================
1451
1452Provides the function ``linuxloader()``, which gives the value of the
1453dynamic loader/linker provided on the platform. This value is used by a
1454number of other classes.
1455
1456.. _ref-classes-logging:
1457
1458``logging.bbclass``
1459===================
1460
1461The ``logging`` class provides the standard shell functions used to log
1462messages for various BitBake severity levels (i.e. ``bbplain``,
1463``bbnote``, ``bbwarn``, ``bberror``, ``bbfatal``, and ``bbdebug``).
1464
1465This class is enabled by default since it is inherited by the ``base``
1466class.
1467
Andrew Geisslerc9f78652020-09-18 14:11:35 -05001468.. _ref-classes-metadata_scm:
1469
1470``metadata_scm.bbclass``
1471========================
1472
1473The ``metadata_scm`` class provides functionality for querying the
1474branch and revision of a Source Code Manager (SCM) repository.
1475
1476The :ref:`base <ref-classes-base>` class uses this class to print the
1477revisions of each layer before starting every build. The
1478``metadata_scm`` class is enabled by default because it is inherited by
1479the ``base`` class.
1480
1481.. _ref-classes-migrate_localcount:
1482
1483``migrate_localcount.bbclass``
1484==============================
1485
1486The ``migrate_localcount`` class verifies a recipe's localcount data and
1487increments it appropriately.
1488
1489.. _ref-classes-mime:
1490
1491``mime.bbclass``
1492================
1493
1494The ``mime`` class generates the proper post-install and post-remove
1495(postinst/postrm) scriptlets for packages that install MIME type files.
1496These scriptlets call ``update-mime-database`` to add the MIME types to
1497the shared database.
1498
1499.. _ref-classes-mirrors:
1500
1501``mirrors.bbclass``
1502===================
1503
1504The ``mirrors`` class sets up some standard
1505:term:`MIRRORS` entries for source code mirrors. These
1506mirrors provide a fall-back path in case the upstream source specified
1507in :term:`SRC_URI` within recipes is unavailable.
1508
1509This class is enabled by default since it is inherited by the
1510:ref:`base <ref-classes-base>` class.
1511
1512.. _ref-classes-module:
1513
1514``module.bbclass``
1515==================
1516
1517The ``module`` class provides support for building out-of-tree Linux
1518kernel modules. The class inherits the
1519:ref:`module-base <ref-classes-module-base>` and
1520:ref:`kernel-module-split <ref-classes-kernel-module-split>` classes,
1521and implements the :ref:`ref-tasks-compile` and
1522:ref:`ref-tasks-install` tasks. The class provides
1523everything needed to build and package a kernel module.
1524
1525For general information on out-of-tree Linux kernel modules, see the
Andrew Geissler09209ee2020-12-13 08:44:15 -06001526":ref:`kernel-dev/common:incorporating out-of-tree modules`"
Andrew Geisslerc9f78652020-09-18 14:11:35 -05001527section in the Yocto Project Linux Kernel Development Manual.
1528
1529.. _ref-classes-module-base:
1530
1531``module-base.bbclass``
1532=======================
1533
1534The ``module-base`` class provides the base functionality for building
1535Linux kernel modules. Typically, a recipe that builds software that
1536includes one or more kernel modules and has its own means of building
1537the module inherits this class as opposed to inheriting the
1538:ref:`module <ref-classes-module>` class.
1539
1540.. _ref-classes-multilib*:
1541
1542``multilib*.bbclass``
1543=====================
1544
1545The ``multilib*`` classes provide support for building libraries with
1546different target optimizations or target architectures and installing
1547them side-by-side in the same image.
1548
1549For more information on using the Multilib feature, see the
Andrew Geissler09209ee2020-12-13 08:44:15 -06001550":ref:`dev-manual/common-tasks:combining multiple versions of library files into one image`"
Andrew Geisslerc9f78652020-09-18 14:11:35 -05001551section in the Yocto Project Development Tasks Manual.
1552
1553.. _ref-classes-native:
1554
1555``native.bbclass``
1556==================
1557
1558The ``native`` class provides common functionality for recipes that
Andrew Geissler4c19ea12020-10-27 13:52:24 -05001559build tools to run on the :term:`Build Host` (i.e. tools that use the compiler
1560or other tools from the build host).
Andrew Geisslerc9f78652020-09-18 14:11:35 -05001561
1562You can create a recipe that builds tools that run natively on the host
1563a couple different ways:
1564
Andrew Geisslereff27472021-10-29 15:35:00 -05001565- Create a ``myrecipe-native.bb`` recipe that inherits the ``native``
Andrew Geisslerc9f78652020-09-18 14:11:35 -05001566 class. If you use this method, you must order the inherit statement
1567 in the recipe after all other inherit statements so that the
1568 ``native`` class is inherited last.
1569
1570 .. note::
1571
1572 When creating a recipe this way, the recipe name must follow this
Andrew Geisslerc926e172021-05-07 16:11:35 -05001573 naming convention::
Andrew Geisslerc9f78652020-09-18 14:11:35 -05001574
1575 myrecipe-native.bb
1576
1577
1578 Not using this naming convention can lead to subtle problems
1579 caused by existing code that depends on that naming convention.
1580
Andrew Geisslerc926e172021-05-07 16:11:35 -05001581- Create or modify a target recipe that contains the following::
Andrew Geisslerc9f78652020-09-18 14:11:35 -05001582
1583 BBCLASSEXTEND = "native"
1584
1585 Inside the
Patrick Williams0ca19cc2021-08-16 14:03:13 -05001586 recipe, use ``:class-native`` and ``:class-target`` overrides to
Andrew Geisslerc9f78652020-09-18 14:11:35 -05001587 specify any functionality specific to the respective native or target
1588 case.
1589
1590Although applied differently, the ``native`` class is used with both
1591methods. The advantage of the second method is that you do not need to
1592have two separate recipes (assuming you need both) for native and
1593target. All common parts of the recipe are automatically shared.
1594
1595.. _ref-classes-nativesdk:
1596
1597``nativesdk.bbclass``
1598=====================
1599
1600The ``nativesdk`` class provides common functionality for recipes that
1601wish to build tools to run as part of an SDK (i.e. tools that run on
1602:term:`SDKMACHINE`).
1603
1604You can create a recipe that builds tools that run on the SDK machine a
1605couple different ways:
1606
Andrew Geisslereff27472021-10-29 15:35:00 -05001607- Create a ``nativesdk-myrecipe.bb`` recipe that inherits the
Andrew Geisslerc9f78652020-09-18 14:11:35 -05001608 ``nativesdk`` class. If you use this method, you must order the
1609 inherit statement in the recipe after all other inherit statements so
1610 that the ``nativesdk`` class is inherited last.
1611
Andrew Geisslerc926e172021-05-07 16:11:35 -05001612- Create a ``nativesdk`` variant of any recipe by adding the following::
Andrew Geisslerc9f78652020-09-18 14:11:35 -05001613
1614 BBCLASSEXTEND = "nativesdk"
1615
1616 Inside the
Patrick Williams0ca19cc2021-08-16 14:03:13 -05001617 recipe, use ``:class-nativesdk`` and ``:class-target`` overrides to
Andrew Geisslerc9f78652020-09-18 14:11:35 -05001618 specify any functionality specific to the respective SDK machine or
1619 target case.
1620
1621.. note::
1622
Andrew Geisslerc926e172021-05-07 16:11:35 -05001623 When creating a recipe, you must follow this naming convention::
Andrew Geisslerc9f78652020-09-18 14:11:35 -05001624
1625 nativesdk-myrecipe.bb
1626
1627
William A. Kennington IIIac69b482021-06-02 12:28:27 -07001628 Not doing so can lead to subtle problems because there is code that
Andrew Geisslerc9f78652020-09-18 14:11:35 -05001629 depends on the naming convention.
1630
1631Although applied differently, the ``nativesdk`` class is used with both
1632methods. The advantage of the second method is that you do not need to
1633have two separate recipes (assuming you need both) for the SDK machine
1634and the target. All common parts of the recipe are automatically shared.
1635
1636.. _ref-classes-nopackages:
1637
1638``nopackages.bbclass``
1639======================
1640
1641Disables packaging tasks for those recipes and classes where packaging
1642is not needed.
1643
1644.. _ref-classes-npm:
1645
1646``npm.bbclass``
1647===============
1648
1649Provides support for building Node.js software fetched using the `node
1650package manager (NPM) <https://en.wikipedia.org/wiki/Npm_(software)>`__.
1651
1652.. note::
1653
Andrew Geissler4c19ea12020-10-27 13:52:24 -05001654 Currently, recipes inheriting this class must use the ``npm://``
Andrew Geisslerc9f78652020-09-18 14:11:35 -05001655 fetcher to have dependencies fetched and packaged automatically.
1656
1657For information on how to create NPM packages, see the
Andrew Geissler09209ee2020-12-13 08:44:15 -06001658":ref:`dev-manual/common-tasks:creating node package manager (npm) packages`"
Andrew Geisslerc9f78652020-09-18 14:11:35 -05001659section in the Yocto Project Development Tasks Manual.
1660
1661.. _ref-classes-oelint:
1662
1663``oelint.bbclass``
1664==================
1665
William A. Kennington IIIac69b482021-06-02 12:28:27 -07001666The ``oelint`` class is an obsolete lint checking tool available in
Andrew Geisslerc9f78652020-09-18 14:11:35 -05001667``meta/classes`` in the :term:`Source Directory`.
1668
William A. Kennington IIIac69b482021-06-02 12:28:27 -07001669There are some classes that could be generally useful in OE-Core but
Andrew Geisslerc9f78652020-09-18 14:11:35 -05001670are never actually used within OE-Core itself. The ``oelint`` class is
1671one such example. However, being aware of this class can reduce the
1672proliferation of different versions of similar classes across multiple
1673layers.
1674
Andrew Geissler5199d832021-09-24 16:47:35 -05001675.. _ref-classes-overlayfs:
1676
1677``overlayfs.bbclass``
1678=======================
1679
Andrew Geissler595f6302022-01-24 19:11:47 +00001680It's often desired in Embedded System design to have a read-only root filesystem.
Andrew Geissler5199d832021-09-24 16:47:35 -05001681But a lot of different applications might want to have read-write access to
1682some parts of a filesystem. It can be especially useful when your update mechanism
Andrew Geissler595f6302022-01-24 19:11:47 +00001683overwrites the whole root filesystem, but you may want your application data to be preserved
Andrew Geissler5199d832021-09-24 16:47:35 -05001684between updates. The :ref:`overlayfs <ref-classes-overlayfs>` class provides a way
1685to achieve that by means of ``overlayfs`` and at the same time keeping the base
Andrew Geissler595f6302022-01-24 19:11:47 +00001686root filesystem read-only.
Andrew Geissler5199d832021-09-24 16:47:35 -05001687
1688To use this class, set a mount point for a partition ``overlayfs`` is going to use as upper
1689layer in your machine configuration. The underlying file system can be anything that
1690is supported by ``overlayfs``. This has to be done in your machine configuration::
1691
1692 OVERLAYFS_MOUNT_POINT[data] = "/data"
1693
1694.. note::
1695
1696 * QA checks fail to catch file existence if you redefine this variable in your recipe!
1697 * Only the existence of the systemd mount unit file is checked, not its contents.
1698 * To get more details on ``overlayfs``, its internals and supported operations, please refer
1699 to the official documentation of the `Linux kernel <https://www.kernel.org/doc/html/latest/filesystems/overlayfs.html>`_.
1700
1701The class assumes you have a ``data.mount`` systemd unit defined elsewhere in your BSP
1702(e.g. in ``systemd-machine-units`` recipe) and it's installed into the image.
1703
1704Then you can specify writable directories on a recipe basis (e.g. in my-application.bb)::
1705
1706 OVERLAYFS_WRITABLE_PATHS[data] = "/usr/share/my-custom-application"
1707
1708To support several mount points you can use a different variable flag. Assuming we
1709want to have a writable location on the file system, but do not need that the data
Andrew Geissler595f6302022-01-24 19:11:47 +00001710survives a reboot, then we could have a ``mnt-overlay.mount`` unit for a ``tmpfs``
1711file system.
Andrew Geissler5199d832021-09-24 16:47:35 -05001712
1713In your machine configuration::
1714
1715 OVERLAYFS_MOUNT_POINT[mnt-overlay] = "/mnt/overlay"
1716
1717and then in your recipe::
1718
1719 OVERLAYFS_WRITABLE_PATHS[mnt-overlay] = "/usr/share/another-application"
1720
Andrew Geissler595f6302022-01-24 19:11:47 +00001721On a practical note, your application recipe might require multiple
1722overlays to be mounted before running to avoid writing to the underlying
1723file system (which can be forbidden in case of read-only file system)
1724To achieve that :ref:`overlayfs <ref-classes-overlayfs>` provides a ``systemd``
1725helper service for mounting overlays. This helper service is named
1726``${PN}-overlays.service`` and can be depended on in your application recipe
1727(named ``application`` in the following example) ``systemd`` unit by adding
1728to the unit the following::
1729
1730 [Unit]
1731 After=application-overlays.service
1732 Requires=application-overlays.service
1733
Andrew Geissler5199d832021-09-24 16:47:35 -05001734.. note::
1735
1736 The class does not support the ``/etc`` directory itself, because ``systemd`` depends on it.
Andrew Geissler595f6302022-01-24 19:11:47 +00001737 In order to get ``/etc`` in overlayfs, see :ref:`overlayfs-etc <ref-classes-overlayfs-etc>`.
1738
1739.. _ref-classes-overlayfs-etc:
1740
1741``overlayfs-etc.bbclass``
1742=========================
1743
1744In order to have the ``/etc`` directory in overlayfs a special handling at early
1745boot stage is required. The idea is to supply a custom init script that mounts
1746``/etc`` before launching the actual init program, because the latter already
1747requires ``/etc`` to be mounted.
1748
1749Example usage in image recipe::
1750
1751 IMAGE_FEATURES += "overlayfs-etc"
1752
1753.. note::
1754
1755 This class must not be inherited directly. Use :term:`IMAGE_FEATURES` or :term:`EXTRA_IMAGE_FEATURES`
1756
1757Your machine configuration should define at least the device, mount point, and file system type
1758you are going to use for ``overlayfs``::
1759
1760 OVERLAYFS_ETC_MOUNT_POINT = "/data"
1761 OVERLAYFS_ETC_DEVICE = "/dev/mmcblk0p2"
1762 OVERLAYFS_ETC_FSTYPE ?= "ext4"
1763
1764To control more mount options you should consider setting mount options
1765(``defaults`` is used by default)::
1766
1767 OVERLAYFS_ETC_MOUNT_OPTIONS = "wsync"
1768
1769The class provides two options for ``/sbin/init`` generation:
1770
1771- The default option is to rename the original ``/sbin/init`` to ``/sbin/init.orig``
1772 and place the generated init under original name, i.e. ``/sbin/init``. It has an advantage
1773 that you won't need to change any kernel parameters in order to make it work,
1774 but it poses a restriction that package-management can't be used, because updating
1775 the init manager would remove the generated script.
1776
1777- If you wish to keep original init as is, you can set::
1778
1779 OVERLAYFS_ETC_USE_ORIG_INIT_NAME = "0"
1780
1781 Then the generated init will be named ``/sbin/preinit`` and you would need to extend your
1782 kernel parameters manually in your bootloader configuration.
Andrew Geissler5199d832021-09-24 16:47:35 -05001783
Andrew Geisslerc9f78652020-09-18 14:11:35 -05001784.. _ref-classes-own-mirrors:
1785
1786``own-mirrors.bbclass``
1787=======================
1788
1789The ``own-mirrors`` class makes it easier to set up your own
1790:term:`PREMIRRORS` from which to first fetch source
1791before attempting to fetch it from the upstream specified in
1792:term:`SRC_URI` within each recipe.
1793
1794To use this class, inherit it globally and specify
Andrew Geisslerc926e172021-05-07 16:11:35 -05001795:term:`SOURCE_MIRROR_URL`. Here is an example::
Andrew Geisslerc9f78652020-09-18 14:11:35 -05001796
1797 INHERIT += "own-mirrors"
1798 SOURCE_MIRROR_URL = "http://example.com/my-source-mirror"
1799
1800You can specify only a single URL
Andrew Geissler09036742021-06-25 14:25:14 -05001801in :term:`SOURCE_MIRROR_URL`.
Andrew Geisslerc9f78652020-09-18 14:11:35 -05001802
1803.. _ref-classes-package:
1804
1805``package.bbclass``
1806===================
1807
1808The ``package`` class supports generating packages from a build's
1809output. The core generic functionality is in ``package.bbclass``. The
1810code specific to particular package types resides in these
1811package-specific classes:
1812:ref:`package_deb <ref-classes-package_deb>`,
1813:ref:`package_rpm <ref-classes-package_rpm>`,
1814:ref:`package_ipk <ref-classes-package_ipk>`, and
1815:ref:`package_tar <ref-classes-package_tar>`.
1816
1817.. note::
1818
1819 The
1820 package_tar
1821 class is broken and not supported. It is recommended that you do not
1822 use this class.
1823
1824You can control the list of resulting package formats by using the
Andrew Geissler09036742021-06-25 14:25:14 -05001825:term:`PACKAGE_CLASSES` variable defined in your ``conf/local.conf``
Andrew Geisslerc9f78652020-09-18 14:11:35 -05001826configuration file, which is located in the :term:`Build Directory`.
1827When defining the variable, you can
1828specify one or more package types. Since images are generated from
1829packages, a packaging class is needed to enable image generation. The
1830first class listed in this variable is used for image generation.
1831
1832If you take the optional step to set up a repository (package feed) on
1833the development host that can be used by DNF, you can install packages
1834from the feed while you are running the image on the target (i.e.
1835runtime installation of packages). For more information, see the
Andrew Geissler09209ee2020-12-13 08:44:15 -06001836":ref:`dev-manual/common-tasks:using runtime package management`"
Andrew Geisslerc9f78652020-09-18 14:11:35 -05001837section in the Yocto Project Development Tasks Manual.
1838
1839The package-specific class you choose can affect build-time performance
1840and has space ramifications. In general, building a package with IPK
1841takes about thirty percent less time as compared to using RPM to build
1842the same or similar package. This comparison takes into account a
1843complete build of the package with all dependencies previously built.
1844The reason for this discrepancy is because the RPM package manager
1845creates and processes more :term:`Metadata` than the IPK package
Andrew Geissler09036742021-06-25 14:25:14 -05001846manager. Consequently, you might consider setting :term:`PACKAGE_CLASSES` to
Andrew Geisslerc9f78652020-09-18 14:11:35 -05001847"package_ipk" if you are building smaller systems.
1848
1849Before making your package manager decision, however, you should
1850consider some further things about using RPM:
1851
1852- RPM starts to provide more abilities than IPK due to the fact that it
1853 processes more Metadata. For example, this information includes
1854 individual file types, file checksum generation and evaluation on
1855 install, sparse file support, conflict detection and resolution for
1856 Multilib systems, ACID style upgrade, and repackaging abilities for
1857 rollbacks.
1858
1859- For smaller systems, the extra space used for the Berkeley Database
1860 and the amount of metadata when using RPM can affect your ability to
1861 perform on-device upgrades.
1862
1863You can find additional information on the effects of the package class
1864at these two Yocto Project mailing list links:
1865
Andrew Geissler4c19ea12020-10-27 13:52:24 -05001866- :yocto_lists:`/pipermail/poky/2011-May/006362.html`
Andrew Geisslerc9f78652020-09-18 14:11:35 -05001867
Andrew Geissler4c19ea12020-10-27 13:52:24 -05001868- :yocto_lists:`/pipermail/poky/2011-May/006363.html`
Andrew Geisslerc9f78652020-09-18 14:11:35 -05001869
1870.. _ref-classes-package_deb:
1871
1872``package_deb.bbclass``
1873=======================
1874
1875The ``package_deb`` class provides support for creating packages that
1876use the Debian (i.e. ``.deb``) file format. The class ensures the
1877packages are written out in a ``.deb`` file format to the
1878``${``\ :term:`DEPLOY_DIR_DEB`\ ``}`` directory.
1879
1880This class inherits the :ref:`package <ref-classes-package>` class and
1881is enabled through the :term:`PACKAGE_CLASSES`
1882variable in the ``local.conf`` file.
1883
1884.. _ref-classes-package_ipk:
1885
1886``package_ipk.bbclass``
1887=======================
1888
1889The ``package_ipk`` class provides support for creating packages that
1890use the IPK (i.e. ``.ipk``) file format. The class ensures the packages
1891are written out in a ``.ipk`` file format to the
1892``${``\ :term:`DEPLOY_DIR_IPK`\ ``}`` directory.
1893
1894This class inherits the :ref:`package <ref-classes-package>` class and
1895is enabled through the :term:`PACKAGE_CLASSES`
1896variable in the ``local.conf`` file.
1897
1898.. _ref-classes-package_rpm:
1899
1900``package_rpm.bbclass``
1901=======================
1902
1903The ``package_rpm`` class provides support for creating packages that
1904use the RPM (i.e. ``.rpm``) file format. The class ensures the packages
1905are written out in a ``.rpm`` file format to the
1906``${``\ :term:`DEPLOY_DIR_RPM`\ ``}`` directory.
1907
1908This class inherits the :ref:`package <ref-classes-package>` class and
1909is enabled through the :term:`PACKAGE_CLASSES`
1910variable in the ``local.conf`` file.
1911
1912.. _ref-classes-package_tar:
1913
1914``package_tar.bbclass``
1915=======================
1916
1917The ``package_tar`` class provides support for creating tarballs. The
1918class ensures the packages are written out in a tarball format to the
1919``${``\ :term:`DEPLOY_DIR_TAR`\ ``}`` directory.
1920
1921This class inherits the :ref:`package <ref-classes-package>` class and
1922is enabled through the :term:`PACKAGE_CLASSES`
1923variable in the ``local.conf`` file.
1924
1925.. note::
1926
Andrew Geissler4c19ea12020-10-27 13:52:24 -05001927 You cannot specify the ``package_tar`` class first using the
Andrew Geissler09036742021-06-25 14:25:14 -05001928 :term:`PACKAGE_CLASSES` variable. You must use ``.deb``, ``.ipk``, or ``.rpm``
Andrew Geisslerc9f78652020-09-18 14:11:35 -05001929 file formats for your image or SDK.
1930
1931.. _ref-classes-packagedata:
1932
1933``packagedata.bbclass``
1934=======================
1935
1936The ``packagedata`` class provides common functionality for reading
1937``pkgdata`` files found in :term:`PKGDATA_DIR`. These
1938files contain information about each output package produced by the
1939OpenEmbedded build system.
1940
1941This class is enabled by default because it is inherited by the
1942:ref:`package <ref-classes-package>` class.
1943
1944.. _ref-classes-packagegroup:
1945
1946``packagegroup.bbclass``
1947========================
1948
1949The ``packagegroup`` class sets default values appropriate for package
Andrew Geissler09036742021-06-25 14:25:14 -05001950group recipes (e.g. :term:`PACKAGES`, :term:`PACKAGE_ARCH`, :term:`ALLOW_EMPTY`, and
Andrew Geisslerc9f78652020-09-18 14:11:35 -05001951so forth). It is highly recommended that all package group recipes
1952inherit this class.
1953
1954For information on how to use this class, see the
Andrew Geissler09209ee2020-12-13 08:44:15 -06001955":ref:`dev-manual/common-tasks:customizing images using custom package groups`"
Andrew Geisslerc9f78652020-09-18 14:11:35 -05001956section in the Yocto Project Development Tasks Manual.
1957
1958Previously, this class was called the ``task`` class.
1959
1960.. _ref-classes-patch:
1961
1962``patch.bbclass``
1963=================
1964
1965The ``patch`` class provides all functionality for applying patches
1966during the :ref:`ref-tasks-patch` task.
1967
1968This class is enabled by default because it is inherited by the
1969:ref:`base <ref-classes-base>` class.
1970
1971.. _ref-classes-perlnative:
1972
1973``perlnative.bbclass``
1974======================
1975
1976When inherited by a recipe, the ``perlnative`` class supports using the
1977native version of Perl built by the build system rather than using the
1978version provided by the build host.
1979
Patrick Williams45852732022-04-02 08:58:32 -05001980.. _ref-classes-python_flit_core:
1981
1982``python_flit_core.bbclass``
1983============================
1984
1985The ``python_flit_core`` class enables building Python modules which declare
1986the `PEP-517 <https://www.python.org/dev/peps/pep-0517/>`__ compliant
1987``flit_core.buildapi`` ``build-backend`` in the ``[build-system]``
1988section of ``pyproject.toml`` (See `PEP-518 <https://www.python.org/dev/peps/pep-0518/>`__).
1989
1990Python modules built with ``flit_core.buildapi`` are pure Python (no
1991``C`` or ``Rust`` extensions).
1992
1993Internally this uses the :ref:`python_pep517 <ref-classes-python_pep517>` class.
1994
Andrew Geissler9aee5002022-03-30 16:27:02 +00001995.. _ref-classes-python_pep517:
1996
1997``python_pep517.bbclass``
Patrick Williams45852732022-04-02 08:58:32 -05001998=========================
Andrew Geissler9aee5002022-03-30 16:27:02 +00001999
Patrick Williams45852732022-04-02 08:58:32 -05002000The ``python_pep517`` class builds and installs a Python ``wheel`` binary
2001archive (see `PEP-517 <https://peps.python.org/pep-0517/>`__).
Andrew Geissler9aee5002022-03-30 16:27:02 +00002002
Patrick Williams45852732022-04-02 08:58:32 -05002003Recipes wouldn't inherit this directly, instead typically another class will
Andrew Geissler615f2f12022-07-15 14:00:58 -05002004inherit this and add the relevant native dependencies.
Andrew Geissler9aee5002022-03-30 16:27:02 +00002005
Patrick Williams45852732022-04-02 08:58:32 -05002006Examples of classes which do this are :ref:`python_flit_core
2007<ref-classes-python_flit_core>`, :ref:`python_setuptools_build_meta
2008<ref-classes-python_setuptools_build_meta>`, and :ref:`python_poetry_core
2009<ref-classes-python_poetry_core>`.
2010
2011.. _ref-classes-python_poetry_core:
2012
2013``python_poetry_core.bbclass``
2014==============================
2015
2016The ``python_poetry_core`` class enables building Python modules which use the
2017`Poetry Core <https://python-poetry.org>`__ build system.
2018
2019Internally this uses the :ref:`python_pep517 <ref-classes-python_pep517>` class.
Andrew Geissler9aee5002022-03-30 16:27:02 +00002020
Andrew Geisslerc9f78652020-09-18 14:11:35 -05002021.. _ref-classes-pixbufcache:
2022
2023``pixbufcache.bbclass``
2024=======================
2025
2026The ``pixbufcache`` class generates the proper post-install and
2027post-remove (postinst/postrm) scriptlets for packages that install
2028pixbuf loaders, which are used with ``gdk-pixbuf``. These scriptlets
2029call ``update_pixbuf_cache`` to add the pixbuf loaders to the cache.
2030Since the cache files are architecture-specific, ``update_pixbuf_cache``
2031is run using QEMU if the postinst scriptlets need to be run on the build
2032host during image creation.
2033
2034If the pixbuf loaders being installed are in packages other than the
2035recipe's main package, set
2036:term:`PIXBUF_PACKAGES` to specify the packages
2037containing the loaders.
2038
2039.. _ref-classes-pkgconfig:
2040
2041``pkgconfig.bbclass``
2042=====================
2043
2044The ``pkgconfig`` class provides a standard way to get header and
2045library information by using ``pkg-config``. This class aims to smooth
2046integration of ``pkg-config`` into libraries that use it.
2047
2048During staging, BitBake installs ``pkg-config`` data into the
2049``sysroots/`` directory. By making use of sysroot functionality within
2050``pkg-config``, the ``pkgconfig`` class no longer has to manipulate the
2051files.
2052
2053.. _ref-classes-populate-sdk:
2054
2055``populate_sdk.bbclass``
2056========================
2057
2058The ``populate_sdk`` class provides support for SDK-only recipes. For
2059information on advantages gained when building a cross-development
2060toolchain using the :ref:`ref-tasks-populate_sdk`
Andrew Geissler09209ee2020-12-13 08:44:15 -06002061task, see the ":ref:`sdk-manual/appendix-obtain:building an sdk installer`"
Andrew Geisslerc9f78652020-09-18 14:11:35 -05002062section in the Yocto Project Application Development and the Extensible
2063Software Development Kit (eSDK) manual.
2064
2065.. _ref-classes-populate-sdk-*:
2066
2067``populate_sdk_*.bbclass``
2068==========================
2069
2070The ``populate_sdk_*`` classes support SDK creation and consist of the
2071following classes:
2072
2073- ``populate_sdk_base``: The base class supporting SDK creation under
2074 all package managers (i.e. DEB, RPM, and opkg).
2075
2076- ``populate_sdk_deb``: Supports creation of the SDK given the Debian
2077 package manager.
2078
2079- ``populate_sdk_rpm``: Supports creation of the SDK given the RPM
2080 package manager.
2081
2082- ``populate_sdk_ipk``: Supports creation of the SDK given the opkg
2083 (IPK format) package manager.
2084
2085- ``populate_sdk_ext``: Supports extensible SDK creation under all
2086 package managers.
2087
2088The ``populate_sdk_base`` class inherits the appropriate
2089``populate_sdk_*`` (i.e. ``deb``, ``rpm``, and ``ipk``) based on
2090:term:`IMAGE_PKGTYPE`.
2091
2092The base class ensures all source and destination directories are
2093established and then populates the SDK. After populating the SDK, the
2094``populate_sdk_base`` class constructs two sysroots:
2095``${``\ :term:`SDK_ARCH`\ ``}-nativesdk``, which
2096contains the cross-compiler and associated tooling, and the target,
2097which contains a target root filesystem that is configured for the SDK
2098usage. These two images reside in :term:`SDK_OUTPUT`,
Andrew Geisslerc926e172021-05-07 16:11:35 -05002099which consists of the following::
Andrew Geisslerc9f78652020-09-18 14:11:35 -05002100
2101 ${SDK_OUTPUT}/${SDK_ARCH}-nativesdk-pkgs
2102 ${SDK_OUTPUT}/${SDKTARGETSYSROOT}/target-pkgs
2103
2104Finally, the base populate SDK class creates the toolchain environment
2105setup script, the tarball of the SDK, and the installer.
2106
2107The respective ``populate_sdk_deb``, ``populate_sdk_rpm``, and
2108``populate_sdk_ipk`` classes each support the specific type of SDK.
2109These classes are inherited by and used with the ``populate_sdk_base``
2110class.
2111
2112For more information on the cross-development toolchain generation, see
Andrew Geissler09209ee2020-12-13 08:44:15 -06002113the ":ref:`overview-manual/concepts:cross-development toolchain generation`"
Andrew Geisslerc9f78652020-09-18 14:11:35 -05002114section in the Yocto Project Overview and Concepts Manual. For
2115information on advantages gained when building a cross-development
2116toolchain using the :ref:`ref-tasks-populate_sdk`
2117task, see the
Andrew Geissler09209ee2020-12-13 08:44:15 -06002118":ref:`sdk-manual/appendix-obtain:building an sdk installer`"
Andrew Geisslerc9f78652020-09-18 14:11:35 -05002119section in the Yocto Project Application Development and the Extensible
2120Software Development Kit (eSDK) manual.
2121
2122.. _ref-classes-prexport:
2123
2124``prexport.bbclass``
2125====================
2126
2127The ``prexport`` class provides functionality for exporting
2128:term:`PR` values.
2129
2130.. note::
2131
2132 This class is not intended to be used directly. Rather, it is enabled
Andrew Geissler4c19ea12020-10-27 13:52:24 -05002133 when using "``bitbake-prserv-tool export``".
Andrew Geisslerc9f78652020-09-18 14:11:35 -05002134
2135.. _ref-classes-primport:
2136
2137``primport.bbclass``
2138====================
2139
2140The ``primport`` class provides functionality for importing
2141:term:`PR` values.
2142
2143.. note::
2144
2145 This class is not intended to be used directly. Rather, it is enabled
Andrew Geissler4c19ea12020-10-27 13:52:24 -05002146 when using "``bitbake-prserv-tool import``".
Andrew Geisslerc9f78652020-09-18 14:11:35 -05002147
2148.. _ref-classes-prserv:
2149
2150``prserv.bbclass``
2151==================
2152
2153The ``prserv`` class provides functionality for using a :ref:`PR
Andrew Geissler09209ee2020-12-13 08:44:15 -06002154service <dev-manual/common-tasks:working with a pr service>` in order to
Andrew Geisslerc9f78652020-09-18 14:11:35 -05002155automatically manage the incrementing of the :term:`PR`
2156variable for each recipe.
2157
2158This class is enabled by default because it is inherited by the
2159:ref:`package <ref-classes-package>` class. However, the OpenEmbedded
2160build system will not enable the functionality of this class unless
2161:term:`PRSERV_HOST` has been set.
2162
2163.. _ref-classes-ptest:
2164
2165``ptest.bbclass``
2166=================
2167
2168The ``ptest`` class provides functionality for packaging and installing
2169runtime tests for recipes that build software that provides these tests.
2170
2171This class is intended to be inherited by individual recipes. However,
2172the class' functionality is largely disabled unless "ptest" appears in
2173:term:`DISTRO_FEATURES`. See the
Andrew Geissler09209ee2020-12-13 08:44:15 -06002174":ref:`dev-manual/common-tasks:testing packages with ptest`"
Andrew Geisslerc9f78652020-09-18 14:11:35 -05002175section in the Yocto Project Development Tasks Manual for more information
2176on ptest.
2177
2178.. _ref-classes-ptest-gnome:
2179
2180``ptest-gnome.bbclass``
2181=======================
2182
2183Enables package tests (ptests) specifically for GNOME packages, which
2184have tests intended to be executed with ``gnome-desktop-testing``.
2185
2186For information on setting up and running ptests, see the
Andrew Geissler09209ee2020-12-13 08:44:15 -06002187":ref:`dev-manual/common-tasks:testing packages with ptest`"
Andrew Geisslerc9f78652020-09-18 14:11:35 -05002188section in the Yocto Project Development Tasks Manual.
2189
Andrew Geissler3b8a17c2021-04-15 15:55:55 -05002190.. _ref-classes-python3-dir:
Andrew Geisslerc9f78652020-09-18 14:11:35 -05002191
Andrew Geissler3b8a17c2021-04-15 15:55:55 -05002192``python3-dir.bbclass``
2193=======================
Andrew Geisslerc9f78652020-09-18 14:11:35 -05002194
Andrew Geissler3b8a17c2021-04-15 15:55:55 -05002195The ``python3-dir`` class provides the base version, location, and site
2196package location for Python 3.
Andrew Geisslerc9f78652020-09-18 14:11:35 -05002197
2198.. _ref-classes-python3native:
2199
2200``python3native.bbclass``
2201=========================
2202
2203The ``python3native`` class supports using the native version of Python
22043 built by the build system rather than support of the version provided
2205by the build host.
2206
Andrew Geissler3b8a17c2021-04-15 15:55:55 -05002207.. _ref-classes-python3targetconfig:
Andrew Geisslerc9f78652020-09-18 14:11:35 -05002208
Andrew Geissler3b8a17c2021-04-15 15:55:55 -05002209``python3targetconfig.bbclass``
2210===============================
Andrew Geisslerc9f78652020-09-18 14:11:35 -05002211
Andrew Geissler3b8a17c2021-04-15 15:55:55 -05002212The ``python3targetconfig`` class supports using the native version of Python
22133 built by the build system rather than support of the version provided
2214by the build host, except that the configuration for the target machine
2215is accessible (such as correct installation directories). This also adds a
2216dependency on target ``python3``, so should only be used where appropriate
2217in order to avoid unnecessarily lengthening builds.
Andrew Geisslerc9f78652020-09-18 14:11:35 -05002218
2219.. _ref-classes-qemu:
2220
2221``qemu.bbclass``
2222================
2223
2224The ``qemu`` class provides functionality for recipes that either need
2225QEMU or test for the existence of QEMU. Typically, this class is used to
2226run programs for a target system on the build host using QEMU's
2227application emulation mode.
2228
2229.. _ref-classes-recipe_sanity:
2230
2231``recipe_sanity.bbclass``
2232=========================
2233
2234The ``recipe_sanity`` class checks for the presence of any host system
2235recipe prerequisites that might affect the build (e.g. variables that
2236are set or software that is present).
2237
2238.. _ref-classes-relocatable:
2239
2240``relocatable.bbclass``
2241=======================
2242
2243The ``relocatable`` class enables relocation of binaries when they are
2244installed into the sysroot.
2245
2246This class makes use of the :ref:`chrpath <ref-classes-chrpath>` class
2247and is used by both the :ref:`cross <ref-classes-cross>` and
2248:ref:`native <ref-classes-native>` classes.
2249
2250.. _ref-classes-remove-libtool:
2251
2252``remove-libtool.bbclass``
2253==========================
2254
2255The ``remove-libtool`` class adds a post function to the
2256:ref:`ref-tasks-install` task to remove all ``.la`` files
2257installed by ``libtool``. Removing these files results in them being
2258absent from both the sysroot and target packages.
2259
2260If a recipe needs the ``.la`` files to be installed, then the recipe can
Andrew Geisslerc926e172021-05-07 16:11:35 -05002261override the removal by setting ``REMOVE_LIBTOOL_LA`` to "0" as follows::
Andrew Geisslerc9f78652020-09-18 14:11:35 -05002262
2263 REMOVE_LIBTOOL_LA = "0"
2264
2265.. note::
2266
Andrew Geissler4c19ea12020-10-27 13:52:24 -05002267 The ``remove-libtool`` class is not enabled by default.
Andrew Geisslerc9f78652020-09-18 14:11:35 -05002268
2269.. _ref-classes-report-error:
2270
2271``report-error.bbclass``
2272========================
2273
2274The ``report-error`` class supports enabling the :ref:`error reporting
Andrew Geissler09209ee2020-12-13 08:44:15 -06002275tool <dev-manual/common-tasks:using the error reporting tool>`",
Andrew Geisslerc9f78652020-09-18 14:11:35 -05002276which allows you to submit build error information to a central database.
2277
2278The class collects debug information for recipe, recipe version, task,
2279machine, distro, build system, target system, host distro, branch,
2280commit, and log. From the information, report files using a JSON format
2281are created and stored in
2282``${``\ :term:`LOG_DIR`\ ``}/error-report``.
2283
2284.. _ref-classes-rm-work:
2285
2286``rm_work.bbclass``
2287===================
2288
2289The ``rm_work`` class supports deletion of temporary workspace, which
2290can ease your hard drive demands during builds.
2291
2292The OpenEmbedded build system can use a substantial amount of disk space
2293during the build process. A portion of this space is the work files
2294under the ``${TMPDIR}/work`` directory for each recipe. Once the build
2295system generates the packages for a recipe, the work files for that
2296recipe are no longer needed. However, by default, the build system
2297preserves these files for inspection and possible debugging purposes. If
2298you would rather have these files deleted to save disk space as the
2299build progresses, you can enable ``rm_work`` by adding the following to
2300your ``local.conf`` file, which is found in the :term:`Build Directory`.
2301::
2302
2303 INHERIT += "rm_work"
2304
2305If you are
2306modifying and building source code out of the work directory for a
2307recipe, enabling ``rm_work`` will potentially result in your changes to
2308the source being lost. To exclude some recipes from having their work
2309directories deleted by ``rm_work``, you can add the names of the recipe
Andrew Geissler09036742021-06-25 14:25:14 -05002310or recipes you are working on to the :term:`RM_WORK_EXCLUDE` variable, which
Andrew Geisslerc926e172021-05-07 16:11:35 -05002311can also be set in your ``local.conf`` file. Here is an example::
Andrew Geisslerc9f78652020-09-18 14:11:35 -05002312
2313 RM_WORK_EXCLUDE += "busybox glibc"
2314
2315.. _ref-classes-rootfs*:
2316
2317``rootfs*.bbclass``
2318===================
2319
2320The ``rootfs*`` classes support creating the root filesystem for an
2321image and consist of the following classes:
2322
2323- The ``rootfs-postcommands`` class, which defines filesystem
2324 post-processing functions for image recipes.
2325
2326- The ``rootfs_deb`` class, which supports creation of root filesystems
2327 for images built using ``.deb`` packages.
2328
2329- The ``rootfs_rpm`` class, which supports creation of root filesystems
2330 for images built using ``.rpm`` packages.
2331
2332- The ``rootfs_ipk`` class, which supports creation of root filesystems
2333 for images built using ``.ipk`` packages.
2334
2335- The ``rootfsdebugfiles`` class, which installs additional files found
2336 on the build host directly into the root filesystem.
2337
2338The root filesystem is created from packages using one of the
2339``rootfs*.bbclass`` files as determined by the
2340:term:`PACKAGE_CLASSES` variable.
2341
2342For information on how root filesystem images are created, see the
Andrew Geissler09209ee2020-12-13 08:44:15 -06002343":ref:`overview-manual/concepts:image generation`"
Andrew Geisslerc9f78652020-09-18 14:11:35 -05002344section in the Yocto Project Overview and Concepts Manual.
2345
2346.. _ref-classes-sanity:
2347
2348``sanity.bbclass``
2349==================
2350
2351The ``sanity`` class checks to see if prerequisite software is present
2352on the host system so that users can be notified of potential problems
2353that might affect their build. The class also performs basic user
2354configuration checks from the ``local.conf`` configuration file to
2355prevent common mistakes that cause build failures. Distribution policy
2356usually determines whether to include this class.
2357
2358.. _ref-classes-scons:
2359
2360``scons.bbclass``
2361=================
2362
2363The ``scons`` class supports recipes that need to build software that
2364uses the SCons build system. You can use the
2365:term:`EXTRA_OESCONS` variable to specify
2366additional configuration options you want to pass SCons command line.
2367
2368.. _ref-classes-sdl:
2369
2370``sdl.bbclass``
2371===============
2372
2373The ``sdl`` class supports recipes that need to build software that uses
2374the Simple DirectMedia Layer (SDL) library.
2375
Patrick Williams45852732022-04-02 08:58:32 -05002376.. _ref-classes-python_setuptools_build_meta:
Andrew Geissler9aee5002022-03-30 16:27:02 +00002377
Patrick Williams45852732022-04-02 08:58:32 -05002378``python_setuptools_build_meta.bbclass``
2379========================================
Andrew Geissler9aee5002022-03-30 16:27:02 +00002380
Patrick Williams45852732022-04-02 08:58:32 -05002381The ``python_setuptools_build_meta`` class enables building Python modules which
Andrew Geissler9aee5002022-03-30 16:27:02 +00002382declare the
2383`PEP-517 <https://www.python.org/dev/peps/pep-0517/>`__ compliant
2384``setuptools.build_meta`` ``build-backend`` in the ``[build-system]``
2385section of ``pyproject.toml`` (See `PEP-518 <https://www.python.org/dev/peps/pep-0518/>`__).
2386
2387Python modules built with ``setuptools.build_meta`` can be pure Python or
2388include ``C`` or ``Rust`` extensions).
2389
Patrick Williams45852732022-04-02 08:58:32 -05002390Internally this uses the :ref:`python_pep517 <ref-classes-python_pep517>` class.
Andrew Geissler9aee5002022-03-30 16:27:02 +00002391
Andrew Geisslerc9f78652020-09-18 14:11:35 -05002392.. _ref-classes-setuptools3:
2393
2394``setuptools3.bbclass``
2395=======================
2396
2397The ``setuptools3`` class supports Python version 3.x extensions that
Andrew Geissler9aee5002022-03-30 16:27:02 +00002398use build systems based on ``setuptools`` (e.g. only have a ``setup.py`` and
2399have not migrated to the official ``pyproject.toml`` format). If your recipe
2400uses these build systems, the recipe needs to inherit the ``setuptools3`` class.
2401
2402 .. note::
2403
Patrick Williams2194f502022-10-16 14:26:09 -05002404 The ``setuptools3`` class :ref:`ref-tasks-compile` task now calls
Andrew Geissler9aee5002022-03-30 16:27:02 +00002405 ``setup.py bdist_wheel`` to build the ``wheel`` binary archive format
2406 (See `PEP-427 <https://www.python.org/dev/peps/pep-0427/>`__).
2407
2408 A consequence of this is that legacy software still using deprecated
2409 ``distutils`` from the Python standard library cannot be packaged as
2410 ``wheels``. A common solution is the replace
2411 ``from distutils.core import setup`` with ``from setuptools import setup``.
2412
2413 .. note::
2414
Patrick Williams2194f502022-10-16 14:26:09 -05002415 The ``setuptools3`` class :ref:`ref-tasks-install` task now installs the ``wheel``
Andrew Geissler9aee5002022-03-30 16:27:02 +00002416 binary archive. In current versions of ``setuptools`` the legacy ``setup.py
2417 install`` method is deprecated. If the ``setup.py`` cannot be used with
2418 wheels, for example it creates files outside of the Python module or
2419 standard entry points, then :ref:`setuptools3_legacy
2420 <ref-classes-setuptools3_legacy>` should be used.
2421
2422.. _ref-classes-setuptools3_legacy:
2423
2424``setuptools3_legacy.bbclass``
2425==============================
2426
2427The ``setuptools3_legacy`` class supports Python version 3.x extensions that use
2428build systems based on ``setuptools`` (e.g. only have a ``setup.py`` and have
2429not migrated to the official ``pyproject.toml`` format). Unlike
2430``setuptools3.bbclass``, this uses the traditional ``setup.py`` ``build`` and
2431``install`` commands and not wheels. This use of ``setuptools`` like this is
2432`deprecated <https://github.com/pypa/setuptools/blob/main/CHANGES.rst#v5830>`_
2433but still relatively common.
Andrew Geisslerc9f78652020-09-18 14:11:35 -05002434
Andrew Geissler595f6302022-01-24 19:11:47 +00002435.. _ref-classes-setuptools3-base:
2436
2437``setuptools3-base.bbclass``
2438============================
2439
2440The ``setuptools3-base`` class provides a reusable base for other classes
2441that support building Python version 3.x extensions. If you need
2442functionality that is not provided by the :ref:`setuptools3 <ref-classes-setuptools3>` class, you may
2443want to ``inherit setuptools3-base``. Some recipes do not need the tasks
2444in the :ref:`setuptools3 <ref-classes-setuptools3>` class and inherit this class instead.
2445
Andrew Geisslerc9f78652020-09-18 14:11:35 -05002446.. _ref-classes-sign_rpm:
2447
2448``sign_rpm.bbclass``
2449====================
2450
2451The ``sign_rpm`` class supports generating signed RPM packages.
2452
2453.. _ref-classes-sip:
2454
2455``sip.bbclass``
2456===============
2457
2458The ``sip`` class supports recipes that build or package SIP-based
2459Python bindings.
2460
2461.. _ref-classes-siteconfig:
2462
2463``siteconfig.bbclass``
2464======================
2465
2466The ``siteconfig`` class provides functionality for handling site
2467configuration. The class is used by the
2468:ref:`autotools <ref-classes-autotools>` class to accelerate the
2469:ref:`ref-tasks-configure` task.
2470
2471.. _ref-classes-siteinfo:
2472
2473``siteinfo.bbclass``
2474====================
2475
2476The ``siteinfo`` class provides information about the targets that might
2477be needed by other classes or recipes.
2478
2479As an example, consider Autotools, which can require tests that must
2480execute on the target hardware. Since this is not possible in general
2481when cross compiling, site information is used to provide cached test
2482results so these tests can be skipped over but still make the correct
2483values available. The ``meta/site directory`` contains test results
2484sorted into different categories such as architecture, endianness, and
2485the ``libc`` used. Site information provides a list of files containing
Andrew Geissler09036742021-06-25 14:25:14 -05002486data relevant to the current build in the :term:`CONFIG_SITE` variable that
Andrew Geisslerc9f78652020-09-18 14:11:35 -05002487Autotools automatically picks up.
2488
Andrew Geissler09036742021-06-25 14:25:14 -05002489The class also provides variables like :term:`SITEINFO_ENDIANNESS` and
2490:term:`SITEINFO_BITS` that can be used elsewhere in the metadata.
Andrew Geisslerc9f78652020-09-18 14:11:35 -05002491
Andrew Geisslerc9f78652020-09-18 14:11:35 -05002492.. _ref-classes-sstate:
2493
2494``sstate.bbclass``
2495==================
2496
2497The ``sstate`` class provides support for Shared State (sstate). By
2498default, the class is enabled through the
2499:term:`INHERIT_DISTRO` variable's default value.
2500
2501For more information on sstate, see the
Andrew Geissler09209ee2020-12-13 08:44:15 -06002502":ref:`overview-manual/concepts:shared state cache`"
Andrew Geisslerc9f78652020-09-18 14:11:35 -05002503section in the Yocto Project Overview and Concepts Manual.
2504
2505.. _ref-classes-staging:
2506
2507``staging.bbclass``
2508===================
2509
2510The ``staging`` class installs files into individual recipe work
2511directories for sysroots. The class contains the following key tasks:
2512
2513- The :ref:`ref-tasks-populate_sysroot` task,
2514 which is responsible for handing the files that end up in the recipe
2515 sysroots.
2516
2517- The
2518 :ref:`ref-tasks-prepare_recipe_sysroot`
2519 task (a "partner" task to the ``populate_sysroot`` task), which
2520 installs the files into the individual recipe work directories (i.e.
2521 :term:`WORKDIR`).
2522
2523The code in the ``staging`` class is complex and basically works in two
2524stages:
2525
2526- *Stage One:* The first stage addresses recipes that have files they
2527 want to share with other recipes that have dependencies on the
2528 originating recipe. Normally these dependencies are installed through
2529 the :ref:`ref-tasks-install` task into
Patrick Williams2194f502022-10-16 14:26:09 -05002530 ``${``\ :term:`D`\ ``}``. The :ref:`ref-tasks-populate_sysroot` task
Andrew Geisslerc9f78652020-09-18 14:11:35 -05002531 copies a subset of these files into ``${SYSROOT_DESTDIR}``. This
2532 subset of files is controlled by the
2533 :term:`SYSROOT_DIRS`,
2534 :term:`SYSROOT_DIRS_NATIVE`, and
Andrew Geissler9aee5002022-03-30 16:27:02 +00002535 :term:`SYSROOT_DIRS_IGNORE`
Andrew Geisslerc9f78652020-09-18 14:11:35 -05002536 variables.
2537
2538 .. note::
2539
2540 Additionally, a recipe can customize the files further by
Andrew Geissler09036742021-06-25 14:25:14 -05002541 declaring a processing function in the :term:`SYSROOT_PREPROCESS_FUNCS`
Andrew Geisslerc9f78652020-09-18 14:11:35 -05002542 variable.
2543
2544 A shared state (sstate) object is built from these files and the
2545 files are placed into a subdirectory of
Andrew Geissler4c19ea12020-10-27 13:52:24 -05002546 :ref:`structure-build-tmp-sysroots-components`.
Andrew Geisslerc9f78652020-09-18 14:11:35 -05002547 The files are scanned for hardcoded paths to the original
2548 installation location. If the location is found in text files, the
2549 hardcoded locations are replaced by tokens and a list of the files
2550 needing such replacements is created. These adjustments are referred
2551 to as "FIXMEs". The list of files that are scanned for paths is
2552 controlled by the :term:`SSTATE_SCAN_FILES`
2553 variable.
2554
2555- *Stage Two:* The second stage addresses recipes that want to use
2556 something from another recipe and declare a dependency on that recipe
2557 through the :term:`DEPENDS` variable. The recipe will
2558 have a
2559 :ref:`ref-tasks-prepare_recipe_sysroot`
2560 task and when this task executes, it creates the ``recipe-sysroot``
2561 and ``recipe-sysroot-native`` in the recipe work directory (i.e.
2562 :term:`WORKDIR`). The OpenEmbedded build system
2563 creates hard links to copies of the relevant files from
2564 ``sysroots-components`` into the recipe work directory.
2565
2566 .. note::
2567
2568 If hard links are not possible, the build system uses actual
2569 copies.
2570
2571 The build system then addresses any "FIXMEs" to paths as defined from
2572 the list created in the first stage.
2573
2574 Finally, any files in ``${bindir}`` within the sysroot that have the
2575 prefix "``postinst-``" are executed.
2576
2577 .. note::
2578
2579 Although such sysroot post installation scripts are not
2580 recommended for general use, the files do allow some issues such
2581 as user creation and module indexes to be addressed.
2582
Andrew Geissler09036742021-06-25 14:25:14 -05002583 Because recipes can have other dependencies outside of :term:`DEPENDS`
Andrew Geisslerc9f78652020-09-18 14:11:35 -05002584 (e.g. ``do_unpack[depends] += "tar-native:do_populate_sysroot"``),
2585 the sysroot creation function ``extend_recipe_sysroot`` is also added
2586 as a pre-function for those tasks whose dependencies are not through
Andrew Geissler09036742021-06-25 14:25:14 -05002587 :term:`DEPENDS` but operate similarly.
Andrew Geisslerc9f78652020-09-18 14:11:35 -05002588
2589 When installing dependencies into the sysroot, the code traverses the
2590 dependency graph and processes dependencies in exactly the same way
2591 as the dependencies would or would not be when installed from sstate.
2592 This processing means, for example, a native tool would have its
2593 native dependencies added but a target library would not have its
2594 dependencies traversed or installed. The same sstate dependency code
2595 is used so that builds should be identical regardless of whether
2596 sstate was used or not. For a closer look, see the
2597 ``setscene_depvalid()`` function in the
2598 :ref:`sstate <ref-classes-sstate>` class.
2599
2600 The build system is careful to maintain manifests of the files it
2601 installs so that any given dependency can be installed as needed. The
2602 sstate hash of the installed item is also stored so that if it
2603 changes, the build system can reinstall it.
2604
2605.. _ref-classes-syslinux:
2606
2607``syslinux.bbclass``
2608====================
2609
2610The ``syslinux`` class provides syslinux-specific functions for building
2611bootable images.
2612
2613The class supports the following variables:
2614
2615- :term:`INITRD`: Indicates list of filesystem images to
2616 concatenate and use as an initial RAM disk (initrd). This variable is
2617 optional.
2618
2619- :term:`ROOTFS`: Indicates a filesystem image to include
2620 as the root filesystem. This variable is optional.
2621
2622- :term:`AUTO_SYSLINUXMENU`: Enables creating
2623 an automatic menu when set to "1".
2624
2625- :term:`LABELS`: Lists targets for automatic
2626 configuration.
2627
2628- :term:`APPEND`: Lists append string overrides for each
2629 label.
2630
2631- :term:`SYSLINUX_OPTS`: Lists additional options
2632 to add to the syslinux file. Semicolon characters separate multiple
2633 options.
2634
2635- :term:`SYSLINUX_SPLASH`: Lists a background
2636 for the VGA boot menu when you are using the boot menu.
2637
2638- :term:`SYSLINUX_DEFAULT_CONSOLE`: Set
2639 to "console=ttyX" to change kernel boot default console.
2640
2641- :term:`SYSLINUX_SERIAL`: Sets an alternate
2642 serial port. Or, turns off serial when the variable is set with an
2643 empty string.
2644
2645- :term:`SYSLINUX_SERIAL_TTY`: Sets an
2646 alternate "console=tty..." kernel boot argument.
2647
2648.. _ref-classes-systemd:
2649
2650``systemd.bbclass``
2651===================
2652
2653The ``systemd`` class provides support for recipes that install systemd
2654unit files.
2655
2656The functionality for this class is disabled unless you have "systemd"
2657in :term:`DISTRO_FEATURES`.
2658
2659Under this class, the recipe or Makefile (i.e. whatever the recipe is
2660calling during the :ref:`ref-tasks-install` task)
2661installs unit files into
2662``${``\ :term:`D`\ ``}${systemd_unitdir}/system``. If the unit
2663files being installed go into packages other than the main package, you
2664need to set :term:`SYSTEMD_PACKAGES` in your
2665recipe to identify the packages in which the files will be installed.
2666
2667You should set :term:`SYSTEMD_SERVICE` to the
2668name of the service file. You should also use a package name override to
2669indicate the package to which the value applies. If the value applies to
2670the recipe's main package, use ``${``\ :term:`PN`\ ``}``. Here
Andrew Geisslerc926e172021-05-07 16:11:35 -05002671is an example from the connman recipe::
Andrew Geisslerc9f78652020-09-18 14:11:35 -05002672
Patrick Williams0ca19cc2021-08-16 14:03:13 -05002673 SYSTEMD_SERVICE:${PN} = "connman.service"
Andrew Geisslerc9f78652020-09-18 14:11:35 -05002674
2675Services are set up to start on boot automatically
2676unless you have set
2677:term:`SYSTEMD_AUTO_ENABLE` to "disable".
2678
2679For more information on ``systemd``, see the
Andrew Geissler09209ee2020-12-13 08:44:15 -06002680":ref:`dev-manual/common-tasks:selecting an initialization manager`"
Andrew Geisslerc9f78652020-09-18 14:11:35 -05002681section in the Yocto Project Development Tasks Manual.
2682
2683.. _ref-classes-systemd-boot:
2684
2685``systemd-boot.bbclass``
2686========================
2687
2688The ``systemd-boot`` class provides functions specific to the
2689systemd-boot bootloader for building bootable images. This is an
2690internal class and is not intended to be used directly.
2691
2692.. note::
2693
Andrew Geissler4c19ea12020-10-27 13:52:24 -05002694 The ``systemd-boot`` class is a result from merging the ``gummiboot`` class
2695 used in previous Yocto Project releases with the ``systemd`` project.
Andrew Geisslerc9f78652020-09-18 14:11:35 -05002696
2697Set the :term:`EFI_PROVIDER` variable to
2698"systemd-boot" to use this class. Doing so creates a standalone EFI
2699bootloader that is not dependent on systemd.
2700
2701For information on more variables used and supported in this class, see
2702the :term:`SYSTEMD_BOOT_CFG`,
2703:term:`SYSTEMD_BOOT_ENTRIES`, and
2704:term:`SYSTEMD_BOOT_TIMEOUT` variables.
2705
2706You can also see the `Systemd-boot
Andrew Geisslerd1e89492021-02-12 15:35:20 -06002707documentation <https://www.freedesktop.org/wiki/Software/systemd/systemd-boot/>`__
Andrew Geisslerc9f78652020-09-18 14:11:35 -05002708for more information.
2709
2710.. _ref-classes-terminal:
2711
2712``terminal.bbclass``
2713====================
2714
2715The ``terminal`` class provides support for starting a terminal session.
2716The :term:`OE_TERMINAL` variable controls which
2717terminal emulator is used for the session.
2718
2719Other classes use the ``terminal`` class anywhere a separate terminal
2720session needs to be started. For example, the
2721:ref:`patch <ref-classes-patch>` class assuming
2722:term:`PATCHRESOLVE` is set to "user", the
2723:ref:`cml1 <ref-classes-cml1>` class, and the
2724:ref:`devshell <ref-classes-devshell>` class all use the ``terminal``
2725class.
2726
2727.. _ref-classes-testimage*:
2728
2729``testimage*.bbclass``
2730======================
2731
2732The ``testimage*`` classes support running automated tests against
2733images using QEMU and on actual hardware. The classes handle loading the
2734tests and starting the image. To use the classes, you need to perform
2735steps to set up the environment.
2736
2737.. note::
2738
Andrew Geissler4c19ea12020-10-27 13:52:24 -05002739 Best practices include using :term:`IMAGE_CLASSES` rather than
2740 :term:`INHERIT` to inherit the ``testimage`` class for automated image
2741 testing.
Andrew Geisslerc9f78652020-09-18 14:11:35 -05002742
2743The tests are commands that run on the target system over ``ssh``. Each
2744test is written in Python and makes use of the ``unittest`` module.
2745
2746The ``testimage.bbclass`` runs tests on an image when called using the
Andrew Geisslerc926e172021-05-07 16:11:35 -05002747following::
Andrew Geisslerc9f78652020-09-18 14:11:35 -05002748
2749 $ bitbake -c testimage image
2750
2751The ``testimage-auto`` class
2752runs tests on an image after the image is constructed (i.e.
2753:term:`TESTIMAGE_AUTO` must be set to "1").
2754
2755For information on how to enable, run, and create new tests, see the
Andrew Geissler09209ee2020-12-13 08:44:15 -06002756":ref:`dev-manual/common-tasks:performing automated runtime testing`"
Andrew Geisslerc9f78652020-09-18 14:11:35 -05002757section in the Yocto Project Development Tasks Manual.
2758
2759.. _ref-classes-testsdk:
2760
2761``testsdk.bbclass``
2762===================
2763
2764This class supports running automated tests against software development
2765kits (SDKs). The ``testsdk`` class runs tests on an SDK when called
Andrew Geisslerc926e172021-05-07 16:11:35 -05002766using the following::
Andrew Geisslerc9f78652020-09-18 14:11:35 -05002767
2768 $ bitbake -c testsdk image
2769
2770.. note::
2771
Andrew Geissler4c19ea12020-10-27 13:52:24 -05002772 Best practices include using :term:`IMAGE_CLASSES` rather than
2773 :term:`INHERIT` to inherit the ``testsdk`` class for automated SDK
2774 testing.
Andrew Geisslerc9f78652020-09-18 14:11:35 -05002775
2776.. _ref-classes-texinfo:
2777
2778``texinfo.bbclass``
2779===================
2780
2781This class should be inherited by recipes whose upstream packages invoke
2782the ``texinfo`` utilities at build-time. Native and cross recipes are
2783made to use the dummy scripts provided by ``texinfo-dummy-native``, for
2784improved performance. Target architecture recipes use the genuine
2785Texinfo utilities. By default, they use the Texinfo utilities on the
2786host system.
2787
2788.. note::
2789
2790 If you want to use the Texinfo recipe shipped with the build system,
Andrew Geissler4c19ea12020-10-27 13:52:24 -05002791 you can remove "texinfo-native" from :term:`ASSUME_PROVIDED` and makeinfo
2792 from :term:`SANITY_REQUIRED_UTILITIES`.
Andrew Geisslerc9f78652020-09-18 14:11:35 -05002793
2794.. _ref-classes-toaster:
2795
2796``toaster.bbclass``
2797===================
2798
2799The ``toaster`` class collects information about packages and images and
2800sends them as events that the BitBake user interface can receive. The
2801class is enabled when the Toaster user interface is running.
2802
2803This class is not intended to be used directly.
2804
2805.. _ref-classes-toolchain-scripts:
2806
2807``toolchain-scripts.bbclass``
2808=============================
2809
2810The ``toolchain-scripts`` class provides the scripts used for setting up
2811the environment for installed SDKs.
2812
2813.. _ref-classes-typecheck:
2814
2815``typecheck.bbclass``
2816=====================
2817
2818The ``typecheck`` class provides support for validating the values of
2819variables set at the configuration level against their defined types.
2820The OpenEmbedded build system allows you to define the type of a
Andrew Geisslerc926e172021-05-07 16:11:35 -05002821variable using the "type" varflag. Here is an example::
Andrew Geisslerc9f78652020-09-18 14:11:35 -05002822
2823 IMAGE_FEATURES[type] = "list"
2824
2825.. _ref-classes-uboot-config:
2826
2827``uboot-config.bbclass``
2828========================
2829
2830The ``uboot-config`` class provides support for U-Boot configuration for
Andrew Geisslerc926e172021-05-07 16:11:35 -05002831a machine. Specify the machine in your recipe as follows::
Andrew Geisslerc9f78652020-09-18 14:11:35 -05002832
2833 UBOOT_CONFIG ??= <default>
2834 UBOOT_CONFIG[foo] = "config,images"
2835
Andrew Geisslerc926e172021-05-07 16:11:35 -05002836You can also specify the machine using this method::
Andrew Geisslerc9f78652020-09-18 14:11:35 -05002837
2838 UBOOT_MACHINE = "config"
2839
2840See the :term:`UBOOT_CONFIG` and :term:`UBOOT_MACHINE` variables for additional
2841information.
2842
2843.. _ref-classes-uninative:
2844
2845``uninative.bbclass``
2846=====================
2847
2848Attempts to isolate the build system from the host distribution's C
2849library in order to make re-use of native shared state artifacts across
2850different host distributions practical. With this class enabled, a
2851tarball containing a pre-built C library is downloaded at the start of
2852the build. In the Poky reference distribution this is enabled by default
2853through ``meta/conf/distro/include/yocto-uninative.inc``. Other
2854distributions that do not derive from poky can also
2855"``require conf/distro/include/yocto-uninative.inc``" to use this.
2856Alternatively if you prefer, you can build the uninative-tarball recipe
2857yourself, publish the resulting tarball (e.g. via HTTP) and set
2858``UNINATIVE_URL`` and ``UNINATIVE_CHECKSUM`` appropriately. For an
2859example, see the ``meta/conf/distro/include/yocto-uninative.inc``.
2860
2861The ``uninative`` class is also used unconditionally by the extensible
2862SDK. When building the extensible SDK, ``uninative-tarball`` is built
2863and the resulting tarball is included within the SDK.
2864
2865.. _ref-classes-update-alternatives:
2866
2867``update-alternatives.bbclass``
2868===============================
2869
2870The ``update-alternatives`` class helps the alternatives system when
2871multiple sources provide the same command. This situation occurs when
2872several programs that have the same or similar function are installed
2873with the same name. For example, the ``ar`` command is available from
2874the ``busybox``, ``binutils`` and ``elfutils`` packages. The
2875``update-alternatives`` class handles renaming the binaries so that
2876multiple packages can be installed without conflicts. The ``ar`` command
2877still works regardless of which packages are installed or subsequently
2878removed. The class renames the conflicting binary in each package and
2879symlinks the highest priority binary during installation or removal of
2880packages.
2881
2882To use this class, you need to define a number of variables:
2883
2884- :term:`ALTERNATIVE`
2885
2886- :term:`ALTERNATIVE_LINK_NAME`
2887
2888- :term:`ALTERNATIVE_TARGET`
2889
2890- :term:`ALTERNATIVE_PRIORITY`
2891
2892These variables list alternative commands needed by a package, provide
2893pathnames for links, default links for targets, and so forth. For
2894details on how to use this class, see the comments in the
Andrew Geissler09209ee2020-12-13 08:44:15 -06002895:yocto_git:`update-alternatives.bbclass </poky/tree/meta/classes/update-alternatives.bbclass>`
Andrew Geisslerc9f78652020-09-18 14:11:35 -05002896file.
2897
2898.. note::
2899
Andrew Geissler4c19ea12020-10-27 13:52:24 -05002900 You can use the ``update-alternatives`` command directly in your recipes.
2901 However, this class simplifies things in most cases.
Andrew Geisslerc9f78652020-09-18 14:11:35 -05002902
2903.. _ref-classes-update-rc.d:
2904
2905``update-rc.d.bbclass``
2906=======================
2907
2908The ``update-rc.d`` class uses ``update-rc.d`` to safely install an
2909initialization script on behalf of the package. The OpenEmbedded build
2910system takes care of details such as making sure the script is stopped
2911before a package is removed and started when the package is installed.
2912
Andrew Geissler09036742021-06-25 14:25:14 -05002913Three variables control this class: :term:`INITSCRIPT_PACKAGES`,
2914:term:`INITSCRIPT_NAME` and :term:`INITSCRIPT_PARAMS`. See the variable links
Andrew Geisslerc9f78652020-09-18 14:11:35 -05002915for details.
2916
2917.. _ref-classes-useradd:
2918
2919``useradd*.bbclass``
2920====================
2921
2922The ``useradd*`` classes support the addition of users or groups for
2923usage by the package on the target. For example, if you have packages
2924that contain system services that should be run under their own user or
2925group, you can use these classes to enable creation of the user or
Andrew Geissler595f6302022-01-24 19:11:47 +00002926group. The :oe_git:`meta-skeleton/recipes-skeleton/useradd/useradd-example.bb
2927</openembedded-core/tree/meta-skeleton/recipes-skeleton/useradd/useradd-example.bb>`
Andrew Geisslerc9f78652020-09-18 14:11:35 -05002928recipe in the :term:`Source Directory` provides a simple
2929example that shows how to add three users and groups to two packages.
Andrew Geisslerc9f78652020-09-18 14:11:35 -05002930
2931The ``useradd_base`` class provides basic functionality for user or
2932groups settings.
2933
2934The ``useradd*`` classes support the
2935:term:`USERADD_PACKAGES`,
2936:term:`USERADD_PARAM`,
2937:term:`GROUPADD_PARAM`, and
2938:term:`GROUPMEMS_PARAM` variables.
2939
2940The ``useradd-staticids`` class supports the addition of users or groups
2941that have static user identification (``uid``) and group identification
2942(``gid``) values.
2943
2944The default behavior of the OpenEmbedded build system for assigning
2945``uid`` and ``gid`` values when packages add users and groups during
2946package install time is to add them dynamically. This works fine for
2947programs that do not care what the values of the resulting users and
2948groups become. In these cases, the order of the installation determines
2949the final ``uid`` and ``gid`` values. However, if non-deterministic
2950``uid`` and ``gid`` values are a problem, you can override the default,
2951dynamic application of these values by setting static values. When you
2952set static values, the OpenEmbedded build system looks in
2953:term:`BBPATH` for ``files/passwd`` and ``files/group``
2954files for the values.
2955
2956To use static ``uid`` and ``gid`` values, you need to set some
2957variables. See the :term:`USERADDEXTENSION`,
2958:term:`USERADD_UID_TABLES`,
2959:term:`USERADD_GID_TABLES`, and
2960:term:`USERADD_ERROR_DYNAMIC` variables.
2961You can also see the :ref:`useradd <ref-classes-useradd>` class for
2962additional information.
2963
2964.. note::
2965
Andrew Geissler4c19ea12020-10-27 13:52:24 -05002966 You do not use the ``useradd-staticids`` class directly. You either enable
Andrew Geissler09036742021-06-25 14:25:14 -05002967 or disable the class by setting the :term:`USERADDEXTENSION` variable. If you
Andrew Geissler4c19ea12020-10-27 13:52:24 -05002968 enable or disable the class in a configured system, :term:`TMPDIR` might
Andrew Geissler09036742021-06-25 14:25:14 -05002969 contain incorrect ``uid`` and ``gid`` values. Deleting the :term:`TMPDIR`
Andrew Geisslerc9f78652020-09-18 14:11:35 -05002970 directory will correct this condition.
2971
2972.. _ref-classes-utility-tasks:
2973
2974``utility-tasks.bbclass``
2975=========================
2976
2977The ``utility-tasks`` class provides support for various "utility" type
2978tasks that are applicable to all recipes, such as
2979:ref:`ref-tasks-clean` and
2980:ref:`ref-tasks-listtasks`.
2981
2982This class is enabled by default because it is inherited by the
2983:ref:`base <ref-classes-base>` class.
2984
2985.. _ref-classes-utils:
2986
2987``utils.bbclass``
2988=================
2989
2990The ``utils`` class provides some useful Python functions that are
2991typically used in inline Python expressions (e.g. ``${@...}``). One
2992example use is for ``bb.utils.contains()``.
2993
2994This class is enabled by default because it is inherited by the
2995:ref:`base <ref-classes-base>` class.
2996
2997.. _ref-classes-vala:
2998
2999``vala.bbclass``
3000================
3001
3002The ``vala`` class supports recipes that need to build software written
3003using the Vala programming language.
3004
3005.. _ref-classes-waf:
3006
3007``waf.bbclass``
3008===============
3009
3010The ``waf`` class supports recipes that need to build software that uses
3011the Waf build system. You can use the
3012:term:`EXTRA_OECONF` or
3013:term:`PACKAGECONFIG_CONFARGS` variables
3014to specify additional configuration options to be passed on the Waf
3015command line.