Snap for lspci functionality in arm64

Hi, I am trying to build an snap for “lspci” command. snapcraft.yaml is as mentioned below.

base: core22
version: '0.1'

summary: List PCI devices on Ubuntu Core
description: |
  The lspci command as a snap

grade: stable
confinement: strict

architectures:
  - build-on: [amd64, arm64]
    build-for: arm64

apps:
  lspci:
    command: usr/bin/lspci
    plugs:
      - hardware-observe

parts:
  lspci:
    source: http://ports.ubuntu.com/pool/main/p/pciutils/pciutils_3.6.4-1ubuntu0.20.04.1_arm64.deb
    plugin: dump
    source-type: deb
    override-build: |
      craftctl default

directory structure for the same is as below

khalid@ubuntu20:lscpi$ tree .

└── snap

└── snapcraft.yaml

1 directory, 1 file

When I try to build snap, using below mentioned command

sudo snapcraft --target-arch=arm64 --enable-experimental-target-arch --destructive-mode

I got logs which are as follows.

khalid@ubuntu20:lscpi$ sudo snapcraft --target-arch=arm64 --enable-experimental-target-arch --destructive-mode
Executed: pull lspci                                                                                                         
Executed: overlay lspci                                                                                                      
Executed: build lspci                                                                                                        
Executed: stage lspci                                                                                                        
Executed: prime lspci                                                                                                        
Executed parts lifecycle                                                                                                     
Generated snap metadata                                                                                                      
Running linter: library                                                                                                      
	not a dynamic executable
	not a dynamic executable
	not a dynamic executable
	not a dynamic executable
Lint warnings:                                                                                                               
- library: usr/bin/lspci: missing dependency 'libc.so.6'.                                                                    
- library: usr/bin/lspci: missing dependency 'libkmod.so.2'.                                                                 
- library: usr/bin/lspci: missing dependency 'libpci.so.3'.                                                                  
- library: usr/bin/setpci: missing dependency 'libc.so.6'.                                                                   
- library: usr/bin/setpci: missing dependency 'libpci.so.3'.                                                                 
Created snap package lspci_0.1_arm64.snap        

Due to above mentioned dependency missing, when I install and try to execute lspci command from generated snap on arm based device, It throws error which is

khalid@ubuntu22:~$ snap connect lspci:hardware-observe
khalid@ubuntu22:~$ sudo lspci
/snap/lspci/x1/usr/bin/lspci: error while loading shared libraries: libpci.so.3: cannot open shared object file: No such file or directory

Please suggest the solution. Thanks in Advance!!

Looks like you are missing libpci.so.3 which is in the libpci3 package.

Rewrite your part and use a stage-packages entry instead of hardcoding an url to a specific deb file…that will resolve dependencies for you…

(and give you security updates on rebuild)