From 549998a867bdd32b9d98de6d047a6544db94ec80 Mon Sep 17 00:00:00 2001 From: mhecko Date: Tue, 2 Apr 2024 11:24:49 +0200 Subject: [PATCH] pes_events_scanner: override repositories when applying an event The Package class has custom __hash__ and __eq__ methods in order to achieve a straightforward presentation via set manipulation. However, this causes problems, e.g., when applying split events. For example: Applying the event Split(in={(A, repo1)}, out={(A, repo2), (B, repo2)}) to the package state {(A, repo1), (B, repo1)} results in the following: {(A, repo1), (B, repo1)} --apply--> {(A, repo2), (B, repo1)} which is undesired as repo1 is a source system repository. Such a package will get reported to the user as potentially removed during the upgrade. This patch addresses this unwanted behavior. --- .../actors/peseventsscanner/libraries/pes_events_scanner.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/repos/system_upgrade/common/actors/peseventsscanner/libraries/pes_events_scanner.py b/repos/system_upgrade/common/actors/peseventsscanner/libraries/pes_events_scanner.py index f9411dfe0e..4f36c75612 100644 --- a/repos/system_upgrade/common/actors/peseventsscanner/libraries/pes_events_scanner.py +++ b/repos/system_upgrade/common/actors/peseventsscanner/libraries/pes_events_scanner.py @@ -139,8 +139,9 @@ def compute_pkg_changes_between_consequent_releases(source_installed_pkgs, if event.action == Action.PRESENT: for pkg in event.in_pkgs: if pkg in seen_pkgs: + # Remove the package with the old repository, add the one with the new one. The Package class has + # a custom __hash__ and __eq__ comparing only name and modulestream - pkg.repository is ignored. if pkg in target_pkgs: - # Remove the package with the old repository, add the one with the new one target_pkgs.remove(pkg) target_pkgs.add(pkg) elif event.action == Action.DEPRECATED: @@ -163,7 +164,10 @@ def compute_pkg_changes_between_consequent_releases(source_installed_pkgs, event.id, event.action, removed_pkgs_str, added_pkgs_str) # In pkgs are present, event can be applied + # Note: We do a .difference(event.out_packages) followed by an .union(event.out_packages) to overwrite + # # repositories of the packages (Package has overwritten __hash__ and __eq__) target_pkgs = target_pkgs.difference(event.in_pkgs) + target_pkgs = target_pkgs.difference(event.out_pkgs) target_pkgs = target_pkgs.union(event.out_pkgs) pkgs_to_demodularize = pkgs_to_demodularize.difference(event.in_pkgs)