Ejemplo n.º 1
0
func (inst *packageInstruction) install() interface{} {
	flags := snappy.DoInstallGC
	if inst.LeaveOld {
		flags = 0
	}
	_, err := snappy.Install(inst.pkg, flags, inst.prog)

	if err != nil {
		return err
	}

	// TODO: return the log
	// also to do: commands update their output dynamically, as it changes.
	return nil
}
Ejemplo n.º 2
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
}