summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHolger Mueller <hom@cm4all.com>2018-07-05 12:28:33 +0200
committerLars Wirzenius <liw@liw.fi>2018-07-08 14:28:49 +0300
commitafd17a32dd130f46cd65b7c036decc485325af87 (patch)
tree656177eb00b0293a7fa09dc7900bcc3c85bbb942
parent79e217300fdba7bd9f4c78d994a743e0a247f47c (diff)
downloadvmdb2-afd17a32dd130f46cd65b7c036decc485325af87.tar.gz
Add: run "apt-get clean" after apt step
can be suppressed if user wan't to keep debs in cache.
-rw-r--r--vmdb/plugins/apt_plugin.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/vmdb/plugins/apt_plugin.py b/vmdb/plugins/apt_plugin.py
index 641109e..4f52fe8 100644
--- a/vmdb/plugins/apt_plugin.py
+++ b/vmdb/plugins/apt_plugin.py
@@ -49,6 +49,9 @@ class AptStepRunner(vmdb.StepRunnerInterface):
state.got_eatmydata = True
self.install_packages(mount_point, ['eatmydata'], packages)
+ if step.get('clean', True):
+ self.clean_cache(mount_point)
+
def got_eatmydata(self, state):
return hasattr(state, 'got_eatmydata') and getattr(state, 'got_eatmydata')
@@ -61,3 +64,12 @@ class AptStepRunner(vmdb.StepRunnerInterface):
argv_prefix +
['apt-get', '-y', '--no-show-progress', 'install'] + packages,
env=env)
+
+ def clean_cache(self, mount_point):
+ env = os.environ.copy()
+ env['DEBIAN_FRONTEND'] = 'noninteractive'
+
+ vmdb.runcmd_chroot(
+ mount_point,
+ ['apt-get', 'clean'],
+ env=env)