Bug 27255 - fedabipkgdiff fails on nfs-utils on Fedora 33

Message ID 877dnyhdan.fsf@redhat.com
State New
Series Bug 27255 - fedabipkgdiff fails on nfs-utils on Fedora 33 |

Commit Message

Dodji Seketeli Jan. 27, 2021, 10:41 a.m. UTC

When running fedabipkgdiff as:

    fedabipkgdiff --self-compare -a --from fc33 nfs-utils

I am getting:

    Error encountered while running fedabipkgdiff with error message:

Running it with the --verbose option yields more clue, though.

It turns out that fedabipkgdiff runs abipkgdiff on an RPM and gives it
the wrong associated -debuginfo RPM.

This is because the member function
RPMCollection.get_sibling_debuginfo() doesn't returns the "first"
debuginfo package that comes with a given RPM.  In the case of the
package nfs-utils-2.5.2-1.rc4.fc33.aarch64.rpm, it was using the
package nfs-utils-coreos-debuginfo-2.5.2-1.rc4.fc33.aarch64.rpm
instead of the package nfs-utils-debuginfo-2.5.2-1.rc4.fc33.aarch64.rpm.

So, of course, abipkgdiff could not find the proper debuginfo for the
binaries carried by nfs-utils-2.5.2-1.rc4.fc33.aarch64.rpm.

This happens only in cases where there a several debuginfo packages
for a given RPM.  In that case, we need to be more careful to select
the right debuginfo package and not just a random one.

This patch adds a RPMCollection.get_matching_debuginfo() member function
that does the right thing.  It thus teaches
generate_comparison_halves() to use the new function.

	* tools/fedabipkgdiff (RPMCollection::get_sibling_debuginfo):
	Update comment.
	(RPMCollection::get_matching_debuginfo): Define new function.
	(generate_comparison_halves): Use
	RPMCollection::get_matching_debuginfo instead of

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
 tools/fedabipkgdiff | 28 ++++++++++++++++++++++++----
 1 file changed, 24 insertions(+), 4 deletions(-)


diff --git a/tools/fedabipkgdiff b/tools/fedabipkgdiff
index ea303a02..89cbd15c 100755
--- a/tools/fedabipkgdiff
+++ b/tools/fedabipkgdiff
@@ -514,11 +514,32 @@  class RPMCollection(object):
                 yield _rpm
     def get_sibling_debuginfo(self, rpm):
-        """Get sibling debuginfo package of given rpm"""
+        """Get sibling debuginfo package of given rpm
+        The sibling debuginfo is a debug info package for the
+        'rpm'.  Note that if there are several debuginfo packages
+        associated to 'rpm' and users want to get the one which name
+        matches exactly 'rpm', then they might want to use the member
+        function 'get_matching_debuginfo' instead.
+        """
         if rpm.arch not in self.ancillary_rpms:
             return None
         return self.ancillary_rpms[rpm.arch].get('debuginfo')
+    def get_matching_debuginfo(self, rpm):
+        """Get the debuginfo package that matches a given one """
+        all_debuginfo_list = self.get_all_debuginfo_rpms(rpm)
+        debuginfo_pkg = None
+        for d in all_debuginfo_list:
+            if d.name == '{0}-debuginfo'.format(rpm.name):
+                debuginfo_pkg = d
+                break
+        if not debuginfo_pkg:
+            debuginfo_pkg = self.get_sibling_debuginfo(rpm)
+        return debuginfo_pkg
     def get_sibling_devel(self, rpm):
         """Get sibling devel package of given rpm"""
         if rpm.arch not in self.ancillary_rpms:
@@ -578,8 +599,7 @@  def generate_comparison_halves(rpm_col1, rpm_col2):
         if _rpm.is_devel:
             debuginfo_list1 = rpm_col1.get_all_debuginfo_rpms(_rpm)
-            debuginfo_list1.append(rpm_col1.get_sibling_debuginfo(_rpm))
+            debuginfo_list1.append(rpm_col1.get_matching_debuginfo(_rpm))
         devel1 = rpm_col1.get_sibling_devel(_rpm)
@@ -590,7 +610,7 @@  def generate_comparison_halves(rpm_col1, rpm_col2):
             if rpm2.is_devel:
                 debuginfo_list2 = rpm_col2.get_all_debuginfo_rpms(rpm2)
-                debuginfo_list2.append(rpm_col2.get_sibling_debuginfo(rpm2))
+                debuginfo_list2.append(rpm_col2.get_matching_debuginfo(rpm2))
             devel2 = rpm_col2.get_sibling_devel(rpm2)
         yield (ComparisonHalf(subject=_rpm,