Created
March 17, 2016 13:14
-
-
Save haraldh/c402b48d57c2c9ca6dd5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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) |
Author
haraldh
commented
Mar 17, 2016
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment