Pull request #5: Feat/sanity checks

Merge in ICO/coreos from feat/sanity-checks to master

* commit '0b9a7d9c7e6c5774def752c924d6baff69afb930':
  feat(coreos-sanity): add some checks to ensure that coreos policies are not overwritted
  fix(coreos-doc): remove the documentation folder if it already exist in DEPLOY_DIR
This commit is contained in:
Samuel Dolt 2022-10-18 14:10:30 +02:00
commit 73a6546bc2
6 changed files with 61 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"

View File

@ -23,6 +23,7 @@ do_install() {
# Deploy to build/tmp/deploy/documentation # Deploy to build/tmp/deploy/documentation
do_deploy() { do_deploy() {
rm -rf ${DEPLOY_DIR}/documentation
cp --no-preserve=ownership -r ${B} ${DEPLOY_DIR}/documentation cp --no-preserve=ownership -r ${B} ${DEPLOY_DIR}/documentation
} }