Don't match the core snap to the host in cleanbuild environments

With regard to Cleanbuild remote on pi grabs wrong arch lxc image

Snapcraft assumes the user wants to match the core snap in an LXD container to the same version as the host. It does this currently by injecting the host-side copy into the container which caused the problem above where the build environment was using a different architecture. In my opinion the solution to restrict the injection is not the correct choice. We should NOT be injecting at all, because most people using snapcraft to build snaps will not be testing various builds of core nor snapcraft itself.

The documentation says that cleanbuild will “Create a snap using a pristine environment managed by lxd”, which in my mind means that nothing from the host will “leak” into the LXD container. Currently, we are leaking the core and snapcraft into the container, which means that builds are unpredictable leading to situations where “it builds on my machine, but the build service doesn’t work”.

Snapcraft should:

  • Default to not matching ANYTHING to the host when using LXD containers.
    • core should be refreshed from the store, not injected from the host.
    • snapcraft should be installed from the snap store, not injected from the host.
  • Allow overriding the default behaviour above:
    • Provide a commandline switch to allow choosing the core snap channel to refresh in the container for people who know they really do want a different version than the stable channel.
    • Provide a commandline switch to allow choosing a different channel for the snapcraft installation from the store.
    • Provide a commandline switch to inject the core snap from the host system for developers of the core snap or snapcraft to test local changes.
    • Provide a commandline switch to inject the snapcraft from the host system for developers of snapcraft to test local changes.

Thanks for translating the irc conversation into a forum post so everyone gets a read.

I do believe that if revnos match what is on the store, we should inject as it saves a download path, we also add the assertion so we know it is the correct snap that you would download anyways.

WRT to the second bullet, we really want a very polished story for application developers themselves and not so much one for developers of snapcraft, the bases or snapd which we will look into future steps.