diff --git a/Makefile.in b/Makefile.in index 37ba5f09..62b22d63 100644 --- a/Makefile.in +++ b/Makefile.in @@ -34,21 +34,6 @@ all: umu-dist umu-docs umu-launcher install: umu-install umu-launcher-install endif -# Special case, do this inside the source directory for release distribution -umu/umu_version.json: umu/umu_version.json.in - $(info :: Updating $(@) ) - cp $(<) $(<).tmp - sed 's|##UMU_VERSION##|$(shell git describe --always --long --tags)|g' -i $(<).tmp - mv $(<).tmp $(@) - -.PHONY: version -version: umu/umu_version.json - -version-install: version - $(info :: Installing umu_version.json ) - install -d $(DESTDIR)$(PYTHONDIR)/$(INSTALLDIR) - install -Dm 644 umu/umu_version.json -t $(DESTDIR)$(PYTHONDIR)/$(INSTALLDIR) - $(OBJDIR)/.build-umu-docs: | $(OBJDIR) $(info :: Building umu man pages ) @@ -67,7 +52,7 @@ umu-docs-install: umu-docs install -m644 $(OBJDIR)/umu.5 $(DESTDIR)$(MANDIR)/man5/umu.5 -$(OBJDIR)/.build-umu-dist: | $(OBJDIR) version +$(OBJDIR)/.build-umu-dist: | $(OBJDIR) $(info :: Building umu ) $(PYTHON_INTERPRETER) -m build --wheel --skip-dependency-check --no-isolation --outdir=$(OBJDIR) touch $(@) @@ -81,9 +66,9 @@ umu-dist-install: umu-dist $(PYTHON_INTERPRETER) -m installer --destdir=$(DESTDIR) $(OBJDIR)/*.whl ifeq ($(FLATPAK), xtrue) -umu-install: version-install umu-dist-install +umu-install: umu-dist-install else -umu-install: version-install umu-dist-install umu-docs-install +umu-install: umu-dist-install umu-docs-install endif ifeq ($(FLATPAK), xtrue) @@ -136,7 +121,7 @@ $(OBJDIR): .PHONY: clean clean: $(info :: Cleaning source directory ) - @rm -rf -v $(OBJDIR) umu/umu_version.json ./$(RELEASEDIR) $(RELEASEDIR).tar.gz + @rm -rf -v ./$(RELEASEDIR) $(RELEASEDIR).tar.gz RELEASEDIR := $(PROJECT)-$(shell git describe --abbrev=0) @@ -144,7 +129,7 @@ $(RELEASEDIR): mkdir -p $(@) .PHONY: release -release: $(RELEASEDIR) | version zipapp +release: $(RELEASEDIR) | zipapp $(info :: Creating source distribution for release ) mkdir -p $(<) rm -rf umu/__pycache__ @@ -165,11 +150,10 @@ ZIPAPP := $(OBJDIR)/umu-run ZIPAPP_STAGING := $(OBJDIR)/zipapp_staging ZIPAPP_VENV := $(OBJDIR)/zipapp_venv -$(OBJDIR)/.build-zipapp: | $(OBJDIR) version +$(OBJDIR)/.build-zipapp: | $(OBJDIR) $(info :: Building umu-launcher as zipapp ) $(PYTHON_INTERPRETER) -m venv $(ZIPAPP_VENV) . $(ZIPAPP_VENV)/bin/activate && python3 -m pip install -t "$(ZIPAPP_STAGING)" -U --no-compile . - install -Dm644 umu/umu_version.json "$(ZIPAPP_STAGING)"/umu/umu_version.json cp umu/__main__.py "$(ZIPAPP_STAGING)" find "$(ZIPAPP_STAGING)" -exec touch -h -d "$(SOURCE_DATE_EPOCH)" {} + . $(ZIPAPP_VENV)/bin/activate && python3 -m zipapp $(ZIPAPP_STAGING) -o $(ZIPAPP) -p "$(PYTHON_INTERPRETER)" -c diff --git a/umu/__init__.py b/umu/__init__.py index 33749636..e99a85cc 100644 --- a/umu/__init__.py +++ b/umu/__init__.py @@ -1 +1,3 @@ __version__ = "1.1.4" # noqa: D104 +__runtime_versions__ = (("sniper", "steamrt3"), ("soldier", "steamrt2")) +__runtime_version__ = __runtime_versions__[0] diff --git a/umu/umu_run.py b/umu/umu_run.py index 687fa5fd..db552397 100755 --- a/umu/umu_run.py +++ b/umu/umu_run.py @@ -31,7 +31,7 @@ from Xlib.protocol.rq import Event from Xlib.xobject.drawable import Window -from umu import __version__ +from umu import __runtime_version__, __version__ from umu.umu_consts import ( PR_SET_CHILD_SUBREAPER, PROTON_VERBS, @@ -803,7 +803,7 @@ def umu_run(args: Namespace | tuple[str, list[str]]) -> int: # Setup the launcher and runtime files future: Future = thread_pool.submit( - setup_umu, root, UMU_LOCAL, thread_pool + setup_umu, root, UMU_LOCAL, __runtime_version__, thread_pool ) if isinstance(args, Namespace): diff --git a/umu/umu_runtime.py b/umu/umu_runtime.py index d777d73b..f886e291 100644 --- a/umu/umu_runtime.py +++ b/umu/umu_runtime.py @@ -11,18 +11,16 @@ from importlib.abc import Traversable from http import HTTPStatus -from json import load from pathlib import Path from secrets import token_urlsafe from shutil import move, rmtree from subprocess import run from tarfile import open as taropen from tempfile import TemporaryDirectory, mkdtemp -from typing import Any from filelock import FileLock -from umu.umu_consts import CONFIG, UMU_CACHE, UMU_LOCAL +from umu.umu_consts import UMU_CACHE, UMU_LOCAL from umu.umu_log import log from umu.umu_util import https_connection, run_zenity @@ -34,6 +32,13 @@ has_data_filter: bool = False +Codename = str + +Variant = str + +RuntimeVersion = tuple[Codename, Variant] + + def create_shim(file_path: Path | None = None): """Create a shell script shim at the specified file path. @@ -81,7 +86,7 @@ def create_shim(file_path: Path | None = None): def _install_umu( - json: dict[str, Any], + runtime_ver: RuntimeVersion, thread_pool: ThreadPoolExecutor, client_session: HTTPSConnection, ) -> None: @@ -89,7 +94,7 @@ def _install_umu( tmp: Path = Path(mkdtemp()) ret: int = 0 # Exit code from zenity # Codename for the runtime (e.g., 'sniper') - codename: str = json["umu"]["versions"]["runtime_platform"] + codename, variant = runtime_ver # Archive containing the runtime archive: str = f"SteamLinuxRuntime_{codename}.tar.xz" base_url: str = ( @@ -97,8 +102,6 @@ def _install_umu( "/snapshots/latest-container-runtime-public-beta" ) token: str = f"?versions={token_urlsafe(16)}" - - log.debug("Codename: %s", codename) log.debug("URL: %s", base_url) # Download the runtime and optionally create a popup with zenity @@ -145,7 +148,7 @@ def _install_umu( break # Download the runtime - log.info("Downloading latest steamrt %s, please wait...", codename) + log.info("Downloading %s (latest), please wait...", variant) client_session.request("GET", f"{endpoint}/{archive}{token}") with ( @@ -236,16 +239,18 @@ def _install_umu( create_shim() # Validate the runtime after moving the files - check_runtime(UMU_LOCAL, json) + check_runtime(UMU_LOCAL, runtime_ver) def setup_umu( - root: Traversable, local: Path, thread_pool: ThreadPoolExecutor + root: Traversable, + local: Path, + runtime_ver: RuntimeVersion, + thread_pool: ThreadPoolExecutor, ) -> None: """Install or update the runtime for the current user.""" log.debug("Root: %s", root) log.debug("Local: %s", local) - json: dict[str, Any] = _get_json(root, CONFIG) host: str = "repo.steampowered.com" # New install or umu dir is empty @@ -255,24 +260,25 @@ def setup_umu( local.mkdir(parents=True, exist_ok=True) with https_connection(host) as client_session: _restore_umu( - json, + runtime_ver, thread_pool, lambda: local.joinpath("umu").is_file(), client_session, ) + log.info("Using %s (latest)", runtime_ver[1]) return if os.environ.get("UMU_RUNTIME_UPDATE") == "0": - log.debug("Runtime Platform updates disabled") + log.info("%s updates disabled, skipping", runtime_ver[1]) return with https_connection(host) as client_session: - _update_umu(local, json, thread_pool, client_session) + _update_umu(local, runtime_ver, thread_pool, client_session) def _update_umu( local: Path, - json: dict[str, Any], + runtime_ver: RuntimeVersion, thread_pool: ThreadPoolExecutor, client_session: HTTPSConnection, ) -> None: @@ -283,27 +289,31 @@ def _update_umu( """ runtime: Path resp: HTTPResponse - codename: str = json["umu"]["versions"]["runtime_platform"] + codename, variant = runtime_ver endpoint: str = ( f"/steamrt-images-{codename}" "/snapshots/latest-container-runtime-public-beta" ) token: str = f"?version={token_urlsafe(16)}" log.debug("Existing install detected") - log.debug("Sending request to '%s'...", client_session.host) + log.debug("Using container runtime '%s' aka '%s'", variant, codename) + log.debug( + "Checking updates for '%s', requesting '%s'...", + variant, + client_session.host, + ) # Find the runtime directory (e.g., sniper_platform_0.20240530.90143) - # Assume the directory begins with the alias + # Assume the directory begins with the variant try: runtime = max( file for file in local.glob(f"{codename}*") if file.is_dir() ) except ValueError: - log.debug("*_platform_* directory missing in '%s'", local) - log.warning("Runtime Platform not found") + log.warning("*_platform_* directory missing in '%s'", local) log.info("Restoring Runtime Platform...") _restore_umu( - json, + runtime_ver, thread_pool, lambda: len( [file for file in local.glob(f"{codename}*") if file.is_dir()] @@ -313,15 +323,11 @@ def _update_umu( ) return - log.debug("Runtime: %s", runtime.name) - log.debug("Codename: %s", codename) - if not local.joinpath("pressure-vessel").is_dir(): - log.debug("pressure-vessel directory missing in '%s'", local) - log.warning("Runtime Platform not found") + log.warning("pressure-vessel directory missing in '%s'", local) log.info("Restoring Runtime Platform...") _restore_umu( - json, + runtime_ver, thread_pool, lambda: local.joinpath("pressure-vessel").is_dir(), client_session, @@ -336,16 +342,16 @@ def _update_umu( release: Path = runtime.joinpath("files", "lib", "os-release") versions: str = f"SteamLinuxRuntime_{codename}.VERSIONS.txt" - log.debug("VERSIONS.txt file missing in '%s'", local) + log.warning("VERSIONS.txt file missing in '%s'", local) # Restore the runtime if os-release is missing, otherwise pressure # vessel will crash when creating the variable directory if not release.is_file(): - log.debug("os-release file missing in '%s'", local) + log.warning("os-release file missing in *_platform_*") log.warning("Runtime Platform corrupt") log.info("Restoring Runtime Platform...") _restore_umu( - json, + runtime_ver, thread_pool, lambda: local.joinpath("VERSIONS.txt").is_file(), client_session, @@ -389,13 +395,15 @@ def _update_umu( resp.read().decode() ) - # Update the runtime if necessary by comparing VERSIONS.txt to the remote + # Update the runtime if necessary by comparing VERSIONS.txt to the remote. # repo.steampowered currently sits behind a Cloudflare proxy, which may # respond with cf-cache-status: HIT in the header for subsequent requests # indicating the response was found in the cache and was returned. Valve # has control over the CDN's cache control behavior, so we must not assume # all of the cache will be purged after new files are uploaded. Therefore, - # always avoid the cache by appending a unique query to the URI + # always avoid the cache by appending a unique query to the URI to avoid + # redownloading the runtime each launch + # See https://github.com/Open-Wine-Components/umu-launcher/issues/188 url: str = f"{endpoint}/SteamLinuxRuntime_{codename}.VERSIONS.txt{token}" client_session.request("GET", url) @@ -420,7 +428,7 @@ def _update_umu( if steamrt_latest_digest != steamrt_local_digest: lock: FileLock = FileLock(f"{local}/umu.lock") - log.info("Updating steamrt to latest...") + log.info("Updating %s to latest...", variant) log.debug("Acquiring file lock '%s'...", lock.lock_file) with lock: @@ -433,60 +441,16 @@ def _update_umu( ): log.debug("Released file lock '%s'", lock.lock_file) return - _install_umu(json, thread_pool, client_session) + _install_umu(runtime_ver, thread_pool, client_session) log.debug("Removing: %s", runtime) rmtree(str(runtime)) log.debug("Released file lock '%s'", lock.lock_file) # Restore shim - if not local.joinpath("umu-shim").exists(): + if not local.joinpath("umu-shim").is_file(): create_shim() - log.info("steamrt is up to date") - - -def _get_json(path: Traversable, config: str) -> dict[str, Any]: - """Validate the state of the configuration file umu_version.json in a path. - - The configuration file will be used to update the runtime and it reflects - the tools currently used by launcher. The key/value pairs umu and versions - must exist. - """ - json: dict[str, Any] - # Steam Runtime platform values - # See https://gitlab.steamos.cloud/steamrt/steamrt/-/wikis/home - steamrts: set[str] = { - "soldier", - "sniper", - "medic", - "steamrt5", - } - - # umu_version.json in the system path should always exist - if not path.joinpath(config).is_file(): - err: str = ( - f"File not found: {config}\n" - "Please reinstall the package to recover configuration file" - ) - raise FileNotFoundError(err) - - with path.joinpath(config).open(mode="r", encoding="utf-8") as file: - json = load(file) - - # Raise an error if "umu" and "versions" doesn't exist - if not json or "umu" not in json or "versions" not in json["umu"]: - err: str = ( - f"Failed to load {config} or 'umu' or 'versions' not in: {config}" - ) - raise ValueError(err) - - # The launcher will use the value runtime_platform to glob files. Attempt - # to guard against directory removal attacks for non-system wide installs - if json["umu"]["versions"]["runtime_platform"] not in steamrts: - err: str = "Value for 'runtime_platform' is not a steamrt" - raise ValueError(err) - - return json + log.info("%s is up to date", variant) def _move(file: Path, src: Path, dst: Path) -> None: @@ -508,7 +472,7 @@ def _move(file: Path, src: Path, dst: Path) -> None: move(src_file, dest_file) -def check_runtime(src: Path, json: dict[str, Any]) -> int: +def check_runtime(src: Path, runtime_ver: RuntimeVersion) -> int: """Validate the file hierarchy of the runtime platform. The mtree file included in the Steam runtime platform will be used to @@ -516,7 +480,7 @@ def check_runtime(src: Path, json: dict[str, Any]) -> int: home directory and used to run games. """ runtime: Path - codename: str = json["umu"]["versions"]["runtime_platform"] + codename, variant = runtime_ver pv_verify: Path = src.joinpath("pressure-vessel", "bin", "pv-verify") ret: int = 1 @@ -526,12 +490,12 @@ def check_runtime(src: Path, json: dict[str, Any]) -> int: file for file in src.glob(f"{codename}*") if file.is_dir() ) except ValueError: - log.warning("steamrt validation failed") - log.warning("Could not find runtime in '%s'", src) + log.warning("%s validation failed", variant) + log.warning("Could not find *_platform_* in '%s'", src) return ret if not pv_verify.is_file(): - log.warning("steamrt validation failed") + log.warning("%s validation failed", variant) log.warning("File does not exist: '%s'", pv_verify) return ret @@ -547,7 +511,7 @@ def check_runtime(src: Path, json: dict[str, Any]) -> int: ).returncode if ret: - log.warning("steamrt validation failed") + log.warning("%s validation failed", variant) log.debug("%s exited with the status code: %s", pv_verify.name, ret) return ret log.info("%s: mtree is OK", runtime.name) @@ -556,7 +520,7 @@ def check_runtime(src: Path, json: dict[str, Any]) -> int: def _restore_umu( - json: dict[str, Any], + runtime_ver: RuntimeVersion, thread_pool: ThreadPoolExecutor, callback_fn: Callable[[], bool], client_session: HTTPSConnection, @@ -565,7 +529,7 @@ def _restore_umu( log.debug("Acquired file lock '%s'...", lock.lock_file) if callback_fn(): log.debug("Released file lock '%s'", lock.lock_file) - log.info("steamrt was restored") + log.info("%s was restored", runtime_ver[1]) return - _install_umu(json, thread_pool, client_session) + _install_umu(runtime_ver, thread_pool, client_session) log.debug("Released file lock '%s'", lock.lock_file) diff --git a/umu/umu_test.py b/umu/umu_test.py index 1852851c..8dacd60c 100644 --- a/umu/umu_test.py +++ b/umu/umu_test.py @@ -1,5 +1,4 @@ import argparse -import json import os import re import sys @@ -84,23 +83,11 @@ def setUp(self): self.test_local_share = Path("./tmp.aDl73CbQCP") # Wine prefix self.test_winepfx = Path("./tmp.AlfLPDhDvA") + self.test_runtime_version = ("sniper", "steamrt3") # /usr self.test_usr = Path("./tmp.QnZRGFfnqH") - # Dictionary that represents the umu_versionS.json - self.root_config = { - "umu": { - "versions": { - "launcher": "0.1-RC3", - "runner": "0.1-RC3", - "runtime_platform": "sniper", - } - } - } - # umu_version.json - self.test_config = json.dumps(self.root_config, indent=4) - self.test_winepfx.mkdir(exist_ok=True) self.test_user_share.mkdir(exist_ok=True) self.test_local_share.mkdir(exist_ok=True) @@ -110,14 +97,6 @@ def setUp(self): self.test_usr.mkdir(exist_ok=True) self.test_cache_home.mkdir(exist_ok=True) - # Mock a valid configuration file at /usr/share/umu: - # tmp.BXk2NnvW2m/umu_version.json - Path(self.test_user_share, "umu_version.json").touch() - with Path(self.test_user_share, "umu_version.json").open( - mode="w", encoding="utf-8" - ) as file: - file.write(self.test_config) - # Mock the launcher files Path(self.test_user_share, "umu_consts.py").touch() Path(self.test_user_share, "umu_proton.py").touch() @@ -459,23 +438,21 @@ def test_check_runtime(self): If the pv-verify binary does not exist, a warning should be logged and the function should return """ - json_root = umu_runtime._get_json( - self.test_user_share, "umu_version.json" - ) self.test_user_share.joinpath( "pressure-vessel", "bin", "pv-verify" ).unlink() - result = umu_runtime.check_runtime(self.test_user_share, json_root) + result = umu_runtime.check_runtime( + self.test_user_share, self.test_runtime_version + ) self.assertEqual(result, 1, "Expected the exit code 1") def test_check_runtime_success(self): """Test check_runtime when runtime validation succeeds.""" - json_root = umu_runtime._get_json( - self.test_user_share, "umu_version.json" - ) mock = CompletedProcess(["foo"], 0) with patch.object(umu_runtime, "run", return_value=mock): - result = umu_runtime.check_runtime(self.test_user_share, json_root) + result = umu_runtime.check_runtime( + self.test_user_share, self.test_runtime_version + ) self.assertEqual(result, 0, "Expected the exit code 0") def test_check_runtime_dir(self): @@ -483,9 +460,6 @@ def test_check_runtime_dir(self): runtime = Path( self.test_user_share, "sniper_platform_0.20240125.75305" ) - json_root = umu_runtime._get_json( - self.test_user_share, "umu_version.json" - ) # Mock the removal of the runtime directory # In the real usage when updating the runtime, this should not happen @@ -496,7 +470,9 @@ def test_check_runtime_dir(self): mock = CompletedProcess(["foo"], 1) with patch.object(umu_runtime, "run", return_value=mock): - result = umu_runtime.check_runtime(self.test_user_share, json_root) + result = umu_runtime.check_runtime( + self.test_user_share, self.test_runtime_version + ) self.assertEqual(result, 1, "Expected the exit code 1") def test_move(self): @@ -727,119 +703,6 @@ def test_ge_proton_none(self): os.environ.get("PROTONPATH"), "Expected empty string" ) - def test_get_json_err(self): - """Test _get_json when specifying a corrupted umu_version.json file. - - A ValueError should be raised because we expect 'umu' and 'version' - keys to exist - """ - test_config = """ - { - "foo": { - "versions": { - "launcher": "0.1-RC3", - "runner": "0.1-RC3", - "runtime_platform": "sniper" - } - } - } - """ - test_config2 = """ - { - "umu": { - "foo": { - "launcher": "0.1-RC3", - "runner": "0.1-RC3", - "runtime_platform": "sniper" - } - } - } - """ - # Remove the valid config created at setup - Path(self.test_user_share, "umu_version.json").unlink(missing_ok=True) - - Path(self.test_user_share, "umu_version.json").touch() - with Path(self.test_user_share, "umu_version.json").open( - mode="w", encoding="utf-8" - ) as file: - file.write(test_config) - - # Test when "umu" doesn't exist - with self.assertRaisesRegex(ValueError, "load"): - umu_runtime._get_json(self.test_user_share, "umu_version.json") - - # Test when "versions" doesn't exist - Path(self.test_user_share, "umu_version.json").unlink(missing_ok=True) - - Path(self.test_user_share, "umu_version.json").touch() - with Path(self.test_user_share, "umu_version.json").open( - mode="w", encoding="utf-8" - ) as file: - file.write(test_config2) - - with self.assertRaisesRegex(ValueError, "load"): - umu_runtime._get_json(self.test_user_share, "umu_version.json") - - def test_get_json_foo(self): - """Test _get_json when not specifying umu_version.json as 2nd arg. - - A FileNotFoundError should be raised - """ - with self.assertRaisesRegex(FileNotFoundError, "configuration"): - umu_runtime._get_json(self.test_user_share, "foo") - - def test_get_json_steamrt(self): - """Test _get_json when passed a non-steamrt value. - - This attempts to mitigate against directory removal attacks for user - installations in the home directory, since the launcher will remove the - old runtime on update. Currently expects runtime_platform value to be - 'soldier', 'sniper', 'medic' and 'steamrt5' - """ - config = { - "umu": { - "versions": { - "launcher": "0.1-RC3", - "runner": "0.1-RC3", - "runtime_platform": "foo", - } - } - } - test_config = json.dumps(config, indent=4) - - self.test_user_share.joinpath("umu_version.json").unlink( - missing_ok=True - ) - self.test_user_share.joinpath("umu_version.json").write_text( - test_config, encoding="utf-8" - ) - - with self.assertRaises(ValueError): - umu_runtime._get_json(self.test_user_share, "umu_version.json") - - def test_get_json(self): - """Test _get_json. - - This function is used to verify the existence and integrity of - umu_version.json file during the setup process - - umu_version.json is used to synchronize the state of 2 directories: - /usr/share/umu and ~/.local/share/umu - - An error should not be raised when passed a JSON we expect - """ - result = None - - self.assertTrue( - self.test_user_share.joinpath("umu_version.json").exists(), - "Expected umu_version.json to exist", - ) - - result = umu_runtime._get_json( - self.test_user_share, "umu_version.json" - ) - self.assertIsInstance(result, dict, "Expected a dict") - def test_latest_interrupt(self): """Test _get_latest when the user interrupts the download/extraction. @@ -1436,7 +1299,10 @@ def test_build_command_linux_exe(self): patch.object(umu_runtime, "_install_umu", return_value=None), ): umu_runtime.setup_umu( - self.test_user_share, self.test_local_share, None + self.test_user_share, + self.test_local_share, + self.test_runtime_version, + None, ) copytree( Path(self.test_user_share, "sniper_platform_0.20240125.75305"), @@ -1520,7 +1386,10 @@ def test_build_command_nopv(self): patch.object(umu_runtime, "_install_umu", return_value=None), ): umu_runtime.setup_umu( - self.test_user_share, self.test_local_share, None + self.test_user_share, + self.test_local_share, + self.test_runtime_version, + None, ) copytree( Path(self.test_user_share, "sniper_platform_0.20240125.75305"), @@ -1649,7 +1518,10 @@ def test_build_command(self): patch.object(umu_runtime, "_install_umu", return_value=None), ): umu_runtime.setup_umu( - self.test_user_share, self.test_local_share, None + self.test_user_share, + self.test_local_share, + self.test_runtime_version, + None, ) copytree( Path(self.test_user_share, "sniper_platform_0.20240125.75305"), diff --git a/umu/umu_test_plugins.py b/umu/umu_test_plugins.py index fd109219..797c22ba 100644 --- a/umu/umu_test_plugins.py +++ b/umu/umu_test_plugins.py @@ -1,5 +1,4 @@ import argparse -import json import os import re import sys @@ -66,19 +65,7 @@ def setUp(self): self.test_user_share = Path("./tmp.jl3W4MtO57") # ~/.local/share/Steam/compatibilitytools.d self.test_local_share = Path("./tmp.WUaQAk7hQJ") - - # Dictionary that represents the umu_versionS.json - self.root_config = { - "umu": { - "versions": { - "launcher": "0.1-RC3", - "runner": "0.1-RC3", - "runtime_platform": "sniper", - } - } - } - # umu_version.json - self.test_config = json.dumps(self.root_config, indent=4) + self.test_runtime_version = ("sniper", "steamrt3") self.test_user_share.mkdir(exist_ok=True) self.test_local_share.mkdir(exist_ok=True) @@ -86,14 +73,6 @@ def setUp(self): self.test_compat.mkdir(exist_ok=True) self.test_proton_dir.mkdir(exist_ok=True) - # Mock a valid configuration file at /usr/share/umu: - # tmp.BXk2NnvW2m/umu_version.json - Path(self.test_user_share, "umu_version.json").touch() - with Path(self.test_user_share, "umu_version.json").open( - mode="w", encoding="utf-8" - ) as file: - file.write(self.test_config) - # Mock the launcher files Path(self.test_user_share, "umu_consts.py").touch() Path(self.test_user_share, "umu_proton.py").touch() @@ -222,8 +201,12 @@ def test_build_command_entry(self): with ( patch.object(umu_runtime, "_install_umu", return_value=None), ): + # TODO umu_runtime.setup_umu( - self.test_user_share, self.test_local_share, None + self.test_user_share, + self.test_local_share, + self.test_runtime_version, + None, ) copytree( Path(self.test_user_share, "sniper_platform_0.20240125.75305"), @@ -298,7 +281,10 @@ def test_build_command_proton(self): patch.object(umu_runtime, "_install_umu", return_value=None), ): umu_runtime.setup_umu( - self.test_user_share, self.test_local_share, None + self.test_user_share, + self.test_local_share, + self.test_runtime_version, + None, ) copytree( Path(self.test_user_share, "sniper_platform_0.20240125.75305"), @@ -380,7 +366,10 @@ def test_build_command_toml(self): patch.object(umu_runtime, "_install_umu", return_value=None), ): umu_runtime.setup_umu( - self.test_user_share, self.test_local_share, None + self.test_user_share, + self.test_local_share, + self.test_runtime_version, + None, ) copytree( Path(self.test_user_share, "sniper_platform_0.20240125.75305"), diff --git a/umu/umu_version.json.in b/umu/umu_version.json.in deleted file mode 100644 index a0bb6ab1..00000000 --- a/umu/umu_version.json.in +++ /dev/null @@ -1,9 +0,0 @@ -{ - "umu": { - "versions": { - "launcher": "##UMU_VERSION##", - "runner": "##UMU_VERSION##", - "runtime_platform": "sniper" - } - } -}