File: yum.go

package info (click to toggle)
golang-github-juju-utils 0.0~git20171220.f38c0b0-5
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 1,748 kB
  • sloc: makefile: 20
file content (56 lines) | stat: -rw-r--r-- 2,231 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
// Copyright 2015 Canonical Ltd.
// Copyright 2015 Cloudbase Solutions SRL
// Licensed under the LGPLv3, see LICENCE file for details.

package commands

const (
	// CentOSSourcesDir is the default directory in which yum sourcefiles
	// may be found.
	CentOSSourcesDir = "/etc/yum/repos.d"

	// CentOSYumKeyfileDir is the default directory for yum repository keys.
	CentOSYumKeyfileDir = "/etc/pki/rpm-gpg/"

	// CentOSSourcesFile is the default file which lists all core sources
	// for yum packages on CentOS.
	CentOSSourcesFile = "/etc/yum/repos.d/CentOS-Base.repo"

	// YumConfigFile is the default configuration file for yum settings.
	YumConfigFilePath = "/etc/yum.conf"
)

const (
	// the basic command for all yum calls
	// 		--assumeyes to never prompt for confirmation
	//		--debuglevel=1 to limit output verbosity
	yum = "yum --assumeyes --debuglevel=1"

	// the basic command for all yum repository configuration operations.
	yumconf = "yum-config-manager"

	// the basic format for specifying a proxy setting for yum.
	// NOTE: only http(s) proxies are relevant.
	yumProxySettingFormat = "%s_proxy=%s"
)

// yumCmder is the packageCommander instantiation for yum-based systems.
var yumCmder = packageCommander{
	prereq:              buildCommand(yum, "install yum-utils"),
	update:              buildCommand(yum, "clean expire-cache"),
	upgrade:             buildCommand(yum, "update"),
	install:             buildCommand(yum, "install"),
	remove:              buildCommand(yum, "remove"),
	purge:               buildCommand(yum, "remove"), // purges by default
	search:              buildCommand(yum, "list %s"),
	isInstalled:         buildCommand(yum, "list installed %s"),
	listAvailable:       buildCommand(yum, "list all"),
	listInstalled:       buildCommand(yum, "list installed"),
	listRepositories:    buildCommand(yum, "repolist all"),
	addRepository:       buildCommand(yumconf, "--add-repo %s"),
	removeRepository:    buildCommand(yumconf, "--disable %s"),
	cleanup:             buildCommand(yum, "clean all"),
	getProxy:            buildCommand("grep -R \".*_proxy=\"", YumConfigFilePath),
	proxySettingsFormat: yumProxySettingFormat,
	setProxy:            buildCommand("echo %s >>", YumConfigFilePath),
}