diff options
| author | Andrew Branson <andrew.branson@jolla.com> | 2026-08-09 15:03:34 +0200 |
|---|---|---|
| committer | Andrew Branson <andrew.branson@jolla.com> | 2026-08-09 15:03:34 +0200 |
| commit | b9746bfa320cdd1464eb6c91fbadad35c84d2459 (patch) | |
| tree | 6528b43f66e0bc6b451666c3fb607a927110d304 /scripts | |
| parent | eb92561bd685961889cc553cd96db4a569eefec5 (diff) | |
Harden build workflows and OBS selection
Add preflight, cancellation, confined status, and timeout handling for
local Sailfish and remote Android build jobs.
Vendor helper 2.0.0 with explicit backend/pull controls, build locking,
local RPM validation, metadata, and structured failure reporting.
Expose named internal, partner, and community OBS servers while retaining
raw osc API aliases.
Diffstat (limited to 'scripts')
| -rw-r--r-- | scripts/update_build_helper.py | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/scripts/update_build_helper.py b/scripts/update_build_helper.py new file mode 100644 index 0000000..c9436a1 --- /dev/null +++ b/scripts/update_build_helper.py @@ -0,0 +1,66 @@ +#!/usr/bin/env python3 + +import argparse +import importlib.util +import os +from pathlib import Path +import py_compile +import shutil +import tempfile + + +DESTINATION = ( + Path(__file__).resolve().parents[1] + / "src" + / "sailfish_devel_mcp" + / "vendor" + / "build_sailfishos.py" +) + + +def helper_version(path: Path) -> str: + spec = importlib.util.spec_from_file_location("candidate_build_sailfishos", path) + if spec is None or spec.loader is None: + raise RuntimeError(f"could not load helper: {path}") + module = importlib.util.module_from_spec(spec) + spec.loader.exec_module(module) + version = getattr(module, "HELPER_VERSION", None) + if not isinstance(version, str) or not version: + raise RuntimeError(f"helper has no HELPER_VERSION: {path}") + return version + + +def main() -> int: + parser = argparse.ArgumentParser(description="Update the vendored build-sailfishos helper") + parser.add_argument("source", type=Path, help="Canonical build_sailfishos.py") + args = parser.parse_args() + + source = args.source.expanduser().resolve() + if not source.is_file(): + parser.error(f"source helper not found: {source}") + version = helper_version(source) + py_compile.compile(str(source), doraise=True) + + DESTINATION.parent.mkdir(parents=True, exist_ok=True) + descriptor, temporary_name = tempfile.mkstemp( + prefix=f".{DESTINATION.name}.", + suffix=".tmp", + dir=DESTINATION.parent, + ) + os.close(descriptor) + temporary = Path(temporary_name) + try: + shutil.copyfile(source, temporary) + temporary.chmod(0o755 if source.stat().st_mode & 0o111 else 0o644) + os.replace(temporary, DESTINATION) + finally: + try: + temporary.unlink() + except FileNotFoundError: + pass + print(f"vendored build helper {version}: {DESTINATION}") + return 0 + + +if __name__ == "__main__": + raise SystemExit(main()) |
