I am currently working on the snapd snap. While doing this work I noticed that snapcraft does not work well when the source code contains a ./snap directory.
In the snapd source tree this ./snap directory contains a bunch of our code that deals with snap packages. However snapcraft has code (in snapcraft/internal/sources/_local.py and snapcraft/internal/pluginhandler/__init__.py) that excludes SNAPCRAFT_FILES which includes the “snap” directory.
So the following:
parts:
snapd:
plugin: x-builddeb
source: .
will not work for snapd because the “./snap” par of the tree is missing in the exported ./parts/snapd/src directory.
For this particular project the “x-builddeb” plugin implements a workaround to unblock but I would love to hear feedback what is the right approach to deal with this. I tried to use “organize” but it seems this happens after pull.
As a strawman it might be nice to be able to tell snapcraft to use e.g. .snapcraft for all the plugin lifecycle directories.
The workaround in the custom snapd plugin stopped working. We still have the problem that our tree has a ./snap directory (which contains code about how to handle snap packages. But that dir name clashes with snapcraft and this causes the build to fail. Right now we cannot release the snapd 2.35.2 snap because of this.
I, too, like the idea of using a .snap/ or .snapcraft/ directory instead of snap/. Migrating everything there (plugins, hooks, etc.) would be rough though.