Skip to content

Commit

Permalink
Remove old leapp packages before installation to make sure we user ri…
Browse files Browse the repository at this point in the history
…ght version of packages
  • Loading branch information
Mikhail Sandakov committed Aug 29, 2024
1 parent 13a01f8 commit 81bdac0
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions centos2almaconverter/actions/installation.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,24 @@ def __init__(self):
"leapp-data-almalinux-0.2-15.el7.20230823",
]

def _remove_previous_installation(self) -> None:
# Remove previously installed leapp packages to make sure we will install the correct version
pkgs_to_remove = rpm.filter_installed_packages(["leapp", "python2-leapp", "leapp-data-almalinux"])
if pkgs_to_remove:
util.logged_check_call(["/usr/bin/yum", "remove", "-y"] + pkgs_to_remove)

# The directory contains leapp-data package configurations, which causes problems with
# the package installation. So we have to remove it, to reinstall package from scratch.
conflict_directory = "/etc/leapp/repos.d/system_upgrade"
if os.path.exists(conflict_directory):
shutil.rmtree(conflict_directory)

def _prepare_action(self) -> action.ActionResult:
if not rpm.is_package_installed("elevate-release"):
util.logged_check_call(["/usr/bin/yum", "install", "-y", "https://repo.almalinux.org/elevate/elevate-release-latest-el7.noarch.rpm"])

self._remove_previous_installation()

util.logged_check_call(["/usr/bin/yum-config-manager", "--enable", "elevate"])

util.logged_check_call(["/usr/bin/yum", "install", "-y"] + self.pkgs_to_install)
Expand Down

0 comments on commit 81bdac0

Please sign in to comment.