diff mbox series

[meta-oe] fwupd: set vendor_ids_dir

Message ID 20250714134657.1620685-1-martin.jansa@gmail.com
State Accepted
Headers show
Series [meta-oe] fwupd: set vendor_ids_dir | expand

Commit Message

Martin Jansa July 14, 2025, 1:46 p.m. UTC
From: Martin Jansa <martin.jansa@gmail.com>

* it's in RSS as fwupd/2.0.12/recipe-sysroot/usr/share/hwdata/usb.ids but
  meson is searching the paths on host with:

  # look for usb.ids in both of the Debian and Fedora locations,
  # and fall back to the system datadir in case we're building in a venv or prefix
  vendor_ids_dir = get_option('vendor_ids_dir')
  if vendor_ids_dir == ''
    vendor_ids_dir = join_paths(datadir, 'misc')
    if not fs.is_file(join_paths(vendor_ids_dir, 'usb.ids'))
      vendor_ids_dir = join_paths(datadir, 'hwdata')
    endif
    if not fs.is_file(join_paths(vendor_ids_dir, 'usb.ids'))
      vendor_ids_dir = '/usr/share/hwdata'
    endif
    if not fs.is_file(join_paths(vendor_ids_dir, 'usb.ids'))
      vendor_ids_dir = '/usr/share/misc'
    endif
    if not fs.is_file(join_paths(vendor_ids_dir, 'usb.ids'))
      vendor_ids_dir = '/usr/local/var/homebrew/linked/usb.ids/share/misc'
    endif
    if not fs.is_file(join_paths(vendor_ids_dir, 'usb.ids'))
      error('could not auto-detect -Dvendor_ids_dir=')
    endif
  endif
  conf.set_quoted ('FWUPD_DATADIR_VENDOR_IDS', vendor_ids_dir)

  it shouldn't be looking at host's paths and and on hosts without
  usb.ids in one of these locations it fails with:

  ../sources/fwupd-2.0.12/meson.build:323:4: ERROR: Problem encountered: could not auto-detect -Dvendor_ids_dir=

Signed-off-by: Martin Jansa <martin.jansa@gmail.com>
---
 meta-oe/recipes-bsp/fwupd/fwupd_2.0.12.bb | 2 ++
 1 file changed, 2 insertions(+)

Comments

Mikko Rapeli July 14, 2025, 1:52 p.m. UTC | #1
Hi,

On Mon, Jul 14, 2025 at 03:46:57PM +0200, martin.jansa@gmail.com wrote:
> From: Martin Jansa <martin.jansa@gmail.com>
> 
> * it's in RSS as fwupd/2.0.12/recipe-sysroot/usr/share/hwdata/usb.ids but
>   meson is searching the paths on host with:
> 
>   # look for usb.ids in both of the Debian and Fedora locations,
>   # and fall back to the system datadir in case we're building in a venv or prefix
>   vendor_ids_dir = get_option('vendor_ids_dir')
>   if vendor_ids_dir == ''
>     vendor_ids_dir = join_paths(datadir, 'misc')
>     if not fs.is_file(join_paths(vendor_ids_dir, 'usb.ids'))
>       vendor_ids_dir = join_paths(datadir, 'hwdata')

Isn't this the same as ${datadir}/hwdata ?

Cheers,

-Mikko

>     endif
>     if not fs.is_file(join_paths(vendor_ids_dir, 'usb.ids'))
>       vendor_ids_dir = '/usr/share/hwdata'
>     endif
>     if not fs.is_file(join_paths(vendor_ids_dir, 'usb.ids'))
>       vendor_ids_dir = '/usr/share/misc'
>     endif
>     if not fs.is_file(join_paths(vendor_ids_dir, 'usb.ids'))
>       vendor_ids_dir = '/usr/local/var/homebrew/linked/usb.ids/share/misc'
>     endif
>     if not fs.is_file(join_paths(vendor_ids_dir, 'usb.ids'))
>       error('could not auto-detect -Dvendor_ids_dir=')
>     endif
>   endif
>   conf.set_quoted ('FWUPD_DATADIR_VENDOR_IDS', vendor_ids_dir)
> 
>   it shouldn't be looking at host's paths and and on hosts without
>   usb.ids in one of these locations it fails with:
> 
>   ../sources/fwupd-2.0.12/meson.build:323:4: ERROR: Problem encountered: could not auto-detect -Dvendor_ids_dir=
> 
> Signed-off-by: Martin Jansa <martin.jansa@gmail.com>
> ---
>  meta-oe/recipes-bsp/fwupd/fwupd_2.0.12.bb | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/meta-oe/recipes-bsp/fwupd/fwupd_2.0.12.bb b/meta-oe/recipes-bsp/fwupd/fwupd_2.0.12.bb
> index e25fbe1f54..eb43c3d865 100644
> --- a/meta-oe/recipes-bsp/fwupd/fwupd_2.0.12.bb
> +++ b/meta-oe/recipes-bsp/fwupd/fwupd_2.0.12.bb
> @@ -37,6 +37,8 @@ GIDOCGEN_MESON_DISABLE_FLAG = 'disabled'
>  GIR_MESON_ENABLE_FLAG = 'enabled'
>  GIR_MESON_DISABLE_FLAG = 'disabled'
>  
> +EXTRA_OEMESON = "-Dvendor_ids_dir=${datadir}/hwdata"
> +
>  PACKAGECONFIG ??= "\
>      ${@bb.utils.contains('DISTRO_FEATURES', 'systemd', 'systemd', '', d)} \
>      ${@bb.utils.contains('PTEST_ENABLED', '1', 'tests', '', d)} \
Martin Jansa July 14, 2025, 2 p.m. UTC | #2
On Mon, Jul 14, 2025 at 3:52 PM Mikko Rapeli <mikko.rapeli@linaro.org> wrote:
>
> Hi,
>
> On Mon, Jul 14, 2025 at 03:46:57PM +0200, martin.jansa@gmail.com wrote:
> > From: Martin Jansa <martin.jansa@gmail.com>
> >
> > * it's in RSS as fwupd/2.0.12/recipe-sysroot/usr/share/hwdata/usb.ids but
> >   meson is searching the paths on host with:
> >
> >   # look for usb.ids in both of the Debian and Fedora locations,
> >   # and fall back to the system datadir in case we're building in a venv or prefix
> >   vendor_ids_dir = get_option('vendor_ids_dir')
> >   if vendor_ids_dir == ''
> >     vendor_ids_dir = join_paths(datadir, 'misc')
> >     if not fs.is_file(join_paths(vendor_ids_dir, 'usb.ids'))
> >       vendor_ids_dir = join_paths(datadir, 'hwdata')
>
> Isn't this the same as ${datadir}/hwdata ?

It is the same value, but on my host, I don't have
/usr/share/hwdata/usb.ids so meson doesn't detect any existing
vendor_ids_dir value and fails.

With this change it accepts passed vendor_ids_dir value without
testing it's existence (neither on host nor in RSS).

Cheers,
Mikko Rapeli July 14, 2025, 2:31 p.m. UTC | #3
Hi,

On Mon, Jul 14, 2025 at 04:00:03PM +0200, Martin Jansa wrote:
> On Mon, Jul 14, 2025 at 3:52 PM Mikko Rapeli <mikko.rapeli@linaro.org> wrote:
> > On Mon, Jul 14, 2025 at 03:46:57PM +0200, martin.jansa@gmail.com wrote:
> > > From: Martin Jansa <martin.jansa@gmail.com>
> > >
> > > * it's in RSS as fwupd/2.0.12/recipe-sysroot/usr/share/hwdata/usb.ids but
> > >   meson is searching the paths on host with:
> > >
> > >   # look for usb.ids in both of the Debian and Fedora locations,
> > >   # and fall back to the system datadir in case we're building in a venv or prefix
> > >   vendor_ids_dir = get_option('vendor_ids_dir')
> > >   if vendor_ids_dir == ''
> > >     vendor_ids_dir = join_paths(datadir, 'misc')
> > >     if not fs.is_file(join_paths(vendor_ids_dir, 'usb.ids'))
> > >       vendor_ids_dir = join_paths(datadir, 'hwdata')
> >
> > Isn't this the same as ${datadir}/hwdata ?
> 
> It is the same value, but on my host, I don't have
> /usr/share/hwdata/usb.ids so meson doesn't detect any existing
> vendor_ids_dir value and fails.
> 
> With this change it accepts passed vendor_ids_dir value without
> testing it's existence (neither on host nor in RSS).

Previous version of fwupd update patches did not include "hwdata"
as build dependency so recipe sysroot did not have usb.ids file
but now it should have. Then meson.bbclass is setting datadir
so I'm wondering if there is a bug in meson.bbclass or in these fwupd
side scripts that they only check the host paths on not the
recipe sysroot ones? Is fwupd not using the correct variables?

Should the fwupd meson config actually check if the file is in
join_paths(sys_root, datadir, 'hwdata')?

I'm fine with this change but just wondering if there is something more
missing. 

Cheers,

-Mikko
Martin Jansa July 14, 2025, 3:12 p.m. UTC | #4
On Mon, Jul 14, 2025 at 4:31 PM Mikko Rapeli <mikko.rapeli@linaro.org> wrote:
>
> Hi,
>
> On Mon, Jul 14, 2025 at 04:00:03PM +0200, Martin Jansa wrote:
> > On Mon, Jul 14, 2025 at 3:52 PM Mikko Rapeli <mikko.rapeli@linaro.org> wrote:
> > > On Mon, Jul 14, 2025 at 03:46:57PM +0200, martin.jansa@gmail.com wrote:
> > > > From: Martin Jansa <martin.jansa@gmail.com>
> > > >
> > > > * it's in RSS as fwupd/2.0.12/recipe-sysroot/usr/share/hwdata/usb.ids but
> > > >   meson is searching the paths on host with:
> > > >
> > > >   # look for usb.ids in both of the Debian and Fedora locations,
> > > >   # and fall back to the system datadir in case we're building in a venv or prefix
> > > >   vendor_ids_dir = get_option('vendor_ids_dir')
> > > >   if vendor_ids_dir == ''
> > > >     vendor_ids_dir = join_paths(datadir, 'misc')
> > > >     if not fs.is_file(join_paths(vendor_ids_dir, 'usb.ids'))
> > > >       vendor_ids_dir = join_paths(datadir, 'hwdata')
> > >
> > > Isn't this the same as ${datadir}/hwdata ?
> >
> > It is the same value, but on my host, I don't have
> > /usr/share/hwdata/usb.ids so meson doesn't detect any existing
> > vendor_ids_dir value and fails.
> >
> > With this change it accepts passed vendor_ids_dir value without
> > testing it's existence (neither on host nor in RSS).
>
> Previous version of fwupd update patches did not include "hwdata"
> as build dependency so recipe sysroot did not have usb.ids file

and previous version wasn't failing like this, it started to fail only
after the upgrade as
https://github.com/fwupd/fwupd/commit/61a863de8dd429be8c393ec267d63db78de71b76#diff-30d8f6be6320feeacf686be94f48c70869b52630e01ea625f0f15adc0d57c3e4
was introduced in version 2.

The hwdata dependency added in v2 might not be needed, I guess it
should be runtime dependency for libfwupdplugin not build time.

> but now it should have. Then meson.bbclass is setting datadir
> so I'm wondering if there is a bug in meson.bbclass or in these fwupd
> side scripts that they only check the host paths on not the
> recipe sysroot ones? Is fwupd not using the correct variables?

Yes it checks the paths on host not in RSS as said in commit message.

> Should the fwupd meson config actually check if the file is in
> join_paths(sys_root, datadir, 'hwdata')?

Something like this might work, but not sure where you expect sys_root
to be defined. I see it added as a property by meson.bbclass, but
doing just this causes:
ERROR: Unknown variable "sys_root".
Martin Jansa July 14, 2025, 3:13 p.m. UTC | #5
On Mon, Jul 14, 2025 at 5:12 PM Martin Jansa <martin.jansa@gmail.com> wrote:
>
> On Mon, Jul 14, 2025 at 4:31 PM Mikko Rapeli <mikko.rapeli@linaro.org> wrote:
> >
> > Hi,
> >
> > On Mon, Jul 14, 2025 at 04:00:03PM +0200, Martin Jansa wrote:
> > > On Mon, Jul 14, 2025 at 3:52 PM Mikko Rapeli <mikko.rapeli@linaro.org> wrote:
> > > > On Mon, Jul 14, 2025 at 03:46:57PM +0200, martin.jansa@gmail.com wrote:
> > > > > From: Martin Jansa <martin.jansa@gmail.com>
> > > > >
> > > > > * it's in RSS as fwupd/2.0.12/recipe-sysroot/usr/share/hwdata/usb.ids but
> > > > >   meson is searching the paths on host with:
> > > > >
> > > > >   # look for usb.ids in both of the Debian and Fedora locations,
> > > > >   # and fall back to the system datadir in case we're building in a venv or prefix
> > > > >   vendor_ids_dir = get_option('vendor_ids_dir')
> > > > >   if vendor_ids_dir == ''
> > > > >     vendor_ids_dir = join_paths(datadir, 'misc')
> > > > >     if not fs.is_file(join_paths(vendor_ids_dir, 'usb.ids'))
> > > > >       vendor_ids_dir = join_paths(datadir, 'hwdata')
> > > >
> > > > Isn't this the same as ${datadir}/hwdata ?
> > >
> > > It is the same value, but on my host, I don't have
> > > /usr/share/hwdata/usb.ids so meson doesn't detect any existing
> > > vendor_ids_dir value and fails.
> > >
> > > With this change it accepts passed vendor_ids_dir value without
> > > testing it's existence (neither on host nor in RSS).
> >
> > Previous version of fwupd update patches did not include "hwdata"
> > as build dependency so recipe sysroot did not have usb.ids file
>
> and previous version wasn't failing like this, it started to fail only
> after the upgrade as
> https://github.com/fwupd/fwupd/commit/61a863de8dd429be8c393ec267d63db78de71b76#diff-30d8f6be6320feeacf686be94f48c70869b52630e01ea625f0f15adc0d57c3e4
> was introduced in version 2.
>
> The hwdata dependency added in v2 might not be needed, I guess it
> should be runtime dependency for libfwupdplugin not build time.
>
> > but now it should have. Then meson.bbclass is setting datadir
> > so I'm wondering if there is a bug in meson.bbclass or in these fwupd
> > side scripts that they only check the host paths on not the
> > recipe sysroot ones? Is fwupd not using the correct variables?
>
> Yes it checks the paths on host not in RSS as said in commit message.
>
> > Should the fwupd meson config actually check if the file is in
> > join_paths(sys_root, datadir, 'hwdata')?
>
> Something like this might work, but not sure where you expect sys_root
> to be defined. I see it added as a property by meson.bbclass, but
> doing just this causes:
> ERROR: Unknown variable "sys_root".

And if you change the meson.build like this then you would need to set
FWUPD_DATADIR_VENDOR_IDS without the sys_root prefix, because in
runtime it will be just ${datadir}/hwdata again.
Mikko Rapeli July 15, 2025, 6:37 a.m. UTC | #6
Hi,

On Mon, Jul 14, 2025 at 05:13:47PM +0200, Martin Jansa wrote:
> On Mon, Jul 14, 2025 at 5:12 PM Martin Jansa <martin.jansa@gmail.com> wrote:
> > On Mon, Jul 14, 2025 at 4:31 PM Mikko Rapeli <mikko.rapeli@linaro.org> wrote:
> > > On Mon, Jul 14, 2025 at 04:00:03PM +0200, Martin Jansa wrote:
> > > > On Mon, Jul 14, 2025 at 3:52 PM Mikko Rapeli <mikko.rapeli@linaro.org> wrote:
> > > > > On Mon, Jul 14, 2025 at 03:46:57PM +0200, martin.jansa@gmail.com wrote:
> > > > > > From: Martin Jansa <martin.jansa@gmail.com>
> > > > > >
> > > > > > * it's in RSS as fwupd/2.0.12/recipe-sysroot/usr/share/hwdata/usb.ids but
> > > > > >   meson is searching the paths on host with:
> > > > > >
> > > > > >   # look for usb.ids in both of the Debian and Fedora locations,
> > > > > >   # and fall back to the system datadir in case we're building in a venv or prefix
> > > > > >   vendor_ids_dir = get_option('vendor_ids_dir')
> > > > > >   if vendor_ids_dir == ''
> > > > > >     vendor_ids_dir = join_paths(datadir, 'misc')
> > > > > >     if not fs.is_file(join_paths(vendor_ids_dir, 'usb.ids'))
> > > > > >       vendor_ids_dir = join_paths(datadir, 'hwdata')
> > > > >
> > > > > Isn't this the same as ${datadir}/hwdata ?
> > > >
> > > > It is the same value, but on my host, I don't have
> > > > /usr/share/hwdata/usb.ids so meson doesn't detect any existing
> > > > vendor_ids_dir value and fails.
> > > >
> > > > With this change it accepts passed vendor_ids_dir value without
> > > > testing it's existence (neither on host nor in RSS).
> > >
> > > Previous version of fwupd update patches did not include "hwdata"
> > > as build dependency so recipe sysroot did not have usb.ids file
> >
> > and previous version wasn't failing like this, it started to fail only
> > after the upgrade as
> > https://github.com/fwupd/fwupd/commit/61a863de8dd429be8c393ec267d63db78de71b76#diff-30d8f6be6320feeacf686be94f48c70869b52630e01ea625f0f15adc0d57c3e4
> > was introduced in version 2.
> >
> > The hwdata dependency added in v2 might not be needed, I guess it
> > should be runtime dependency for libfwupdplugin not build time.
> >
> > > but now it should have. Then meson.bbclass is setting datadir
> > > so I'm wondering if there is a bug in meson.bbclass or in these fwupd
> > > side scripts that they only check the host paths on not the
> > > recipe sysroot ones? Is fwupd not using the correct variables?
> >
> > Yes it checks the paths on host not in RSS as said in commit message.
> >
> > > Should the fwupd meson config actually check if the file is in
> > > join_paths(sys_root, datadir, 'hwdata')?
> >
> > Something like this might work, but not sure where you expect sys_root
> > to be defined. I see it added as a property by meson.bbclass, but
> > doing just this causes:
> > ERROR: Unknown variable "sys_root".
> 
> And if you change the meson.build like this then you would need to set
> FWUPD_DATADIR_VENDOR_IDS without the sys_root prefix, because in
> runtime it will be just ${datadir}/hwdata again.

Right, so your patch is the way out for now. Thanks for checking this!

Cheers,

-Mikko
diff mbox series

Patch

diff --git a/meta-oe/recipes-bsp/fwupd/fwupd_2.0.12.bb b/meta-oe/recipes-bsp/fwupd/fwupd_2.0.12.bb
index e25fbe1f54..eb43c3d865 100644
--- a/meta-oe/recipes-bsp/fwupd/fwupd_2.0.12.bb
+++ b/meta-oe/recipes-bsp/fwupd/fwupd_2.0.12.bb
@@ -37,6 +37,8 @@  GIDOCGEN_MESON_DISABLE_FLAG = 'disabled'
 GIR_MESON_ENABLE_FLAG = 'enabled'
 GIR_MESON_DISABLE_FLAG = 'disabled'
 
+EXTRA_OEMESON = "-Dvendor_ids_dir=${datadir}/hwdata"
+
 PACKAGECONFIG ??= "\
     ${@bb.utils.contains('DISTRO_FEATURES', 'systemd', 'systemd', '', d)} \
     ${@bb.utils.contains('PTEST_ENABLED', '1', 'tests', '', d)} \