pungi-fedora/extras-to-comps
Stephen Gallagher 3009dcdaaf
Add proper support for ELN-Extras
Signed-off-by: Stephen Gallagher <sgallagh@redhat.com>
2022-07-18 12:45:21 -04:00

47 lines
1.5 KiB
Python
Executable File

#!/usr/bin/python
import requests
from collections import OrderedDict, defaultdict
import xmltodict
eln_comps_xml = "https://pagure.io/fedora-comps/raw/main/f/comps-eln.xml.in"
r = requests.get(eln_comps_xml, stream=True)
r.raise_for_status()
comps = xmltodict.parse(r.text)
comps_group = OrderedDict()
comps_group["id"] = "eln-extras"
comps_group["_name"] = "ELN Extras"
comps_group["_description"] = "Extra packages not in ELN, but needed to be built like ELN for testing"
comps_group["default"] = "false"
comps_group["uservisible"] = "false"
comps_group["packagelist"] = OrderedDict()
comps_group["packagelist"]["packagereq"] = list()
ARCHES = ["aarch64", "ppc64le", "s390x", "x86_64"]
package_arches = defaultdict(set)
for arch in ARCHES:
r = requests.get(f'https://tiny.distro.builders/view-all-binary-package-name-list--view-eln-extras--{arch}.txt')
r.raise_for_status()
packages = r.text.split("\n")
for package in packages:
package_arches[package].add(arch)
for package in sorted(package_arches.keys()):
entry = OrderedDict()
entry['@variant'] = "Extras"
entry['@arch'] = ",".join(package_arches[package])
entry['#text'] = package
comps_group["packagelist"]["packagereq"].append(entry)
comps['comps']['group'].append(comps_group)
raw_xml = xmltodict.unparse(comps, full_document=True, pretty=True, indent=' ')
xml = raw_xml.replace('<?xml version="1.0" encoding="utf-8"?>',
'<!DOCTYPE comps PUBLIC "-//Red Hat, Inc.//DTD Comps info//EN" "comps.dtd">',
1)
print(xml)