From afd17a32dd130f46cd65b7c036decc485325af87 Mon Sep 17 00:00:00 2001 From: Holger Mueller Date: Thu, 5 Jul 2018 12:28:33 +0200 Subject: Add: run "apt-get clean" after apt step can be suppressed if user wan't to keep debs in cache. --- vmdb/plugins/apt_plugin.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) 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) -- cgit v1.2.1