summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOlav Vitters <olav@vitters.nl>2020-04-21 20:28:32 +0200
committerOlav Vitters <olav@vitters.nl>2020-04-21 20:28:32 +0200
commitf586ee2445bfb28398a5be1ec57e60fc37fa84d9 (patch)
tree43bc4d89e4275e6db2844dac3337c27e6cb0da66
parentd74a55c4ccc358a563ed3107f7bceab19106e7f3 (diff)
downloadmgagnome-f586ee2445bfb28398a5be1ec57e60fc37fa84d9.tar
mgagnome-f586ee2445bfb28398a5be1ec57e60fc37fa84d9.tar.gz
mgagnome-f586ee2445bfb28398a5be1ec57e60fc37fa84d9.tar.bz2
mgagnome-f586ee2445bfb28398a5be1ec57e60fc37fa84d9.tar.xz
mgagnome-f586ee2445bfb28398a5be1ec57e60fc37fa84d9.zip
further improve mgagnome clean-spec
-rwxr-xr-xmgagnome32
1 files 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):
@@ -330,6 +331,10 @@ class SpecFile(object):
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<keeppre>{,.*}', re.compile(r'^(?P<keeppre>%{_libdir}[^\n]+})\*$', re.MULTILINE)),
('keep library matching using two lines', r'\g<keeppre>\n\g<keeppre>.*', re.compile(r'^(?P<keeppre>%{_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<keeppre> --with-gnome\g<keeppost>', re.compile(r'^(?P<keeppre>\s*\%find_lang[^\\\n]+) --with-help(?P<keeppost>[^\\\n]*\n)', re.MULTILINE + re.IGNORECASE)),
('change find_lang remove duplicate with_gnome', None, re.compile(r'^(?P<keeppre>\%find_lang[^\\\n]+ --with-gnome) --with-gnome(?P<keeppost>[^\\\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<keeppre>'
@@ -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):