Skip to content

Instantly share code, notes, and snippets.

@siddhesh
Created October 6, 2022 19:19
Show Gist options
  • Save siddhesh/277527821a4d698f36e16bf39190985c to your computer and use it in GitHub Desktop.
Save siddhesh/277527821a4d698f36e16bf39190985c to your computer and use it in GitHub Desktop.
For a tree of copr packages builds done with mass-prebuilder, record the rpm size along with the corresponding build in koji.
#!/usr/bin/python3
import json
import requests
import sys
import os
def eprint(inp):
#print(inp)
return
KOJI_PATH = 'https://kojipkgs.fedoraproject.org/packages/%s/%s/%s/%s/%s'
def get_pkg_size(projpath, project, name, version, release, arch):
pkg = '%s-%s-%s.%s.rpm' % (name, version, release, arch)
local_size = os.stat(os.path.join(projpath, pkg)).st_size
url = KOJI_PATH % (project, version, release, arch, pkg)
koji_info = requests.head(url)
if koji_info.status_code < 300 and koji_info.status_code >= 200:
koji_size = int(koji_info.headers['Content-Length'])
print('%s,%s,%d,%d' % (project, pkg, koji_size, local_size))
else:
# The koji build is against an older dist tag. Ignore for now.
eprint('Error: %s returned %d' % (url, koji_info.status_code))
root = sys.argv[1]
for project in os.listdir(root):
projpath = os.path.join(root,project)
projpath = os.path.join(projpath, os.listdir(projpath)[0])
results_file = os.path.join(projpath, 'results.json')
results = json.load(open(results_file))
for package in results['packages']:
get_pkg_size(projpath, project, package['name'], package['version'],
package['release'], package['arch'])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment