From 9020f2e1fd0f26e2c19ada0beb9f33219e0a0283 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= Date: Thu, 1 Apr 2021 01:31:35 +0200 Subject: [PATCH] qvm-template: fix downloading template for install Donwload a template into a cache dir, not into default of `qvm-template download` (current directory). --- qubesadmin/tests/tools/qvm_template.py | 11 +++++++++++ qubesadmin/tools/qvm_template.py | 1 + 2 files changed, 12 insertions(+) diff --git a/qubesadmin/tests/tools/qvm_template.py b/qubesadmin/tests/tools/qvm_template.py index d6c2709..e97d03c 100644 --- a/qubesadmin/tests/tools/qvm_template.py +++ b/qubesadmin/tests/tools/qvm_template.py @@ -300,6 +300,7 @@ class TC_00_qvm_template(qubesadmin.tests.QubesTestCase): ]) # Nothing downloaded mock_dl.assert_called_with(args, self.app, + path_override='/var/cache/qvm-template', dl_list={}, version_selector=selector) mock_verify.assert_called_once_with(template_file.name, '/tmp/keyring.gpg', nogpgcheck=False) @@ -409,6 +410,7 @@ class TC_00_qvm_template(qubesadmin.tests.QubesTestCase): ]) # Nothing downloaded mock_dl.assert_called_with(args, self.app, + path_override='/var/cache/qvm-template', dl_list={}, version_selector=selector) # Package is extracted mock_extract.assert_called_with('test-vm', path, @@ -554,6 +556,7 @@ class TC_00_qvm_template(qubesadmin.tests.QubesTestCase): # Nothing downloaded self.assertEqual(mock_dl.mock_calls, [ mock.call(args, self.app, + path_override='/var/cache/qvm-template', dl_list={}, version_selector=selector) ]) # Should not be executed: @@ -762,6 +765,7 @@ class TC_00_qvm_template(qubesadmin.tests.QubesTestCase): mock.call(args, self.app, version_selector=selector) ]) mock_dl.assert_called_with(args, self.app, + path_override='/var/cache/qvm-template', dl_list=dl_list, version_selector=selector) # download already verify the package internally self.assertEqual(mock_verify.mock_calls, []) @@ -863,6 +867,7 @@ class TC_00_qvm_template(qubesadmin.tests.QubesTestCase): ]) # Nothing downloaded nor installed mock_dl.assert_called_with(args, self.app, + path_override='/var/cache/qvm-template', dl_list={}, version_selector=selector) mock_verify.assert_not_called() mock_extract.assert_not_called() @@ -943,6 +948,7 @@ class TC_00_qvm_template(qubesadmin.tests.QubesTestCase): ]) # Nothing downloaded mock_dl.assert_called_with(args, self.app, + path_override='/var/cache/qvm-template', dl_list={}, version_selector=selector) mock_verify.assert_called_once_with(template_file.name, '/tmp/keyring.gpg', @@ -4042,6 +4048,7 @@ test-vm : Qubes template for fedora-31 mock.call(args, self.app, version_selector=selector) ]) mock_dl.assert_called_with(args, self.app, + path_override='/var/cache/qvm-template', dl_list=dl_list, version_selector=selector) # already verified by download() self.assertEqual(mock_verify.mock_calls, []) @@ -4148,6 +4155,7 @@ test-vm : Qubes template for fedora-31 mock.call(args, self.app, version_selector=selector) ]) mock_dl.assert_called_with(args, self.app, + path_override='/var/cache/qvm-template', dl_list=dl_list, version_selector=selector) # already verified by download() self.assertEqual(mock_verify.mock_calls, []) @@ -4266,6 +4274,7 @@ test-vm : Qubes template for fedora-31 mock.call(args, self.app, version_selector=selector) ]) mock_dl.assert_called_with(args, self.app, + path_override='/var/cache/qvm-template', dl_list=dl_list, version_selector=selector) # Expect override confirmation self.assertEqual(mock_confirm.mock_calls, @@ -4662,6 +4671,7 @@ gpgkey = file:///etc/qubes/repo-templates/keys/RPM-GPG-KEY-qubes-$releasever-pri mock.call(args, self.app, version_selector=selector) ]) mock_dl.assert_called_with(args, self.app, + path_override='/var/cache/qvm-template', dl_list={}, version_selector=selector) self.assertEqual(mock_verify.mock_calls, [ mock.call(template_file.name, '/tmp/keyring.gpg', nogpgcheck=False) @@ -4747,6 +4757,7 @@ gpgkey = file:///etc/qubes/repo-templates/keys/RPM-GPG-KEY-qubes-$releasever-pri mock.call(args, self.app, version_selector=selector) ]) mock_dl.assert_called_with(args, self.app, + path_override='/var/cache/qvm-template', dl_list={}, version_selector=selector) self.assertEqual(mock_verify.mock_calls, [ mock.call(template_file.name, '/tmp/keyring.gpg', nogpgcheck=False) diff --git a/qubesadmin/tools/qvm_template.py b/qubesadmin/tools/qvm_template.py index 528712c..e01770f 100644 --- a/qubesadmin/tools/qvm_template.py +++ b/qubesadmin/tools/qvm_template.py @@ -996,6 +996,7 @@ def install( package_hdrs = download(args, app, dl_list=dl_list, + path_override=args.cachedir, version_selector=version_selector) # Verify downloaded templates