From 5cf40b4e6ec682fb7563c562db822e868bf162ae Mon Sep 17 00:00:00 2001 From: Michael Z Date: Thu, 23 Jun 2022 12:00:48 -0400 Subject: [PATCH 1/3] Remove 4.0 support from launcher/updater --- launcher/sdw_updater_gui/Updater.py | 14 +++++++----- launcher/tests/fixtures/os-release-qubes-4.0 | 7 ------ launcher/tests/test_updater.py | 10 +++++---- launcher/tests/test_updaterapp.py | 8 +++---- launcher/tests/test_util.py | 23 +++++++++----------- 5 files changed, 28 insertions(+), 34 deletions(-) delete mode 100644 launcher/tests/fixtures/os-release-qubes-4.0 diff --git a/launcher/sdw_updater_gui/Updater.py b/launcher/sdw_updater_gui/Updater.py index 34cd05fc..5f8cca5e 100644 --- a/launcher/sdw_updater_gui/Updater.py +++ b/launcher/sdw_updater_gui/Updater.py @@ -31,6 +31,8 @@ # logic to leverage the Qubes Python API. MIGRATION_DIR = "/tmp/sdw-migrations" # nosec +DEBIAN_VERSION = "bullseye" + sdlog = Util.get_logger(module=__name__) detail_log = Util.get_logger(prefix=DETAIL_LOGGER_PREFIX, module=__name__) @@ -39,13 +41,13 @@ # In the future, we could use qvm-prefs to extract this information. current_vms = { "fedora": "fedora-35", - "sd-viewer": "sd-large-buster-template", - "sd-app": "sd-small-buster-template", - "sd-log": "sd-small-buster-template", - "sd-devices": "sd-large-buster-template", - "sd-proxy": "sd-small-buster-template", + "sd-viewer": "sd-large-{}-template".format(DEBIAN_VERSION), + "sd-app": "sd-small-{}-template".format(DEBIAN_VERSION), + "sd-log": "sd-small-{}-template".format(DEBIAN_VERSION), + "sd-devices": "sd-large-{}-template".format(DEBIAN_VERSION), + "sd-proxy": "sd-small-{}-template".format(DEBIAN_VERSION), "sd-whonix": "whonix-gw-16", - "sd-gpg": "sd-small-buster-template", + "sd-gpg": "sd-small-{}-template".format(DEBIAN_VERSION), } current_templates = set([val for key, val in current_vms.items() if key != "dom0"]) diff --git a/launcher/tests/fixtures/os-release-qubes-4.0 b/launcher/tests/fixtures/os-release-qubes-4.0 deleted file mode 100644 index 567f3464..00000000 --- a/launcher/tests/fixtures/os-release-qubes-4.0 +++ /dev/null @@ -1,7 +0,0 @@ -NAME=Qubes -VERSION="4.0 (R4.0)" -ID=qubes -VERSION_ID=4.0 -PRETTY_NAME="Qubes 4.0 (R4.0)" -ANSI_COLOR="0;31" -CPE_NAME="cpe:/o:ITL:qubes:4.0" diff --git a/launcher/tests/test_updater.py b/launcher/tests/test_updater.py index a672c9b0..7d5c5a9d 100644 --- a/launcher/tests/test_updater.py +++ b/launcher/tests/test_updater.py @@ -27,6 +27,8 @@ "sd-devices", ] +DEBIAN_VERSION = "bullseye" + TEST_RESULTS_OK = { "dom0": UpdateStatus.UPDATES_OK, "fedora": UpdateStatus.UPDATES_OK, @@ -491,8 +493,8 @@ def test_shutdown_and_start_vms( ] template_vm_calls = [ call("fedora-35"), - call("sd-large-buster-template"), - call("sd-small-buster-template"), + call("sd-large-{}-template".format(DEBIAN_VERSION)), + call("sd-small-{}-template".format(DEBIAN_VERSION)), call("whonix-gw-16"), ] app_vm_calls = [ @@ -537,8 +539,8 @@ def test_shutdown_and_start_vms_sysvm_fail( ] template_vm_calls = [ call("fedora-35"), - call("sd-large-buster-template"), - call("sd-small-buster-template"), + call("sd-large-{}-template".format(DEBIAN_VERSION)), + call("sd-small-{}-template".format(DEBIAN_VERSION)), call("whonix-gw-16"), ] error_calls = [ diff --git a/launcher/tests/test_updaterapp.py b/launcher/tests/test_updaterapp.py index 930675cf..5bb5a29a 100644 --- a/launcher/tests/test_updaterapp.py +++ b/launcher/tests/test_updaterapp.py @@ -39,7 +39,7 @@ def setUpClass(cls): def tearDownClass(cls): cls._app.quit() - @mock.patch("UpdaterApp.Util.get_qubes_version", return_value="4.0") + @mock.patch("UpdaterApp.Util.get_qubes_version", return_value="4.1") @mock.patch("UpdaterApp.subprocess.check_output", return_value=b"none") def test_netcheck_no_network_should_fail(self, mocked_output, mocked_qubes_version): """ @@ -61,7 +61,7 @@ def test_netcheck_no_qubes_should_fail_with_error(self, mocked_error, mocked_qub assert mocked_error.called @mock.patch("subprocess.check_output", return_value=b"full") - @mock.patch("UpdaterApp.Util.get_qubes_version", return_value="4.0") + @mock.patch("UpdaterApp.Util.get_qubes_version", return_value="4.1") def test_netcheck_should_succeed(self, mocked_qubes_version, mocked_output): """ When the network connectivity check is run in Qubes @@ -70,7 +70,7 @@ def test_netcheck_should_succeed(self, mocked_qubes_version, mocked_output): """ assert updater_app._is_netcheck_successful() - @mock.patch("UpdaterApp.Util.get_qubes_version", return_value="4.0") + @mock.patch("UpdaterApp.Util.get_qubes_version", return_value="4.1") @mock.patch("UpdaterApp.logger.error") @mock.patch("subprocess.check_output", return_value=b"none") def test_updater_app_with_no_connectivity_should_error( @@ -85,7 +85,7 @@ def test_updater_app_with_no_connectivity_should_error( updater_app_dialog._check_network_and_update() assert self._is_network_fail_view(updater_app_dialog) - @mock.patch("UpdaterApp.Util.get_qubes_version", return_value="4.0") + @mock.patch("UpdaterApp.Util.get_qubes_version", return_value="4.1") @mock.patch("subprocess.check_output", return_value=b"full") @mock.patch("UpdaterApp.logger.info") @mock.patch("UpdaterApp.UpgradeThread") diff --git a/launcher/tests/test_util.py b/launcher/tests/test_util.py index 1d7d367d..c91f789f 100644 --- a/launcher/tests/test_util.py +++ b/launcher/tests/test_util.py @@ -22,6 +22,8 @@ path_to_util = os.path.join(os.path.dirname(os.path.abspath(__file__)), relpath_util) util = SourceFileLoader("Util", path_to_util).load_module() +DEBIAN_VERSION = "bullseye" + @mock.patch("Util.sdlog.error") @mock.patch("Util.sdlog.warning") @@ -200,7 +202,6 @@ def test_for_conflicting_process( @pytest.mark.parametrize( "os_release_fixture,version_contains", [ - ("os-release-qubes-4.0", "4.0"), ("os-release-qubes-4.1", "4.1"), ("os-release-ubuntu", None), ("no-such-file", None), @@ -209,7 +210,7 @@ def test_for_conflicting_process( @mock.patch("Util.sdlog.error") @mock.patch("Util.sdlog.warning") @mock.patch("Util.sdlog.info") -@mock.patch("Util.OS_RELEASE_FILE", os.path.join(FIXTURES_PATH, "os-release-qubes-4.0")) +@mock.patch("Util.OS_RELEASE_FILE", os.path.join(FIXTURES_PATH, "os-release-qubes-4.1")) def test_detect_qubes( mocked_info, mocked_warning, mocked_error, os_release_fixture, version_contains ): @@ -232,7 +233,6 @@ def test_detect_qubes( @pytest.mark.parametrize( "os_release_fixture,expected_qt_version", [ - ("os-release-qubes-4.0", 4), ("os-release-qubes-4.1", 5), ("os-release-ubuntu", 4), ("no-such-file", 4), @@ -242,7 +242,7 @@ def test_detect_qubes( @mock.patch("Util.sdlog.error") @mock.patch("Util.sdlog.warning") @mock.patch("Util.sdlog.info") -@mock.patch("Util.OS_RELEASE_FILE", os.path.join(FIXTURES_PATH, "os-release-qubes-4.0")) +@mock.patch("Util.OS_RELEASE_FILE", os.path.join(FIXTURES_PATH, "os-release-qubes-4.1")) def test_pick_qt( mocked_info, mocked_warning, @@ -282,7 +282,7 @@ def test_pick_bad_qt(mocked_info, mocked_warning, mocked_error, env_override): """ mocked_env = {"SDW_UPDATER_QT": env_override} with mock.patch.dict("os.environ", mocked_env), mock.patch( - "Util.OS_RELEASE_FILE", os.path.join(FIXTURES_PATH, "os-release-qubes-4.0") + "Util.OS_RELEASE_FILE", os.path.join(FIXTURES_PATH, "os-release-qubes-4.1") ), pytest.raises(ValueError): util.get_qt_version() @@ -303,13 +303,12 @@ def test_get_logger(): @pytest.mark.parametrize( "os_release_fixture,version_contains", [ - ("os-release-qubes-4.0", "4.0"), ("os-release-qubes-4.1", "4.1"), ("os-release-ubuntu", None), ("no-such-file", None), ], ) -@mock.patch("Util.OS_RELEASE_FILE", os.path.join(FIXTURES_PATH, "os-release-qubes-4.0")) +@mock.patch("Util.OS_RELEASE_FILE", os.path.join(FIXTURES_PATH, "os-release-qubes-4.1")) def test_is_sdapp_halted_yes(os_release_fixture, version_contains): """ When sd-app state is 'Halted' @@ -317,7 +316,7 @@ def test_is_sdapp_halted_yes(os_release_fixture, version_contains): """ output = bytes( "NAME STATE CLASS LABEL TEMPLATE\nsd-app" - " Halted AppVM yellow sd-small-buster-template\n", + " Halted AppVM yellow sd-small-{}-template\n".format(DEBIAN_VERSION), "utf-8", ) @@ -329,13 +328,12 @@ def test_is_sdapp_halted_yes(os_release_fixture, version_contains): @pytest.mark.parametrize( "os_release_fixture,version_contains", [ - ("os-release-qubes-4.0", "4.0"), ("os-release-qubes-4.1", "4.1"), ("os-release-ubuntu", None), ("no-such-file", None), ], ) -@mock.patch("Util.OS_RELEASE_FILE", os.path.join(FIXTURES_PATH, "os-release-qubes-4.0")) +@mock.patch("Util.OS_RELEASE_FILE", os.path.join(FIXTURES_PATH, "os-release-qubes-4.1")) def test_is_sdapp_halted_no(os_release_fixture, version_contains): """ When sd-app is not Halted (i.e. Running, Pasued) @@ -343,7 +341,7 @@ def test_is_sdapp_halted_no(os_release_fixture, version_contains): """ output = bytes( "NAME STATE CLASS LABEL TEMPLATE\nsd-app" - " Paused AppVM yellow sd-small-buster-template\n", + " Paused AppVM yellow sd-small-{}-template\n".format(DEBIAN_VERSION), "utf-8", ) @@ -355,13 +353,12 @@ def test_is_sdapp_halted_no(os_release_fixture, version_contains): @pytest.mark.parametrize( "os_release_fixture,version_contains", [ - ("os-release-qubes-4.0", "4.0"), ("os-release-qubes-4.1", "4.1"), ("os-release-ubuntu", None), ("no-such-file", None), ], ) -@mock.patch("Util.OS_RELEASE_FILE", os.path.join(FIXTURES_PATH, "os-release-qubes-4.0")) +@mock.patch("Util.OS_RELEASE_FILE", os.path.join(FIXTURES_PATH, "os-release-qubes-4.1")) @mock.patch("subprocess.check_output", side_effect=subprocess.CalledProcessError(1, "check_output")) def test_is_sdapp_halted_error(patched_subprocess, os_release_fixture, version_contains): """ From b6f953b17032f1a6e6adf12f430beada84874d73 Mon Sep 17 00:00:00 2001 From: Michael Z Date: Thu, 23 Jun 2022 14:20:47 -0400 Subject: [PATCH 2/3] Stop building unnecessary fc25 rpms --- scripts/build-dom0-rpm | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/scripts/build-dom0-rpm b/scripts/build-dom0-rpm index 54ad218a..f32d3de1 100755 --- a/scripts/build-dom0-rpm +++ b/scripts/build-dom0-rpm @@ -27,22 +27,14 @@ export SOURCE_DATE_EPOCH # Place tarball where rpmbuild will find it cp dist/*.tar.gz rpm-build/SOURCES/ -# Build for Qubes 4.0.x and 4.1.x, for which dom0 is based on -# fedora-25 and fedora-32, respectively. -for i in 25 32; do - # dom0 defaults to python3.5 in fedora-25 - python_version="python3.5" - if [[ $i = 32 ]]; then - python_version="python3.8" - fi - dist=".fc${i}" - rpmbuild \ - --quiet \ - --define "_topdir $PWD/rpm-build" \ - --define "dist $dist" \ - --define "_python_version $python_version" \ - -bb --clean "rpm-build/SPECS/securedrop-workstation-dom0-config.spec" -done +python_version="python3.8" +dist=".fc32" +rpmbuild \ + --quiet \ + --define "_topdir $PWD/rpm-build" \ + --define "dist $dist" \ + --define "_python_version $python_version" \ + -bb --clean "rpm-build/SPECS/securedrop-workstation-dom0-config.spec" printf '\nBuild complete! RPMs and their checksums are:\n\n' find rpm-build/ -type f -iname '*.rpm' -print0 | sort -zV | xargs -0 sha256sum From f1ff276d333c11023bbf8e34a900ad27509ff3b3 Mon Sep 17 00:00:00 2001 From: Erik Moeller Date: Thu, 23 Jun 2022 16:15:47 -0700 Subject: [PATCH 3/3] Remove Qt5 print statement --- launcher/sdw-launcher.py | 1 - 1 file changed, 1 deletion(-) diff --git a/launcher/sdw-launcher.py b/launcher/sdw-launcher.py index a8fbf6be..e225b53b 100755 --- a/launcher/sdw-launcher.py +++ b/launcher/sdw-launcher.py @@ -8,7 +8,6 @@ import argparse if Util.get_qt_version() == 5: - print("Using Qt5 (experimental)") from PyQt5.QtWidgets import QApplication else: from PyQt4.QtGui import QApplication