From 1cd76b321a2b35830dbb68dc8a63174f5e8ef9f7 Mon Sep 17 00:00:00 2001 From: Olav Vitters Date: Wed, 6 May 2020 17:16:22 +0200 Subject: SpecFile: again explain convert_buildrequire; also add a spec_path property --- mgagnome | 40 +++++++++++++++++++++++----------------- 1 file changed, 23 insertions(+), 17 deletions(-) diff --git a/mgagnome b/mgagnome index 00f2a16..f20dccd 100755 --- a/mgagnome +++ b/mgagnome @@ -444,7 +444,7 @@ class SpecFile(): """Return the sources""" return self._sources_and_patches(flag=1) - def convert_buildrequires(self): + def convert_buildrequires(self, explain_changes=False): """Converts BuildRequires into their preferred form Requires SpecFile to be initialized with its package argument""" @@ -600,6 +600,20 @@ class SpecFile(): if change_to is not None: keys['changes'][req] = change_to + # Optionally explain the intended and failed buildrequire changes + if explain_changes: + if debug_enabled: + for keys in list(convert_brs.items()): + if 'changes' in keys and keys['changes']: + pprint.pprint(keys['changes']) + + if no_alt: + print("WARNING: no alternatives found for: %s" % ", ".join(sorted(no_alt))) + + if no_change and debug_enabled: + pprint.pprint(no_change) + + keys_with_changes = [keys for keys in convert_brs.values() if 'changes' in keys and keys['changes']] # XXX - seems to cause false messages # if not keys_with_changes: @@ -1610,8 +1624,13 @@ class Package: """Return the SpecFile for a given package""" path = self.path - return SpecFile(os.path.join(path, "SPECS", "%s.spec" % self.name), package=self, module=self.name) + return SpecFile(self.spec_path, package=self, module=self.name) + @cached_property + def spec_path(self): + path = self.path + + return os.path.join(path, "SPECS", "%s.spec" % self.name) @retry(subprocess.CalledProcessError) def checkout(self, cwd=None, spec_only=False): @@ -1975,23 +1994,10 @@ def _cmd_clean_spec_multi(args): # Convert perl- and -devel buildrequires into perl() and pkgconfig() requires if options.convert_br: - if spec.convert_buildrequires(): + if spec.convert_buildrequires(explain_changes=not options.doit): made_changes = True -# if not options.doit: -# if options.debug: -# for keys in list(convert_brs.items()): -# if 'changes' in keys and keys['changes']: -# pprint.pprint(keys['changes']) -# -# if no_alt: -# print("WARNING: no alternatives found for: %s" % ", ".join(sorted(no_alt))) -# -# if no_change and options.debug: -# pprint.pprint(no_change) -# else: -# convert_brs = {} - + # Clean the spec file if spec.clean_spec(): made_changes = True -- cgit v1.2.1