rpm: Improve logging in case of rpmlib error
authorMarkus Lehtonen <markus.lehtonen@linux.intel.com>
Fri, 16 Aug 2013 10:51:13 +0000 (13:51 +0300)
committerMarkus Lehtonen <markus.lehtonen@linux.intel.com>
Thu, 5 Jun 2014 11:20:07 +0000 (14:20 +0300)
Signed-off-by: Markus Lehtonen <markus.lehtonen@linux.intel.com>
gbp/rpm/__init__.py
gbp/rpm/lib_rpm.py

index 2290bc3..e62ae2d 100644 (file)
@@ -35,7 +35,7 @@ import gbp.log
 from gbp.pkg import (UpstreamSource, compressor_opts, parse_archive_filename)
 from gbp.rpm.policy import RpmPkgPolicy
 from gbp.rpm.linkedlist import LinkedList
-from gbp.rpm.lib_rpm import librpm
+from gbp.rpm.lib_rpm import librpm, get_librpm_log
 
 
 class NoSpecError(Exception):
@@ -181,8 +181,11 @@ class SpecFile(object):
                 librpm.spec(filtered.name)
                 return librpm.spec(filtered.name)
             except ValueError as err:
-                raise GbpError("RPM error while parsing %s: %s" %
-                                (self.specfile, err))
+                rpmlog = get_librpm_log()
+                gbp.log.debug("librpm log:\n        %s" %
+                                "\n        ".join(rpmlog))
+                raise GbpError("RPM error while parsing %s: %s (%s)" %
+                                (self.specfile, err, rpmlog[-1]))
 
     @property
     def version(self):
index adf40d1..4bad44e 100644 (file)
@@ -37,7 +37,7 @@ librpm.setVerbosity(librpm.RPMLOG_INFO)
 librpm.setLogFile(_rpmlogfd)
 
 
-def get_log(truncate=True):
+def get_librpm_log(truncate=True):
     """Get rpmlib log output"""
     _rpmlogfd.seek(0)
     log = [line.strip() for line in _rpmlogfd.readlines()]