Parts/usbutils/insrtall is empty, prime fails

I’m trying to build a snap of usbutils based on this repo (My repo, which adds an install hook and refactors a few things, is here).

The primary difference is how it builds. It seems like the old repo is incomplete, so I copied the build instructions from usbutils.

So here’s my snapcraft.yaml:

name: usbutils
version: None
summary: USB utilities for Linux, including lsusb
description: |
  USB utilities for Linux, including lsusb. Make sure you connect the
  raw-usb and network-control interfaces with

  snap connect usbutils:network-control :network-control
  snap connect usbutils:raw-usb :raw-usb

  Though that should now be done for you ;)
grade: stable
confinement: strict

apps:
  lsusb:
    command: bin/lsusb
    plugs: [network-control, raw-usb]
  usb-devices:
    command: bin/usb-devices
    plugs: [raw-usb]
  # XXX only works in devmode; permission error with
  # `sudo usbutils.usbhid-dump`, but this should be granted by raw-usb?!
  # libusb: error [_get_usbfs_fd] libusb couldn't open USB device /dev/bus/usb/00m/00n: O
peration not permitted
  usbhid-dump:
    command: bin/usbhid-dump
    plugs: [network-control, raw-usb]

parts:
  usbutils:
    source: https://github.com/gregkh/usbutils.git
    plugin: autotools
    organize:
      usr/bin: bin
    build-packages: [libudev-dev, libusb-1.0-0-dev, pkg-config]
    override-build: |
      git submodule init
      git submodule update
      autoreconf --install --symlink
      ./configure
      make 
      make install

The issue, is that this gives me errors:

Sorry, an error occurred in Snapcraft:
Traceback (most recent call last):
  File "/usr/bin/snapcraft", line 11, in <module>
    load_entry_point('snapcraft==2.43.1+18.4', 'console_scripts', 'snapcraft')()
  File "/usr/lib/python3/dist-packages/click/core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/click/core.py", line 697, in main
    rv = self.invoke(ctx)
  File "/usr/lib/python3/dist-packages/click/core.py", line 1043, in invoke
    return Command.invoke(self, ctx)
  File "/usr/lib/python3/dist-packages/click/core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/lib/python3/dist-packages/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/click/decorators.py", line 17, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/usr/lib/python3/dist-packages/snapcraft/cli/_runner.py", line 93, in run
    ctx.forward(lifecyclecli.commands["snap"])
  File "/usr/lib/python3/dist-packages/click/core.py", line 553, in forward
    return self.invoke(cmd, **kwargs)
  File "/usr/lib/python3/dist-packages/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/snapcraft/cli/lifecycle.py", line 136, in snap
    project = _execute(steps.PRIME, parts=[], **kwargs)
  File "/usr/lib/python3/dist-packages/snapcraft/cli/lifecycle.py", line 35, in _execute
    lifecycle.execute(step, project_config, parts)
  File "/usr/lib/python3/dist-packages/snapcraft/internal/lifecycle/_runner.py", line 90, in execute
    executor.run(step, part_names)
  File "/usr/lib/python3/dist-packages/snapcraft/internal/lifecycle/_runner.py", line 196, in run
    self._create_meta(step, processed_part_names)
  File "/usr/lib/python3/dist-packages/snapcraft/internal/lifecycle/_runner.py", line 359, in _create_meta
    self.config.validator.schema,
  File "/usr/lib/python3/dist-packages/snapcraft/internal/meta/_snap_packaging.py", line 109, in create_snap_packaging
    packaging.write_snap_yaml()
  File "/usr/lib/python3/dist-packages/snapcraft/internal/meta/_snap_packaging.py", line 312, in write_snap_yaml
    snap_yaml = self._compose_snap_yaml()
  File "/usr/lib/python3/dist-packages/snapcraft/internal/meta/_snap_packaging.py", line 468, in _compose_snap_yaml
    snap_yaml["apps"] = self._wrap_apps(self._config_data["apps"])
  File "/usr/lib/python3/dist-packages/snapcraft/internal/meta/_snap_packaging.py", line 567, in _wrap_apps
    self._wrap_app(app, apps[app])
  File "/usr/lib/python3/dist-packages/snapcraft/internal/meta/_snap_packaging.py", line 575, in _wrap_app
    app[k] = self._wrap_exe(app[k], "{}-{}".format(k, name))
  File "/usr/lib/python3/dist-packages/snapcraft/internal/meta/_snap_packaging.py", line 546, in _wrap_exe
    with open(exepath, "rb") as exefile:
FileNotFoundError: [Errno 2] No such file or directory: '/home/wnilges/Documents/telig-ubuntu-core-updates/usbutils-snap/prime/bin/lsusb'
We would appreciate it if you created a bug report at
https://launchpad.net/snapcraft/+filebug with the above text included.

f7u12! But I found this thread which suggests that I just need to organize:

But, parts/usbutils/install is empty. That’s because usbutils seems to drop its builds into the base repo, which is in parts/usbutils/build.

$ ls
aclocal.m4      config.status  desc-dump.h  lsusb.c            lsusb.py         missing            usb-devices       usbmisc.h
autogen.sh      configure      install-sh   lsusb-desc-defs.o  lsusb.py.in      names.c            usb-devices.1     usbreset
autom4te.cache  configure.ac   LICENSES     lsusb-desc-dump.o  lsusb-t.c        names.h            usb-devices.1.in  usbreset.c
compile         depcomp        list.h       lsusb.h            lsusb-usbmisc.o  NEWS               usbhid-dump       usbreset.o
config.h        desc-defs.c    lsusb        lsusb-lsusb.o      Makefile         README.md          usbhid-dump.8     usb-spec.h
config.h.in     desc-defs.h    lsusb.8      lsusb-lsusb-t.o    Makefile.am      stamp-h1           usbhid-dump.8.in  usbutils.spdx
config.log      desc-dump.c    lsusb.8.in   lsusb-names.o      Makefile.in      travis-autogen.sh  usbmisc.c

Any ideas? What do I do about this? How can I get snapcraft to see the binaries?

have you checked prime/bin and prime/usr/bin … (or simply tried to call find prime/ -name '*lsusb*') ?
(my guess would be that the organize statement does not what you expect)

1 Like

You have an override-build. I suspect you need to correctly set the DESTDIR for make install to get it to install to the correct location.

Something like DESTDIR=$SNAPCRAFT_PART_INSTALL make install should do the trick.

1 Like

It definitely doesn’t :sweat_smile:

the only thing in prime is meta.

Just to confirm, DESTDIR=$SNAPCRAFT_PART_INSTALL make install worked for you? I gave it a test with that and base: core18 added - which did the trick.

Apologies, seems I forgot to reply!

Yes, I got it to build! Unfortunately, I can’t go into the office and test it this week because I’m still quarantined, but it does build!

Here’s the updated snapcraft.yaml