There may be times that a snap needs to expose a larger number of commands, for example, in the case of a toolkit or when snapping a utility package like linux-tools
. The current snapcraft.yaml schema supports this by adding multiple individual commands, one for each executable. This can result in a large snapcraft.yaml file such as graphics-test-tools/snap/snapcraft.yaml. For development, I find it easier to just dump the packages and then run the tools directly using snap run --shell
. There can be some shell script trickery using a single meta command, but none of these are ideal.
Trying to find a more efficient alternative, I got some suggestions from AI using commands
keyword but I think that’s made-up as I can’t find any references to it!
Having such an apps.<app-name>.commands
, or alternatively extending command
to also take a dictionary array of commands as input would be useful to quickly add multiple commands and keep the yaml file brief:
apps:
linux-tools-common:
commands:
- acpidbg: usr/bin/acpidbg
- cpupower: usr/bin/cpupower
- perf: usr/bin/perf
- turbostat: usr/bin/turbostat
- usbip: usr/bin/usbip
- usbipd: usr/bin/usbipd
- x86_energy_perf_policy: usr/bin/x86_energy_perf_policy
- bpftool: usr/sbin/bpftool
Example to run perf: $ linux-tools-common.perf