/
zypper.go
60 lines (51 loc) · 2.28 KB
/
zypper.go
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
57
58
59
60
// Copyright 2017 Canonical Ltd.
// Licensed under the LGPLv3, see LICENCE file for details.
// Created from yum.go
package commands
const (
// OpenSUSESourcesDir is the default directory in which openSUSE sourcefiles
// may be found.
OpenSUSESourcesDir = "/etc/zypp/repos.d"
// OpenSUSECredentialsDir is the sirectory for credentials.
OpenSUSECredentialsDir = "/etc/zypp/credentials.d"
// OpenSUSESourcesFile is the default file which lists all core sources
// for zypper packages on OpenSUSE.
OpenSUSESourcesFile = "/etc/zypp/repos.d/repo-oss.repo"
// ZypperConfigFile is the default configuration file for yum settings.
ZypperConfigFilePath = "/etc/zypp/zypp.conf"
//OpenSUSE proxy settings
OpenSUSEProxy = "/etc/sysconfig/proxy"
)
const (
// Zypper command for managing packages and repos
// --quiet to only show errors
// --non-interactive to install without asking packages
zypper = "zypper --quiet --non-interactive"
// OpenSUSE format for proxy environment variables
zypperProxySettingFormat = "%s_PROXY=%s"
)
// zypperCmder is the packageCommander instantiation for zypper-based systems.
var zypperCmder = packageCommander{
prereq: buildCommand(":", "#No action here"),
update: buildCommand(zypper, "refresh"),
upgrade: buildCommand(zypper, "update"),
install: buildCommand(zypper, "install"),
remove: buildCommand(zypper, "remove"),
purge: buildCommand(zypper, "remove"), // No purges with zypper
search: buildCommand(zypper, "search %s"),
isInstalled: buildCommand(zypper, "search -i %s"),
listAvailable: buildCommand(zypper, "packages"),
listInstalled: buildCommand(zypper, "packages -i"),
listRepositories: buildCommand(zypper, "repos"),
addRepository: buildCommand(zypper, "addrepo %s"),
removeRepository: buildCommand(zypper, "removerepo %s"),
cleanup: buildCommand(zypper, "clean --all"),
getProxy: buildCommand("grep -R \".*_PROXY=\"", OpenSUSEProxy),
proxySettingsFormat: zypperProxySettingFormat,
setProxy: buildCommand("sed -ie 's/PROXY_ENABLED=\"no\"/PROXY_ENABLED=\"yes\"/g'",
OpenSUSEProxy,
"echo %s >>",
OpenSUSEProxy),
setNoProxy: buildCommand("echo %s >> ", OpenSUSEProxy),
proxyLabelInCapital: true,
}