def _parse_filtered_spec(self, skip_tags):
     """Parse a filtered spec file in rpm-python"""
     skip_tags = [tag.lower() for tag in skip_tags]
     with tempfile.NamedTemporaryFile(prefix="gbp") as filtered:
         filtered.writelines(
             str(line) for line in self._content if str(line).split(":")[0].strip().lower() not in skip_tags
         )
         filtered.flush()
         try:
             # Parse two times to circumvent a rpm-python problem where
             # macros are not expanded if used before their definition
             librpm.spec(filtered.name)
             return librpm.spec(filtered.name)
         except ValueError as 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]))
Esempio n. 2
0
 def _parse_filtered_spec(self, skip_tags):
     """Parse a filtered spec file in rpm-python"""
     skip_tags = [tag.lower() for tag in skip_tags]
     with tempfile.NamedTemporaryFile(prefix='gbp', mode='w+') as filtered:
         filtered.writelines(
             str(line) for line in self._content
             if str(line).split(":")[0].strip().lower() not in skip_tags)
         filtered.flush()
         try:
             # Parse two times to circumvent a rpm-python problem where
             # macros are not expanded if used before their definition
             librpm.spec(filtered.name)
             return librpm.spec(filtered.name)
         except ValueError as 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]))