All of lore.kernel.org
 help / color / mirror / Atom feed
From: liu.ming50@gmail.com
To: meta-ti@lists.yoctoproject.org
Cc: max.krummenacher@toradex.com, francesco.dolcini@toradex.com,
	Ming Liu <liu.ming50@gmail.com>
Subject: [meta-ti-bsp] [PATCH] ti-localversion.bbclass: introduce bbclass
Date: Tue, 30 May 2023 20:09:26 +0200	[thread overview]
Message-ID: <20230530180926.265920-1-liu.ming50@gmail.com> (raw)

From: Ming Liu <liu.ming50@gmail.com>

An error was observed as follows:
ERROR: ExpansionError during parsing .../meta-ti/meta-ti-bsp/recipes-kernel/linux/linux-ti-staging-systest_5.10.bb
Traceback (most recent call last):
  File "Var <KERNEL_LOCALVERSION>", line 1, in <module>
  File ".../openembedded-core/bitbake/lib/bb/fetch2/__init__.py", line 788, in get_srcrev(d=<bb.data_smart.DataSmart object at 0x7fe9da2f0c70>, method_name='sortable_revision'):
         if not scms:
    >        raise FetchError("SRCREV was used yet no valid SCM was found in SRC_URI")

with the latest bitbake on commit: 893f3b116b6
[ fetch2/npm: evaluate PATH before patching HOME ]

the root cause is the variable SRCPV could not be expanded during
recipe parsing stage due to some uri variables in bitbake being unset.

Insteadly, it has to be expanded in recipe finializing stage, let's
introduce a RecipeParsed event handler to set it.

We need set UBOOT_LOCALVERSION in this handler as well, because that
has the same problem.

Meanwhile, I have sent a patch to OE:
https://patchwork.yoctoproject.org/project/oe-core/patch/20230530170949.12045-1-liu.ming50@gmail.com/

to make KERNEL_LOCALVERSION to be a standard OE variable, just like how
UBOOT_LOCALVERSION being handled in OE.

Signed-off-by: Ming Liu <liu.ming50@gmail.com>
---
 meta-ti-bsp/classes/ti-localversion.bbclass       | 15 +++++++++++++++
 meta-ti-bsp/recipes-bsp/u-boot/u-boot-ti.inc      |  8 +++-----
 .../recipes-kernel/linux/setup-defconfig.inc      |  4 +---
 3 files changed, 19 insertions(+), 8 deletions(-)
 create mode 100644 meta-ti-bsp/classes/ti-localversion.bbclass

diff --git a/meta-ti-bsp/classes/ti-localversion.bbclass b/meta-ti-bsp/classes/ti-localversion.bbclass
new file mode 100644
index 00000000..6e7246af
--- /dev/null
+++ b/meta-ti-bsp/classes/ti-localversion.bbclass
@@ -0,0 +1,15 @@
+# Helper class to append a string to the name of the local version of kernel/uboot images.
+
+# Take 'KERNEL', 'UBOOT', set 'KERNEL_LOCALVERSION' and 'UBOOT_LOCALVERSION' accordingly
+LOCALVERSION_VAR ??= "KERNEL"
+
+python localversion_handler () {
+    import bb.event
+
+    if isinstance(e, bb.event.RecipeParsed):
+        srcpv = bb.fetch2.get_srcrev(e.data)
+        e.data.setVar('%s_LOCALVERSION' % e.data.getVar('LOCALVERSION_VAR'), "-g%s" % srcpv.replace('AUTOINC+','')[:10])
+}
+
+addhandler localversion_handler
+localversion_handler[eventmask] = "bb.event.RecipeParsed"
diff --git a/meta-ti-bsp/recipes-bsp/u-boot/u-boot-ti.inc b/meta-ti-bsp/recipes-bsp/u-boot/u-boot-ti.inc
index 8e236dfe..2f461ad4 100644
--- a/meta-ti-bsp/recipes-bsp/u-boot/u-boot-ti.inc
+++ b/meta-ti-bsp/recipes-bsp/u-boot/u-boot-ti.inc
@@ -1,7 +1,3 @@
-# UBOOT_LOCALVERSION can be set to add a tag to the end of the
-# U-boot version string.  such as the commit id
-UBOOT_LOCALVERSION = "-g${@d.getVar('SRCPV', True).replace('AUTOINC+','')[:10]}"
-
 UBOOT_SUFFIX ?= "img"
 SPL_BINARY ?= "MLO"
 
@@ -61,7 +57,9 @@ PKG:${PN}-dbg = "u-boot-dbg"
 S = "${WORKDIR}/git"
 
 # Support for secure devices - detailed info is in doc/README.ti-secure
-inherit ti-secdev
+inherit ti-secdev ti-localversion
+
+LOCALVERSION_VAR = "UBOOT"
 
 SYSROOT_DIRS += "/boot"
 
diff --git a/meta-ti-bsp/recipes-kernel/linux/setup-defconfig.inc b/meta-ti-bsp/recipes-kernel/linux/setup-defconfig.inc
index df7d9ac8..2db2bb84 100644
--- a/meta-ti-bsp/recipes-kernel/linux/setup-defconfig.inc
+++ b/meta-ti-bsp/recipes-kernel/linux/setup-defconfig.inc
@@ -1,6 +1,4 @@
-# KERNEL_LOCALVERSION can be set to add a tag to the end of the
-# kernel version string.  such as the commit id
-KERNEL_LOCALVERSION = "-g${@d.getVar('SRCPV', True).replace('AUTOINC+','')[:10]}"
+inherit ti-localversion
 
 # Check the defconfig file and see if it points to an in kernel
 # defconfig that should be used, or if it is a complete config file
-- 
2.25.1



             reply	other threads:[~2023-05-30 18:09 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-30 18:09 liu.ming50 [this message]
2023-05-30 18:11 ` [meta-ti] [meta-ti-bsp] [PATCH] ti-localversion.bbclass: introduce bbclass Ryan Eatmon
2023-05-30 18:13   ` Ming Liu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230530180926.265920-1-liu.ming50@gmail.com \
    --to=liu.ming50@gmail.com \
    --cc=francesco.dolcini@toradex.com \
    --cc=max.krummenacher@toradex.com \
    --cc=meta-ti@lists.yoctoproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.