From a89a0ec8338696a031d705bb1ea2f1d18eb7acc1 Mon Sep 17 00:00:00 2001 From: Rodolfo Olivieri Date: Wed, 26 Jun 2024 14:24:49 -0300 Subject: [PATCH] Fix exclude parameter in dnf transaction handler --- .../pkgmanager/handlers/dnf/__init__.py | 7 +++-- convert2rhel/unit_tests/pkghandler_test.py | 30 ------------------- 2 files changed, 4 insertions(+), 33 deletions(-) diff --git a/convert2rhel/pkgmanager/handlers/dnf/__init__.py b/convert2rhel/pkgmanager/handlers/dnf/__init__.py index 02275c4b25..7e166b23ec 100644 --- a/convert2rhel/pkgmanager/handlers/dnf/__init__.py +++ b/convert2rhel/pkgmanager/handlers/dnf/__init__.py @@ -86,9 +86,10 @@ def _set_up_base(self): # going in with the packages in the transaction. self._base._ds_callback = DependencySolverProgressIndicatorCallback() - # Override the exclude option that is loaded from the config and set it - # to empty. - self._base.conf.substitutions["exclude"] = [] + # Override the exclude option that is loaded from the config and set it to empty. + # NOTE(r0x0d): In DNF they have exclude to be `py:excludepkgs`. It is fine to use `exclude` for now as it is + # compatible with yum. + self._base.conf.exclude = [] def _enable_repos(self): """Enable a list of required repositories.""" diff --git a/convert2rhel/unit_tests/pkghandler_test.py b/convert2rhel/unit_tests/pkghandler_test.py index c4e78364eb..c5b01886d7 100644 --- a/convert2rhel/unit_tests/pkghandler_test.py +++ b/convert2rhel/unit_tests/pkghandler_test.py @@ -231,36 +231,6 @@ def test_get_rpm_header_failure(self, monkeypatch): pkghandler.get_rpm_header(unknown_pkg) -class TestPreserveOnlyRHELKernel: - @centos7 - def test_preserve_only_rhel_kernel(self, pretend_os, monkeypatch): - monkeypatch.setattr(pkghandler, "install_rhel_kernel", lambda: True) - monkeypatch.setattr(pkghandler, "fix_invalid_grub2_entries", lambda: None) - monkeypatch.setattr(pkghandler, "remove_non_rhel_kernels", mock.Mock(return_value=[])) - monkeypatch.setattr(pkghandler, "install_gpg_keys", mock.Mock()) - monkeypatch.setattr(utils, "run_subprocess", RunSubprocessMocked()) - monkeypatch.setattr( - pkghandler, - "get_installed_pkgs_by_fingerprint", - GetInstalledPkgsByFingerprintMocked(return_value=[create_pkg_information(name="kernel")]), - ) - monkeypatch.setattr(system_info, "name", "CentOS7") - monkeypatch.setattr(system_info, "arch", "x86_64") - monkeypatch.setattr(utils, "store_content_to_file", StoreContentToFileMocked()) - - pkghandler.preserve_only_rhel_kernel() - - assert utils.run_subprocess.cmd == [ - "yum", - "update", - "--setopt=exclude=", - "-y", - "--releasever=7Server", - "kernel", - ] - assert pkghandler.get_installed_pkgs_by_fingerprint.call_count == 1 - - class TestGetKernelAvailability: @pytest.mark.parametrize( ("subprocess_output", "expected_installed", "expected_available"),