meta-virtualization/recipes-kernel/linux/linux-yocto_virtualization.inc
Mark Hatle 1665d1e2ad linux-yocto_virtualization.inc: If using externalsrc adjust dependency
When using externalsrc, the system will disable a number of tasks such as
do_validate_branches, do_unpack and do_patch.  The do_kernel_metadata task
is configured to run after do_validate_branches do_unpack and before
do_patch.  Since all of these have been removed, the task will never
run.

The do_kernel_metadata task is responsible for populating the
recipe-sysroot-native/kcfg directory via it's own dependency to
yocto-cfg-fragments-native:do_populate_sysroot.

Without do_kernel_metadata running, do_kernel_configme will fail to run
with errors like:
  ERROR: linux-xlnx-6.6.40+git-r0 do_kernel_configme: Feature '../recipe-sysroot-native/kcfg/cfg/virtio.scc' not found, this will cause configuration failures.
  ERROR: linux-xlnx-6.6.40+git-r0 do_kernel_configme: Check the SRC_URI for meta-data repositories or directories that may be missing
  ERROR: linux-xlnx-6.6.40+git-r0 do_kernel_configme: Set KERNEL_DANGLING_FEATURES_WARN_ONLY to ignore this issue

Fix this issue by detecting if we're running with externalsrc, and then
adding the task do_kernel_metadata (from the current recipe) as a
dependency of do_kernel_configme.

To reproduce th original issue:

  $ . ./oe-initbuild-env
  $ bitbake linux-yocto -c patch
  $ cp -r tmp/work-shared/<machine>/kernel-source linux-yocto

  edit the conf/local.conf adding:
  DISTRO_FEATURES:append = " virtualization"
  INHERIT += "externalsrc"
  EXTERNALSRC:pn-linux-yocto = "${TOPDIR}/linux-yocto"

  $ rm -rf tmp
  $ bitbake linux-yocto -c menuconfig

Signed-off-by: Mark Hatle <mark.hatle@amd.com>
Signed-off-by: Bruce Ashfield <bruce.ashfield@gmail.com>
2024-10-10 13:14:07 +00:00

82 lines
4.0 KiB
C++

FILESEXTRAPATHS:prepend := "${THISDIR}/linux-yocto:"
KERNEL_FEATURES:append = " ${@bb.utils.contains('DISTRO_FEATURES', 'kvm', ' features/kvm/qemu-kvm-enable.scc', '', d)}"
KERNEL_MODULE_AUTOLOAD += "nf_conntrack_ipv6 openvswitch"
KERNEL_MODULE_AUTOLOAD += "${@bb.utils.contains('DISTRO_FEATURES', 'kvm', 'kvm', '', d)}"
# aufs kernel support required for xen-image-minimal
KERNEL_FEATURES:append = "${@bb.utils.contains('DISTRO_FEATURES', 'aufs', ' features/aufs/aufs-enable.scc', '', d)}"
# Always add a local/layer fragment for easy debug and enabling of options
SRC_URI += "file://extra-configs.cfg"
# if the kernel-yocto meta-data routine automatically starts to add the
# recipe-sysroot-native, we can do away with this conditional, since all
# features will be found at the same relative offset from a search
# directory
def kernel_cache_cond_feature(src_uri,feature):
import re
kernel_cache = re.search("kernel-cache", src_uri )
if kernel_cache:
return feature
return "../../recipe-sysroot-native/kcfg/" + feature
# no conditional, just use the yocto-kernel-cache addition, yes
# the src_uri isn't used, but we may need to check it in the future
def kernel_cache_feature(src_uri,feature):
return "../../recipe-sysroot-native/kcfg/" + feature
def distro_cond_feature(feature_fragment,distro_feature,d):
import bb
feat = kernel_cache_feature("",feature_fragment)
return bb.utils.contains('DISTRO_FEATURES', distro_feature, ' ' + feat, ' ', d)
# kept as a reference if we go back to a dynamically calculated
# fragment dependency.
def kernel_meta_ver_depends(d):
yocto_enabled = bb.data.inherits_class('kernel-yocto', d)
if yocto_enabled:
pv = oe.utils.trim_version(d.getVar('PV'), 2)
return "yocto-cfg-fragments-%s-native:do_populate_sysroot" % pv
else:
return ""
KERNEL_CFG_DEPENDS ?= "${@['', 'yocto-cfg-fragments-${LINUX_MAJOR}.${LINUX_MINOR}-native:do_populate_sysroot'][(bb.data.inherits_class('kernel-yocto', d))]}"
KERNEL_CACHE_FEATURES ?= "${@kernel_cache_feature(d.getVar('SRC_URI'),'cfg/virtio.scc')} \
${@kernel_cache_feature(d.getVar('SRC_URI'),'cfg/xt-checksum.scc')} \
${@kernel_cache_feature(d.getVar('SRC_URI'),'cfg/vswitch.scc')} \
${@kernel_cache_feature(d.getVar('SRC_URI'),'cfg/lxc.scc')} \
${@kernel_cache_feature(d.getVar('SRC_URI'),'cfg/docker.scc')} \
${@kernel_cache_feature(d.getVar('SRC_URI'),'cfg/cgroup-hugetlb.scc')} \
${@kernel_cache_feature(d.getVar('SRC_URI'),'cfg/criu.scc')} \
"
KERNEL_FEATURES:append = " ${KERNEL_CACHE_FEATURES}"
# if kernel-yocto has been inherited (how we can check for configuration
# fragment merging suport at the moment, then add a dependency on the
# configuration fragment repository. This allows us to be sure that our
# features can be enabled via the fragments
do_kernel_metadata[depends] += "${KERNEL_CFG_DEPENDS}"
# if externalsrc is enabled, do_kernel_metadata dependency on
# yocto-cfg-fragments-native won't be run to populate
# recipe-sysroot-native/kcfg because do_patch is not run. Manully add
# the dependency to do_kernel_configme for this special case
do_kernel_configme[depends] += "${@['', d.getVar('PN') + ':do_kernel_metadata'][(bb.data.inherits_class('externalsrc', d))]}"
# xen kernel support
# SRC_URI += "${@bb.utils.contains('DISTRO_FEATURES', 'xen', ' file://xen.scc', '', d)}"
KERNEL_FEATURES:append = "${@distro_cond_feature('cfg/xen.scc', 'xen', d )}"
# k8s and k3s kernel support
# SRC_URI += "${@bb.utils.contains('DISTRO_FEATURES', 'k8s', ' file://kubernetes.scc', '', d)}"
# SRC_URI += "${@bb.utils.contains('DISTRO_FEATURES', 'k3s', ' file://kubernetes.scc', '', d)}"
KERNEL_FEATURES:append = "${@distro_cond_feature('cfg/kubernetes.scc', 'k8s', d )}"
KERNEL_FEATURES:append = "${@distro_cond_feature('cfg/kubernetes.scc', 'k3s', d )}"
# selinux
KERNEL_FEATURES:append = "${@distro_cond_feature('cgl/features/selinux/selinux.cfg', 'selinux', d )}"