diff options
author | Olav Vitters <olav@vitters.nl> | 2020-04-23 10:09:34 +0200 |
---|---|---|
committer | Olav Vitters <olav@vitters.nl> | 2020-04-23 10:09:34 +0200 |
commit | cfff2a1844b636eff0dc613d2d16a67e1bced850 (patch) | |
tree | 26370efbea726af4f8bdf1be60bffbeb3aaa9095 | |
parent | 247f624dd86f15ae57fb88e719a02d5e8916ff8b (diff) | |
download | mgagnome-cfff2a1844b636eff0dc613d2d16a67e1bced850.tar mgagnome-cfff2a1844b636eff0dc613d2d16a67e1bced850.tar.gz mgagnome-cfff2a1844b636eff0dc613d2d16a67e1bced850.tar.bz2 mgagnome-cfff2a1844b636eff0dc613d2d16a67e1bced850.tar.xz mgagnome-cfff2a1844b636eff0dc613d2d16a67e1bced850.zip |
add check-spec subcommand
-rwxr-xr-x | mgagnome | 56 |
1 files changed, 54 insertions, 2 deletions
@@ -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") |