Ignore building a stale part

Say I have a snapcraft.yaml file with two parts, “core” and “config”. The “core” part comprises my source code and takes 30 minutes to build from scratch. The “config” part comprises some custom command wrapper files.

In the latest version of snapcraft (2.43.1), I am now alerted if the “core” part is stale and it requires me to clean it before performing a new build. Older versions of snapcraft didn’t detect that the “core” part was stale, so I could choose not to clean it if I wanted to just to build the “config” part. Now, I have to clean the “core” part and wait 30 minutes just so that I can test a small config change. Is there anyway around this now?

I suppose I could copy the “core” source files into an intermediate folder that snapcraft uses only when I want to build it, but that seems like a bit of a hack.

The parts shouldn’t become stale unless snapcraft found a reason to make it be, what is your part’s source key’s value?

It is the folder that I do all my dev work in.

If the parts don’t depend on each other and you were using snap try prime to test it, you can just run snapcraft prime config to prime it, which should ignore the core part. That is a workaround though, snapcraft wasn’t really designed to create a snap that it knows doesn’t represent the current state of the code on which it’s based.

That said, what kind of part is core? Snapcraft shouldn’t be building it from scratch every time, assuming the plugin being used supports re-using already built bits (e.g. cmake, make). Or are we talking significant-enough changes that it doesn’t matter?

The parts don’t depend on each other. core is a part that doesn’t use a plugin (“nil”), rather makes use of a scriptlet in override-build. The scriptlet is similar to the python plugin, but uses pipenv to build a virtual environment into the snap instead of using requirements.txt. There is also a custom python c extension that needs to be built. All this is being performed on an ARM hence the much longer build times.

nil plugin is made for parts that has no source, you might want to use the dump plugin instead.