diff options
Diffstat (limited to 'mgagnome')
-rwxr-xr-x | mgagnome | 21 |
1 files changed, 19 insertions, 2 deletions
@@ -301,6 +301,12 @@ def clean_pkgconfig_prov(prov): prov = re_clean_1.sub('', prov) return prov + +class SpecFileError(Exception): + """Used for problems in the spec file""" + pass + + class SpecFile(object): re_update_version = re.compile(r'^(?P<pre>Version[ \t]*:\s*)(?P<version>.+)(?P<post>\s*)$', re.MULTILINE + re.IGNORECASE) re_update_release = re.compile(r'^(?P<pre>Release[ \t]*:\s*)(?P<release>%mkrel [0-9.]+)(?P<post>\s*)$', re.MULTILINE + re.IGNORECASE) @@ -347,6 +353,9 @@ class SpecFile(object): try: srclist = spec.sources if isinstance(spec.sources, (list, tuple)) \ else spec.sources() + except ValueError as exc + # Reraise this into a more specific exception + raise SpecFileError from exc finally: # ts.parseSpec can affect changing of internal macros, e.g. redefining things like mkrel and so on # reload the config to fix this @@ -558,7 +567,15 @@ class SpecFile(object): rpm.delMacro("_topdir" ) rpm.addMacro("_topdir", os.path.join(self.cwd, '..')) ts = rpm.ts() - spec = ts.parseSpec(self.path) + try: + spec = ts.parseSpec(self.path) + except ValueError as exc + # Reraise this into a more specific exception + raise SpecFileError from exc + finally: + # ts.parseSpec can affect changing of internal macros, e.g. redefining things like mkrel and so on + # reload the config to fix this + rpm.reloadConfig() requires = spec.sourceHeader[rpm.RPMTAG_REQUIRES] require_flags = spec.sourceHeader[rpm.RPMTAG_REQUIREFLAGS] @@ -1079,7 +1096,7 @@ class Downstream(object): for line in contents: try: srpm, version, filename = line.split("|") - except ValueError: + except SpecFileError: print(line, file=sys.stderr) continue |