many: generalize assertstate.Batch to asserts.Batch, have assertstate.AddBatch
This generalizes assertstate.Batch to asserts.Batch which grows a bit more functionality. To achieve the same result, assertstate.AddBatch subsuming assertstate.Batch.Precheck/Commit is introduced.
doFetch in assertstate is also switched to use asserts.Batch which can be built by fetching for convenience.
The fallback code for dealing with receiving unsupported format assertions, which should not happen except for bugs, is reorganized.
The mkversion script is used during the build of the snapd snap.
Today its a bit naive and just uses "git describe" there to
generate the version number. The downside of this is that for
pre-releases like 2.41~pre1 we may end up with a version number
lower than the version in debian/changelog if the pre release
does not have a git tag. We historically don't tag pre/rc
releases and doing so would be a bit messy (IMO) so we need
a less naive approach to generate the version number.
This PR changes the mkversion.sh script to use something
similar to what a packaging recipe does to construct a version.
On the current master this will yield:
2.41~pre1+git906.g45df4b1
instead of
2.40+git872.gf9b531f
Which is what we want.
* mkversion.sh: use dpkg-parsechangelog only when it is available
store, image, cmd: make 'snap download' leave partials
Without this change, a network error during a 'snap download' will
remove the .partial file.
While this is probably OK for snapd, as it's the simpler & safer
route¹, it's not OK for 'snap download'; the .partial should be left
so that a following 'snap download' will resume, as the user can see
and remove the file if needed.
So, this change adds a LeavePartialOnError to store.DownloadOptions,
exports it through image.DownloadOptions, and sets that to true in
cmd_download.
Also note, it explicitly makes sure it doesn't leave _empty_ partial
files, as those would just be noise.
----
1. We might want to revisit what we do in snapstate so that there also
we can resume, but it needs careful consideraiton of available space
and removing stale partial files, which is one of the hard problems.