summaryrefslogtreecommitdiff
path: root/cloudinit/distros/debian.py
diff options
context:
space:
mode:
authorCraig Tracey <craigtracey@gmail.com>2013-01-27 21:48:03 -0500
committerCraig Tracey <craigtracey@gmail.com>2013-01-27 21:48:03 -0500
commitdc3ebfe2416028b78b6a846e939201d894b2c9b6 (patch)
tree2bb3ee3e3ffb6be44a66639934815fe6138c66e0 /cloudinit/distros/debian.py
parentcabd9653546586d2370d9c1d81f14e12dd28b94b (diff)
downloadvyos-cloud-init-dc3ebfe2416028b78b6a846e939201d894b2c9b6.tar.gz
vyos-cloud-init-dc3ebfe2416028b78b6a846e939201d894b2c9b6.zip
Adding package versioning logic to package_command
This change adds the ability to provide specific package versions to Distro.install_packages and subsequently Distro.package_command. In order to effectively use Distro.install_packages, one is now able to pass a variety of formats in order to easily manage package requirements. These are examples of what can be passed: - "package" - ["package1","package2"] - ("package",) - ("package", "version") - [("package1",)("package2",)] - [("package1", "version1"),("package2","version2")] This change also adds the option to install a specific version for the puppet configuration module. This is especially important here as successful puppet deployments are highly reliant on specific puppet versions.
Diffstat (limited to 'cloudinit/distros/debian.py')
-rw-r--r--cloudinit/distros/debian.py17
1 files changed, 13 insertions, 4 deletions
diff --git a/cloudinit/distros/debian.py b/cloudinit/distros/debian.py
index 49b73477..1a8e927b 100644
--- a/cloudinit/distros/debian.py
+++ b/cloudinit/distros/debian.py
@@ -65,7 +65,7 @@ class Distro(distros.Distro):
def install_packages(self, pkglist):
self.update_package_sources()
- self.package_command('install', pkglist)
+ self.package_command('install', pkgs=pkglist)
def _write_network(self, settings):
util.write_file(self.network_conf_fn, settings)
@@ -142,15 +142,24 @@ class Distro(distros.Distro):
# This ensures that the correct tz will be used for the system
util.copy(tz_file, self.tz_local_fn)
- def package_command(self, command, args=None):
+ def package_command(self, command, args=None, pkgs=[]):
e = os.environ.copy()
# See: http://tiny.cc/kg91fw
# Or: http://tiny.cc/mh91fw
e['DEBIAN_FRONTEND'] = 'noninteractive'
cmd = ['apt-get', '--option', 'Dpkg::Options::=--force-confold',
- '--assume-yes', '--quiet', command]
- if args:
+ '--assume-yes', '--quiet']
+
+ if args and isinstance(args, str):
+ cmd.append(args)
+ elif args and isinstance(args, list):
cmd.extend(args)
+
+ cmd.append(command)
+
+ pkglist = util.expand_package_list('%s=%s', pkgs)
+ cmd.extend(pkglist)
+
# Allow the output of this to flow outwards (ie not be captured)
util.subp(cmd, env=e, capture=False)