From 33049b97e64ee2ec65935c7251aa9e5b4527dc43 Mon Sep 17 00:00:00 2001 From: Andrew Phelps Date: Fri, 20 Dec 2024 10:40:58 -0500 Subject: [PATCH] o/devicestate: ignore file extensions when creating seed from validated snaps --- overlord/devicestate/devicestate_systems_test.go | 12 +++++++++++- overlord/devicestate/systems.go | 5 +++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/overlord/devicestate/devicestate_systems_test.go b/overlord/devicestate/devicestate_systems_test.go index 82b6ca523ba..38d145e1962 100644 --- a/overlord/devicestate/devicestate_systems_test.go +++ b/overlord/devicestate/devicestate_systems_test.go @@ -3833,7 +3833,6 @@ func (s *deviceMgrSystemsCreateSuite) TestDeviceManagerCreateRecoverySystemValid localSnaps := make([]devicestate.LocalSnap, 0, len(snapRevisions)) for name, rev := range snapRevisions { - var files [][]string var base string if snapTypes[name] == snap.TypeGadget { @@ -3845,6 +3844,17 @@ func (s *deviceMgrSystemsCreateSuite) TestDeviceManagerCreateRecoverySystemValid si, path := createLocalSnap(c, name, fakeSnapID(name), rev.N, string(snapTypes[name]), base, files) + // when we're creating a recovery system from snaps that are uploaded, + // they get written to disk as tmp files. these don't have a .snap file + // extension. this emulates that behavior. + // + // here we make sure that the seed writer allows us to create a seed + // from snaps with invalid/missing file extensions. + trimmed := strings.TrimSuffix(path, ".snap") + err := os.Rename(path, trimmed) + c.Assert(err, IsNil) + path = trimmed + localSnaps = append(localSnaps, devicestate.LocalSnap{ SideInfo: si, Path: path, diff --git a/overlord/devicestate/systems.go b/overlord/devicestate/systems.go index 9926a607da0..0f0e0523dd0 100644 --- a/overlord/devicestate/systems.go +++ b/overlord/devicestate/systems.go @@ -347,8 +347,9 @@ func createSystemForModelFromValidatedSnaps( wOpts := &seedwriter.Options{ // RW mount of ubuntu-seed - SeedDir: boot.InitramfsUbuntuSeedDir, - Label: label, + SeedDir: boot.InitramfsUbuntuSeedDir, + Label: label, + IgnoreOptionFileExtentions: true, } w, err := seedwriter.New(model, wOpts) if err != nil {