ci: Fix FPSLocker-Warehouse fetch on Gitea runners
Skip submodule checkout in workflows and fall back to downloading the v4 archive when git clone from GitHub fails during OC pack builds.
This commit is contained in:
4
.github/workflows/build-all.yml
vendored
4
.github/workflows/build-all.yml
vendored
@@ -12,7 +12,9 @@ jobs:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
submodules: true
|
||||
# Submodule clone via GitHub HTTPS fails on some Gitea/act runners.
|
||||
# OC build fetches FPSLocker-Warehouse in generate-fpslocker-patches.py.
|
||||
submodules: false
|
||||
|
||||
- name: Build all variants
|
||||
run: bash scripts/build-all.sh
|
||||
|
||||
2
.github/workflows/update-release.yml
vendored
2
.github/workflows/update-release.yml
vendored
@@ -18,7 +18,7 @@ jobs:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
submodules: true
|
||||
submodules: false
|
||||
|
||||
- name: Get latest non-draft release
|
||||
id: release
|
||||
|
||||
@@ -8,8 +8,12 @@ Archivwurzel ist patches/, passend zu boot_package.ini
|
||||
from __future__ import annotations
|
||||
|
||||
import argparse
|
||||
import shutil
|
||||
import subprocess
|
||||
import sys
|
||||
import tempfile
|
||||
import urllib.error
|
||||
import urllib.request
|
||||
import zipfile
|
||||
from pathlib import Path
|
||||
|
||||
@@ -27,6 +31,9 @@ DEST = (
|
||||
/ "FPSLocker"
|
||||
/ "patches.zip"
|
||||
)
|
||||
WAREHOUSE_ZIP_URL = (
|
||||
"https://github.com/masagrator/FPSLocker-Warehouse/archive/refs/heads/v4.zip"
|
||||
)
|
||||
|
||||
|
||||
def should_exclude(path: Path) -> bool:
|
||||
@@ -50,37 +57,89 @@ def warehouse_head() -> str | None:
|
||||
return proc.stdout.strip() or None
|
||||
|
||||
|
||||
def update_warehouse() -> int:
|
||||
print("Hole neuesten Stand von FPSLocker-Warehouse (v4)...")
|
||||
def fetch_warehouse_archive() -> int:
|
||||
"""Fallback when git submodule clone fails (e.g. CI without GitHub access)."""
|
||||
print(f"Lade FPSLocker-Warehouse (v4) von {WAREHOUSE_ZIP_URL} ...")
|
||||
try:
|
||||
subprocess.run(
|
||||
[
|
||||
"git",
|
||||
"submodule",
|
||||
"update",
|
||||
"--init",
|
||||
"--remote",
|
||||
"--",
|
||||
WAREHOUSE_REL,
|
||||
],
|
||||
cwd=PROJECT_ROOT,
|
||||
check=True,
|
||||
)
|
||||
except FileNotFoundError:
|
||||
print("git nicht gefunden", file=sys.stderr)
|
||||
with tempfile.TemporaryDirectory() as tmp_name:
|
||||
tmp = Path(tmp_name)
|
||||
zip_path = tmp / "warehouse.zip"
|
||||
with urllib.request.urlopen(WAREHOUSE_ZIP_URL, timeout=120) as response:
|
||||
zip_path.write_bytes(response.read())
|
||||
|
||||
with zipfile.ZipFile(zip_path) as zf:
|
||||
zf.extractall(tmp)
|
||||
|
||||
extracted_dirs = [
|
||||
path
|
||||
for path in tmp.iterdir()
|
||||
if path.is_dir() and path.name.startswith("FPSLocker-Warehouse-")
|
||||
]
|
||||
if len(extracted_dirs) != 1:
|
||||
print(
|
||||
"Unerwartete Archivstruktur in FPSLocker-Warehouse v4.zip",
|
||||
file=sys.stderr,
|
||||
)
|
||||
return 1
|
||||
|
||||
if WAREHOUSE.exists():
|
||||
shutil.rmtree(WAREHOUSE)
|
||||
shutil.move(str(extracted_dirs[0]), str(WAREHOUSE))
|
||||
except (urllib.error.URLError, OSError, zipfile.BadZipFile) as exc:
|
||||
print(f"Archiv-Download fehlgeschlagen: {exc}", file=sys.stderr)
|
||||
return 1
|
||||
except subprocess.CalledProcessError as e:
|
||||
|
||||
if not SRC.is_dir():
|
||||
print(f"patches/ fehlt nach Archiv-Extraktion: {SRC}", file=sys.stderr)
|
||||
return 1
|
||||
|
||||
sha = warehouse_head()
|
||||
if sha:
|
||||
print(f"FPSLocker-Warehouse: {sha}")
|
||||
else:
|
||||
print("FPSLocker-Warehouse: v4 (Archiv)")
|
||||
return 0
|
||||
|
||||
|
||||
def ensure_warehouse(*, remote: bool) -> int:
|
||||
label = "Hole neuesten Stand" if remote else "Initialisiere"
|
||||
print(f"{label} von FPSLocker-Warehouse (v4)...")
|
||||
|
||||
if SRC.is_dir() and not remote:
|
||||
sha = warehouse_head()
|
||||
if sha:
|
||||
print(f"FPSLocker-Warehouse: {sha}")
|
||||
return 0
|
||||
|
||||
try:
|
||||
cmd = ["git", "submodule", "update", "--init", "--force", "--depth=1"]
|
||||
if remote:
|
||||
cmd.extend(["--remote", "--", WAREHOUSE_REL])
|
||||
else:
|
||||
cmd.extend(["--", WAREHOUSE_REL])
|
||||
subprocess.run(cmd, cwd=PROJECT_ROOT, check=True)
|
||||
except FileNotFoundError:
|
||||
print("git nicht gefunden, versuche Archiv-Download...", file=sys.stderr)
|
||||
return fetch_warehouse_archive()
|
||||
except subprocess.CalledProcessError:
|
||||
print(
|
||||
"Aktualisieren des FPSLocker-Warehouse-Submodules fehlgeschlagen",
|
||||
"Git-Submodule fehlgeschlagen, versuche Archiv-Download...",
|
||||
file=sys.stderr,
|
||||
)
|
||||
return e.returncode or 1
|
||||
if WAREHOUSE.exists():
|
||||
shutil.rmtree(WAREHOUSE, ignore_errors=True)
|
||||
return fetch_warehouse_archive()
|
||||
|
||||
sha = warehouse_head()
|
||||
if sha:
|
||||
print(f"FPSLocker-Warehouse: {sha}")
|
||||
return 0
|
||||
|
||||
|
||||
def update_warehouse() -> int:
|
||||
return ensure_warehouse(remote=True)
|
||||
|
||||
|
||||
def parse_args(argv: list[str] | None = None) -> argparse.Namespace:
|
||||
parser = argparse.ArgumentParser(description=__doc__)
|
||||
parser.add_argument(
|
||||
@@ -97,6 +156,10 @@ def main(argv: list[str] | None = None) -> int:
|
||||
rc = update_warehouse()
|
||||
if rc != 0:
|
||||
return rc
|
||||
elif not SRC.is_dir():
|
||||
rc = ensure_warehouse(remote=False)
|
||||
if rc != 0:
|
||||
return rc
|
||||
|
||||
if not SRC.is_dir():
|
||||
print(
|
||||
|
||||
Reference in New Issue
Block a user