summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOlav Vitters <olav@vitters.nl>2014-07-06 14:03:16 +0200
committerOlav Vitters <olav@vitters.nl>2014-07-06 14:03:16 +0200
commit7b51a695ac6d0d66d1f19d98f72671fc3a69e9c7 (patch)
tree04847fd3f97381b416f512f99bce332188c28180
parent607619bcc79af585c0754aec49fcbb22ed121296 (diff)
downloadmgagnome-7b51a695ac6d0d66d1f19d98f72671fc3a69e9c7.tar
mgagnome-7b51a695ac6d0d66d1f19d98f72671fc3a69e9c7.tar.gz
mgagnome-7b51a695ac6d0d66d1f19d98f72671fc3a69e9c7.tar.bz2
mgagnome-7b51a695ac6d0d66d1f19d98f72671fc3a69e9c7.tar.xz
mgagnome-7b51a695ac6d0d66d1f19d98f72671fc3a69e9c7.zip
remove summary and group variable definitions, add ability to clean all downstream packages and be more careful when removing variable definitions
-rwxr-xr-xmgagnome31
1 files changed, 21 insertions, 10 deletions
diff --git a/mgagnome b/mgagnome
index 1200cb3..8c8e948 100755
--- a/mgagnome
+++ b/mgagnome
@@ -384,7 +384,7 @@ class SpecFile(object):
re_rm_buildroot = r'^(?:rm|\%\{__rm\}) *(?:-rf|-rf|-r) *(?:\%buildroot|\%\{buildroot\}|\$RPM_BUILDROOT|\$RPM_BUILD_ROOT) *\n'
re_clean_spec = [
# remove %defattr
- ('remove defattr', re.compile(r'(?P<keeppre>^\%files[^\n]*\n)^\%defattr\(-, *root, *root(?:, *-)?\)\s*\n', re.MULTILINE + re.IGNORECASE)),
+ ('remove defattr', re.compile(r'(?P<keeppre>^\%files[^\n]*\n)^\%defattr\s*\(-, *root, *root(?:, *-)?\)\s*\n', re.MULTILINE + re.IGNORECASE)),
('remove cleaning buildroot in install', re.compile(r'(?P<keeppre>^\%install[^\n]*\n)' + re_rm_buildroot + r'\n?', re.MULTILINE + re.IGNORECASE)),
('remove clean section', re.compile(r'^\%clean[^\n]*\n' + re_rm_buildroot + r'\n*(?P<keeppost>^(?:\%files|\%post|\%preun))', re.MULTILINE + re.IGNORECASE)),
('remove buildroot definition', re.compile(r'^BuildRoot:[^\n]+\n', re.MULTILINE + re.IGNORECASE)),
@@ -408,13 +408,13 @@ class SpecFile(object):
# Into
# name: SOMETHING
converted_defines = []
- for search_for in ('name', 'version', 'release'):
+ for search_for in ('name', 'version', 'release', 'summary', 'group'):
re_spec = re.compile(r'^(?P<keeppre>' + re.escape(search_for) + r'[ \t]*:[ \t]*)\%\{' + re.escape(search_for) + r'\}(?P<keeppost>[ \t]*\n)', re.MULTILINE + re.IGNORECASE)
regexp = r'^(?P<keeppre>\%define[ \t]+'+ re.escape(search_for) + r'[ \t]+(?P<variable>\S+))(?P<keeppost>[ \t]*\n)'
re_variable = re.compile(r'^(?P<keeppre>\%define[ \t]+'+ re.escape(search_for) + r'[ \t]+(?P<definition>[^\n]+?))(?P<keeppost>[ \t]*\n)', re.MULTILINE + re.IGNORECASE)
mo = re_variable.search(data)
- if mo and mo.group('definition'):
+ if mo and mo.group('definition') and len(re_variable.findall(data)) == 1:
mo2 = re_spec.search(data)
if mo2:
data, nr = re_spec.subn('\g<keeppre>' + mo.group('definition').replace('\\', '\\\\') + '\g<keeppost>', data)
@@ -423,8 +423,9 @@ class SpecFile(object):
data, nr = re_variable.subn('', data)
converted_defines.append(search_for)
- if converted_defines:
- self._changes.append('SILENT remove variable definitions %s' % ", ".join(converted_defines))
+ if made_changes and converted_defines:
+ data = data.lstrip()
+ self._changes.append('SILENT remove variable definition(s) %s' % ", ".join(converted_defines))
# Overwrite file with new version number
if made_changes:
@@ -579,7 +580,7 @@ class SpecFile(object):
data, nr = self.re_update_br_unsplit.subn(lambda mo: ''.join((''.join((mo.group('pre'), mo2.group(0), mo.group('unsplitpost'))) for mo2 in self.re_br_part.finditer(mo.group('unsplit')) if mo.group(0).strip() != '')), data)
if data_before != data:
made_changes = True
- self._changes.append('SILENT clean buildrequirements')
+ self._changes.append('SILENT one line per buildrequirement')
data_before = data
# Now update buildrequires if any
@@ -1205,7 +1206,10 @@ def cmd_check_prep(options, parser):
def cmd_clean_spec(options, parser):
# Directories packages are located in
root = os.path.expanduser(Downstream.PKGROOT)
- packages = options.package if len(options.package) else (l[0] for l in join_streams())
+ if options.all:
+ packages = Downstream().packages
+ else:
+ packages = options.package if len(options.package) else (l[0] for l in join_streams())
import pprint
@@ -1215,7 +1219,12 @@ def cmd_clean_spec(options, parser):
s = SpecFile(os.path.join(cwd, "SPECS", "%s.spec" % package), module=package)
- if not s.ensure_no_local_changes():
+ try:
+ if not s.ensure_no_local_changes():
+ continue
+ except subprocess.CalledProcessError:
+ # Package was probably not checked out or something
+ print >>sys.stderr, "ERROR: cannot clean spec file for %s" % package
continue
made_changes=False
@@ -1466,9 +1475,11 @@ def main():
subparser = subparsers.add_parser('clean-spec', help='clean specfile')
subparser.add_argument("package", help="Package name", nargs='*')
subparser.add_argument("-d", action="store_true", dest="doit")
+ subparser.add_argument("-a", "--all", action="store_true", dest="all",
+ help="checkout all Downstream packages")
subparser.add_argument("--no-convert-devel", action="store_false", dest="pkgconfig")
subparser.set_defaults(
- func=cmd_clean_spec, doit=False, pkgconfig=True
+ func=cmd_clean_spec, doit=False, pkgconfig=True, all=False
)
subparser = subparsers.add_parser('check-version', help='check if spec version and downstream version match')
@@ -1478,7 +1489,7 @@ def main():
subparser = subparsers.add_parser('co', help='checkout all GNOME packages')
subparser.add_argument("-a", "--all", action="store_true", dest="all",
- help="Wait before trying to retrieve the new version")
+ help="checkout all Downstream packages")
subparser.set_defaults(
func=cmd_co, all=False
)