Skip to content

Commit 32bc725

Browse files
committed
feat: pull vendor on undefined manifest/clone repos
* this only works for lineage 21 and above for codenames, that do not contain each other
1 parent 77747fe commit 32bc725

File tree

4 files changed

+61
-3
lines changed

4 files changed

+61
-3
lines changed

TODO.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
## ToDo
2-
- automatic repo pulling for officially supported lineage devices
2+
- make vendor pulling work for multiple devices
4.02 KB
Binary file not shown.

py-utils/xml_roomservice.py

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
#!/usr/bin/python3
2+
3+
import xml
4+
import xml_manifest_gen
5+
from xml.etree import ElementTree
6+
import sys
7+
from urllib.request import urlopen, Request
8+
9+
10+
def fetch_device_vendor(local_manifest, remote_manifest, device: str) -> xml:
11+
for projects in remote_manifest.findall("project"):
12+
if projects.get("groups").__contains__(device):
13+
if projects.get("remote") == "":
14+
remote = ""
15+
else:
16+
remote = projects.get("remote")
17+
18+
if projects.get("revision") == "":
19+
revision = ""
20+
else:
21+
revision = projects.get("revision")
22+
23+
local_manifest = xml_manifest_gen.add_project_to_manifest(
24+
manifest=local_manifest,
25+
project_name=projects.get("name"),
26+
project_path=projects.get("path"),
27+
project_remote=remote,
28+
project_revision=revision
29+
)
30+
31+
ElementTree.indent(local_manifest)
32+
return local_manifest
33+
34+
35+
def main() -> None:
36+
devices = f"muppets_{sys.argv[1]}".split(",")
37+
branch = sys.argv[2]
38+
39+
url = f"https://github.com/TheMuppets/manifests/raw/refs/heads/{branch}/muppets.xml"
40+
request = Request(url, headers={"User-Agent": "Mozilla/5.0"})
41+
source_manifest = urlopen(request).read()
42+
remote_manifest = ElementTree.fromstring(source_manifest)
43+
44+
local_manifest = ElementTree.Element("manifest")
45+
for device in devices:
46+
local_manifest = fetch_device_vendor(local_manifest, remote_manifest, device)
47+
48+
print('<?xml version="1.0" encoding="UTF-8"?>')
49+
print(ElementTree.tostring(local_manifest).decode())
50+
51+
52+
if __name__ == '__main__':
53+
main()

scripts/sync.sh

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,13 @@ _sync() {
1616
cd "${ROM_DIR}" || exit
1717
# Remove local manifests
1818
find "${ROM_DIR}"/.repo/local_manifests/ -type f -exec rm {} \;
19-
# Merge local manifests into one to avoid conflicts with duplicate dependencies
20-
xml_manifest_gen.py "${LOCAL_MANIFEST}" > "${ROM_DIR}"/.repo/local_manifests/manifest.xml
19+
if [[ -n "${LOCAL_MANIFEST}" ]]; then
20+
# Merge local manifests into one to avoid conflicts with duplicate dependencies
21+
xml_manifest_gen.py "${LOCAL_MANIFEST}" > "${ROM_DIR}"/.repo/local_manifests/manifest.xml
22+
elif [[ -z "${CLONE_REPOS}" ]]; then
23+
# Generate vendor manifest, so that official lineage just builds
24+
xml_roomservice.py "${DEVICE}" "${ROM_BRANCH}" > "${ROM_DIR}"/.repo/local_manifests/manifest.xml
25+
fi
2126
local threads
2227
threads=$(nproc)
2328
repo forall -c "rm .git/*.lock" || true

0 commit comments

Comments
 (0)