summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xmgagnome56
1 files changed, 54 insertions, 2 deletions
diff --git a/mgagnome b/mgagnome
index 80a402c..a947188 100755
--- a/mgagnome
+++ b/mgagnome
@@ -344,8 +344,13 @@ class SpecFile(object):
rpm.addMacro("_topdir", os.path.join(self.cwd, '..'))
ts = rpm.ts()
spec = ts.parseSpec(self.path)
- srclist = spec.sources if isinstance(spec.sources, (list, tuple)) \
- else spec.sources()
+ try:
+ srclist = spec.sources if isinstance(spec.sources, (list, tuple)) \
+ else spec.sources()
+ 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()
return dict((os.path.basename(name), [name, 0 if no == 2147483647 and flags == 2 else no]) for name, no, flags in srclist if flag is None or flags == flag)
@property
@@ -1671,6 +1676,45 @@ def cmd_clean_spec_multi(args):
print(s.changes)
s.ensure_no_local_changes(force=True)
+def cmd_check_spec_multi(args):
+ options, package = args
+ # Directories packages are located in
+ root = os.path.expanduser(Downstream.PKGROOT)
+ cwd = os.path.join(root, package)
+
+ path = os.path.join(cwd, "SPECS", "%s.spec" % package)
+ if not os.path.exists(path):
+ return False
+
+
+ s = SpecFile(path, module=package)
+ try:
+ patches = s.patches
+ except ValueError:
+ print('ERROR: Broken spec file for package %s' % package, file=sys.stderr)
+ return False
+
+ return True
+
+
+def cmd_check_spec(options, parser):
+ if options.all:
+ packages = Downstream().packages
+ else:
+ packages = options.package if len(options.package) else (l[0] for l in join_streams())
+
+
+ if options.debug:
+ for package in packages:
+ cmd_check_spec_multi((options, package))
+ else:
+ import os
+ workers=os.cpu_count() or 4
+ with concurrent.futures.ThreadPoolExecutor(max_workers=workers) as executor:
+ executor.map(cmd_check_spec_multi, ((options, package) for package in packages))
+
+
+
def cmd_clean_spec(options, parser):
if options.all:
packages = Downstream().packages
@@ -1980,6 +2024,14 @@ def main():
func=cmd_check_version
)
+ subparser = subparsers.add_parser('check-spec', help='check if spec file is ok')
+ subparser.add_argument("package", help="Package name", nargs='*')
+ subparser.add_argument("-a", "--all", action="store_true", dest="all",
+ help="checkout all Downstream packages")
+ subparser.set_defaults(
+ func=cmd_check_spec
+ )
+
subparser = subparsers.add_parser('co', help='checkout all GNOME packages')
subparser.add_argument("-a", "--all", action="store_true", dest="all",
help="checkout all Downstream packages")