From f93abf869ad49e80889487de168e101cfee8a35b Mon Sep 17 00:00:00 2001 From: Bruce Ashfield Date: Mon, 5 Jan 2026 15:40:34 +0000 Subject: classes: factor out shared functions to container-common.bbclass Create container-common.bbclass with shared Python functions used by both container-bundle.bbclass and container-cross-install.bbclass: - get_vruntime_multiconfig(d): Maps TARGET_ARCH to multiconfig name - get_vruntime_machine(d): Maps TARGET_ARCH to MACHINE for deploy path - get_blob_arch(d): Maps TARGET_ARCH to blob directory name This removes ~55 lines of duplicated code and ensures consistency between the two bbclass files. Signed-off-by: Bruce Ashfield --- classes/container-bundle.bbclass | 36 +++--------------------------------- 1 file changed, 3 insertions(+), 33 deletions(-) (limited to 'classes/container-bundle.bbclass') diff --git a/classes/container-bundle.bbclass b/classes/container-bundle.bbclass index fdd241ee..406e70cc 100644 --- a/classes/container-bundle.bbclass +++ b/classes/container-bundle.bbclass @@ -157,45 +157,15 @@ def get_bundle_runtime(d): CONTAINER_BUNDLE_RUNTIME ?= "${@get_bundle_runtime(d)}" +# Inherit shared functions for multiconfig/machine/arch mapping +inherit container-common + # Dependencies on native tools # vcontainer-native provides vrunner.sh # Blobs come from multiconfig builds (vdkr-initramfs-create, vpdmn-initramfs-create) DEPENDS += "qemuwrapper-cross qemu-system-native skopeo-native" DEPENDS += "vcontainer-native" -# Determine multiconfig name for blob building based on target architecture -def get_vruntime_multiconfig(d): - arch = d.getVar('TARGET_ARCH') - if arch == 'aarch64': - return 'vruntime-aarch64' - elif arch in ['x86_64', 'i686', 'i586']: - return 'vruntime-x86-64' - else: - return None - -# Get the MACHINE name used in the multiconfig (for deploy path) -def get_vruntime_machine(d): - arch = d.getVar('TARGET_ARCH') - if arch == 'aarch64': - return 'qemuarm64' - elif arch in ['x86_64', 'i686', 'i586']: - return 'qemux86-64' - else: - return None - -# Map TARGET_ARCH to blob directory name (aarch64, x86_64) -def get_blob_arch(d): - """Map Yocto TARGET_ARCH to blob directory name""" - arch = d.getVar('TARGET_ARCH') - blob_map = { - 'aarch64': 'aarch64', - 'arm': 'aarch64', # Use aarch64 blobs for 32-bit ARM too - 'x86_64': 'x86_64', - 'i686': 'x86_64', - 'i586': 'x86_64', - } - return blob_map.get(arch, 'aarch64') - VRUNTIME_MULTICONFIG = "${@get_vruntime_multiconfig(d)}" VRUNTIME_MACHINE = "${@get_vruntime_machine(d)}" BLOB_ARCH = "${@get_blob_arch(d)}" -- cgit v1.2.3-54-g00ecf