Skip to content
This repository was archived by the owner on Aug 5, 2022. It is now read-only.

Commit e846f89

Browse files
ipuustinmythi
authored andcommitted
doc: detail methods for configuring Refkit images.
v2: update the original text (in PR #217) with review suggestions from Patrick Ohly. Signed-off-by: Ismo Puustinen <ismo.puustinen@intel.com>
1 parent 550acd0 commit e846f89

1 file changed

Lines changed: 92 additions & 0 deletions

File tree

doc/howtos/image-configuration.rst

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
Configuring IoT Refkit images
2+
#############################
3+
4+
Many packages in IoT Refkit come with a default set of configuration
5+
files. This document gives guidance for configuring a Refkit image with
6+
custom package configuration files.
7+
8+
Using .bbappend files to override package configuration
9+
=======================================================
10+
11+
If you have only a limited set of packages which you need to configure,
12+
you can create ``.bbappend`` files which append the recipes for each
13+
package which you want to modify. A usual way to change the
14+
configuration is to change the install phase to replace or remove the
15+
default configuration files.
16+
17+
You can add the ``.bbappend`` files to your own customization layer and
18+
use ``do_install_append()`` for modifying package configuration.
19+
20+
.. code::
21+
22+
do_install_append () {
23+
install -d ${D}${sysconfdir}
24+
echo "some configuration" > ${D}${sysconfdir}/config_file
25+
...
26+
}
27+
28+
Using virtual packages
29+
======================
30+
31+
Some recipes in IoT Refkit and other Yocto layers have the configuration
32+
split into separate configuration packages. For example, see
33+
`nftables-settings-default recipe
34+
<../../meta-refkit-core/recipes-security/nftables-settings-default/nftables-settings-default_0.1.bb>`_.
35+
In these cases, if you want to replace the configuration fully, you can
36+
create your own configuration package (say ``nftables-settings-custom``)
37+
and just use it in place of the default configuration package.
38+
39+
Other recipes, where having a configuration package is mandatory, take
40+
this further and use ``VIRTUAL_RUNTIME`` convention to enforce that a
41+
configuration package will be installed to the target. For example,
42+
consider `groupcheck recipe
43+
<../../meta-refkit-core/recipes-security/groupcheck/groupcheck_git.bb>`_,
44+
which has the following lines:
45+
46+
.. code::
47+
48+
VIRTUAL-RUNTIME_groupcheck-settings ?= "groupcheck-settings-default"
49+
RDEPENDS_${PN} += "${VIRTUAL-RUNTIME_groupcheck-settings}"
50+
51+
If a configuration package (say ``groupcheck-settings-custom``) is made,
52+
it needs to be set to be the required configuration package. This is
53+
done by changing ``local.conf`` or other distro configuration file to
54+
override the particular ``VIRTUAL_RUNTIME`` variable:
55+
56+
.. code::
57+
58+
VIRTUAL-RUNTIME_groupcheck-settings = "groupcheck-settings-custom"
59+
60+
Image configuration during root filesystem creation
61+
===================================================
62+
63+
An alternative to configuring individual packages is the configuration
64+
of the entire image during rootfs creation. The image recipes can be
65+
appended as any other recipe. This is the correct approach if you have
66+
several files in different packges which you need to change or if you
67+
just want to keep the configuration changes in one place.
68+
69+
One practical way for implementing a certain configuration would be to
70+
add it as a ``.bbclass`` file, which would then be inherited by all
71+
images which require that configuration. For example, you can create
72+
``custom-config.bbclass`` file and add a Python task function to do the
73+
necessary configuration changes there:
74+
75+
.. code::
76+
77+
python change_image_configuration () {
78+
etcdir = oe.path.join(d.getVar("IMAGE_ROOTFS"), d.getVar("sysconfdir"))
79+
...
80+
}
81+
82+
ROOTFS_POSTPROCESS_COMMAND_prepend = "change_image_configuration;"
83+
84+
You can then inherit the class directly into your own image recipes.
85+
86+
A drawback of this method is that the image is changed after the
87+
packages are installed. This means that you can't use package-based
88+
methods for updating devices, but should instead use `an atomic update
89+
mechanism which treats the entire modified rootfs as a single entity
90+
<https://wiki.yoctoproject.org/wiki/System_Update>`_. Supported system
91+
update mechanisms IoT Refkit are documented in `system-update.rst
92+
<../system-update.rst>`_.

0 commit comments

Comments
 (0)