56 lines
1.6 KiB
Python
56 lines
1.6 KiB
Python
|
import sys
|
||
|
import xml.etree.ElementTree as ET
|
||
|
|
||
|
if len(sys.argv) < 2:
|
||
|
print("ERRIR: Require at least the updateinfo.xml file name")
|
||
|
sys.exit(1)
|
||
|
|
||
|
filename = sys.argv[1]
|
||
|
timestamp = None
|
||
|
if len(sys.argv) > 2:
|
||
|
timestamp = sys.argv[2]
|
||
|
|
||
|
tree = ET.parse(filename)
|
||
|
root = tree.getroot()
|
||
|
|
||
|
package_versions = {}
|
||
|
package_versions_skip = []
|
||
|
|
||
|
for update in root:
|
||
|
patch_id = update.find("id").text
|
||
|
issued_date = int(update.find('issued').attrib['date'])
|
||
|
pkglist = update.find("pkglist").find("collection")
|
||
|
# updates which are newer than the time stamp should be blocked (conflict of the released version)
|
||
|
# if there were more patches with it, it applies to all of them
|
||
|
if not timestamp is None and issued_date > timestamp:
|
||
|
continue
|
||
|
for package in pkglist:
|
||
|
name = package.attrib['name']
|
||
|
version = package.attrib['version']
|
||
|
release = package.attrib['release']
|
||
|
|
||
|
# if there is a newer patch already known, ignore the old one
|
||
|
if name in package_versions:
|
||
|
if issued_date < package_versions[name]["issued"]:
|
||
|
print("Older patch, skipping ", name, file=sys.stderr)
|
||
|
continue
|
||
|
|
||
|
package_versions[name] = {
|
||
|
"version" : version,
|
||
|
"release" : release,
|
||
|
"issued" : issued_date
|
||
|
}
|
||
|
|
||
|
# list of require statements for the .spec-file
|
||
|
lines = []
|
||
|
|
||
|
for package in package_versions.keys():
|
||
|
requires = "Requires: ({0} = {1}-{2} if {0})".format(package, package_versions[package]["version"], package_versions[package]["release"])
|
||
|
lines.append(requires)
|
||
|
|
||
|
lines = list(dict.fromkeys(lines))
|
||
|
lines.sort()
|
||
|
for line in lines:
|
||
|
print(line)
|
||
|
|