From f053f51644c06f200009c365281fdb07b852e5f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= Date: Sat, 30 Jan 2021 06:07:24 +0100 Subject: [PATCH] qvm-template: remove downloaded package after installation At least by default. Otherwise they will pile up in the cache dir. --- qubesadmin/tools/qvm_template.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/qubesadmin/tools/qvm_template.py b/qubesadmin/tools/qvm_template.py index cb65b4d..c99ddac 100644 --- a/qubesadmin/tools/qvm_template.py +++ b/qubesadmin/tools/qvm_template.py @@ -124,6 +124,8 @@ def get_parser() -> argparse.ArgumentParser: help='Set repository metadata as expired before running the command.') parser_main.add_argument('--cachedir', default=CACHE_DIR, help='Specify cache directory.') + parser_main.add_argument('--keep-cache', default=False, + help='Keep downloaded packages in cache dir') parser_main.add_argument('--yes', action='store_true', help='Assume "yes" to questions.') parser_main.add_argument('--quiet', action='store_true', @@ -982,6 +984,8 @@ def install( package_hdr[rpm.RPMTAG_SUMMARY] tpl.features['template-description'] = \ package_hdr[rpm.RPMTAG_DESCRIPTION].replace('\n', '|') + if rpmfile.startswith(args.cachedir) and not args.keep_cache: + os.remove(rpmfile) def list_templates(args: argparse.Namespace, app: qubesadmin.app.QubesBase, operation: str) -> None: