Skip to content

Commit

Permalink
o/devicestate: ignore file extensions when creating seed from validat…
Browse files Browse the repository at this point in the history
…ed snaps
  • Loading branch information
andrewphelpsj committed Dec 20, 2024
1 parent 2dc8887 commit 33049b9
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
12 changes: 11 additions & 1 deletion overlord/devicestate/devicestate_systems_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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,
Expand Down
5 changes: 3 additions & 2 deletions overlord/devicestate/systems.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 33049b9

Please sign in to comment.