When a gadget is installed, we compare the previous gadget to detect
removed files and remove them. Preserved files that are removed from
content list are kept.
This is important to be able to remove old boot firmware since some,
like shim, change behavior depending of files that are present.
This does not support directories. If the gadget install directories
with content, the files in the directories will not be removed.
* o/snapstate,snap: introduce snap.SelfContainedSetPrereqTracker
It is meant to be used when dealing with a self-contained set of snaps, with no
desire to fetch further snaps, so all prerequisites must be present in the set
itself. This applies to first boot seeding and remodeling for example.
* many: use snap.SelfContainedSetPrereqTracker
also in snap.ValidateBasesAndProviders
these now can produce warnings, OTOH the relaxed checks allow to build/seed an
image even if a content requirement is fulfilled by an alternative provider
notice that with the relaxed checks seeding might fail or the system not work
if the right auto-connections or connections are not in-place
snaps used as default-providers usually have been taken care of already but it
might be up to the user to ask to set that up for alternative ones
* snap: clarify some names
* many: rename and clarify to PrereqTracker.MissingProviderContentTags
* seed/seedwriter: clarify TODO
---------
Co-authored-by: Ernest Lotter <ernest.lotter@canonical.com>
this is a preparatory step to fix the image building side of the issue of not supporting when a default-provider content is fulfilled by an alternative snap
this also drops some tests and behavior related to core16, as it's not pursued anymore and it was getting in the way here
* seed/seedwriter: drop tests about core16 as we are not pursuing it
and are in the way of the changes I'm planning
* seed/seedwriter,image: use snap.ValidateBasesAndProviders for prereq checks
this will be user to adapt to do the right thing when a default provider
is omitted but the content is fulfilled by another snap
* seed/seedwriter: drop some now unused code
* seed/seedwriter: clarify checkPrereqs with comment
also remove spurious repeated call
thanks @alfonsosanchezbeato
* seed/seedwriter: expand the comment in checkPrereqsInMode
* o/c/configcore: add store.access configurable to allow store access to be disable
* o/devicestate: expose store.access via the storeContextBackend
* overlord,o/storecontext: expose store.access via storecontext.storeContext
* store: use store.access to disable access to snap store when using methods store.Store
* configcore: add tests for validation of store.access
* store: test offline store functionality
* o/storecontext: add test case for StoreAccess
* store, o/c/configcore, o/storecontext: remove usage of online as valid value for store.access
* store: correct ErrStoreOffline message
* store: add unit test to check that http retries do not happen when store is offline
* store: rename isStoreOnline to checkStoreOnline for consistency
* store: remove outdated comment
* o/c/configcore: convert handleStoreAccess to be a fsOnlyHandler since it does not need state
* store: disable more instances of store network access
* overlord,o/storecontext: combine ProxyStoreer and StoreAccessQuerier into one interface
* o/devicestate: add test for storeContextBackend.StoreAccess
* store: modify Store.endpointURL to check if the store is offline
* o/storecontext: simplify TestStoreAccess test case
* store: make Store.assertionsEndpointURL return an error if the store is offline
* store: add more test cases for an offline store
* o/devicestate: remove outdated comment
* store: remove outdated comment
* store: fix outdated comments
* store: test that SnapAction returns an error when the store is offline
* store: clarify ErrStoreOffline message
* o/c/configcore: move store.access registration for more general use
* o/c/configcore, dirs: write config file for snap-repair in store.access handler
* cmd/snap-repair: consume snap repair config file to check if store access is offline
* overlord: remove accidental goimports change
* image: set root dir to temp dir for tests
* o/c/configcore: remove build flags from store.go
* store: rename checkStoreOnline to checkStoreOffline for consistency
* Revert "store: rename checkStoreOnline to checkStoreOffline for consistency"
This reverts commit dd07e487127964c417eeac11d1d954a5d1132469.
* cmd/snap-repair, o/c/configcore: use unexported repairConfig for configuring snap-repair
* o/c/configcore: fix broken test following type rename
* o/c/configcore: remove defined error to make future modifications less error-prone
* o/c/configcore: remove superfluous $
* store, o/devicestate, o/storecontext: change StoreAccess methods to StoreOffline methods that return a boolean indicator
* dirs, o/c/configcore: make sure to check fsOnlyContext for a different root dir
* cmd/snap-repair: move this change into a seperate PR
* o/c/configcore: fixup some comments
Co-authored-by: Miguel Pires <miguelpires94@gmail.com>
* o/c/configcore: add test for setting store.access on filesystem only apply
---------
Co-authored-by: Miguel Pires <miguelpires94@gmail.com>
Replace ioutil.WriteFile with os.WriteFile since the former has been
deprecated since go1.16 and simply calls the latter.
Signed-off-by: Miguel Pires <miguel.pires@canonical.com>
* image, store/tooling: fix how validation-sets and required revision was set for snaps that were controlled by validation-sets. Mirror how it's done for the snap validate --refresh.
* image: fix unit tests and optimize a bit how many times we call validationSetsAndRevisionForSnap
* image: wrong revision in comment
* image: review feedback, add TODO around missing logic for optional snaps, and add unit test for conflict logic that is now added
* image: review feedback, be a bit more consistent in naming between keys and actual validation-set objects
* image: pass validation-sets to store functions
* image: get fetched validation set assertions and use them for keys to store
* image: add additional check to unit test
* image: move seed database into imageSeeder structure
* image: fix unit test
* image: review feedback
add unit test case for the case where we end up downloading a different revision than we requested
* image: fix merge gone wrong
* image,seed/seedwriter: integrate SeedManifest into seedwriter.Writer
* seed/seedwriter: add a docstring to writer.SeedManifest()
* image,seed/seedwriter: fix uses of SeedManifest after rename
* seed/seedwriter: review feedback
don't copy ManifestPath as we already store a copy of options, but do keep a new instance of Manifest itself as we may initialize a new copy, fix docstring typo
move initManifest function to Options as a member function. Add seedwriter specific unit tests for manifest functionality.
rename initManifest() to manifest()
* image: review feedback
add unit test case for the case where we end up downloading a different revision than we requested
* image: fix merge gone wrong
* multiple: rename SeedManifest to Manifest for most references, unless it makes sense in the context to keep it as SeedManifest
* seed/seedwriter: rename tests from SeedManifest to Manifest
* multiple: review feedback
rename NewManifestForTest to MockManifest
* image: review feedback
add unit test case for the case where we end up downloading a different revision than we requested
* multiple: move SeedManifest into the seedwriter package.
* image: fix merge gone wrong