Beispiel #1
0
func outputHWAccessForAll() error {
	installed, err := snappy.ListInstalled()
	if err != nil {
		return err
	}

	for _, snap := range installed {
		writePaths, err := snappy.ListHWAccess(snap.Name())
		if err == nil && len(writePaths) > 0 {
			outputHWAccessForPkgname(snap.Name(), writePaths)
		}
	}

	return nil
}
func (x *cmdUpdate) doUpdate() error {
	// FIXME: handle (more?) args
	flags := snappy.DoInstallGC
	if x.DisableGC {
		flags = 0
	}

	var err error
	var updates []snappy.Part
	if x.Positional.PackageName != "" {
		updates, err = snappy.Update(x.Positional.PackageName, flags, progress.MakeProgressBar())
	} else {
		updates, err = snappy.UpdateAll(flags, progress.MakeProgressBar())
	}
	if err != nil {
		return err
	}

	if len(updates) > 0 {
		showVerboseList(updates, os.Stdout)
	}

	if x.AutoReboot {
		installed, err := snappy.ListInstalled()
		if err != nil {
			return err
		}

		var rebootTriggers []string
		for _, part := range installed {
			if part.NeedsReboot() {
				rebootTriggers = append(rebootTriggers, part.Name())
			}
		}

		if len(rebootTriggers) != 0 {
			// TRANSLATORS: the %s shows a comma separated list
			//              of package names
			fmt.Printf(i18n.G("Rebooting to satisfy updates for %s\n"), strings.Join(rebootTriggers, ", "))
			cmd := exec.Command(shutdownCmd, shutdownTimeout, "-r", shutdownMsg)
			if out, err := cmd.CombinedOutput(); err != nil {
				return fmt.Errorf("failed to auto reboot: %s", out)
			}
		}
	}

	return nil
}
Beispiel #3
0
func (x cmdList) list() error {
	installed, err := snappy.ListInstalled()
	if err != nil {
		return err
	}

	if x.Updates {
		updates, err := snappy.ListUpdates()
		if err != nil {
			return err
		}
		showUpdatesList(installed, updates, os.Stdout)
	} else if x.Verbose {
		showVerboseList(installed, os.Stdout)
	} else {
		showInstalledList(installed, os.Stdout)
	}

	return err
}
Beispiel #4
0
func (x *cmdInstall) doInstall() error {
	pkgName := x.Positional.PackageName
	configFile := x.Positional.ConfigFile

	// FIXME patch goflags to allow for specific n required positional arguments
	if pkgName == "" {
		return errors.New(i18n.G("package name is required"))
	}

	flags := snappy.DoInstallGC
	if x.DisableGC {
		flags = 0
	}
	if x.AllowUnauthenticated {
		flags |= snappy.AllowUnauthenticated
	}
	// TRANSLATORS: the %s is a pkgname
	fmt.Printf(i18n.G("Installing %s\n"), pkgName)

	realPkgName, err := snappy.Install(pkgName, flags, progress.MakeProgressBar())
	if err != nil {
		return err
	}

	if configFile != "" {
		if _, err := configurePackage(realPkgName, configFile); err != nil {
			return err
		}
	}

	// call show versions afterwards
	installed, err := snappy.ListInstalled()
	if err != nil {
		return err
	}

	showInstalledList(installed, os.Stdout)

	return nil
}