From 41c526ab5ef81c2b975e363658a587e39973c6ef Mon Sep 17 00:00:00 2001 From: CentOS Sources Date: Tue, 28 Apr 2020 05:37:19 -0400 Subject: [PATCH] import libreport-2.9.5-10.el8 --- ...client-Find-debuginfos-in-own-method.patch | 146 ++++++++++++++++++ ...d-and-download-required-debuginfo-pa.patch | 77 +++++++++ ...rch-for-required-packages-recursivel.patch | 60 +++++++ SPECS/libreport.spec | 13 +- 4 files changed, 294 insertions(+), 2 deletions(-) create mode 100644 SOURCES/0025-report-client-Find-debuginfos-in-own-method.patch create mode 100644 SOURCES/0026-reportclient-Find-and-download-required-debuginfo-pa.patch create mode 100644 SOURCES/0027-reportclient-Search-for-required-packages-recursivel.patch diff --git a/SOURCES/0025-report-client-Find-debuginfos-in-own-method.patch b/SOURCES/0025-report-client-Find-debuginfos-in-own-method.patch new file mode 100644 index 0000000..891f67d --- /dev/null +++ b/SOURCES/0025-report-client-Find-debuginfos-in-own-method.patch @@ -0,0 +1,146 @@ +From f4a632838a453f168037257d0c48e9b0976d6321 Mon Sep 17 00:00:00 2001 +From: Matej Marusak +Date: Fri, 30 Nov 2018 11:40:09 +0100 +Subject: [PATCH] report-client: Find debuginfos in own method + +This commit picks a piece of code responsible for looking up debuginfo +packages into own method. For making sure that it works in any code that +used it the old way, it checks if the method for finding packages was +already called and if not, calls it directly. + +Purpose of this change is to be able to get size of packages those are +going to be installed before installing them. In that case anyone using +these downloader classes is going to be able for example prepare enough +space for the newly installed packages. + +Related to #811978. + +Signed-off-by: Matej Marusak +--- + src/client-python/reportclient/debuginfo.py | 69 +++++++++++++-------- + 1 file changed, 43 insertions(+), 26 deletions(-) + +diff --git a/src/client-python/reportclient/debuginfo.py b/src/client-python/reportclient/debuginfo.py +index 4390304e..561de52f 100644 +--- a/src/client-python/reportclient/debuginfo.py ++++ b/src/client-python/reportclient/debuginfo.py +@@ -233,6 +233,17 @@ class DebugInfoDownload(object): + self.keeprpms = keep_rpms + self.noninteractive = noninteractive + self.repo_pattern = repo_pattern ++ self.package_files_dict = {} ++ self.not_found = [] ++ self.todownload_size = 0 ++ self.installed_size = 0 ++ self.find_packages_run = False ++ ++ def get_download_size(self): ++ return self.todownload_size ++ ++ def get_install_size(self): ++ return self.installed_size + + def mute_stdout(self): + """ +@@ -286,6 +297,26 @@ class DebugInfoDownload(object): + def download_package(self, pkg): + pass + ++ def find_packages(self, files): ++ self.find_packages_run = True; ++ # nothing to download? ++ if not files: ++ return RETURN_FAILURE ++ ++ print(_("Initializing package manager")) ++ self.prepare() ++ ++ # This takes some time, let user know what we are doing ++ print(_("Setting up repositories")) ++ self.initialize_repositories() ++ ++ print(_("Looking for needed packages in repositories")) ++ (self.package_files_dict, ++ self.not_found, ++ self.todownload_size, ++ self.installed_size) = self.triage(files) ++ ++ + # return value will be used as exitcode. So 0 = ok, !0 - error + def download(self, files, download_exact_files=False): + """ +@@ -309,32 +340,18 @@ class DebugInfoDownload(object): + if retval != RETURN_OK: + return retval + +- print(_("Initializing package manager")) +- self.prepare() +- #if verbose == 0: +- # # this suppress yum messages about setting up repositories +- # mute_stdout() +- +- # This takes some time, let user know what we are doing +- print(_("Setting up repositories")) +- self.initialize_repositories() +- +- #if verbose == 0: +- # # re-enable the output to stdout +- # unmute_stdout() +- +- print(_("Looking for needed packages in repositories")) +- package_files_dict, not_found, todownload_size, installed_size = self.triage(files) ++ if not self.find_packages_run: ++ self.find_packages(files) + +- if verbose != 0 or len(not_found) != 0: +- print(_("Can't find packages for {0} debuginfo files").format(len(not_found))) ++ if verbose != 0 or len(self.not_found) != 0: ++ print(_("Can't find packages for {0} debuginfo files").format(len(self.not_found))) + +- if verbose != 0 or len(package_files_dict) != 0: +- print(_("Packages to download: {0}").format(len(package_files_dict))) ++ if verbose != 0 or len(self.package_files_dict) != 0: ++ print(_("Packages to download: {0}").format(len(self.package_files_dict))) + question = _( + "Downloading {0:.2f}Mb, installed size: {1:.2f}Mb. Continue?") \ +- .format(todownload_size / (1024 * 1024), +- installed_size / (1024 * 1024)) ++ .format(self.todownload_size / (1024 * 1024), ++ self.installed_size / (1024 * 1024)) + + if not self.noninteractive and not ask_yes_no(question): + print(_("Download cancelled by user")) +@@ -343,7 +360,7 @@ class DebugInfoDownload(object): + # check if there is enough free space in both tmp and cache + res = os.statvfs(self.tmpdir) + tmp_space = float(res.f_bsize * res.f_bavail) / (1024 * 1024) +- if (todownload_size / (1024 * 1024)) > tmp_space: ++ if (self.todownload_size / (1024 * 1024)) > tmp_space: + question = _("Warning: Not enough free space in tmp dir '{0}'" + " ({1:.2f}Mb left). Continue?").format( + self.tmpdir, tmp_space) +@@ -354,7 +371,7 @@ class DebugInfoDownload(object): + + res = os.statvfs(self.cachedir) + cache_space = float(res.f_bsize * res.f_bavail) / (1024 * 1024) +- if (installed_size / (1024 * 1024)) > cache_space: ++ if (self.installed_size / (1024 * 1024)) > cache_space: + question = _("Warning: Not enough free space in cache dir " + "'{0}' ({1:.2f}Mb left). Continue?").format( + self.cachedir, cache_space) +@@ -363,10 +380,10 @@ class DebugInfoDownload(object): + print(_("Download cancelled by user")) + return RETURN_CANCEL_BY_USER + +- progress_observer = DownloadProgress(len(package_files_dict)) ++ progress_observer = DownloadProgress(len(self.package_files_dict)) + self.initialize_progress(progress_observer) + +- for pkg, files in package_files_dict.items(): ++ for pkg, files in self.package_files_dict.items(): + # Download + package_full_path, err = self.download_package(pkg) + +-- +2.24.1 + diff --git a/SOURCES/0026-reportclient-Find-and-download-required-debuginfo-pa.patch b/SOURCES/0026-reportclient-Find-and-download-required-debuginfo-pa.patch new file mode 100644 index 0000000..00835d2 --- /dev/null +++ b/SOURCES/0026-reportclient-Find-and-download-required-debuginfo-pa.patch @@ -0,0 +1,77 @@ +From 23110cb7198e53c1e211ba8a41c7406b04641574 Mon Sep 17 00:00:00 2001 +From: Martin Kutlak +Date: Mon, 3 Dec 2018 13:54:34 +0100 +Subject: [PATCH] reportclient: Find and download required debuginfo packages + +The current solution finds packages for given build-ids and then +downloads them. The problem is that some debuginfo packages require +other packages and if they are not available the generated backtrace +becomes unusable. + +This commit adds a query for required packages and downloads them together +with the main packages. + +Related: rhbz#1515265 + +Signed-off-by: Martin Kutlak +--- + .../reportclient/dnfdebuginfo.py | 34 +++++++++++++------ + 1 file changed, 23 insertions(+), 11 deletions(-) + +diff --git a/src/client-python/reportclient/dnfdebuginfo.py b/src/client-python/reportclient/dnfdebuginfo.py +index 1867484f..04f98579 100644 +--- a/src/client-python/reportclient/dnfdebuginfo.py ++++ b/src/client-python/reportclient/dnfdebuginfo.py +@@ -106,26 +106,38 @@ class DNFDebugInfoDownload(DebugInfoDownload): + print(_("Error setting up repositories: '{0!s}'").format(str(ex))) + + def triage(self, files): +- q = self.base.sack.query() +- i = q.available() ++ dnf_query = self.base.sack.query() ++ dnf_available = dnf_query.available() + package_files_dict = {} + not_found = [] + todownload_size = 0 + installed_size = 0 + for debuginfo_path in files: +- packages = i.filter(file=debuginfo_path) ++ di_package_list = [] ++ packages = dnf_available.filter(file=debuginfo_path) ++ + if not packages: + log2("not found package for %s", debuginfo_path) + not_found.append(debuginfo_path) + else: +- if packages[0] in package_files_dict.keys(): +- package_files_dict[packages[0]].append(debuginfo_path) +- else: +- package_files_dict[packages[0]] = [debuginfo_path] +- todownload_size += float(packages[0].downloadsize) +- installed_size += float(packages[0].installsize) +- +- log2("found packages for %s: %s", debuginfo_path, packages[0]) ++ di_package_list.append(packages[0]) ++ if packages[0].requires: ++ package_reqs = dnf_available.filter(provides=packages[0].requires, ++ arch=packages[0].arch) ++ for pkg in package_reqs: ++ if pkg not in di_package_list: ++ di_package_list.append(pkg) ++ log2("found required package {0} for {1}".format(pkg, packages[0])) ++ ++ for pkg in di_package_list: ++ if pkg in package_files_dict.keys(): ++ package_files_dict[pkg].append(debuginfo_path) ++ else: ++ package_files_dict[pkg] = [debuginfo_path] ++ todownload_size += float(pkg.downloadsize) ++ installed_size += float(pkg.installsize) ++ ++ log2("found packages for %s: %s", debuginfo_path, pkg) + return (package_files_dict, not_found, todownload_size, installed_size) + + def download_package(self, pkg): +-- +2.24.1 + diff --git a/SOURCES/0027-reportclient-Search-for-required-packages-recursivel.patch b/SOURCES/0027-reportclient-Search-for-required-packages-recursivel.patch new file mode 100644 index 0000000..e4ee7d6 --- /dev/null +++ b/SOURCES/0027-reportclient-Search-for-required-packages-recursivel.patch @@ -0,0 +1,60 @@ +From c0d0e59df7d73feb971ba495c81f4651a8cea8a6 Mon Sep 17 00:00:00 2001 +From: Martin Kutlak +Date: Wed, 5 Dec 2018 16:52:07 +0100 +Subject: [PATCH] reportclient: Search for required packages recursively + +Adds recursive function to search for required packages of required packages +of re... + +Signed-off-by: Martin Kutlak +--- + .../reportclient/dnfdebuginfo.py | 21 +++++++++++++++++-- + 1 file changed, 19 insertions(+), 2 deletions(-) + +diff --git a/src/client-python/reportclient/dnfdebuginfo.py b/src/client-python/reportclient/dnfdebuginfo.py +index 04f98579..165c12d0 100644 +--- a/src/client-python/reportclient/dnfdebuginfo.py ++++ b/src/client-python/reportclient/dnfdebuginfo.py +@@ -112,6 +112,23 @@ class DNFDebugInfoDownload(DebugInfoDownload): + not_found = [] + todownload_size = 0 + installed_size = 0 ++ ++ def required_packages(query, package, origin): ++ """ ++ Recursive function to find all required packages of required packages of ... ++ origin - should stop infinite recursion (A => B => ... => X => A) ++ """ ++ required_pkg_list = [] ++ if package.requires: ++ pkg_reqs = query.filter(provides=package.requires, arch=package.arch) ++ for p in pkg_reqs: ++ if p.name != origin.name and p not in required_pkg_list: ++ required_pkg_list.append(p) ++ required_pkg_list += required_packages(query, p, origin) ++ ++ return required_pkg_list ++ ++ + for debuginfo_path in files: + di_package_list = [] + packages = dnf_available.filter(file=debuginfo_path) +@@ -122,13 +139,13 @@ class DNFDebugInfoDownload(DebugInfoDownload): + else: + di_package_list.append(packages[0]) + if packages[0].requires: +- package_reqs = dnf_available.filter(provides=packages[0].requires, +- arch=packages[0].arch) ++ package_reqs = required_packages(dnf_available, packages[0], packages[0]) + for pkg in package_reqs: + if pkg not in di_package_list: + di_package_list.append(pkg) + log2("found required package {0} for {1}".format(pkg, packages[0])) + ++ + for pkg in di_package_list: + if pkg in package_files_dict.keys(): + package_files_dict[pkg].append(debuginfo_path) +-- +2.24.1 + diff --git a/SPECS/libreport.spec b/SPECS/libreport.spec index 1ca3c66..b646137 100644 --- a/SPECS/libreport.spec +++ b/SPECS/libreport.spec @@ -29,7 +29,7 @@ Summary: Generic library for reporting various problems Name: libreport Version: 2.9.5 -Release: 9%{?dist} +Release: 10%{?dist} License: GPLv2+ URL: https://abrt.readthedocs.org/ Source: https://github.com/abrt/%{name}/archive/%{version}/%{name}-%{version}.tar.gz @@ -60,7 +60,10 @@ Patch0023: 0023-tests-Disable-strcpm-ing-a-freed-pointer.patch #git format-patch -N --start-number=24 Patch0024: 0024-lib-fix-a-SEGV-in-list_possible_events.patch #git format-patch -N --start-number=25 - +Patch0025: 0025-report-client-Find-debuginfos-in-own-method.patch +Patch0026: 0026-reportclient-Find-and-download-required-debuginfo-pa.patch +Patch0027: 0027-reportclient-Search-for-required-packages-recursivel.patch +#git format-patch -N --start-number=28 c0d0e59d # autogen.sh is need to regenerate all the Makefile files Patch9000: 9000-Add-autogen.sh.patch @@ -847,6 +850,12 @@ gtk-update-icon-cache %{_datadir}/icons/hicolor &>/dev/null || : %endif %changelog +* Tue Jan 21 2020 Martin Kutlak - 2.9.5-10 +- reportclient: Search for required packages recursively +- reportclient: Find and download required debuginfo packages +- report-client: Find debuginfos in own method +- Resolves: rhbz#1783897 + * Fri Jul 29 2019 Martin Kutlak - 2.9.5-9 - lib: fix a SEGV in list_possible_events() - Resolves: rhbz#1733515