#!/usr/bin/env python3 """Compatibility entry point for the deterministic native-launcher update.""" from __future__ import annotations import argparse import os from pathlib import Path import sys import time from typing import Sequence # This file remains at its historical path for release scripts and imports. The # implementation belongs to the canonical release library under scripts/. _BOOTSTRAP_ROOT = Path(__file__).resolve().parents[1] if str(_BOOTSTRAP_ROOT) not in sys.path: sys.path.insert(0, str(_BOOTSTRAP_ROOT)) from scripts.release_lib import ( # noqa: E402 ReleaseToolError, build_legacy_launcher_update, ) from scripts.repository_paths import PROJECT_ROOT # noqa: E402 DEFAULT_REPOSITORY_URL = "https://git.m4ko.net/m4ko/pristontale-eu-linux" DEFAULT_MINIMUM_UPDATER_VERSION = "0.5.0" ReleaseBuildError = ReleaseToolError def build_parser() -> argparse.ArgumentParser: parser = argparse.ArgumentParser(description=__doc__) parser.add_argument("--version", required=True) parser.add_argument("--output-directory", type=Path, required=True) parser.add_argument( "--repository-url", default=DEFAULT_REPOSITORY_URL, help="public Gitea repository base URL", ) parser.add_argument( "--minimum-updater-version", default=DEFAULT_MINIMUM_UPDATER_VERSION, ) parser.add_argument("--signing-key", type=Path) parser.add_argument( "--require-signature", action="store_true", help="fail unless a signing key is provided and matches the bundled public key", ) parser.add_argument( "--source-date-epoch", type=int, default=int(os.environ.get("SOURCE_DATE_EPOCH", str(int(time.time())))), ) return parser def build_launcher_update( *, version: str, output_directory: Path, repository_url: str, minimum_updater_version: str, signing_key: Path | None, require_signature: bool = False, source_date_epoch: int, ) -> tuple[Path, ...]: """Forward the historical Python API to the canonical release library.""" return build_legacy_launcher_update( version=version, output_directory=output_directory, repository_url=repository_url, minimum_updater_version=minimum_updater_version, signing_key=signing_key, require_signature=require_signature, source_date_epoch=source_date_epoch, ) def main(argv: Sequence[str] | None = None) -> int: arguments = build_parser().parse_args(argv) try: artifacts = build_launcher_update( version=arguments.version, output_directory=arguments.output_directory, repository_url=arguments.repository_url, minimum_updater_version=arguments.minimum_updater_version, signing_key=arguments.signing_key, require_signature=arguments.require_signature, source_date_epoch=arguments.source_date_epoch, ) except (OSError, ReleaseBuildError) as exc: print(f"Could not build launcher update: {exc}", file=sys.stderr) return 1 for artifact in artifacts: print(artifact) return 0 if __name__ == "__main__": raise SystemExit(main())