Skip to content

Instantly share code, notes, and snippets.

@haraldh
Created March 17, 2016 13:14
Show Gist options
  • Save haraldh/c402b48d57c2c9ca6dd5 to your computer and use it in GitHub Desktop.
Save haraldh/c402b48d57c2c9ca6dd5 to your computer and use it in GitHub Desktop.
#!/usr/bin/python3
#
# Usage:
# $ python3 prereq.py repodata-primary.xml.gz
#
import sys
import xml.etree.ElementTree as ET
import gzip
document = ET.parse(gzip.open(sys.argv[1]))
root = document.getroot()
ns = { 'yum' : 'http://linux.duke.edu/metadata/common', 'rpm' : 'http://linux.duke.edu/metadata/rpm' }
for rpm in root.findall('yum:package', ns):
for f in rpm.findall('yum:format', ns):
preset = set()
reqset = set()
rpmname = rpm.findall('yum:name', ns)[0].text + "." + rpm.findall('yum:arch', ns)[0].text
srpmname = f.findall('rpm:sourcerpm', ns)[0].text
for req in f.findall('rpm:requires', ns):
for e in req.findall('rpm:entry', ns):
if 'pre' in e.attrib:
preset.add(str(e.get("name")))
else:
reqset.add(str(e.get("name")))
for i in preset.difference(reqset):
print("SRPM: ", srpmname, "\t RPM: ", rpmname ,"\t Require(pre): ", i)
@haraldh
Copy link
Author

haraldh commented Mar 17, 2016

$ python3 prereq.py /var/cache/dnf/rawhide-2d95c80a1fa0a67d/repodata/9ad57e54c0d30a01fe1de48f4bb45004c300f0ee4d541fb5e927e42dcf1b4611-primary.xml.gz | fgrep linux-firmware
SRPM:  kernel-4.6.0-0.rc0.git1.1.fc25.src.rpm    RPM:  kernel-core.x86_64    Require(pre):  linux-firmware

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment