From 73ff49999edeb446d102728cd198acf3db338594 Mon Sep 17 00:00:00 2001 From: Ali Mirjamali Date: Thu, 11 Jul 2024 16:56:10 +0330 Subject: [PATCH] Cleaner messages on attempting to remove a Template currently in use fixes: https://github.com/QubesOS/qubes-issues/issues/4763 --- qubesadmin/tools/qvm_template_postprocess.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/qubesadmin/tools/qvm_template_postprocess.py b/qubesadmin/tools/qvm_template_postprocess.py index 2aa165ddd..613a1e8f7 100644 --- a/qubesadmin/tools/qvm_template_postprocess.py +++ b/qubesadmin/tools/qvm_template_postprocess.py @@ -407,12 +407,22 @@ def import_template_config(args, conf_path, vm): def pre_remove(args): '''Handle pre-removal tasks''' app = args.app + app.log.name = "qvm-template-postprocess" try: tpl = app.domains[args.name] except KeyError: parser.error('No Qube with this name exists') + dependant_vms = False for appvm in tpl.appvms: - parser.error('Qube {} uses this template'.format(appvm.name)) + dependant_vms = True + app.log.error( + 'ERROR! Qube "{}" uses this template'.format(appvm.name)) + if dependant_vms: + app.log.warning( + 'WARNING! Do not use dnf to uninstall templates!') + app.log.info('Info: Use qvm-template(1) or ' \ + 'Qubes Template Manager GUI to uninstall templates\n') + sys.exit(1) tpl.installed_by_rpm = False del app.domains[args.name]