Skip to content

Commit

Permalink
Fix exclude parameter in dnf transaction handler
Browse files Browse the repository at this point in the history
  • Loading branch information
r0x0d authored and Venefilyn committed Aug 13, 2024
1 parent ccf12a9 commit a89a0ec
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 33 deletions.
7 changes: 4 additions & 3 deletions convert2rhel/pkgmanager/handlers/dnf/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."""
Expand Down
30 changes: 0 additions & 30 deletions convert2rhel/unit_tests/pkghandler_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand Down

0 comments on commit a89a0ec

Please sign in to comment.