[21/27] barebox: Migrate to a bbclass

Message ID df215db6b6e6d1cf8d3fa631237bc15896de5d76.1762170735.git.jan.kiszka@siemens.com
State Under Review
Headers show
Series [01/27] linux-custom: Drop redundant template inheritance | expand

Commit Message

Jan Kiszka Nov. 3, 2025, 11:52 a.m. UTC
From: Jan Kiszka <jan.kiszka@siemens.com>

"inherit barebox" is shorter and a more common pattern compared to
OE/yocto. Keep the original .inc file as transitional helper, issuing a
warning when it's used with a migration suggestion.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
---
 .../barebox.bbclass}                          |  3 +-
 meta/recipes-bsp/barebox/barebox.inc          | 60 +++----------------
 2 files changed, 9 insertions(+), 54 deletions(-)
 copy meta/{recipes-bsp/barebox/barebox.inc => classes-recipe/barebox.bbclass} (95%)

Patch

diff --git a/meta/recipes-bsp/barebox/barebox.inc b/meta/classes-recipe/barebox.bbclass
similarity index 95%
copy from meta/recipes-bsp/barebox/barebox.inc
copy to meta/classes-recipe/barebox.bbclass
index a11ef9e2..63c70fa1 100644
--- a/meta/recipes-bsp/barebox/barebox.inc
+++ b/meta/classes-recipe/barebox.bbclass
@@ -1,5 +1,6 @@ 
 # This software is a part of ISAR.
 # Copyright (C) 2022 ilbers GmbH
+# Copyright (c) Siemens, 2025
 #
 # SPDX-License-Identifier: MIT
 
@@ -18,7 +19,7 @@  BAREBOX_BUILD_DIR ?= "build"
 BAREBOX_VERSION_EXTENSION ?= ""
 BAREBOX_ENV ?= ""
 
-FILESPATH:append := ":${FILE_DIRNAME}/files"
+FILESPATH:append = ":${LAYERDIR_core}/recipes-bsp/barebox/files"
 SRC_URI += "file://rules.tmpl \
             file://version.cfg.tmpl \
             file://defaultenv.cfg.tmpl"
diff --git a/meta/recipes-bsp/barebox/barebox.inc b/meta/recipes-bsp/barebox/barebox.inc
index a11ef9e2..90004a70 100644
--- a/meta/recipes-bsp/barebox/barebox.inc
+++ b/meta/recipes-bsp/barebox/barebox.inc
@@ -1,59 +1,13 @@ 
+# Transitional include for barebox.bbclass
+#
 # This software is a part of ISAR.
-# Copyright (C) 2022 ilbers GmbH
+# Copyright (c) Siemens AG, 2025
 #
 # SPDX-License-Identifier: MIT
 
-inherit dpkg
-
-DESCRIPTION ?= "The barebox is a bootloader designed for embedded systems. It \
-                runs on a variety of architectures including x86, ARM, MIPS, \
-                PowerPC and others."
-CHANGELOG_V = "${PV}+${PR}"
-MAINTAINER ?= "isar-users <isar-users@googlegroups.com>"
-
-DEBIAN_BUILD_DEPENDS ?= "lzop, coreutils, bison, flex, lz4"
-
-BAREBOX_CONFIG ?= ""
-BAREBOX_BUILD_DIR ?= "build"
-BAREBOX_VERSION_EXTENSION ?= ""
-BAREBOX_ENV ?= ""
-
-FILESPATH:append := ":${FILE_DIRNAME}/files"
-SRC_URI += "file://rules.tmpl \
-            file://version.cfg.tmpl \
-            file://defaultenv.cfg.tmpl"
-
-BAREBOX_CONFIG_FRAGMENTS = "version.cfg defaultenv.cfg"
-
-SRC_URI += "${@'file://%s' % d.getVar('BAREBOX_ENV') if d.getVar('BAREBOX_ENV') else ''}"
-
-TEMPLATE_FILES += "rules.tmpl version.cfg.tmpl defaultenv.cfg.tmpl"
-TEMPLATE_VARS += "BAREBOX_CONFIG BAREBOX_BUILD_DIR BAREBOX_VERSION_EXTENSION BAREBOX_ENV BAREBOX_CONFIG_FRAGMENTS BAREBOX_BASE_BIN"
-
-do_prepare_build[cleandirs] += "${S}/debian"
-do_prepare_build() {
-    deb_debianize
-
-    if [ -n "${BAREBOX_CONFIG_FRAGMENTS}" ]; then
-        (cd ${WORKDIR} && cp ${BAREBOX_CONFIG_FRAGMENTS} ${S}/)
-    fi
-    if [ -n "${BAREBOX_ENV}" ]; then
-        (cd ${WORKDIR} && cp -r ${BAREBOX_ENV} ${S}/)
-    fi
-}
-
-BAREBOX_BASE_BIN ?= "barebox"
-
-do_deploy[dirs] = "${DEPLOY_DIR_IMAGE}"
-do_deploy() {
-    dpkg --fsys-tarfile ${WORKDIR}/${PN}_${CHANGELOG_V}_${DISTRO_ARCH}.deb | \
-        tar xOf - ./usr/lib/barebox/barebox.bin \
-        > "${DEPLOY_DIR_IMAGE}/${BAREBOX_BASE_BIN}.img"
-    ln -sf ${BAREBOX_BASE_BIN}.img ${DEPLOY_DIR_IMAGE}/barebox.bin
+inherit barebox
 
-    dpkg --fsys-tarfile ${WORKDIR}/${PN}_${CHANGELOG_V}_${DISTRO_ARCH}.deb | \
-        tar xOf - ./usr/lib/barebox/barebox.config \
-        > "${DEPLOY_DIR_IMAGE}/${BAREBOX_BASE_BIN}.config"
-    ln -sf ${BAREBOX_BASE_BIN}.config ${DEPLOY_DIR_IMAGE}/barebox.config
+do_warn_custom_inc() {
+    bbwarn "Please migrate from \"require recipes-bsp/barebox/barebox.inc\" to \"inherit barebox\""
 }
-addtask deploy before do_deploy_deb after do_dpkg_build
+addtask warn_custom_inc before do_unpack