summaryrefslogtreecommitdiff
path: root/cloudinit/util.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/util.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/util.py')
-rw-r--r--cloudinit/util.py23
1 files changed, 23 insertions, 0 deletions
diff --git a/cloudinit/util.py b/cloudinit/util.py
index c0ea8d91..c9c5f794 100644
--- a/cloudinit/util.py
+++ b/cloudinit/util.py
@@ -1560,3 +1560,26 @@ def is_partition(device):
device = device[5:]
return os.path.isfile("/sys/class/block/%s/partition" % device)
+
+
+def expand_package_list(version_fmt, pkgs):
+ # we will accept tuples, lists of tuples, or just plain lists
+ if not isinstance(pkgs, list):
+ pkgs = [pkgs]
+
+ pkglist = []
+ for pkg in pkgs:
+ if isinstance(pkg, str):
+ pkglist.append(pkg)
+ continue
+
+ if len(pkg) < 1 or len(pkg) > 2:
+ raise RuntimeError("Invalid package_command tuple.")
+
+ if len(pkg) == 2 and pkg[1]:
+ pkglist.append(version_fmt % pkg)
+ continue
+
+ pkglist.append(pkg[0])
+
+ return pkglist