Sharing local plugins across snaps

Is there a way to share local plugins across snaps? Sometimes you want to re-use them in more than one snap, in that case you would ideally want them in their own separate repository so any snap using it can benefit immediately from changes. Although calling them “local” if this can be done would not be that accurate anymore :slight_smile:

@ondra ^^

If this is git, is using submodules out of the equation?

Thanks, that is a good suggestion. I did a quick try and git submodules can do the trick, if putting the plugin in the root of a repo and then adding to the target repo with:

git submodule add <plugin_repo.git> snap/plugins/
git commit -am "Add plugin as submodule"

Then I can clone everything elsewhere with

git clone --recurse-submodules <my_repo.git>

This can work in my use case, but I feel it is limited too:

  • It would not be possible to use local plugins from more that one source
  • You need to explicitly clone with the --recurse-submodules option or init/update the submodules. There is no easy way to warn developers from snapcraft.yaml if they forgot or did not know about that (this is a generic problem with git submodule I think: the submodule.recurse config option does not apply to git clone)
  • I wonder if www.snapcraft.io will use --recurse-submodules by default when building a snap (it probably should if it is not doing it already)

So a solution integrated with snapcraft would still be interesting, I think.

One possibility would be to clone your submodules to some other path, and then add symlinks in snap/plugins to the Python files within the submodules.

1 Like