Skip to content

Commit

Permalink
Honor protect_running_kernel configuration option
Browse files Browse the repository at this point in the history
= changelog =
msg: Introduce protect_running_kernel config option
type: enhancement
resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1698145

Closes: #1625
Approved by: lukash
  • Loading branch information
pkratoch authored and rh-atomic-bot committed Sep 17, 2020
1 parent 241c258 commit 9db593d
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 1 deletion.
2 changes: 2 additions & 0 deletions dnf/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,7 @@ def fill_sack(self, load_system_repo=True, load_available_repos=True):
self._setup_excludes_includes()
timer()
self._goal = dnf.goal.Goal(self._sack)
self._goal.protect_running_kernel = conf.protect_running_kernel
self._plugins.run_sack()
return self._sack

Expand Down Expand Up @@ -488,6 +489,7 @@ def reset(self, sack=False, repos=False, goal=False):
self._goal = None
if self._sack is not None:
self._goal = dnf.goal.Goal(self._sack)
self._goal.protect_running_kernel = self.conf.protect_running_kernel
if self._sack and self._moduleContainer:
# sack must be set to enable operations on moduleContainer
self._moduleContainer.rollback()
Expand Down
1 change: 1 addition & 0 deletions dnf/cli/commands/check.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ def run(self):
selector = dnf.selector.Selector(sack)
selector.set(provides=str(require))
goal = dnf.goal.Goal(sack)
goal.protect_running_kernel = self.base.conf.protect_running_kernel
goal.install(select=selector, optional=False)
solved = goal.run()
# there ase only @system repo in sack, therefore solved is only in case
Expand Down
9 changes: 8 additions & 1 deletion doc/conf_ref.rst
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,14 @@ configuration file by your distribution to override the DNF defaults.

The default is: ``dnf``, ``glob:/etc/yum/protected.d/*.conf`` and ``glob:/etc/dnf/protected.d/*.conf``. So any packages which should be protected can do so by including a file in ``/etc/dnf/protected.d`` with their package name in it.

DNF will protect also the package corresponding to the running version of the kernel.
DNF will protect also the package corresponding to the running version of the kernel. See also :ref:`protect_running_kernel <protect_running_kernel-label>` option.

.. _protect_running_kernel-label:

``protect_running_kernel``
:ref:`boolean <boolean-label>`

Controls whether the package corresponding to the running version of kernel is protected from removal. Default is ``True``.

``releasever``
:ref:`string <string-label>`
Expand Down
2 changes: 2 additions & 0 deletions tests/support.py
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,7 @@ def init_sack(self):

self._sack._configure(self.conf.installonlypkgs)
self._goal = dnf.goal.Goal(self._sack)
self._goal.protect_running_kernel = self.conf.protect_running_kernel
return self._sack

def mock_cli(self):
Expand Down Expand Up @@ -494,6 +495,7 @@ def __init__(self, **kwargs):
('persistdir', dnf.const.PERSISTDIR),
('transformdb', False),
('protected_packages', ["dnf"]),
('protect_running_kernel', True),
('plugins', False),
('showdupesfromrepos', False),
('tsflags', []),
Expand Down

0 comments on commit 9db593d

Please sign in to comment.