// 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 := apt.GetPreparePackages(requiredPackages, series) for _, commands := range aptGetInstallCommandList { err = apt.GetInstall(commands...) if err != nil { return err } } return err }
func (s *AptSuite) TestOnePackage(c *gc.C) { cmdChan := s.HookCommandOutput(&apt.CommandOutput, []byte{}, nil) err := apt.GetInstall("test-package") c.Assert(err, gc.IsNil) cmd := <-cmdChan c.Assert(cmd.Args, gc.DeepEquals, []string{ "apt-get", "--option=Dpkg::Options::=--force-confold", "--option=Dpkg::options::=--force-unsafe-io", "--assume-yes", "--quiet", "install", "test-package", }) c.Assert(cmd.Env[len(cmd.Env)-1], gc.Equals, "DEBIAN_FRONTEND=noninteractive") }
func (s *AptSuite) TestAptGetError(c *gc.C) { const expected = `E: frobnicator failure detected` cmdError := fmt.Errorf("error") cmdExpectedError := fmt.Errorf("apt-get failed: error") cmdChan := s.HookCommandOutput(&apt.CommandOutput, []byte(expected), cmdError) err := apt.GetInstall("foo") c.Assert(err, gc.DeepEquals, cmdExpectedError) cmd := <-cmdChan c.Assert(cmd.Args, gc.DeepEquals, []string{ "apt-get", "--option=Dpkg::Options::=--force-confold", "--option=Dpkg::options::=--force-unsafe-io", "--assume-yes", "--quiet", "install", "foo", }) }
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 := apt.GetPreparePackages([]string{pkg}, version.Current.Series) logger.Infof("installing %s", pkg) for _, cmd := range cmds { if err := apt.GetInstall(cmd...); err != nil { return err } } return nil }
func addAptRepository(name string) error { // add-apt-repository requires python-software-properties cmds := apt.GetPreparePackages( []string{"python-software-properties"}, version.Current.Series, ) logger.Infof("installing python-software-properties") for _, cmd := range cmds { if err := apt.GetInstall(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 }
// installRsyslogGnutls installs the rsyslog-gnutls package, // which is required for our rsyslog configuration from 1.18.0. func installRsyslogGnutls(context Context) error { return apt.GetInstall("rsyslog-gnutls") }
func ensureDependencies() error { return apt.GetInstall(requiredPackages...) }