Package a bash script as a snap?

Is it possible to package a bash script as a snap? If so, how can this be done?

I’ve seen the “Building your first Snap” section of https://snapcraft.io/, but it doesn’t say anything about bash.

I don’t recall ever doing it, but I don’t see why it’s not possible. I’d follow the pre-built but instead of having a source: which is an upstream binary tarball, maybe link to a directory containing your shell script. Make the apps: section point to the script inside the snap.

1 Like

I’d just use the dump plugin. Put your script under a scripts/ subdirectory and have that directory as the source for the dump plugin. Remember to add stage-packages for anything your bash script calls which isn’t already in the core snap.

1 Like

here is an example …

1 Like

Thanks. That’s useful. I’ve been able to package the snap, and it runs, but it doesn’t seem to have permission to execute other scripts. This seems helpful: https://docs.snapcraft.io/build-snaps/parts