func (x *cmdBooted) Execute(args []string) error { if len(args) > 0 { return ErrExtraArgs } if release.OnClassic { fmt.Fprintf(Stdout, i18n.G("Ignoring 'booted' on classic")) return nil } bootloader, err := partition.FindBootloader() if err != nil { return fmt.Errorf(i18n.G("cannot mark boot successful: %s"), err) } if err := partition.MarkBootSuccessful(bootloader); err != nil { return err } ovld, err := overlord.New() if err != nil { return err } return boot.UpdateRevisions(ovld) }
func (bs *bootedSuite) TestUpdateRevisionsOSErrorsEarly(c *C) { st := bs.overlord.State() bs.makeInstalledKernelOS(c, st) bs.bootloader.BootVars["snap_core"] = "ubuntu-core_99.snap" err := boot.UpdateRevisions(bs.overlord) c.Assert(err, ErrorMatches, `cannot find revision 99 for snap "ubuntu-core"`) }
func (bs *bootedSuite) TestUpdateRevisionsKernelErrorsEarly(c *C) { st := bs.overlord.State() bs.makeInstalledKernelOS(c, st) bs.bootloader.BootVars["snap_kernel"] = "canonical-pc-linux_99.snap" err := boot.UpdateRevisions(bs.overlord) c.Assert(err, ErrorMatches, `cannot find revision 99 for snap "canonical-pc-linux"`) }
func (bs *bootedSuite) TestUpdateRevisionsOSErrorsLate(c *C) { st := bs.overlord.State() st.Lock() // put ubuntu-core into the state but add no files on disk // will break in the tasks snapstate.Set(st, "ubuntu-core", &snapstate.SnapState{ SnapType: "os", Active: true, Sequence: []*snap.SideInfo{osSI1, osSI2}, Current: snap.R(2), }) st.Unlock() bs.bootloader.BootVars["snap_kernel"] = "ubuntu-core_1.snap" err := boot.UpdateRevisions(bs.overlord) c.Assert(err, ErrorMatches, `(?ms)cannot update revisions after boot changes:.*`) }
func (bs *bootedSuite) TestUpdateRevisionsKernelSimple(c *C) { st := bs.overlord.State() bs.makeInstalledKernelOS(c, st) bs.bootloader.BootVars["snap_kernel"] = "canonical-pc-linux_1.snap" err := boot.UpdateRevisions(bs.overlord) c.Assert(err, IsNil) st.Lock() defer st.Unlock() // canonical-pc-linux "current" got reverted but ubuntu-core did not var snapst snapstate.SnapState err = snapstate.Get(st, "canonical-pc-linux", &snapst) c.Assert(err, IsNil) c.Assert(snapst.Current, Equals, snap.R(1)) c.Assert(snapst.Active, Equals, true) err = snapstate.Get(st, "ubuntu-core", &snapst) c.Assert(err, IsNil) c.Assert(snapst.Current, Equals, snap.R(2)) c.Assert(snapst.Active, Equals, true) }