Moving the state files of snapcraft parts to snap/.snapcraft


This topic is a continuation from this one, where we agreed about saving the global state of snapcraft (things like global build-packages, grade, version, lxc image) to the file snap/.snapcraft/state.

Currently, snapcraft saves also state files for each part and for each step. We save in there data that’s relevant to know if a part has been changed on a way that requires the step to be re-run (like stage-packages, filesets, filters), and data that will be recorded in the build manifest of the resulting snap for auditing and to enable reproducible builds.

So, if we have a part called example-part, after snapcraft finishes the build it will have created the files:

  • parts/example-part/state/pull
  • parts/example-part/state/build
  • parts/example-part/state/stage
  • parts/example-part/state/prime

These state files are something that the user shouldn’t touch, ever, so they should be less visible. We want to move everything that’s snapcraft internal to the directory snap/.snapcraft. Now we just have to agree on the location for part-step-state files.

There are many options. The ones I like are:

  • snap/.snapcraft/{part-name}/{step-name} (snap/.snapcraft/example-part/pull)
  • snap/.snapcraft/{part-name}.{step-name}.state (snap/.snapcraft/example-part.pull.state)

(If you have other preference, please mention it in the comments)

I’m more inclined to the first one, but that might be because I tend to like a lot of directories after my dark past in the Java world.

I’m opening this topic in case somebody has a strong opinion in favour of one of the options, or a good reason to avoid one of them. Please let us know your opinion.


@elopio Has anything happened about this since?

I find it a bit awkward to have all those state files. The more natural option to me is the one I had described in the previous related topic, with .snapcraft.state under the part, and without having several files to track the same state. 10 parts would end up with 50 files? Seems unnecessary.

1 Like