Explorar el Código

fix(download-kernel): resolve relative fetch URLs in manifest

TheWildJames hace 4 meses
padre
commit
75f13d8555

BIN
.github/actions/download-kernel/__pycache__/download_kernel_archives.cpython-312.pyc


+ 15 - 1
.github/actions/download-kernel/download_kernel_archives.py

@@ -40,6 +40,7 @@ def main() -> int:
     manifest_branch = f"common-{formatted_branch}"
     manifest_ref = f"refs/heads/{manifest_branch}"
     manifest_base = f"https://android.googlesource.com/kernel/manifest/+/{manifest_ref}/"
+    manifest_origin = f"{urllib.parse.urlparse(manifest_base).scheme}://{urllib.parse.urlparse(manifest_base).netloc}"
 
     target_repo = os.environ.get("GITHUB_REPOSITORY", "")
     github_token = os.environ.get("GITHUB_TOKEN", "")
@@ -138,7 +139,20 @@ def main() -> int:
         return combined, link_copy
 
     manifest_root, link_copy = load_manifest_with_includes("default.xml")
-    remotes = {r.get("name"): (r.get("fetch") or "").rstrip("/") for r in manifest_root.findall("remote")}
+
+    def resolve_remote_fetch(fetch: str) -> str:
+        fetch = fetch.strip()
+        if fetch.startswith("https://") or fetch.startswith("http://"):
+            return fetch.rstrip("/")
+        base = f"{manifest_origin}/"
+        resolved = urllib.parse.urljoin(base, f"{fetch.rstrip('/')}/")
+        return resolved.rstrip("/")
+
+    remotes = {
+        r.get("name"): resolve_remote_fetch(r.get("fetch") or "")
+        for r in manifest_root.findall("remote")
+        if r.get("name") and r.get("fetch") is not None
+    }
     default = manifest_root.find("default")
     def_remote = default.get("remote") if default is not None else None
     def_rev = default.get("revision") if default is not None else None