summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGunnar Wolf <gwolf@gwolf.org>2021-03-17 13:28:07 -0600
committerGunnar Wolf <gwolf@gwolf.org>2021-03-17 13:28:07 -0600
commitfca186cd22511bde93d37f0f5857726651d34b92 (patch)
treecb957c8dff988fd75d996a4559be20eb6ae610d7
parentd55167ad0680740b5c0552a1824a9781583bb21b (diff)
downloadvmdb2-fca186cd22511bde93d37f0f5857726651d34b92.tar.gz
Add an option to apt allowing users to set --no-install-recommends
-rw-r--r--vmdb/plugins/apt.mdwn4
-rw-r--r--vmdb/plugins/apt_plugin.py15
2 files changed, 14 insertions, 5 deletions
diff --git a/vmdb/plugins/apt.mdwn b/vmdb/plugins/apt.mdwn
index a05922a..e66454c 100644
--- a/vmdb/plugins/apt.mdwn
+++ b/vmdb/plugins/apt.mdwn
@@ -12,6 +12,10 @@ Step keys:
* `packages` &mdash; REQUIRED; value is a list of packages to install.
+* `recommends` &mdash; OPTIONAL; defaults to true. Setting value to a
+ false (i.e. `0`, `null`, `false`) asks apt-get to run with the
+ `--no-install-recommends` option set.
+
Example (in the .vmdb file):
- apt: install
diff --git a/vmdb/plugins/apt_plugin.py b/vmdb/plugins/apt_plugin.py
index 09b8902..5f11855 100644
--- a/vmdb/plugins/apt_plugin.py
+++ b/vmdb/plugins/apt_plugin.py
@@ -28,7 +28,7 @@ class AptPlugin(vmdb.Plugin):
class AptStepRunner(vmdb.StepRunnerInterface):
def get_key_spec(self):
- return {"apt": str, "packages": [], "tag": "", "fs-tag": "", "clean": True}
+ return {"apt": str, "packages": [], "tag": "", "fs-tag": "", "clean": True, "recommends": True}
def run(self, values, settings, state):
operation = values["apt"]
@@ -36,15 +36,16 @@ class AptStepRunner(vmdb.StepRunnerInterface):
raise Exception('"apt" must always have value "install"')
packages = values["packages"]
+ recommends = values["recommends"]
tag = values.get("tag") or None
if tag is None:
tag = values["fs-tag"]
mount_point = state.tags.get_builder_mount_point(tag)
if not self.got_eatmydata(state):
- self.install_packages(mount_point, [], ["eatmydata"])
+ self.install_packages(mount_point, [], recommends, ["eatmydata"])
state.got_eatmydata = True
- self.install_packages(mount_point, ["eatmydata"], packages)
+ self.install_packages(mount_point, ["eatmydata"], recommends, packages)
if values["clean"]:
self.clean_cache(mount_point)
@@ -52,15 +53,19 @@ class AptStepRunner(vmdb.StepRunnerInterface):
def got_eatmydata(self, state):
return hasattr(state, "got_eatmydata") and getattr(state, "got_eatmydata")
- def install_packages(self, mount_point, argv_prefix, packages):
+ def install_packages(self, mount_point, argv_prefix, recommends, packages):
env = os.environ.copy()
env["DEBIAN_FRONTEND"] = "noninteractive"
vmdb.runcmd_chroot(mount_point, argv_prefix + ["apt-get", "update"], env=env)
+ rec = ''
+ if recommends:
+ rec = '--no-install-recommends'
+
vmdb.runcmd_chroot(
mount_point,
- argv_prefix + ["apt-get", "-y", "--no-show-progress", "install"] + packages,
+ argv_prefix + ["apt-get", "-y", "--no-show-progress", rec, "install"] + packages,
env=env,
)