repos: recursive_build_report improvements

- support for multiple arguments
- allow an argument to be in '.src.rpm' form
  (also, the version and release are ignored for now)
- mark any additional sources which were not explicitly
  asked for in summary.
This commit is contained in:
Ivan A. Melnikov 2021-09-07 11:36:26 +04:00
parent 4a75b16600
commit 9459d2b700

View File

@ -338,10 +338,17 @@ def build_report(from_repo, to_repo, source_name):
return format_triplet_report(report, source_name.decode())
def recursive_build_report(from_repo, to_repo, source_name):
def _src_name(source):
if source.endswith(b'.src.rpm'):
return source.rsplit(b'-', 2)[0]
return source
def recursive_build_report(from_repo, to_repo, *source_names):
reports = []
by_source = {}
stack = [source_name]
requested_source_names = set(_src_name(s) for s in source_names)
stack = list(requested_source_names)
seen = set(stack)
while stack:
@ -359,8 +366,9 @@ def recursive_build_report(from_repo, to_repo, source_name):
reports.append('\n== SUMMARY ==\n')
for source, deps in sorted(by_source.items()):
reports.append('{}: {}'.format(source.decode(),
b' '.join(deps).decode()))
reports.append('{}\t{}: {}'.format(
'' if source in requested_source_names else 'N',
source.decode(), b' '.join(deps).decode()))
return '\n'.join(reports)