repos: Add candidates_to_build

This is a helper function to find out which packages
from one repo can probably be immediately build for
the other one.

The implementation is suboptimal, but works just fine
for now.
This commit is contained in:
Ivan A. Melnikov 2024-12-20 13:08:12 +04:00
parent e2f1051f7d
commit 47d5f6fa92

View File

@ -765,6 +765,34 @@ def extras_to_remove(base_repo, repo, ignore=()):
print(name.decode())
def read_list(filename):
'''Read list of names from a file'''
with open(filename, 'rb') as f:
return f.read().split()
def write_list(data, filename):
'''Write a list of name to the file'''
with open(filename, 'wb') as f:
f.write(b'\n'.join(data))
f.write(b'\n')
def candidates_to_build(build_reporter,
ignore=(),
ignore_jpp=False):
ignore = set(ignore)
ignore.update(build_reporter.to_repo.sources)
for name, src in build_reporter.from_repo.sources.items():
if name in ignore:
continue
if ignore_jpp and b'jpp' in src.release:
continue
if build_reporter.report(name).triplets:
continue
yield name
def _format_evr(pkg):
if not pkg:
return 'MISSING'