Beispiel #1
0
// ensureDependencies creates a set of install packages using AptGetPreparePackages
// and runs each set of packages through AptGetInstall
func ensureDependencies(series string) error {
	var err error
	aptGetInstallCommandList := utils.AptGetPreparePackages(requiredPackages, series)
	for _, commands := range aptGetInstallCommandList {
		err = utils.AptGetInstall(commands...)
		if err != nil {
			return err
		}
	}
	return err
}
Beispiel #2
0
func aptGetInstallMongod() error {
	// Only Quantal requires the PPA.
	if version.Current.Series == "quantal" {
		if err := addAptRepository("ppa:juju/stable"); err != nil {
			return err
		}
	}
	pkg := packageForSeries(version.Current.Series)
	cmds := utils.AptGetPreparePackages([]string{pkg}, version.Current.Series)
	logger.Infof("installing %s", pkg)
	for _, cmd := range cmds {
		if err := utils.AptGetInstall(cmd...); err != nil {
			return err
		}
	}
	return nil
}
Beispiel #3
0
func addAptRepository(name string) error {
	// add-apt-repository requires python-software-properties
	cmds := utils.AptGetPreparePackages(
		[]string{"python-software-properties"},
		version.Current.Series,
	)
	logger.Infof("installing python-software-properties")
	for _, cmd := range cmds {
		if err := utils.AptGetInstall(cmd...); err != nil {
			return err
		}
	}

	logger.Infof("adding apt repository %q", name)
	cmd := exec.Command("add-apt-repository", "-y", name)
	out, err := cmd.CombinedOutput()
	if err != nil {
		return fmt.Errorf("cannot add apt repository: %v (output %s)", err, bytes.TrimSpace(out))
	}
	return nil
}
Beispiel #4
0
func (s *AptSuite) TestAptGetPreparePackages(c *gc.C) {
	packagesList := utils.AptGetPreparePackages([]string{"lxc", "bridge-utils", "git", "mongodb"}, "precise")
	c.Assert(packagesList[0], gc.DeepEquals, []string{"--target-release", "precise-updates/cloud-tools", "lxc", "mongodb"})
	c.Assert(packagesList[1], gc.DeepEquals, []string{"bridge-utils", "git"})
}