Пример #1
0
func installRemote(mStore *store.SnapUbuntuStoreRepository, remoteSnap *snap.Info, flags InstallFlags, meter progress.Meter) (string, error) {
	downloadedSnap, err := mStore.Download(remoteSnap, meter, nil)
	if err != nil {
		return "", fmt.Errorf("cannot download %s: %s", remoteSnap.Name(), err)
	}
	defer os.Remove(downloadedSnap)

	localSnap, err := (&Overlord{}).InstallWithSideInfo(downloadedSnap, &remoteSnap.SideInfo, flags, meter)
	if err != nil {
		return "", err
	}

	return localSnap.Name(), nil
}
Пример #2
0
// snapUpdates identifies which snaps have updates in the store.
func snapUpdates(repo *store.SnapUbuntuStoreRepository) (snaps []*snap.Info, err error) {
	// TODO: this should eventually be snap-id based
	// NOTE this *will* send .sideload apps to the store.
	installed, err := ActiveSnapIterByType(fullNameWithChannel, snap.TypeApp, snap.TypeGadget, snap.TypeOS, snap.TypeKernel)
	if err != nil || len(installed) == 0 {
		return nil, err
	}

	rsnaps, err := repo.Updates(installed, nil)
	if err != nil {
		return nil, err
	}

	for _, rsnap := range rsnaps {
		current := ActiveSnapByName(rsnap.Name())
		if current == nil || current.Revision() != rsnap.Revision {
			snaps = append(snaps, rsnap)
		}
	}

	return snaps, nil
}