We call state tracking when we save information about what snapcraft is doing to package the snap.
Currently we have state tracking for parts. We put in there things like the source, the build and stage packages installed, and specifics of the plugin like the python and npm packages. It is saved in directories like parts/part-name/state
. It is useful to identify when the snapcraft.yaml
changes and a part needs to be cleaned, and later to record all that happened during the build and keep it in prime/snap/snapcraft.yaml
for auditing and reproducible builds.
Now we need also a place to save information about global state. In here we will put things like the lxc image used during cleanbuild and the snapcraft version. We are also thinking of moving here build-packages, because they are installed before any part is pulled, thus affecting all the parts.
After a short discussion with @kyrofa, I think that a good place for this information would be in the file snap/state/global
.
Update: following @niemeyer’s suggestion, the path will be snap/.snapcraft/state
.
It’s good that it’s inside the snap directory, because if we put it outside it’s very likely that some projects will already have a directory called state. We then would have to use something more obscure, like .state
or snapcraft-state
. Another option was to put it in parts
, but we have the same problem that we could have a part called state
, and again would have to obscure the dir name by using something that is not valid as a part name. And the last point to support putting it in snap
is that we will move the other snapcraft directories there (hopefully soon) in the future.
Now, I’m not sure what to do for projects that don’t have a snap
directory, the ones that just put their snapcraft.yaml
in the root. I guess it would be pretty harmless to create that snap directory, and it will be useful for the future migration of the other directories anyway.
I’m going to start implementing this right now to solve a little mess we have for tracking build packages. So if you have suggestions, or you think I missed a potential downside of using snap/state/global
, please let me know.