Example #1
0
func ensureUbuntuCore(chg *state.Change, userID int) error {
	var ss snapstate.SnapState

	ubuntuCore := "ubuntu-core"
	err := snapstateGet(chg.State(), ubuntuCore, &ss)
	if err != state.ErrNoState {
		return err
	}

	// FIXME: workaround because we are not fully state based yet
	installed, err := (&snappy.Overlord{}).Installed()
	snaps := snappy.FindSnapsByName(ubuntuCore, installed)
	if len(snaps) > 0 {
		return nil
	}

	return installSnap(chg, ubuntuCore, "stable", userID, 0)
}
Example #2
0
func showUpdatesList(installed []snappy.Part, updates []snappy.Part, o io.Writer) {
	// TODO tabwriter and output in general to adapt to the spec
	w := tabwriter.NewWriter(o, 5, 3, 1, ' ', 0)
	defer w.Flush()

	fmt.Fprintln(w, i18n.G("Name\tDate\tVersion\t"))
	for _, part := range installed {
		if !part.IsActive() {
			continue
		}
		hasUpdate := ""
		ver := part.Version()
		date := part.Date()
		update := snappy.FindSnapsByName(part.Name(), updates)
		if len(update) == 1 {
			hasUpdate = "*"
			ver = update[0].Version()
			date = update[0].Date()
		}
		fmt.Fprintln(w, fmt.Sprintf("%s%s\t%v\t%s\t", part.Name(), hasUpdate, formatDate(date), ver))
	}
}