Exemple #1
0
func snapInfo(pkgname string, includeStore, verbose bool) error {
	snap := snappy.ActiveSnapByName(pkgname)
	if snap == nil && includeStore {
		m := snappy.NewUbuntuStoreSnapRepository()
		var err error
		snap, err = m.Snap(pkgname)
		if err != nil {
			return fmt.Errorf("cannot get details for snap %q: %s", pkgname, err)
		}
	}

	if snap == nil {
		return fmt.Errorf("no snap '%s' found", pkgname)
	}

	// TRANSLATORS: the %s is a channel name
	fmt.Printf(i18n.G("channel: %s\n"), snap.Channel())
	// TRANSLATORS: the %s is a version string
	fmt.Printf(i18n.G("version: %s\n"), snap.Version())
	// TRANSLATORS: the %s is a date
	fmt.Printf(i18n.G("updated: %s\n"), snap.Date())
	if verbose {
		// TRANSLATORS: the %s is a date
		fmt.Printf(i18n.G("installed: %s\n"), "n/a")
		// TRANSLATORS: the %s is a size
		fmt.Printf(i18n.G("binary-size: %v\n"), snap.InstalledSize())
		// TRANSLATORS: the %s is a size
		fmt.Printf(i18n.G("data-size: %s\n"), "n/a")
		// FIXME: implement backup list per spec
	}

	return nil
}
Exemple #2
0
func snapInfo(pkgname string, includeStore, verbose bool) error {
	snap := snappy.ActiveSnapByName(pkgname)
	if snap == nil && includeStore {
		m := snappy.NewUbuntuStoreSnapRepository()
		snaps, err := m.Details(snappy.SplitOrigin(pkgname))
		if err == nil && len(snaps) == 1 {
			snap = snaps[0]
		}
	}

	if snap == nil {
		return fmt.Errorf("No snap '%s' found", pkgname)
	}

	// TRANSLATORS: the %s is a channel name
	fmt.Printf(i18n.G("channel: %s\n"), snap.Channel())
	// TRANSLATORS: the %s is a version string
	fmt.Printf(i18n.G("version: %s\n"), snap.Version())
	// TRANSLATORS: the %s is a date
	fmt.Printf(i18n.G("updated: %s\n"), snap.Date())
	if verbose {
		// TRANSLATORS: the %s is a date
		fmt.Printf(i18n.G("installed: %s\n"), "n/a")
		// TRANSLATORS: the %s is a size
		fmt.Printf(i18n.G("binary-size: %v\n"), snap.InstalledSize())
		// TRANSLATORS: the %s is a size
		fmt.Printf(i18n.G("data-size: %s\n"), "n/a")
		// FIXME: implement backup list per spec
	}

	return nil
}
Exemple #3
0
	}

	if store := snappy.StoreID(); store != "" {
		m["store"] = store
	}

	return SyncResponse(m)
}

type metarepo interface {
	Details(string, string) ([]snappy.Part, error)
	Find(string) ([]snappy.Part, error)
}

var newRemoteRepo = func() metarepo {
	return snappy.NewUbuntuStoreSnapRepository()
}

var muxVars = mux.Vars

func getSnapInfo(c *Command, r *http.Request) Response {
	vars := muxVars(r)
	name := vars["name"]
	origin := vars["origin"]

	lock, err := lockfile.Lock(dirs.SnapLockFile, true)
	if err != nil {
		return InternalError("unable to acquire lock: %v", err)
	}
	defer lock.Unlock()