From 3bbfc8a9cdb6efdf39ed8fe8696ed7b833074989 Mon Sep 17 00:00:00 2001 From: Dylan Baker Date: Mon, 17 Aug 2026 17:35:29 +0000 Subject: [PATCH] build_runtime: detect whether flatpak-builder install workaround is needed Prior to flatpak-builder 1.4.5, we needed to explicitly install the Platform component when an Sdk and Platform are built together. If we have a newer version, don't do the workaround --- flatpaker/actions/build_runtime.py | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/flatpaker/actions/build_runtime.py b/flatpaker/actions/build_runtime.py index 00df5a3..cd6e520 100644 --- a/flatpaker/actions/build_runtime.py +++ b/flatpaker/actions/build_runtime.py @@ -14,7 +14,8 @@ from ..entry import BaseBuildArguments, BuildRuntimeArguments -def _build_runtime(args: BaseBuildArguments, sdk: pathlib.Path) -> None: +def _build_runtime(args: BaseBuildArguments, sdk: pathlib.Path, + need_platform_workaround: bool) -> None: build_command: list[str] = [ 'flatpak-builder', '--force-clean', '--user', 'build', sdk.as_posix()] @@ -28,7 +29,7 @@ def _build_runtime(args: BaseBuildArguments, sdk: pathlib.Path) -> None: subprocess.run(build_command, check=True) # Work around https://github.com/flatpak/flatpak-builder/issues/630 - if args.install and 'Sdk' in sdk.name: + if need_platform_workaround and args.install and 'Sdk' in sdk.name: if '8' in sdk.name: branch = '8' elif '7.py2' in sdk.name: @@ -48,6 +49,24 @@ def _build_runtime(args: BaseBuildArguments, sdk: pathlib.Path) -> None: subprocess.run(install_command, check=True) +def _need_platform_workaround() -> bool: + """Do we need the workaround for platform installation? + + Prior to flatpak-builder 1.4.5, flatpak would only install the Sdk component + when a Platform and and Sdk are built together. This means that for the Ren'Py + platforms, only the Sdk would be installed. For later versions this is fixed, + and we don't need the workaround. + """ + out = subprocess.run( + ['flatpak-builder', '--version'], + stdout=subprocess.PIPE, + text=True, + check=True, + ) + raw_ver = out.stdout.rsplit('-', 1)[1] + return tuple(int(v) for v in raw_ver.split('.')) < (1, 4, 5) + + def build_runtimes(args: BuildRuntimeArguments) -> bool: command = [ 'flatpak', 'install', '--no-auto-pin', '--user', @@ -69,11 +88,12 @@ def build_runtimes(args: BuildRuntimeArguments) -> bool: success = True + need_platform_workaround = _need_platform_workaround() datadir = importlib.resources.files('flatpaker') / 'data' for runtime in runtimes: try: with importlib.resources.as_file(datadir / runtime) as sdk: - _build_runtime(args, sdk) + _build_runtime(args, sdk, need_platform_workaround) except Exception: if not args.keep_going: raise