From 7756c9e559346ca3b34201963f80f5f21a81ff04 Mon Sep 17 00:00:00 2001 From: Miro HronĨok Date: Aug 19 2018 12:29:00 +0000 Subject: Find orphaned packages --- diff --git a/README.rst b/README.rst index 6be1001..91190cc 100644 --- a/README.rst +++ b/README.rst @@ -42,3 +42,9 @@ the corresponding source packages. For convenience, will look for ldconfig and install-info calls when called as find-ldconfig-calls and find-installinfo-calls, respectively. + +find-orphaned-packages +---------------------- + +This lists all orphaned packages that are not retired on master. +Needs Python 3.7 and aiohttp. diff --git a/find-orphaned-packages b/find-orphaned-packages new file mode 100755 index 0000000..a6fb6c8 --- /dev/null +++ b/find-orphaned-packages @@ -0,0 +1,40 @@ +#!/usr/bin/python3.7 +import asyncio +import aiohttp + + +async def all_orphanned(): + url = 'https://src.fedoraproject.org/extras/pagure_owner_alias.json' + async with aiohttp.ClientSession() as session: + async with session.get(url) as resp: + rpms = (await resp.json())['rpms'] + for pkg in rpms: + if 'orphan' in rpms[pkg]: + yield pkg + + +async def print_if_not_retired(pkg, sleep=1): + url = f'https://src.fedoraproject.org/rpms/{pkg}/blob/master/f/dead.package' + async with aiohttp.ClientSession() as session: + try: + async with session.head(url) as resp: + if resp.status == 404: + print(pkg) + elif resp.status >= 400: + raise aiohttp.client_exceptions.ServerConnectionError() + except (aiohttp.client_exceptions.ClientError, asyncio.TimeoutError): + if sleep > 15 * 60: + raise + await asyncio.sleep(sleep) + return await print_if_not_retired(pkg, sleep*2) + + +async def main(): + tasks = [] + async for pkg in all_orphanned(): + tasks.append(asyncio.create_task(print_if_not_retired(pkg))) + await asyncio.gather(*tasks) + + +if __name__ == '__main__': + asyncio.run(main())