Skip to content

Commit

Permalink
Fix the issue
Browse files Browse the repository at this point in the history
  • Loading branch information
hosekadam committed Feb 19, 2024
1 parent 9b08cc6 commit 61b1eb4
Show file tree
Hide file tree
Showing 17 changed files with 297 additions and 38 deletions.
12 changes: 7 additions & 5 deletions convert2rhel/data/7/ppc64/configs/centos-7-ppc64.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,13 @@ gpg_fingerprints =
# List of packages to be removed before the system conversion starts.
# Delimited by any whitespace(s).
excluded_pkgs =
centos-bookmarks
centos-logos
centos-indexhtml
libreport-centos
libreport-plugin-mantisbt

# Mapping of packages that need to be swapped during the transaction
swap_pkgs =
centos-logos | redhat-logos
centos-indexhtml | redhat-indexhtml
centos-bookmarks | redhat-bookmarks
libreport-centos | libreport-rhel

# List of packages that either contain repofiles or affect variables in the repofiles (e.g. $releasever).
# Delimited by any whitespace(s).
Expand Down
12 changes: 7 additions & 5 deletions convert2rhel/data/7/x86_64/configs/centos-7-x86_64.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,22 @@ gpg_fingerprints = 24c6a8a7f4a80eb5
# Delimited by any whitespace(s).
excluded_pkgs =
anaconda-dracut
centos-bookmarks
centos-indexhtml
centos-logos
cockpit-subscriptions
geoipupdate
kmod-kvdo
libreport-centos
libreport-plugin-mantisbt
mod_ldap
mod_proxy_html
rhn*
yum-rhn-plugin
gnome-documents-libs

# Mapping of packages that need to be swapped during the transaction
swap_pkgs =
centos-logos | redhat-logos
centos-indexhtml | redhat-indexhtml
centos-bookmarks | redhat-bookmarks
libreport-centos | libreport-rhel

# List of packages that either contain repofiles or affect variables in the repofiles (e.g. $releasever).
# Delimited by any whitespace(s).
repofile_pkgs =
Expand Down
5 changes: 4 additions & 1 deletion convert2rhel/data/7/x86_64/configs/oracle-7-x86_64.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ gpg_fingerprints = 72f97b74ec551f03
excluded_pkgs =
akonadi-mysql
anaconda-dracut
oracle-logos
oracle-rdbms-server-*
oracleasm-support
rhn-check
Expand All @@ -26,6 +25,10 @@ excluded_pkgs =
gnome-documents-libs
shim-x64

# Mapping of packages that need to be swapped during the transaction
swap_pkgs =
oracle-logos | redhat-logos

# List of packages that either contain repofiles or affect variables in the repofiles (e.g. $releasever).
# The rhn-client-tools package contains repofiles on OL 7.6 and older, but when it's installed it's not possible to
# install subscription-manager. That means that the conversion using RHSM is not possible on OL 7.6 and older.
Expand Down
9 changes: 6 additions & 3 deletions convert2rhel/data/7/x86_64/configs/scientific-7-x86_64.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@ gpg_fingerprints = b0b4183f192a7d7d
# Delimited by any whitespace(s).
excluded_pkgs =
anaconda-dracut
sl-bookmarks
sl-indexhtml
sl-logos
sl-release-notes
sl7-upgrade
cockpit-subscriptions
Expand All @@ -23,6 +20,12 @@ excluded_pkgs =
rhn*
yum-rhn-plugin

# Mapping of packages that need to be swapped during the transaction
swap_pkgs =
sl-logos | redhat-logos
sl-indexhtml | redhat-indexhtml
sl-bookmarks | redhat-bookmarks

# List of packages that either contain repofiles or affect variables in the repofiles (e.g. $releasever).
# Delimited by any whitespace(s).
repofile_pkgs =
Expand Down
11 changes: 8 additions & 3 deletions convert2rhel/data/8/x86_64/configs/almalinux-8-x86_64.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,15 @@ gpg_fingerprints =
# List of packages to be removed before the system conversion starts.
# Delimited by any whitespace(s).
excluded_pkgs =
almalinux-logos*
almalinux-indexhtml
almalinux-gpg-keys
almalinux-backgrounds*

# Mapping of packages that need to be swapped during the transaction
swap_pkgs =
almalinux-logos | redhat-logos
almalinux-logos-httpd | redhat-logos-httpd
almalinux-logos-ipa | redhat-logos-ipa
almalinux-indexhtml | redhat-indexhtml
almalinux-backgrounds | redhat-backgrounds

# List of packages that either contain repofiles or affect variables in the repofiles (e.g. $releasever).
# Delimited by any whitespace(s).
Expand Down
11 changes: 8 additions & 3 deletions convert2rhel/data/8/x86_64/configs/centos-8-x86_64.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,16 @@ gpg_fingerprints = 05b555b38483c65d
# List of packages to be removed before the system conversion starts.
# Delimited by any whitespace(s).
excluded_pkgs =
centos-logos*
centos-indexhtml
centos-obsolete-packages
centos-gpg-keys
centos-backgrounds

# Mapping of packages that need to be swapped during the transaction
swap_pkgs =
centos-logos | redhat-logos
centos-logos-httpd | redhat-logos-httpd
centos-logos-ipa | redhat-logos-ipa
centos-indexhtml | redhat-indexhtml
centos-backgrounds | redhat-backgrounds

# List of packages that either contain repofiles or affect variables in the repofiles (e.g. $releasever).
# Delimited by any whitespace(s).
Expand Down
12 changes: 9 additions & 3 deletions convert2rhel/data/8/x86_64/configs/oracle-8-x86_64.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,15 @@ gpg_fingerprints = 82562ea9ad986da3
# List of packages to be removed before the system conversion starts.
# Delimited by any whitespace(s).
excluded_pkgs =
oracle-logos*
oracle-indexhtml
oracle-backgrounds


# Mapping of packages that need to be swapped during the transaction
swap_pkgs =
oracle-logos | redhat-logos
oracle-logos-httpd | redhat-logos-httpd
oracle-logos-ipa | redhat-logos-ipa
oracle-indexhtml | redhat-indexhtml
oracle-backgrounds | redhat-backgrounds

# List of packages that either contain repofiles or affect variables in the repofiles (e.g. $releasever).
# Delimited by any whitespace(s).
Expand Down
11 changes: 8 additions & 3 deletions convert2rhel/data/8/x86_64/configs/rocky-8-x86_64.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,16 @@ gpg_fingerprints = 15af5dac6d745a60
# List of packages to be removed before the system conversion starts.
# Delimited by any whitespace(s).
excluded_pkgs =
rocky-logos*
rocky-indexhtml
rocky-obsolete-packages
rocky-gpg-keys
rocky-backgrounds

# Mapping of packages that need to be swapped during the transaction
swap_pkgs =
rocky-logos | redhat-logos
rocky-logos-httpd | redhat-logos-httpd
rocky-logos-ipa | redhat-logos-ipa
rocky-indexhtml | redhat-indexhtml
rocky-backgrounds | redhat-backgrounds

# List of packages that either contain repofiles or affect variables in the repofiles (e.g. $releasever).
# Delimited by any whitespace(s).
Expand Down
12 changes: 9 additions & 3 deletions convert2rhel/data/9/x86_64/configs/almalinux-9-x86_64.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,16 @@ gpg_fingerprints = d36cb86cb86b3716
# List of packages to be removed before the system conversion starts.
# Delimited by any whitespace(s).
excluded_pkgs =
almalinux-logos*
almalinux-indexhtml
almalinux-gpg-keys
almalinux-backgrounds*

# Mapping of packages that need to be swapped during the transaction
swap_pkgs =
almalinux-logos | redhat-logos
almalinux-logos-httpd | redhat-logos-httpd
almalinux-logos-ipa | redhat-logos-ipa
almalinux-indexhtml | redhat-indexhtml
almalinux-backgrounds | redhat-backgrounds


# List of packages that either contain repofiles or affect variables in the repofiles (e.g. $releasever).
# Delimited by any whitespace(s).
Expand Down
11 changes: 8 additions & 3 deletions convert2rhel/data/9/x86_64/configs/oracle-9-x86_64.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,14 @@ gpg_fingerprints =
# List of packages to be removed before the system conversion starts.
# Delimited by any whitespace(s).
excluded_pkgs =
oracle-logos*
oracle-indexhtml
oracle-backgrounds

# Mapping of packages that need to be swapped during the transaction
swap_pkgs =
oracle-logos | redhat-logos
oracle-logos-httpd | redhat-logos-httpd
oracle-logos-ipa | redhat-logos-ipa
oracle-indexhtml | redhat-indexhtml
oracle-backgrounds | redhat-backgrounds

# List of packages that either contain repofiles or affect variables in the repofiles (e.g. $releasever).
# Delimited by any whitespace(s).
Expand Down
11 changes: 8 additions & 3 deletions convert2rhel/data/9/x86_64/configs/rocky-9-x86_64.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,16 @@ gpg_fingerprints = 702d426d350d275d
# List of packages to be removed before the system conversion starts.
# Delimited by any whitespace(s).
excluded_pkgs =
rocky-logos*
rocky-indexhtml
rocky-obsolete-packages
rocky-gpg-keys
rocky-backgrounds

# Mapping of packages that need to be swapped during the transaction
swap_pkgs =
rocky-logos | redhat-logos
rocky-logos-httpd | redhat-logos-httpd
rocky-logos-ipa | redhat-logos-ipa
rocky-indexhtml | redhat-indexhtml
rocky-backgrounds | redhat-backgrounds

# List of packages that either contain repofiles or affect variables in the repofiles (e.g. $releasever).
# Delimited by any whitespace(s).
Expand Down
22 changes: 22 additions & 0 deletions convert2rhel/pkgmanager/handlers/dnf/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,26 @@ def _enable_repos(self):
diagnosis="Loading repository metadata failed with error %s." % (str(e)),
)

def _swap_base_os_specific_packages(self):
"""Swap base os specific packages for their RHEL counterparts in the transaction.
Some packages need to be manually injected in the transaction as a
"swap", since those packages are not always able to be installed
automatically by yum if they don't exist in the system anymore, this
can cause problems during the transaction as missing dependencies.
"""
# Related issue: https://issues.redhat.com/browse/RHELC-1130, see comments
# to get more proper description of solution
for old_package, new_package in system_info.swap_pkgs.items():
loggerinst.debug("Checking if %s installed for later swap." % old_package)
is_installed = system_info.is_rpm_installed(old_package)
if is_installed:
loggerinst.debug("Package %s will be swapped to %s during conversion." % (old_package, new_package))
# Order of commands based on DNF implementation of swap, different from YUM order:
# https://github.com/rpm-software-management/dnf/blob/master/dnf/cli/commands/swap.py#L60
self._base.install(pkg_spec=new_package)
self._base.remove(pkg_spec=old_package)

def _perform_operations(self):
"""Perform the necessary operations in the transaction.
Expand Down Expand Up @@ -146,6 +166,8 @@ def _perform_operations(self):
except pkgmanager.exceptions.PackagesNotInstalledError:
loggerinst.warning("Package %s not available in RHEL repositories.", pkg)

self._swap_base_os_specific_packages()

def _resolve_dependencies(self):
"""Resolve the dependencies for the transaction.
Expand Down
25 changes: 24 additions & 1 deletion convert2rhel/pkgmanager/handlers/yum/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,26 @@ def _enable_repos(self):
diagnosis="Loading repository metadata failed with error %s." % (str(e)),
)

def _swap_base_os_specific_packages(self):
"""Swap base os specific packages for their RHEL counterparts in the transaction.
Some packages need to be manually injected in the transaction as a
"swap", since those packages are not always able to be installed
automatically by yum if they don't exist in the system anymore, this
can cause problems during the transaction as missing dependencies.
"""
# Related issue: https://issues.redhat.com/browse/RHELC-1130, see comments
# to get more proper description of solution
for old_package, new_package in system_info.swap_pkgs.items():
loggerinst.debug("Checking if %s installed for later swap." % old_package)
is_installed = system_info.is_rpm_installed(old_package)
if is_installed:
loggerinst.debug("Package %s will be swapped to %s during conversion." % (old_package, new_package))
# Order of operations based on YUM implementation of swap:
# https://github.com/rpm-software-management/yum/blob/master/yumcommands.py#L3488
self._base.remove(pattern=old_package)
self._base.install(pattern=new_package)

def _perform_operations(self):
"""Perform the necessary operations in the transaction.
Expand All @@ -187,7 +207,6 @@ def _perform_operations(self):
# being outdated in the system after the conversion.
if can_update:
continue

try:
self._base.reinstall(pattern=pkg)
except (pkgmanager.Errors.ReinstallInstallError, pkgmanager.Errors.ReinstallRemoveError):
Expand All @@ -199,6 +218,10 @@ def _perform_operations(self):
pkgmanager.Errors.DowngradeError,
):
loggerinst.warning("Package %s not available in RHEL repositories.", pkg)

# Swapping the packages needs to be after the operations
# If not, swapped packages are removed from transaction as obsolete
self._swap_base_os_specific_packages()
except pkgmanager.Errors.NoMoreMirrorsRepoError as e:
loggerinst.debug("Got the following exception message: %s", e)
loggerinst.critical_no_exit("There are no suitable mirrors available for the loaded repositories.")
Expand Down
33 changes: 33 additions & 0 deletions convert2rhel/systeminfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ def __init__(self):
self.eus_system = None
# Packages to be removed before the system conversion
self.excluded_pkgs = []
# Packages that need to perform a swap in the transaction
self.swap_pkgs = {}
# Release packages to be removed before the system conversion
self.repofile_pkgs = []
self.cfg_filename = None
Expand Down Expand Up @@ -124,6 +126,7 @@ def resolve_system_info(self):
self.cfg_filename = self._get_cfg_filename()
self.cfg_content = self._get_cfg_content()
self.excluded_pkgs = self._get_excluded_pkgs()
self.swap_pkgs = self._get_swap_pkgs()
self.repofile_pkgs = self._get_repofile_pkgs()
self.default_rhsm_repoids = self._get_default_rhsm_repoids()
self.eus_rhsm_repoids = self._get_eus_rhsm_repoids()
Expand Down Expand Up @@ -251,6 +254,36 @@ def _get_gpg_key_fingerprints(self):
def _get_excluded_pkgs(self):
return self._get_cfg_opt("excluded_pkgs").split()

def _get_swap_pkgs(self):
pkgs_to_swap = {}

try:
lines = self._get_cfg_opt("swap_pkgs").strip().split("\n")
for line in lines:
old_package, new_package = tuple(line.split("|"))

old_package = old_package.strip()
new_package = new_package.strip()

if old_package in pkgs_to_swap:
self.logger.warning(
"Package {old_package} redefined in swap packages list.\n"
"Old package {old_package} will be swapped by {newest_package} instead of {new_package}.".format(
old_package=old_package, new_package=pkgs_to_swap[old_package], newest_package=new_package
)
)
pkgs_to_swap.update({old_package: new_package})

except ValueError:
# Leave the swap packages dict empty, packages for swap aren't defined
self.logger.debug("Leaving the swap package list empty. No packages defined.")

except AttributeError:
# Leave the swap packages dict empty, missing swap_pkgs in config file
self.logger.warning("Leaving the swap package list empty. Missing swap_pkgs key in configuration file.")

return pkgs_to_swap

def _get_repofile_pkgs(self):
return self._get_cfg_opt("repofile_pkgs").split()

Expand Down
Loading

0 comments on commit 61b1eb4

Please sign in to comment.