Skip to contentSkip to conversation

ti-localversion.bbclass: introduce bbclass

PATCH In review [email protected] 2 participants 3 messages May 30, 2023

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ti-localversion.bbclass: introduce bbclass

From: Ming Liu <[email protected]>

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/[email protected]/

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

---
 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
meta-ti-bsp/classes/ti-localversion.bbclass new file +15 -0
new file mode 100644
index 00000000..6e7246af
@@ -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"
meta-ti-bsp/recipes-bsp/u-boot/u-boot-ti.inc +3 -5
index 8e236dfe..2f461ad4 100644
@@ -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"
 
meta-ti-bsp/recipes-kernel/linux/setup-defconfig.inc +1 -3
index df7d9ac8..2db2bb84 100644
@@ -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
Signature · 1 line
2.25.1
#1 lore raw
Quoted 19 lines · Ming Liu

From: Ming Liu <[email protected]>

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.

Quoted 8 lines

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/[email protected]/

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

Sadly, UBOOT_LOCALVERSION has the same error. It's just random which one presents itself as the parser error. We already have a patch from Denys that addresses this, I'm looking at it now.

Quoted 75 lines
---
  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

meta-ti-bsp/classes/ti-localversion.bbclass new file +15 -0
new file mode 100644
index 00000000..6e7246af
@@ -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"
meta-ti-bsp/recipes-bsp/u-boot/u-boot-ti.inc +3 -5
index 8e236dfe..2f461ad4 100644
@@ -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"
 
meta-ti-bsp/recipes-kernel/linux/setup-defconfig.inc +1 -4
index df7d9ac8..2db2bb84 100644
@@ -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
 
 
 
-=-=-=-=-=-=-=-=-=-=-=-

Links: You receive all messages sent to this group.
View/Reply Online (#16628): https://lists.yoctoproject.org/g/meta-ti/message/16628
Mute This Topic: https://lists.yoctoproject.org/mt/99225679/6551054
Group Owner: [email protected]
Unsubscribe: https://lists.yoctoproject.org/g/meta-ti/unsub [[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

Signature · 3 lines
Ryan Eatmon                [email protected]
-----------------------------------------
Texas Instruments, Inc.  -  LCPD  -  MGTS
author
#2 lore raw

Hi, Ryan:

Thanks for the quick reply.

Arha, I did not see that MR, just subscribed this mail list today.

Yes exactly, UBOOT_LOCALVERSION has the same problem, it's also handled in this patch.

the best,
thank you

Ryan Eatmon <[email protected]> 於 2023年5月30日 週二 下午8:11寫道:

Quoted 134 lines · Ming Liu
Quoted 4 lines

From: Ming Liu <[email protected]>

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

Quoted 3 lines

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'):

Quoted 2 lines

if not scms:
> raise FetchError("SRCREV was used yet no valid SCM was

found in SRC_URI")

Quoted 7 lines

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.

Quoted 8 lines

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/[email protected]/

Quoted 3 lines

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

Sadly, UBOOT_LOCALVERSION has the same error. It's just random which one presents itself as the parser error. We already have a patch from Denys that addresses this, I'm looking at it now.

Review

Quoted 9 lines
---
  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

(quoted diff) +0 -0

b/meta-ti-bsp/classes/ti-localversion.bbclass

meta-ti-bsp/classes/ti-localversion.bbclass line 1

Quoted 6 lines

new file mode 100644
index 00000000..6e7246af

meta-ti-bsp/classes/ti-localversion.bbclass new file +1 -0
@@ -0,0 +1,15 @@
+# Helper class to append a string to the name of the local version of

kernel/uboot images.

meta-ti-bsp/classes/ti-localversion.bbclass line 3

Quoted 2 lines
meta-ti-bsp/classes/ti-localversion.bbclass new file +2 -0
+
+# Take 'KERNEL', 'UBOOT', set 'KERNEL_LOCALVERSION' and

'UBOOT_LOCALVERSION' accordingly

meta-ti-bsp/classes/ti-localversion.bbclass

Quoted 8 lines
meta-ti-bsp/classes/ti-localversion.bbclass new file +8 -0
+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])

Review

Quoted 5 lines
meta-ti-bsp/classes/ti-localversion.bbclass new file +4 -0
+}
+
+addhandler localversion_handler
+localversion_handler[eventmask] = "bb.event.RecipeParsed"
(quoted diff) +0 -0

b/meta-ti-bsp/recipes-bsp/u-boot/u-boot-ti.inc

meta-ti-bsp/recipes-bsp/u-boot/u-boot-ti.inc line 3

Quoted 7 lines

index 8e236dfe..2f461ad4 100644

meta-ti-bsp/recipes-bsp/u-boot/u-boot-ti.inc +0 -3
@@ -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]}"

Review

Quoted 16 lines
meta-ti-bsp/recipes-bsp/u-boot/u-boot-ti.inc +3 -2
-
  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"
 
(quoted diff) +0 -0

b/meta-ti-bsp/recipes-kernel/linux/setup-defconfig.inc

meta-ti-bsp/recipes-kernel/linux/setup-defconfig.inc line 3

Quoted 7 lines

index df7d9ac8..2db2bb84 100644

meta-ti-bsp/recipes-kernel/linux/setup-defconfig.inc +0 -3
@@ -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]}"

Quoted 10 lines
meta-ti-bsp/recipes-kernel/linux/setup-defconfig.inc +1 -1
+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
 
 
 
-=-=-=-=-=-=-=-=-=-=-=-

Links: You receive all messages sent to this group. View/Reply Online (#16628):

https://lists.yoctoproject.org/g/meta-ti/message/16628

Quoted 3 lines

Mute This Topic: https://lists.yoctoproject.org/mt/99225679/6551054
Group Owner: [email protected]
Unsubscribe: https://lists.yoctoproject.org/g/meta-ti/unsub [

[email protected]]

Quoted 2 lines

-=-=-=-=-=-=-=-=-=-=-=-

--
Ryan Eatmon [email protected]
-----------------------------------------
Texas Instruments, Inc. - LCPD - MGTS