summaryrefslogtreecommitdiff
diff options
authorMichael Vogt <mvo@ubuntu.com>2018-08-22 10:22:40 +0200
committerMichael Vogt <mvo@ubuntu.com>2018-08-22 10:22:40 +0200
commit85f017ef42955ae06f333b27255dc1be86b9b1bb (patch)
tree2aa1c59e62f10d5cc042bef929c38bdfc9fc317d
parent445f8e795bfa66a3a778a83beec09bbe0ea1b1c4 (diff)
-rw-r--r--image/image.go1
-rw-r--r--overlord/devicestate/firstboot.go19
-rw-r--r--overlord/devicestate/firstboot_test.go25
-rw-r--r--snap/seed_yaml.go2
4 files changed, 46 insertions, 1 deletions
diff --git a/image/image.go b/image/image.go
index 808cade8dd..54da5e3e1c 100644
--- a/image/image.go
+++ b/image/image.go
@@ -494,6 +494,7 @@ func bootstrapToRootDir(tsto *ToolingStore, model *asserts.Model, opts *Options,
Contact: info.Contact,
// no assertions for this snap were put in the seed
Unasserted: info.SnapID == "",
+ Type: info.Type,
})
}
if len(locals) > 0 {
diff --git a/overlord/devicestate/firstboot.go b/overlord/devicestate/firstboot.go
index 3150afadaa..23c1d8d1d6 100644
--- a/overlord/devicestate/firstboot.go
+++ b/overlord/devicestate/firstboot.go
@@ -25,6 +25,7 @@ import (
"io/ioutil"
"os"
"path/filepath"
+ "sort"
"github.com/snapcore/snapd/asserts"
"github.com/snapcore/snapd/asserts/snapasserts"
@@ -41,6 +42,22 @@ import (
var errNothingToDo = errors.New("nothing to do")
+var typeOrder = map[snap.Type]int{
+ snap.TypeApp: 90,
+ snap.TypeBase: 80,
+ snap.TypeGadget: 70,
+ snap.TypeKernel: 60,
+ snap.TypeOS: 50,
+}
+
+type byBase []*snap.SeedSnap
+
+func (r byBase) Len() int { return len(r) }
+func (r byBase) Swap(i, j int) { r[i], r[j] = r[j], r[i] }
+func (r byBase) Less(i, j int) bool {
+ return typeOrder[r[i].Type] < typeOrder[r[j].Type]
+}
+
func installSeedSnap(st *state.State, sn *snap.SeedSnap, flags snapstate.Flags) (*state.TaskSet, error) {
if sn.Classic {
flags.Classic = true
@@ -206,6 +223,8 @@ func populateStateFromSeedImpl(st *state.State) ([]*state.TaskSet, error) {
last += len(configTss)
}
+ // ensure bases go first
+ sort.Stable(byBase(seed.Snaps))
for _, sn := range seed.Snaps {
if alreadySeeded[sn.Name] {
continue
diff --git a/overlord/devicestate/firstboot_test.go b/overlord/devicestate/firstboot_test.go
index ed1cef4653..9b2b1d0f59 100644
--- a/overlord/devicestate/firstboot_test.go
+++ b/overlord/devicestate/firstboot_test.go
@@ -1306,18 +1306,41 @@ func (s *FirstBootTestSuite) TestPopulateFromSeedWithBaseHappy(c *C) {
c.Assert(err, IsNil)
}
+ snapYaml := `name: snap-req-other-base
+version: 1.0
+base: other-base
+`
+ snapFname, snapDecl, snapRev := s.makeAssertedSnap(c, snapYaml, nil, snap.R(128), "developerid")
+ writeAssertionsToFile("snap-req-other-base.asserts", []asserts.Assertion{devAcct, snapRev, snapDecl})
+ baseYaml := `name: other-base
+version: 1.0
+type: base
+`
+ baseFname, baseDecl, baseRev := s.makeAssertedSnap(c, baseYaml, nil, snap.R(127), "developerid")
+ writeAssertionsToFile("other-base.asserts", []asserts.Assertion{devAcct, baseRev, baseDecl})
+
// create a seed.yaml
content := []byte(fmt.Sprintf(`
snaps:
- name: snapd
file: %s
+ type: app
- name: core18
file: %s
+ type: base
- name: pc-kernel
file: %s
+ type: kernel
- name: pc
file: %s
-`, snapdFname, core18Fname, kernelFname, gadgetFname))
+ type: gadget
+ - name: snap-req-other-base
+ file: %s
+ type: app
+ - name: other-base
+ file: %s
+ type: base
+`, snapdFname, core18Fname, kernelFname, gadgetFname, snapFname, baseFname))
err = ioutil.WriteFile(filepath.Join(dirs.SnapSeedDir, "seed.yaml"), content, 0644)
c.Assert(err, IsNil)
diff --git a/snap/seed_yaml.go b/snap/seed_yaml.go
index 5e3c9e128e..665c13b2d3 100644
--- a/snap/seed_yaml.go
+++ b/snap/seed_yaml.go
@@ -51,6 +51,8 @@ type SeedSnap struct {
Unasserted bool `yaml:"unasserted,omitempty"`
File string `yaml:"file"`
+
+ Type Type `yaml:"type"`
}
type Seed struct {