1
// Copyright 2015 Canonical Ltd.
2
// Copyright 2015 Cloudbase Solutions SRL
3
// Licensed under the LGPLv3, see LICENCE file for details.
8
// AptConfFilePath is the full file path for the proxy settings that are
9
// written by cloud-init and the machine environ worker.
10
AptConfFilePath = "/etc/apt/apt.conf.d/42-juju-proxy-settings"
12
// the basic command for all dpkg calls:
15
// the basic command for all dpkg-query calls:
16
dpkgquery = "dpkg-query"
18
// the basic command for all apt-get calls:
19
// --force-confold is passed to dpkg to never overwrite config files
20
// --force-unsafe-io makes dpkg less sync-happy
21
// --assume-yes to never prompt for confirmation
22
aptget = "apt-get --option=Dpkg::Options::=--force-confold --option=Dpkg::options::=--force-unsafe-io --assume-yes --quiet"
24
// the basic command for all apt-cache calls:
25
aptcache = "apt-cache"
27
// the basic command for all add-apt-repository calls:
28
// --yes to never prompt for confirmation
29
addaptrepo = "add-apt-repository --yes"
31
// the basic command for all apt-config calls:
32
aptconfig = "apt-config dump"
34
// the basic format for specifying a proxy option for apt:
35
aptProxySettingFormat = "Acquire::%s::Proxy %q;"
38
// aptCmder is the packageCommander instantiation for apt-based systems.
39
var aptCmder = packageCommander{
40
prereq: buildCommand(aptget, "install python-software-properties"),
41
update: buildCommand(aptget, "update"),
42
upgrade: buildCommand(aptget, "upgrade"),
43
install: buildCommand(aptget, "install"),
44
remove: buildCommand(aptget, "remove"),
45
purge: buildCommand(aptget, "purge"),
46
search: buildCommand(aptcache, "search --names-only ^%s$"),
47
isInstalled: buildCommand(dpkgquery, "-s %s"),
48
listAvailable: buildCommand(aptcache, "pkgnames"),
49
listInstalled: buildCommand(dpkg, "--get-selections"),
50
addRepository: buildCommand(addaptrepo, "%q"),
51
listRepositories: buildCommand(`sed -r -n "s|^deb(-src)? (.*)|\2|p"`, "/etc/apt/sources.list"),
52
removeRepository: buildCommand(addaptrepo, "--remove ppa:%s"),
53
cleanup: buildCommand(aptget, "autoremove"),
54
getProxy: buildCommand(aptconfig, "Acquire::http::Proxy Acquire::https::Proxy Acquire::ftp::Proxy"),
55
proxySettingsFormat: aptProxySettingFormat,
56
setProxy: buildCommand("echo %s >> ", AptConfFilePath),