From 47d5f6fa9215adce165960759f832df5e268fcd7 Mon Sep 17 00:00:00 2001 From: "Ivan A. Melnikov" Date: Fri, 20 Dec 2024 13:08:12 +0400 Subject: [PATCH] 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. --- repos_cmp/repos.py | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/repos_cmp/repos.py b/repos_cmp/repos.py index f361134..892a903 100644 --- a/repos_cmp/repos.py +++ b/repos_cmp/repos.py @@ -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'