From 37d2f77964b0c717c0d52ab2e0d32f8e5b57f918 Mon Sep 17 00:00:00 2001 From: Ralph Bean Date: Nov 09 2017 02:20:25 +0000 Subject: A script for finding which packages have EPEL BZ components, that shouldn't. Signed-off-by: Ralph Bean --- diff --git a/scripts/bugzilla/list-bad-epel.py b/scripts/bugzilla/list-bad-epel.py new file mode 100644 index 0000000..348ce95 --- /dev/null +++ b/scripts/bugzilla/list-bad-epel.py @@ -0,0 +1,63 @@ +""" A script for listing which components have bz epel entries that shouldn't. + +https://pagure.io/releng/issue/7148 +""" + +import bugzilla +import dogpile.cache +import requests + +bz = bugzilla.Bugzilla('https://bugzilla.redhat.com') +cache = dogpile.cache.make_region().configure( + 'dogpile.cache.dbm', + arguments=dict( + filename='/var/tmp/bugzilla-component-cache.dbm', + expiration_time=-1, + ) +) + + +@cache.cache_on_arguments() +def get_pdc_data(url): + response = requests.get(url) + if not response: + raise ValueError("%r failed %r" % (url, response)) + return response.json() + + +@cache.cache_on_arguments() +def in_bugzilla(component): + matches = bz._proxy.Component.get(dict(names=[ + dict(product='Fedora EPEL', component=component)])) + return bool(matches['components']) + + +def get_all_branches_from_pdc(): + next = 'https://pdc.fedoraproject.org/rest_api/v1/component-branches' + \ + '?type=rpm&page_size=100&page=1' + while next: + print("Getting %r" % next) + data = get_pdc_data(next) + for entry in data['results']: + yield entry + next = data['next'] + + +all_packages = set() +in_epel_in_pdc = set() +in_epel_in_bz = set() +for branch in get_all_branches_from_pdc(): + all_packages.add(branch['global_component']) + if branch['name'].startswith('epel') or branch['name'].startswith('el'): + in_epel_in_pdc.add(branch['global_component']) + if in_bugzilla(branch['global_component']): + in_epel_in_bz.add(branch['global_component']) + print("All: %r, EPEL(PDC): %r, EPEL(BZ): %r, " + "In BZ and shouldn't be: %r, " + "Not in BZ and should be: %r" % ( + len(all_packages), + len(in_epel_in_pdc), + len(in_epel_in_bz), + len(in_epel_in_bz - in_epel_in_pdc), + len(in_epel_in_pdc - in_epel_in_bz), + )) \ No newline at end of file