Add terrible forge scan

This commit is contained in:
Ryan Fox 2021-11-04 14:44:19 -07:00
parent 8320df3bc5
commit 962c214664
Signed by: flewkey
GPG Key ID: 94F56ADFD848851E
2 changed files with 47 additions and 0 deletions

View File

@ -5,11 +5,13 @@ from sys import argv
from pkgcrap.list_update import main as update
from pkgcrap.list_update import maintlist as maintlist
from pkgcrap.outdated_check import main as outdated
from pkgcrap.forge_scan import main as forgescan
options = {
'update': update,
'outdated': outdated,
'maintlist': maintlist,
'forgescan': forgescan,
}
def main():

45
pkgcrap/forge_scan.py Normal file
View File

@ -0,0 +1,45 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
from pkgcrap.util import conf_file_path
import pkgcrap.parse as parse
from urllib.parse import urlparse
def main(args):
repos = parse.repos()
repos.load()
checked = 0
failed = 0
forges = {}
for repo in repos.repos.values():
repo.load()
print('Scanning', repo.name)
for cat in repo.categories.values():
cat.load()
for pkg in cat.packages.values():
pkg.load()
if len(pkg.ebuilds) == 0 or 'EGIT_REPO_URI' not in pkg.ebuilds[0].vars:
failed += 1
continue
eb = pkg.ebuilds[0]
repo = pkg.ebuilds[0].vars['EGIT_REPO_URI'].replace('${PN}', pkg.name)
if 'HOMEPAGE' in pkg.ebuilds[0].vars:
repo = repo.replace('${HOMEPAGE}', eb.vars['HOMEPAGE'])
if 'EGO_PN' in pkg.ebuilds[0].vars:
repo = repo.replace('${EGO_PN}', eb.vars['EGO_PN'])
if 'MY_REPO_URI' in pkg.ebuilds[0].vars:
repo = repo.replace('${MY_REPO_URI}', eb.vars['MY_REPO_URI'])
forge = urlparse(repo).netloc
if forge == '' or forge.startswith('${'):
failed += 1
continue
if forge not in forges:
forges[forge] = 0
forges[forge] += 1
checked += 1
print('Found git URI in '+str(checked)+' packages')
print('Failed to find git URI in '+str(failed)+' packages')
for forge in dict(reversed(sorted(forges.items(), key=lambda item: item[1]))):
c = forges[forge]
p = float(c)/checked*100
print(forge+': '+str(c)+f' ({p:.2f}%)')