|
|
e582f9 |
From 5a3b3bf30c37ebdcf7f3e25d4eac7039acfe57c4 Mon Sep 17 00:00:00 2001
|
|
|
e582f9 |
From: Marek Blaha <mblaha@redhat.com>
|
|
|
e582f9 |
Date: Fri, 31 May 2019 09:48:13 +0200
|
|
|
e582f9 |
Subject: [PATCH] [builddep] Report all rpm errors (RhBug:1663619,1658292,1724668)
|
|
|
e582f9 |
|
|
|
e582f9 |
Dnf uses rpm for parsing .spec and srpm files. Any parsing
|
|
|
e582f9 |
errors were not reported to the user, but swallowed by dnf.
|
|
|
e582f9 |
User was only informed that the spec file could not be parsed:
|
|
|
e582f9 |
|
|
|
e582f9 |
$ dnf builddep gdb.spec
|
|
|
e582f9 |
Failed to open: 'gdb.spec', not a valid spec file: can't parse specfile
|
|
|
e582f9 |
|
|
|
e582f9 |
This patch also prints messages from rpm error log to the user so he
|
|
|
e582f9 |
could better understand what the root cause of the problem is:
|
|
|
e582f9 |
|
|
|
e582f9 |
$ dnf builddep gdb.spec
|
|
|
e582f9 |
RPM: error: Unable to open /root/rpmbuild/SOURCES/_gdb.spec.Patch.include: No such file or directory
|
|
|
e582f9 |
Failed to open: 'gdb.spec', not a valid spec file: can't parse specfile
|
|
|
e582f9 |
|
|
|
e582f9 |
https://bugzilla.redhat.com/show_bug.cgi?id=1663619
|
|
|
e582f9 |
https://bugzilla.redhat.com/show_bug.cgi?id=1658292
|
|
|
e582f9 |
https://bugzilla.redhat.com/show_bug.cgi?id=1724668
|
|
|
e582f9 |
---
|
|
|
e582f9 |
dnf-plugins-core.spec | 2 +-
|
|
|
e582f9 |
plugins/builddep.py | 38 +++++++++-----------------------------
|
|
|
e582f9 |
2 files changed, 10 insertions(+), 30 deletions(-)
|
|
|
e582f9 |
|
|
|
e582f9 |
diff --git a/dnf-plugins-core.spec b/dnf-plugins-core.spec
|
|
|
e582f9 |
index be01cd2..b84477f 100644
|
|
|
e582f9 |
--- a/dnf-plugins-core.spec
|
|
|
e582f9 |
+++ b/dnf-plugins-core.spec
|
|
|
e582f9 |
@@ -1,4 +1,4 @@
|
|
|
e582f9 |
-%{?!dnf_lowest_compatible: %global dnf_lowest_compatible 4.2.1}
|
|
|
e582f9 |
+%{?!dnf_lowest_compatible: %global dnf_lowest_compatible 4.2.8}
|
|
|
e582f9 |
%global dnf_plugins_extra 2.0.0
|
|
|
e582f9 |
%global hawkey_version 0.34.0
|
|
|
e582f9 |
%global yum_utils_subpackage_name dnf-utils
|
|
|
e582f9 |
diff --git a/plugins/builddep.py b/plugins/builddep.py
|
|
|
e582f9 |
index bc3b257..0252d1f 100644
|
|
|
e582f9 |
--- a/plugins/builddep.py
|
|
|
e582f9 |
+++ b/plugins/builddep.py
|
|
|
e582f9 |
@@ -21,44 +21,18 @@
|
|
|
e582f9 |
|
|
|
e582f9 |
from __future__ import absolute_import
|
|
|
e582f9 |
from __future__ import unicode_literals
|
|
|
e582f9 |
-from dnfpluginscore import _, logger, rpm_logger
|
|
|
e582f9 |
+from dnfpluginscore import _, logger
|
|
|
e582f9 |
|
|
|
e582f9 |
import argparse
|
|
|
e582f9 |
import dnf
|
|
|
e582f9 |
import dnf.cli
|
|
|
e582f9 |
import dnf.exceptions
|
|
|
e582f9 |
import dnf.rpm.transaction
|
|
|
e582f9 |
-import functools
|
|
|
e582f9 |
-import logging
|
|
|
e582f9 |
+import dnf.yum.rpmtrans
|
|
|
e582f9 |
import os
|
|
|
e582f9 |
import rpm
|
|
|
e582f9 |
|
|
|
e582f9 |
|
|
|
e582f9 |
-class redirect_rpm_logging(object):
|
|
|
e582f9 |
- def __init__(self):
|
|
|
e582f9 |
- self.sink = None
|
|
|
e582f9 |
-
|
|
|
e582f9 |
- def __call__(self, func):
|
|
|
e582f9 |
- @functools.wraps(func)
|
|
|
e582f9 |
- def inner(*args, **kwds):
|
|
|
e582f9 |
- with self:
|
|
|
e582f9 |
- return func(*args, **kwds)
|
|
|
e582f9 |
- return inner
|
|
|
e582f9 |
-
|
|
|
e582f9 |
- def __enter__(self):
|
|
|
e582f9 |
- for handler in rpm_logger.handlers:
|
|
|
e582f9 |
- if isinstance(handler, logging.FileHandler):
|
|
|
e582f9 |
- rpm.setLogFile(handler.stream)
|
|
|
e582f9 |
- break
|
|
|
e582f9 |
- else:
|
|
|
e582f9 |
- self.sink = open('/dev/null', 'w')
|
|
|
e582f9 |
- rpm.setLogFile(self.sink)
|
|
|
e582f9 |
-
|
|
|
e582f9 |
- def __exit__(self, exc_type, exc, exc_tb):
|
|
|
e582f9 |
- if self.sink:
|
|
|
e582f9 |
- self.sink.close()
|
|
|
e582f9 |
-
|
|
|
e582f9 |
-
|
|
|
e582f9 |
@dnf.plugin.register_command
|
|
|
e582f9 |
class BuildDepCommand(dnf.cli.Command):
|
|
|
e582f9 |
|
|
|
e582f9 |
@@ -91,6 +65,10 @@ class BuildDepCommand(dnf.cli.Command):
|
|
|
e582f9 |
ptype.add_argument('--srpm', action='store_true',
|
|
|
e582f9 |
help=_('treat commandline arguments as source rpm'))
|
|
|
e582f9 |
|
|
|
e582f9 |
+ def pre_configure(self):
|
|
|
e582f9 |
+ if not self.opts.rpmverbosity:
|
|
|
e582f9 |
+ self.opts.rpmverbosity = 'error'
|
|
|
e582f9 |
+
|
|
|
e582f9 |
def configure(self):
|
|
|
e582f9 |
demands = self.cli.demands
|
|
|
e582f9 |
demands.available_repos = True
|
|
|
e582f9 |
@@ -107,8 +85,8 @@ class BuildDepCommand(dnf.cli.Command):
|
|
|
e582f9 |
self.base.repos.enable_source_repos()
|
|
|
e582f9 |
break
|
|
|
e582f9 |
|
|
|
e582f9 |
- @redirect_rpm_logging()
|
|
|
e582f9 |
def run(self):
|
|
|
e582f9 |
+ rpmlog = dnf.yum.rpmtrans.RPMTransaction(self.base)
|
|
|
e582f9 |
# Push user-supplied macro definitions for spec parsing
|
|
|
e582f9 |
for macro in self.opts.define:
|
|
|
e582f9 |
rpm.addMacro(macro[0], macro[1])
|
|
|
e582f9 |
@@ -127,6 +105,8 @@ class BuildDepCommand(dnf.cli.Command):
|
|
|
e582f9 |
else:
|
|
|
e582f9 |
self._remote_deps(pkgspec)
|
|
|
e582f9 |
except dnf.exceptions.Error as e:
|
|
|
e582f9 |
+ for line in rpmlog.messages():
|
|
|
e582f9 |
+ logger.error(_("RPM: {}").format(line))
|
|
|
e582f9 |
logger.error(e)
|
|
|
e582f9 |
pkg_errors = True
|
|
|
e582f9 |
|
|
|
e582f9 |
--
|
|
|
e582f9 |
libgit2 0.28.2
|
|
|
e582f9 |
|