diff mbox series

[v1] license.bbclass: directly expand LIC_FILES_CHKSUMS to apply inline python

Message ID 20260207002856.2847527-1-johannes.schneider@leica-geosystems.com
State New
Headers show
Series [v1] license.bbclass: directly expand LIC_FILES_CHKSUMS to apply inline python | expand

Commit Message

SCHNEIDER Johannes Feb. 7, 2026, 12:28 a.m. UTC
Add 'expand=True' to directly resolve file checksums that are added
conditionally with inline python code.

Otherwise it can happend that the license.bbclass still sees the
un-expanded values and either misses or even skipps adjacent licenses.

E.g. an unvaforable combination of
LIC_FILES_CHKSUM += "file://docs/license.rst;md5=83b7626b8c7a37263c6a58af8d19bee1"
LIC_FILES_CHKSUM:append = "${@bb.utils.contains('TFA_MBEDTLS', '1', ' ${LIC_FILES_CHKSUM_MBEDTLS}', '', d)}"

would lead to a
 # pre-expansion value:
 #   " file://docs/license.rst;md5=83b7626b8c7a37263c6a58af8d19bee1${@bb.utils.contains('TFA_MBEDTLS', '1', ' ${LIC_FILES_CHKSUM_MBEDTLS}', '', d)}"
 LIC_FILES_CHKSUM=" file://docs/license.rst;md5=83b7626b8c7a37263c6a58af8d19bee1"
and the license checksum verification on 'license.rst' being sometimes skipped.

Signed-off-by: Johannes Schneider <johannes.schneider@leica-geosystems.com>
---
 meta/classes-global/license.bbclass | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)


base-commit: 6ce19709f7835ee5cd7915e181f89397975236c8

Comments

Richard Purdie Feb. 7, 2026, 8:53 a.m. UTC | #1
On Sat, 2026-02-07 at 00:28 +0000, Johannes Schneider wrote:
> Add 'expand=True' to directly resolve file checksums that are added
> conditionally with inline python code.
> 
> Otherwise it can happend that the license.bbclass still sees the
> un-expanded values and either misses or even skipps adjacent licenses.
> 
> E.g. an unvaforable combination of
> LIC_FILES_CHKSUM += "file://docs/license.rst;md5=83b7626b8c7a37263c6a58af8d19bee1"
> LIC_FILES_CHKSUM:append = "${@bb.utils.contains('TFA_MBEDTLS', '1', ' ${LIC_FILES_CHKSUM_MBEDTLS}', '', d)}"
> 
> would lead to a
>  # pre-expansion value:
>  #   " file://docs/license.rst;md5=83b7626b8c7a37263c6a58af8d19bee1${@bb.utils.contains('TFA_MBEDTLS', '1', ' ${LIC_FILES_CHKSUM_MBEDTLS}', '', d)}"
>  LIC_FILES_CHKSUM=" file://docs/license.rst;md5=83b7626b8c7a37263c6a58af8d19bee1"
> and the license checksum verification on 'license.rst' being sometimes skipped.
> 
> Signed-off-by: Johannes Schneider <johannes.schneider@leica-geosystems.com>
> ---
>  meta/classes-global/license.bbclass | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/meta/classes-global/license.bbclass b/meta/classes-global/license.bbclass
> index af5f1ed41d..62116ba31d 100644
> --- a/meta/classes-global/license.bbclass
> +++ b/meta/classes-global/license.bbclass
> @@ -125,7 +125,7 @@ def find_license_files(d):
>      from collections import defaultdict, OrderedDict
>  
>      # All the license files for the package
> -    lic_files = d.getVar('LIC_FILES_CHKSUM') or ""
> +    lic_files = d.getVar('LIC_FILES_CHKSUM', expand=True) or ""
>      pn = d.getVar('PN')
>      # The license files are located in S/LIC_FILE_CHECKSUM.
>      srcdir = d.getVar('S')

This is a little strange as expand has been the default value for a
long time. On a modern code base, this should therefore be the default
and the change would make no difference. 

Was this an issue you were seeing on an older release?

Cheers,

Richard
SCHNEIDER Johannes Feb. 7, 2026, 5:29 p.m. UTC | #2
Hoi


>
> On Sat, 2026-02-07 at 00:28 +0000, Johannes Schneider wrote:
> > Add 'expand=True' to directly resolve file checksums that are added
> > conditionally with inline python code.
> >
> > Otherwise it can happend that the license.bbclass still sees the
> > un-expanded values and either misses or even skipps adjacent licenses.
> >
> > E.g. an unvaforable combination of
> > LIC_FILES_CHKSUM += "file://docs/license.rst;md5=83b7626b8c7a37263c6a58af8d19bee1"
> > LIC_FILES_CHKSUM:append = "${@bb.utils.contains('TFA_MBEDTLS', '1', ' ${LIC_FILES_CHKSUM_MBEDTLS}', '', d)}"
> >
> > would lead to a
> >  # pre-expansion value:
> >  #   " file://docs/license.rst;md5=83b7626b8c7a37263c6a58af8d19bee1${@bb.utils.contains('TFA_MBEDTLS', '1', ' ${LIC_FILES_CHKSUM_MBEDTLS}', '', d)}"
> >  LIC_FILES_CHKSUM=" file://docs/license.rst;md5=83b7626b8c7a37263c6a58af8d19bee1"
> > and the license checksum verification on 'license.rst' being sometimes skipped.
> >
> > Signed-off-by: Johannes Schneider <johannes.schneider@leica-geosystems.com>
> > ---
> >  meta/classes-global/license.bbclass | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/meta/classes-global/license.bbclass b/meta/classes-global/license.bbclass
> > index af5f1ed41d..62116ba31d 100644
> > --- a/meta/classes-global/license.bbclass
> > +++ b/meta/classes-global/license.bbclass
> > @@ -125,7 +125,7 @@ def find_license_files(d):
> >      from collections import defaultdict, OrderedDict
> >
> >      # All the license files for the package
> > -    lic_files = d.getVar('LIC_FILES_CHKSUM') or ""
> > +    lic_files = d.getVar('LIC_FILES_CHKSUM', expand=True) or ""
> >      pn = d.getVar('PN')
> >      # The license files are located in S/LIC_FILE_CHECKSUM.
> >      srcdir = d.getVar('S')
>
> This is a little strange as expand has been the default value for a
> long time. On a modern code base, this should therefore be the default
> and the change would make no difference.
>

of the default i wasn't aware of (or checked ... my bad)
My train of thought was that bitbake expands variables lazily and
thought/remembered (wrongly) that this leads to edge cases with in-line python.

>
> Was this an issue you were seeing on an older release?
>

indeed, we ran into this with a 'scarthgap' setup
(oe-core and meta-oe on scarthgap; bitbake at 2.8)
so not that old :-S

More investigation later: it was neither variable expansion nor sstate - but a
change in our ci setup that i didn't get wind of; previously the do_populate_lic
task simply wasn't triggered - now it is, and it promptly steped on an old
landmine = a wrong checksum.

Please disregard this patch => sorry for the noise! :-S

>
> Cheers,
>
> Richard
>

gruß
Johannes
diff mbox series

Patch

diff --git a/meta/classes-global/license.bbclass b/meta/classes-global/license.bbclass
index af5f1ed41d..62116ba31d 100644
--- a/meta/classes-global/license.bbclass
+++ b/meta/classes-global/license.bbclass
@@ -125,7 +125,7 @@  def find_license_files(d):
     from collections import defaultdict, OrderedDict
 
     # All the license files for the package
-    lic_files = d.getVar('LIC_FILES_CHKSUM') or ""
+    lic_files = d.getVar('LIC_FILES_CHKSUM', expand=True) or ""
     pn = d.getVar('PN')
     # The license files are located in S/LIC_FILE_CHECKSUM.
     srcdir = d.getVar('S')