Skip to content

Commit

Permalink
Fix The same or higher version of epel-release is already installed
Browse files Browse the repository at this point in the history
… error
  • Loading branch information
to-bar committed Jun 8, 2022
1 parent d775dad commit 8a0307b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,17 @@ class Dnf(DnfBase):
def update(self, package: str = None,
disablerepo: str = None,
enablerepo: str = None,
ignore_already_installed_error: bool = False,
releasever: str = None,
assume_yes: bool = True):

"""
Interface for `dnf update`
:param package:
:param disablerepo:
:param enablerepo:
:param ignore_already_installed_error: if set to True,
`The same or higher version of {package} is already installed` error is ignored
:param releasever:
:param assume_yes: if set to True, -y flag will be used
"""
Expand All @@ -61,11 +63,18 @@ def update(self, package: str = None,
if 'error' in proc.stdout:
raise CriticalError(
f'Found an error. dnf update failed for package `{package}`, reason: `{proc.stdout}`')
if self._filter_non_critical_errors(proc.stderr):

filtered_stderr: str = self._filter_non_critical_errors(proc.stderr)

if filtered_stderr:
if (ignore_already_installed_error
and all(string in filtered_stderr for string in
('The same or higher version', 'is already installed, cannot update it.'))):
return

raise CriticalError(
f'dnf update failed for packages `{package}`, reason: `{proc.stderr}`')


def install(self, package: str,
assume_yes: bool = True):
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ def _install_base_packages(self):
if not epel_package_initially_present:
self.__installed_packages.append('epel-release')
else:
self._tools.dnf.update('https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm')
self._tools.dnf.update('https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm',
ignore_already_installed_error=True)

self.__remove_dnf_cache_for_custom_repos()
self._tools.dnf.makecache(timer=True)
Expand Down

0 comments on commit 8a0307b

Please sign in to comment.