-
Notifications
You must be signed in to change notification settings - Fork 26
/
Copy pathparse-supported-gpus.py
executable file
·43 lines (33 loc) · 1.22 KB
/
parse-supported-gpus.py
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
#!/usr/bin/python3
# -*- coding: utf-8 -*-
#
# Copyright (C) 2021-2024 Simone Caronni <[email protected]>
# Licensed under the GNU General Public License Version or later
import json
import sys
import xml.etree.ElementTree as ElementTree
def main():
if len(sys.argv) != 3:
print("usage: %s supported-gpus.json com.nvidia.driver.metainfo.xml" % sys.argv[0])
return 1
json_input = open(sys.argv[1])
gpus_raw = json.load(json_input)
legacy = 'legacybranch'
devids = []
for product in gpus_raw["chips"]:
if legacy not in product.keys():
devid = int(product["devid"], 16)
if not devid in devids:
devids.append(devid)
appstream_xml = ElementTree.parse(sys.argv[2])
root = appstream_xml.getroot()
provides = ElementTree.Element('provides')
root.append(provides)
for devid in devids:
modalias = ElementTree.SubElement(provides, "modalias")
modalias.text = "pci:v000010DEd%08Xsv*sd*bc*sc*i*" % (devid)
ElementTree.indent(root, space=" ", level=0)
# appstream-util validate requires the xml header
appstream_xml.write(sys.argv[2], encoding="utf-8", xml_declaration=True)
if __name__ == "__main__":
main()