How to package a plugin that will work on Snap
Special actions need to be taken in order for plug-ins work on the Linux Snap version of GIMP. Specifically, they should be packaged as a “content” snap. This is due to Snap’s sandboxing, for example. From start, they needs:
- snapcraft.yaml
- add-ld-library-path
- Plug-in source code
Configuring the ‘content’ snap manifest
The Snap package that we will create is a content producer snap (being gimp the content consumer snap through gimp-plugins plug), which should have the following snapcraft.yaml in the root folder:
name: PLUG-IN-NAME-WITHOUT-SYMBOLS-OR-SPACES
title: PLUG-IN-NAME
summary: PLUG-IN-NAME GIMP Plugin
description: PLUG-IN-DESC
website: PLUG-IN-REPO-URL
license: PLUG-IN-LICENSE
version: PLUG-IN-RELEASE-VERSION
grade: stable
base: SDK-VERSION
compression: lzo
confinement: strict
platforms:
arm64:
amd64:
slots:
gimp-plugins:
interface: content
content: gimp-plugins-MAJOR
source:
read:
- $SNAP/PLUG-IN-NAME-WITHOUT-SYMBOLS-OR-SPACES.conf
- $SNAP/PLUG-IN-NAME-WITHOUT-SYMBOLS-OR-SPACES
apps:
dummy-PLUG-IN-NAME-WITHOUT-SYMBOLS-OR-SPACES:
command: "PATH_TO_PLUG-IN"
extensions: [gnome]
parts:
add-ld-library-path:
plugin: dump
source: PLUG-IN-NAME-WITHOUT-SYMBOLS-OR-SPACES.conf/
organize:
add-ld-library-path: PLUG-IN-NAME-WITHOUT-SYMBOLS-OR-SPACES.conf/add-ld-library-path
PLUG-IN-NAME-WITHOUT-SYMBOLS-OR-SPACES:
organize:
usr/lib/$CRAFT_ARCH_TRIPLET_BUILD_FOR: PLUG-IN-NAME-WITHOUT-SYMBOLS-OR-SPACES/libs
build-snaps:
- gimp
etc...
Change MAJOR
to the GIMP API version your plugin supports, which
should correspond to the same plugs:gimp-plugins:content: on
GIMP snap manifest.
SDK-VERSION
should correspond to core:.
Then, set the PLUG-IN-NAME-WITHOUT-SYMBOLS-OR-SPACES
and
other metadata accordingly, and configure the parts:
section
following your build needs.
Creating the add-ld-library-path file
The only asset needed by an content producer snap is the add-ld-library-path file. This is a conventional file that works similarly to Flatpak’s “add-extensions”.“add-ld-path” but on the plug-in side.
So, create a folder named PLUG-IN-NAME-WITHOUT-SYMBOLS-OR-SPACES.conf
in the same dir
as the snapcraft.yaml file and put the add-ld-library-path
file there.
It should contain the following line:
PLUG-IN-NAME-WITHOUT-SYMBOLS-OR-SPACES/libs
Packaging the .snap
Continuing, in the manifest folder, build and package the plug-in this way:
sudo snapcraft pack --destructive-mode --verbosity=verbose
Note that we chose --destructive-mode
for convenience. Remove it if
you are not running on an Ubuntu-based distro with the target SDK-VERSION.
Now, if necessary, test the package installing it:
sudo snap install --dangerous PLUG-IN-NAME-WITHOUT-SYMBOLS-OR-SPACES*_$(dpkg --print-architecture).snap
Distributing with Snap Store
Typically, your plugin may continue to get new features and bug fixes. And the easiest way to ensure this for the users is to distribute it on Snap Store, the same repository that distributes GIMP Snap.
Take a look at the Snap submission guidelines and, to save your time in the future, we recommend mimic the GIMP Snap distribution script.