This repository has been archived by the owner on May 26, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
update-eln-extras-comps
executable file
·75 lines (63 loc) · 2.19 KB
/
update-eln-extras-comps
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#!/usr/bin/python3
import click
import requests
from collections import OrderedDict, defaultdict
from os import path
import xmltodict
DEFAULT_CONTENT_RESOLVER_URL = "https://tiny.distro.builders"
DEFAULT_CONTENT_RESOLVER_VIEW = "eln-extras"
@click.command()
@click.option(
"--content-resolver-url",
"-u",
default=DEFAULT_CONTENT_RESOLVER_URL,
show_default=True,
)
@click.option(
"--content-resolver-view",
"-w",
default=DEFAULT_CONTENT_RESOLVER_VIEW,
show_default=True,
)
@click.argument("infile", type=click.File(mode="rb"))
@click.argument("outfile", type=click.File(mode="wb", atomic=True))
def cli(content_resolver_url, content_resolver_view, infile, outfile):
comps = xmltodict.parse(infile)
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"{content_resolver_url}/view-all-binary-package-name-list--view-{content_resolver_view}--{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,
)
outfile.write(xml.encode("UTF-8"))
if __name__ == "__main__":
cli()