Skip to content

Commit

Permalink
Merge pull request #218 from plesk/avoid-rewrite-removed-packages
Browse files Browse the repository at this point in the history
Append the recently removed conflict packages instead of overwriting to prevent issues if centos2alma server is started multiple times
  • Loading branch information
SandakovMM authored Mar 26, 2024
2 parents cae72cf + 44a18f1 commit b3cfe83
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions actions/packages.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,16 +114,16 @@ def _prepare_action(self):

rpm.remove_packages(packages_to_remove)

with open(self.removed_packages_file, "w") as f:
f.write("\n".join(packages_to_remove))
with open(self.removed_packages_file, "a") as f:
f.write("\n".join(packages_to_remove) + "\n")

def _post_action(self):
if not os.path.exists(self.removed_packages_file):
log.warn("File with removed packages list is not exists. While the action itself was not skipped. Skip reinstalling packages.")
return

with open(self.removed_packages_file, "r") as f:
packages_to_install = [self.conflict_pkgs_map[pkg] for pkg in f.read().splitlines()]
packages_to_install = [self.conflict_pkgs_map[pkg] for pkg in set(f.read().splitlines())]
rpm.install_packages(packages_to_install)

os.unlink(self.removed_packages_file)
Expand All @@ -134,7 +134,7 @@ def _revert_action(self):
return

with open(self.removed_packages_file, "r") as f:
packages_to_install = f.read().splitlines()
packages_to_install = list(set(f.read().splitlines()))
rpm.install_packages(packages_to_install)

os.unlink(self.removed_packages_file)
Expand Down

0 comments on commit b3cfe83

Please sign in to comment.