From f586ee2445bfb28398a5be1ec57e60fc37fa84d9 Mon Sep 17 00:00:00 2001 From: Olav Vitters Date: Tue, 21 Apr 2020 20:28:32 +0200 Subject: further improve mgagnome clean-spec --- mgagnome | 32 ++++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/mgagnome b/mgagnome index c000d25..224b69c 100755 --- a/mgagnome +++ b/mgagnome @@ -320,6 +320,7 @@ class SpecFile(object): self.cwd = os.path.dirname(path) self.module = module self._changes = collections.OrderedDict() + self._should_rebuild = False @property def changes(self): @@ -329,6 +330,10 @@ class SpecFile(object): def version(self): return subprocess.check_output(["rpm", "--define", "_topdir %s" % os.path.join(self.cwd, ".."), "--specfile", self.path, "--queryformat", "%{VERSION}\n"]).decode("utf-8").splitlines()[0] + @property + def should_rebuild(self): + return self._should_rebuild + @property def release(self): return subprocess.check_output(["rpm", "--define", "%dist %nil", "--define", "_topdir %s" % os.path.join(self.cwd, ".."), "--specfile", self.path, "--queryformat", "%{RELEASE}\n"]).decode("utf-8").splitlines()[0] @@ -365,6 +370,7 @@ class SpecFile(object): ('restrict what libraries are matched with major numbers', r'\g{,.*}', re.compile(r'^(?P%{_libdir}[^\n]+})\*$', re.MULTILINE)), ('keep library matching using two lines', r'\g\n\g.*', re.compile(r'^(?P%{_libdir}[^\n]+})$\n(?P=keeppre)\{,\.\*\}$', re.MULTILINE)), ('make use of autopatch', r'%autopatch -p1', re.compile(r'^%apply_patches$', re.MULTILINE)), + ('change configure2_5x macro to configure', r'%configure', re.compile(r'^%configure2_5x\b', re.MULTILINE)), ('change find_lang --with-help into --with-gnome', '\g --with-gnome\g', re.compile(r'^(?P\s*\%find_lang[^\\\n]+) --with-help(?P[^\\\n]*\n)', re.MULTILINE + re.IGNORECASE)), ('change find_lang remove duplicate with_gnome', None, re.compile(r'^(?P\%find_lang[^\\\n]+ --with-gnome) --with-gnome(?P[^\\\n]*\n)', re.MULTILINE + re.IGNORECASE)), # Use new Python macros @@ -388,7 +394,13 @@ class SpecFile(object): made_changes = False with open(self.path, "r", encoding="utf-8") as f: data = f.read() - for reason, change_to, regexp in re_clean_spec: + for reason, change_to, regexp, *extra in re_clean_spec: + if len(extra): + should_rebuild = extra[0] + else: + should_rebuild = False + + if change_to is None: change_to = "" if 'keeppre' in regexp.groupindex: change_to += r'\g' @@ -397,6 +409,8 @@ class SpecFile(object): if nr: made_changes = True self._changes['SILENT %s' % reason] = True + if should_rebuild: + self._should_rebuild = True # Convert %py_requires and %py_requires -d # - first figure out how a buildrequire is usually defined @@ -1482,6 +1496,12 @@ def cmd_clean_spec_multi(args): path = os.path.join(cwd, "SPECS", "%s.spec" % package) if not os.path.exists(path): + try: + Downstream.co(package) + except subprocess.CalledProcessError: + # XXX - ignoring packages which cannot be checked out + return False + print('ERROR: Cannot find spec file for package %s' % package, file=sys.stderr) return False @@ -1579,6 +1599,9 @@ def cmd_clean_spec_multi(args): if made_changes: if options.doit: Downstream.ci(package, s.changes, cwd=cwd) + if s.should_rebuild: + cmd = ['mgagnome', 'rebuild', '-s', '-m', 'to test removal of deprecated macros', package] + subprocess.call(cmd, cwd=os.path.expanduser(os.path.join(Downstream.PKGROOT, package))) else: # show the diff and undo all changes print(s.changes) @@ -1595,7 +1618,12 @@ def cmd_clean_spec(options, parser): for package in packages: cmd_clean_spec_multi((options, package)) else: - with concurrent.futures.ThreadPoolExecutor(max_workers=8) as executor: + import os + workers=os.cpu_count() or 4 + # Hack: warm alternative provides cache + if options.convert_br: + Downstream.alternative_provides('XXXX') + with concurrent.futures.ThreadPoolExecutor(max_workers=workers) as executor: executor.map(cmd_clean_spec_multi, ((options, package) for package in packages)) def cmd_new_release(options, parser): -- cgit v1.2.1