-
Notifications
You must be signed in to change notification settings - Fork 25
/
caf-regen.py
executable file
·89 lines (64 loc) · 2.18 KB
/
caf-regen.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
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#!/usr/bin/env python3
from bs4 import BeautifulSoup
import os
import re
import sys
import urllib.request
import xml.etree.ElementTree as ET
def groups_for_repo(repo, extra=[]):
groups = set(extra)
if re.match(r"device/.*[_-]kernel", repo):
groups.add("kernel")
if re.match(r"kernel/prebuilts/", repo):
groups.add("kernel")
if re.match(r"device/generic/.*mips", repo):
groups.add("mips")
if re.match(r"platform/prebuilts/.*/mips/.*", repo):
groups.add("mips")
if repo == "platform/external/chromium-webview":
groups.add("chromium")
if repo.startswith("platform/hardware/bsp/"):
groups.add("bsp")
if re.match(r"platform/prebuilts/.*darwin(-x86)?.*", repo):
groups.add("darwin")
if re.match(r"platform/prebuilts/.*windows(-x86)?.*", repo):
groups.add("windows")
return sorted(groups)
def get_all_repos():
repos = set()
try:
caf = urllib.request.urlopen(
urllib.request.Request("https://source.codeaurora.org/quic/la/")
).read()
except urllib.error.HTTPError as e:
sys.exit(e)
soup = BeautifulSoup(caf, "html.parser")
for repo in soup.find_all(class_="sublevel-repo"):
repos.add(repo.a["href"][9:-1]) # Drop /quic/la/
return repos
# Generate groups for all repositories
repos = {}
for repo in get_all_repos():
repos[repo] = groups_for_repo(repo)
file = open("caf.xml", "w")
file.write('<?xml version="1.0" encoding="UTF-8"?>\n')
file.write("<manifest>\n")
file.write("\n")
file.write(' <remote name="caf"\n')
file.write(' fetch="https://source.codeaurora.org/quic/la/" />\n')
file.write(' <default revision="master"\n')
file.write(' remote="caf"\n')
file.write(' sync-j="4" />\n')
file.write("\n")
for repo in sorted(repos):
line = 'name="' + repo + '"'
# Would we get a path conflict?
if any(s.startswith(repo + "/") for s in repos):
line += ' path="' + repo + '.git"'
# Add groups
groups = repos[repo]
if len(groups) > 0:
line += ' groups="' + ",".join(groups) + '"'
file.write(" <project " + line + " />\n")
file.write("</manifest>\n")
file.close()