[applied] abipkgdiff: Avoid wrongly considering binaries being added/removed

Message ID 87msdo7b82.fsf@redhat.com
State New
Headers
Series [applied] abipkgdiff: Avoid wrongly considering binaries being added/removed |

Commit Message

Dodji Seketeli March 13, 2025, 11:38 p.m. UTC
  Hello,

When the layout of binaries in a package changes across versions of
the package, abipkgdiff can wrongly consider one particular binary to
be removed from the old package and then added again in the new one,
even though the SONAME (when present) has not changed.

This patch makes it so that only the SONAME (when present) is used as
a key for the binary.  That fixes the issue.

	* tools/abipkgdiff.cc (create_maps_of_package_set_content): Use
	the SONAME when present as the key of the binary.
	* tests/data/test-diff-pkg/dbus-glib-0.104-3.fc23.x86_64--dbus-glib-0.104-3.fc23.armv7hl-report-0.txt: Adjust.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
---
 ..._64--dbus-glib-0.104-3.fc23.armv7hl-report-0.txt | 13 +++++++++----
 tools/abipkgdiff.cc                                 | 10 ++--------
 2 files changed, 11 insertions(+), 12 deletions(-)
  

Patch

diff --git a/tests/data/test-diff-pkg/dbus-glib-0.104-3.fc23.x86_64--dbus-glib-0.104-3.fc23.armv7hl-report-0.txt b/tests/data/test-diff-pkg/dbus-glib-0.104-3.fc23.x86_64--dbus-glib-0.104-3.fc23.armv7hl-report-0.txt
index 8bd25704..b72d855b 100644
--- a/tests/data/test-diff-pkg/dbus-glib-0.104-3.fc23.x86_64--dbus-glib-0.104-3.fc23.armv7hl-report-0.txt
+++ b/tests/data/test-diff-pkg/dbus-glib-0.104-3.fc23.x86_64--dbus-glib-0.104-3.fc23.armv7hl-report-0.txt
@@ -1,3 +1,12 @@ 
+================ changes of 'libdbus-glib-1.so.2.3.2'===============
+  ELF architecture changed
+  Functions changes summary: 0 Removed, 0 Changed, 0 Added function
+  Variables changes summary: 0 Removed, 0 Changed, 0 Added variable
+
+  architecture changed from 'elf-amd-x86_64' to 'elf-arm'
+
+================ end of changes of 'libdbus-glib-1.so.2.3.2'===============
+
 ================ changes of 'dbus-binding-tool'===============
   ELF architecture changed
   Functions changes summary: 0 Removed, 0 Changed, 0 Added function
@@ -17,7 +26,3 @@ 
 
 ================ end of changes of 'dbus-binding-tool'===============
 
-Removed binaries:
-  [D] /usr/lib64/libdbus-glib-1.so.2.3.2, SONAME: libdbus-glib-1.so.2
-Added binaries:
-  [A] /usr/lib/libdbus-glib-1.so.2.3.2, SONAME: libdbus-glib-1.so.2
diff --git a/tools/abipkgdiff.cc b/tools/abipkgdiff.cc
index aae23577..5193f7c4 100644
--- a/tools/abipkgdiff.cc
+++ b/tools/abipkgdiff.cc
@@ -2850,11 +2850,11 @@  create_maps_of_package_set_content(const package_set_sptr& ps,
 	  // soname.  So let's *also* consider the full path of the
 	  // binary inside the extracted directory, not just the
 	  // soname.
-	  string key = e->soname;
+	  string key = string("/@soname:") + e->soname;
 
 	  if (must_compare_public_dso_only(ps, opts))
 	    {
-	      if (ps->public_dso_sonames().find(key)
+	      if (ps->public_dso_sonames().find(e->soname)
 		  == ps->public_dso_sonames().end())
 		{
 		  // We are instructed to compare public DSOs only and
@@ -2867,12 +2867,6 @@  create_maps_of_package_set_content(const package_set_sptr& ps,
 		}
 	    }
 
-	  if (ps->convert_path_to_unique_suffix(resolved_e_path, key))
-	    {
-	      dir_name(key, key);
-	      key += string("/@soname:") + e->soname;
-	    }
-
 	  if (ps->path_elf_file_sptr_map().find(key)
 	      != ps->path_elf_file_sptr_map().end())
 	    // 'key' has already been seen before.  So we won't do itl