Blame SOURCES/0026-reportclient-Find-and-download-required-debuginfo-pa.patch

8256c5
From 23110cb7198e53c1e211ba8a41c7406b04641574 Mon Sep 17 00:00:00 2001
8256c5
From: Martin Kutlak <mkutlak@redhat.com>
8256c5
Date: Mon, 3 Dec 2018 13:54:34 +0100
8256c5
Subject: [PATCH] reportclient: Find and download required debuginfo packages
8256c5
8256c5
The current solution finds packages for given build-ids and then
8256c5
downloads them. The problem is that some debuginfo packages require
8256c5
other packages and if they are not available the generated backtrace
8256c5
becomes unusable.
8256c5
8256c5
This commit adds a query for required packages and downloads them together
8256c5
with the main packages.
8256c5
8256c5
Related: rhbz#1515265
8256c5
8256c5
Signed-off-by: Martin Kutlak <mkutlak@redhat.com>
8256c5
---
8256c5
 .../reportclient/dnfdebuginfo.py              | 34 +++++++++++++------
8256c5
 1 file changed, 23 insertions(+), 11 deletions(-)
8256c5
8256c5
diff --git a/src/client-python/reportclient/dnfdebuginfo.py b/src/client-python/reportclient/dnfdebuginfo.py
8256c5
index 1867484f..04f98579 100644
8256c5
--- a/src/client-python/reportclient/dnfdebuginfo.py
8256c5
+++ b/src/client-python/reportclient/dnfdebuginfo.py
8256c5
@@ -106,26 +106,38 @@ class DNFDebugInfoDownload(DebugInfoDownload):
8256c5
             print(_("Error setting up repositories: '{0!s}'").format(str(ex)))
8256c5
 
8256c5
     def triage(self, files):
8256c5
-        q = self.base.sack.query()
8256c5
-        i = q.available()
8256c5
+        dnf_query = self.base.sack.query()
8256c5
+        dnf_available = dnf_query.available()
8256c5
         package_files_dict = {}
8256c5
         not_found = []
8256c5
         todownload_size = 0
8256c5
         installed_size = 0
8256c5
         for debuginfo_path in files:
8256c5
-            packages = i.filter(file=debuginfo_path)
8256c5
+            di_package_list = []
8256c5
+            packages = dnf_available.filter(file=debuginfo_path)
8256c5
+
8256c5
             if not packages:
8256c5
                 log2("not found package for %s", debuginfo_path)
8256c5
                 not_found.append(debuginfo_path)
8256c5
             else:
8256c5
-                if packages[0] in package_files_dict.keys():
8256c5
-                    package_files_dict[packages[0]].append(debuginfo_path)
8256c5
-                else:
8256c5
-                    package_files_dict[packages[0]] = [debuginfo_path]
8256c5
-                    todownload_size += float(packages[0].downloadsize)
8256c5
-                    installed_size += float(packages[0].installsize)
8256c5
-
8256c5
-                log2("found packages for %s: %s", debuginfo_path, packages[0])
8256c5
+                di_package_list.append(packages[0])
8256c5
+                if packages[0].requires:
8256c5
+                    package_reqs = dnf_available.filter(provides=packages[0].requires,
8256c5
+                                                        arch=packages[0].arch)
8256c5
+                    for pkg in package_reqs:
8256c5
+                        if pkg not in di_package_list:
8256c5
+                            di_package_list.append(pkg)
8256c5
+                            log2("found required package {0} for {1}".format(pkg, packages[0]))
8256c5
+
8256c5
+                for pkg in di_package_list:
8256c5
+                    if pkg in package_files_dict.keys():
8256c5
+                        package_files_dict[pkg].append(debuginfo_path)
8256c5
+                    else:
8256c5
+                        package_files_dict[pkg] = [debuginfo_path]
8256c5
+                        todownload_size += float(pkg.downloadsize)
8256c5
+                        installed_size += float(pkg.installsize)
8256c5
+
8256c5
+                    log2("found packages for %s: %s", debuginfo_path, pkg)
8256c5
         return (package_files_dict, not_found, todownload_size, installed_size)
8256c5
 
8256c5
     def download_package(self, pkg):
8256c5
-- 
8256c5
2.24.1
8256c5