Skip to content

Commit 12c4380

Browse files
committed
misc: copr_new_packages, drop requests to koji api, use repoquery
Asking koji for each package was slow, also we were spamming koji API. This gets every package just once.
1 parent 1ed8800 commit 12c4380

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

misc/copr_new_packages.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,12 @@ def pick_project_candidates(client, projects, since):
3333
Magazine article). By such projects we consider those with at least one
3434
succeeded build and at least some project information filled.
3535
"""
36+
rawhide_pks_resp = subprocess.run(
37+
["dnf", "repoquery", "rawhide", "--queryformat", "%{name}", "*"],
38+
stdout=subprocess.PIPE,
39+
)
40+
fedora_rawhide_pkgs = {x for x in rawhide_pks_resp.stdout.decode().split("\n")}
41+
3642
picked = []
3743
for project in projects:
3844
if project.unlisted_on_hp:
@@ -55,7 +61,9 @@ def pick_project_candidates(client, projects, since):
5561
continue
5662

5763
builds = filter_unique_package_builds(builds)
58-
builds = [b for b in builds if not is_in_fedora(b.source_package["name"])]
64+
builds = [
65+
b for b in builds if b.source_package["name"] not in fedora_rawhide_pkgs
66+
]
5967
if not builds:
6068
print("Skipping {}, all packages already in Fedora".format(project.full_name))
6169
continue
@@ -81,14 +89,6 @@ def filter_unique_package_builds(builds):
8189
return unique.values()
8290

8391

84-
def is_in_fedora(packagename):
85-
"""
86-
Check if a given package is already provided by Fedora official repositories
87-
"""
88-
cmd = ["koji", "search", "package", packagename]
89-
return bool(subprocess.check_output(cmd))
90-
91-
9292
def get_parser():
9393
description = ("This tool lists new packages in Copr, that are not yet "
9494
"available in Fedora. It's main purpose is to help us pick "

0 commit comments

Comments
 (0)