Ubuntu commands in snap

How do I enable/put certain unix commands into my snap? My application currently does an

lspci | grep someHardware

to determine what to do based on hardware present. I noticed it always failed, so I launched it with

snap run --shell myapp

I discovered lspci is not a valid command. How do I go about adding it to my snap?

The source code for lspci and other utilities can be found on github. You could build that as a part. Alternatively you could stage it from the deb in the Ubuntu archive.

$ dpkg -S `which lspci`
pciutils: /usr/bin/lspci

This tells you the lspci command is in the pciutils deb. So use:-

  - pciutils

However Iā€™m not sure it will work, as your application will be confined, and may not be able to see the PCI devices.

1 Like

I followed your advice and added pciutils to stage-packages and it appears to have worked. Thanks!