554 Commits

Author SHA1 Message Date
Alfonso Sánchez-Beato
d2f1a9ff2a image: support for local components 2024-07-11 15:11:21 -04:00
Valentin David
30111eaca4 snap-presed: overwrite snapd current symlink when resetting 2024-04-25 10:02:28 +02:00
Valentin David
4f649f9976 snap-preseed: set symlink before calling snapd 2024-04-25 10:02:28 +02:00
Valentin David
3de3d65923 gadget: cleanup files removed by gadgets
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.
2024-04-10 09:54:06 +02:00
Miguel Pires
79c5ac14b2 many: remove usages of deprecated io/ioutil package (#13768)
* many: remove usages of deprecated io/ioutil package

Signed-off-by: Miguel Pires <miguel.pires@canonical.com>

* .golangci.yml: remove errcheck ignore rule for io/ioutil

Signed-off-by: Miguel Pires <miguel.pires@canonical.com>

* run-checks: prevent new usages of io/ioutil

Signed-off-by: Miguel Pires <miguel.pires@canonical.com>

---------

Signed-off-by: Miguel Pires <miguel.pires@canonical.com>
2024-04-03 23:23:24 +02:00
Samuele Pedroni
79ec92d414 many: introduce and use snap.SelfContainedSetPrereqTracker (#13340)
* 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>
2023-11-16 21:48:35 +02:00
Samuele Pedroni
d7d0ab7126 seed/seedwriter,image: prereq check strategy change to use snap.ValidateBasesAndProviders (#13318)
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
2023-10-23 10:43:25 +02:00
Alfonso Sánchez-Beato
75e3f68fa1 many: move gadgettest.OnDiskStructsFromGadget to gadget package
as this function is used also by production code.
2023-10-11 14:53:28 +02:00
Alfonso Sánchez-Beato
41009d9bc1 many: fill all layout data from disk data
and finally remove layoutVSFromDiskData.
2023-10-11 14:53:28 +02:00
Andrew Phelps
ec12734fa2 store, o/storecontext, o/devicestate, o/c/configcore: use store.access to disable access to snap store (#13198)
* 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>
2023-09-27 15:27:21 -04:00
Miguel Pires
29c9752d66 many: s/ioutil.WriteFile/os.WriteFile (#13217)
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>
2023-09-26 11:38:46 +01:00
Dimitri John Ledkov
d55f3123d4 go: go fix with 1.18
Apply `go fix ./...` to the whole code base using go-1.18 to remove
old build tags.
2023-09-25 13:22:14 +02:00
Alfonso Sánchez-Beato
3e9b296ff7 gadget,image: add optional param to LayoutVolume*
So they can accept a mapping from gadget volume structures to real
disk structures.
2023-07-28 10:40:05 +02:00
Michael Vogt
ca49727e35 preseed: remove unneeded error check after sd.EssentialSnaps()
There is no need to check `sd.EssentialSnaps()` as it does not
return an error.
2023-07-20 15:30:02 +02:00
Valentin David
bd642de304 image: relax version checks for preseeding 2023-06-23 16:27:34 +02:00
Philip Meulengracht
44dc7cfe8c image, store/tooling: correct how validation-sets were sent to store (#12763)
* 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
2023-04-26 15:42:00 +02:00
Philip Meulengracht
bdc82f35d7 image: pass validation-sets to store actions (#12692)
* 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
2023-04-20 14:59:18 +02:00
Philip Meulengracht
4ccba690df image,seed/seedwriter: integrate manifest functionality into seed.Writer (3/3) (#12700)
* 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()
2023-04-17 21:42:20 +02:00
Philip Meulengracht
cd5bfe2c2c multiple: rename SeedManifest to Manifest after moving into seedwriter package (2/3) (#12732)
* 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
2023-04-17 08:22:20 +02:00
Philip Meulengracht
7e676f7686 image,seed/seedwriter: move SeedManifest to the seedwriter package (1/3) (#12699)
* 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
2023-04-14 12:54:07 +02:00
Philip Meulengracht
be48e19373 image: review feedback
fix wrong docstrings, better docs for the test-only function, add protection with MustBeTestBinary.
2023-04-13 15:32:15 +02:00
Philip Meulengracht
98e7d05269 image: a bit more consistency in the error messages 2023-04-13 15:32:15 +02:00
Philip Meulengracht
5977e58185 image: review feedback
Clarify error messages, move a few bits around so it makes more sense. Switch to snap.Revisions instead of integers.
2023-04-13 15:32:15 +02:00
Philip Meulengracht
f7c0c0f1e3 cmd/snap,image: fix unit tests in cmd_prepare_image, add unit test case validation sets where revisions are not specified, and where presence is invalid 2023-04-13 15:32:15 +02:00
Philip Meulengracht
696f01419c image: add missing unit test for manifest 2023-04-13 15:32:15 +02:00