feat(coreos-sanity): add some checks to ensure that coreos policies are not overwritted

This commit is contained in:
Samuel Dolt 2022-10-13 15:22:09 +02:00
parent a6f33081eb
commit 0b9a7d9c7e
5 changed files with 60 additions and 2 deletions

2
.gitignore vendored
View File

@ -1,4 +1,6 @@
build/ build/
vscode-bitbake-build/ vscode-bitbake-build/
documentation/_build/ documentation/_build/
documentation/oe-logs
documentation/oe-workdir

View File

@ -21,12 +21,26 @@ The ``coreos_metadata_scm`` is automatically inherited if ``DISTRO`` is set to
``belden-coreos`` or to any distro based on ``belden-coreos``. ``belden-coreos`` or to any distro based on ``belden-coreos``.
.. _ref-classes-coreos-image: .. _ref-classes-coreos-image:
.. index:: coreos_image.bbclass .. index:: coreos-image.bbclass
``coreos_image.bbclass`` ``coreos-image.bbclass``
======================== ========================
The ``coreos-image`` class provides common definitions for the The ``coreos-image`` class provides common definitions for the
``coreos-image-*`` image recipes, such as support for additional ``coreos-image-*`` image recipes, such as support for additional
:extern:ref:`IMAGE_FEATURE <ref-features-image>`. :extern:ref:`IMAGE_FEATURE <ref-features-image>`.
.. _ref-classes-coreos-sanity:
.. index:: coreos-sanity.class
``coreos-sanity.bbclass``
========================
The ``coreos-sanity`` class is inherited inside the CoreOS layer
configuration file to add some sanity checks. Theses check ensure that the
policies of CoreOS are followed.
Currently, this add check to ensure:
- that the distro is based on CoreOS
- that SystemD is used as ``INIT_MANAGER``
- that glibc is used as the default C library

View File

@ -0,0 +1,33 @@
# This class add some sanity checks to ensure that distribution based on
# CoreOS only use the subset of openembedded-core that is supported by the
# CoreOS team.
SANITY_COREOS_COMPATIBLE ??= "0"
addhandler check_coreos_sanity_eventhandler
check_coreos_sanity_eventhandler[eventmask] = "bb.event.SanityCheck"
python check_coreos_sanity_eventhandler() {
if e.data.getVar('SANITY_COREOS_COMPATIBLE') != "1":
bb.fatal(
"The CoreOS layer is only compatible with distribution based on "
"conf/distro/belden-core.conf.\n"
"Please ensure that your distribution configuration file contains "
" `require conf/distro/belden-core.conf`"
)
if e.data.getVar('VIRTUAL-RUNTIME_init_manager') != "systemd":
bb.fatal(
"systemd is not set as `INIT_MANAGER`. "
"Using SystemD is mandatory on CoreOS based distribution"
)
if e.data.getVar("TCLIBC") != "glibc":
bb.fatal(
"glibc is not set as `TCLIBC`. "
"Using glibc is mandatory on CoreOS based distribution"
)
return
}

View File

@ -31,6 +31,10 @@ SANITY_TESTED_DISTROS ?= " \
debian-11 \n \ debian-11 \n \
" "
# This variable is used to ensure that any distribution using the CoreOS layer
# include this file. This is checked by the coreos-sanity class
SANITY_COREOS_COMPATIBLE ?= "1"
require conf/distro/include/no-static-libs.inc require conf/distro/include/no-static-libs.inc
require conf/distro/include/yocto-uninative.inc require conf/distro/include/yocto-uninative.inc
require conf/distro/include/security_flags.inc require conf/distro/include/security_flags.inc

View File

@ -11,3 +11,8 @@ BBFILE_PRIORITY_meta-belden-coreos = "6"
LAYERDEPENDS_meta-belden-coreos = "core" LAYERDEPENDS_meta-belden-coreos = "core"
LAYERSERIES_COMPAT_meta-belden-coreos = "kirkstone" LAYERSERIES_COMPAT_meta-belden-coreos = "kirkstone"
# Sanity Checks
# ==============================================================================
INHERIT += "coreos-sanity"