From 8f8174649b8f00150c3f53a4d69809c0615f4560 Mon Sep 17 00:00:00 2001 From: R1kaB3rN <100738684+R1kaB3rN@users.noreply.github.com> Date: Wed, 9 Oct 2024 18:30:24 -0700 Subject: [PATCH 1/6] umu_util: delete obsolete files instead of warn --- umu/umu_util.py | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/umu/umu_util.py b/umu/umu_util.py index f3bc1c579..16e375aeb 100644 --- a/umu/umu_util.py +++ b/umu/umu_util.py @@ -6,7 +6,7 @@ from pathlib import Path from re import Pattern from re import compile as re_compile -from shutil import which +from shutil import rmtree, which from ssl import SSLContext, create_default_context from subprocess import PIPE, STDOUT, Popen, TimeoutExpired @@ -183,6 +183,7 @@ def find_obsolete() -> None: "umu_version.json", "sniper_platform_0.20231211.70175", } + obsolete: Path # Obsoleted files in $HOME/.local/share/umu from RC4 and below for file in UMU_LOCAL.glob("*"): @@ -190,19 +191,25 @@ def find_obsolete() -> None: file.name.startswith(("umu", "ulwgl")) ) if is_umu_file or file.name in obsoleted: - log.warning("'%s' is obsolete", file) + if file.is_file(): + file.unlink() + if file.is_dir(): + rmtree(str(file)) # $HOME/.local/share/Steam/compatibilitytool.d - if (launcher := STEAM_COMPAT.joinpath("ULWGL-Launcher")).is_dir(): - log.warning("'%s' is obsolete", launcher) + obsolete = STEAM_COMPAT.joinpath("ULWGL-Launcher") + if obsolete.is_dir(): + rmtree(str(obsolete)) # $HOME/.cache - if (cache := home.joinpath(".cache", "ULWGL")).is_dir(): - log.warning("'%s' is obsolete", cache) + obsolete = home.joinpath(".cache", "ULWGL") + if obsolete.is_dir(): + rmtree(str(obsolete)) # $HOME/.local/share - if (ulwgl := home.joinpath(".local", "share", "ULWGL")).is_dir(): - log.warning("'%s' is obsolete", ulwgl) + obsolete = home.joinpath(".local", "share", "ULWGL") + if obsolete.is_dir(): + rmtree(str(obsolete)) @contextmanager From baf6baec747af63d434750c770d158caec0abd17 Mon Sep 17 00:00:00 2001 From: R1kaB3rN <100738684+R1kaB3rN@users.noreply.github.com> Date: Wed, 9 Oct 2024 18:57:56 -0700 Subject: [PATCH 2/6] umu_runtime: allow reinstalling runtime to clean state --- umu/umu_runtime.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/umu/umu_runtime.py b/umu/umu_runtime.py index a25784703..74c5e935b 100644 --- a/umu/umu_runtime.py +++ b/umu/umu_runtime.py @@ -212,6 +212,21 @@ def setup_umu( find_obsolete() + # Force a runtime update + if os.environ.get("UMU_RUNTIME_UPDATE") == "1": + log.debug("Forcing update to Runtime Platform") + log.debug("Removing: %s", local) + rmtree(str(local)) + local.mkdir(parents=True, exist_ok=True) + with https_connection(host) as client_session: + _restore_umu( + json, + thread_pool, + lambda: local.joinpath("umu").is_file(), + client_session, + ) + return + with https_connection(host) as client_session: _update_umu(local, json, thread_pool, client_session) From 35131d617f97f5b0d79154fa6bec364147438800 Mon Sep 17 00:00:00 2001 From: R1kaB3rN <100738684+R1kaB3rN@users.noreply.github.com> Date: Wed, 9 Oct 2024 19:09:53 -0700 Subject: [PATCH 3/6] docs: add description for UMU_RUNTIME_UPDATE=1 --- docs/umu.1.scd | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/umu.1.scd b/docs/umu.1.scd index 0449b30f9..9003f573c 100644 --- a/docs/umu.1.scd +++ b/docs/umu.1.scd @@ -166,7 +166,8 @@ _UMU_ZENITY_ _UMU_RUNTIME_UPDATE_ Optional. Disables automatic updates to the *Steam Linux Runtime*[6]. - Set _0_ to disable updates. + Set _0_ to disable updates. Set _1_ to force updates and restore + _$HOME/.local/share/umu_ to clean state. # SEE ALSO From 6fad08a02a4e8ecafd62cb943a7da16e5f5575e1 Mon Sep 17 00:00:00 2001 From: R1kaB3rN <100738684+R1kaB3rN@users.noreply.github.com> Date: Thu, 10 Oct 2024 19:15:25 -0700 Subject: [PATCH 4/6] umu_util: remove find_obsolete function --- umu/umu_util.py | 42 +----------------------------------------- 1 file changed, 1 insertion(+), 41 deletions(-) diff --git a/umu/umu_util.py b/umu/umu_util.py index 16e375aeb..26073ca85 100644 --- a/umu/umu_util.py +++ b/umu/umu_util.py @@ -6,13 +6,12 @@ from pathlib import Path from re import Pattern from re import compile as re_compile -from shutil import rmtree, which +from shutil import which from ssl import SSLContext, create_default_context from subprocess import PIPE, STDOUT, Popen, TimeoutExpired from Xlib import display -from umu.umu_consts import STEAM_COMPAT, UMU_LOCAL from umu.umu_log import log ssl_context: SSLContext | None = None @@ -173,45 +172,6 @@ def is_winetricks_verb( return True -def find_obsolete() -> None: - """Find obsoleted launcher files and log them.""" - home: Path = Path.home() - obsoleted: set[str] = { - "reaper", - "sniper_platform_0.20240125.75305", - "BUILD_ID.txt", - "umu_version.json", - "sniper_platform_0.20231211.70175", - } - obsolete: Path - - # Obsoleted files in $HOME/.local/share/umu from RC4 and below - for file in UMU_LOCAL.glob("*"): - is_umu_file: bool = file.name.endswith(".py") and ( - file.name.startswith(("umu", "ulwgl")) - ) - if is_umu_file or file.name in obsoleted: - if file.is_file(): - file.unlink() - if file.is_dir(): - rmtree(str(file)) - - # $HOME/.local/share/Steam/compatibilitytool.d - obsolete = STEAM_COMPAT.joinpath("ULWGL-Launcher") - if obsolete.is_dir(): - rmtree(str(obsolete)) - - # $HOME/.cache - obsolete = home.joinpath(".cache", "ULWGL") - if obsolete.is_dir(): - rmtree(str(obsolete)) - - # $HOME/.local/share - obsolete = home.joinpath(".local", "share", "ULWGL") - if obsolete.is_dir(): - rmtree(str(obsolete)) - - @contextmanager def https_connection(host: str): # noqa: ANN201 """Create an HTTPSConnection.""" From 909fb8274aad0613efd78619cf70ca265945b6d3 Mon Sep 17 00:00:00 2001 From: R1kaB3rN <100738684+R1kaB3rN@users.noreply.github.com> Date: Thu, 10 Oct 2024 19:15:45 -0700 Subject: [PATCH 5/6] umu_runtime: don't find obsolete files --- umu/umu_runtime.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/umu/umu_runtime.py b/umu/umu_runtime.py index 74c5e935b..616f577ed 100644 --- a/umu/umu_runtime.py +++ b/umu/umu_runtime.py @@ -23,7 +23,7 @@ from umu.umu_consts import CONFIG, UMU_CACHE, UMU_LOCAL from umu.umu_log import log -from umu.umu_util import find_obsolete, https_connection, run_zenity +from umu.umu_util import https_connection, run_zenity try: from tarfile import tar_filter @@ -210,8 +210,6 @@ def setup_umu( log.debug("Runtime Platform updates disabled") return - find_obsolete() - # Force a runtime update if os.environ.get("UMU_RUNTIME_UPDATE") == "1": log.debug("Forcing update to Runtime Platform") From eeca4653f79535bbfdcdd7d949132123e83384ab Mon Sep 17 00:00:00 2001 From: R1kaB3rN <100738684+R1kaB3rN@users.noreply.github.com> Date: Fri, 11 Oct 2024 11:41:57 -0700 Subject: [PATCH 6/6] umu_runtime: hold a lock while removing files --- umu/umu_runtime.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/umu/umu_runtime.py b/umu/umu_runtime.py index 616f577ed..29f988347 100644 --- a/umu/umu_runtime.py +++ b/umu/umu_runtime.py @@ -212,10 +212,18 @@ def setup_umu( # Force a runtime update if os.environ.get("UMU_RUNTIME_UPDATE") == "1": + lock: FileLock = FileLock(f"{local}/umu.lock") log.debug("Forcing update to Runtime Platform") - log.debug("Removing: %s", local) - rmtree(str(local)) - local.mkdir(parents=True, exist_ok=True) + log.debug("Acquiring file lock '%s'...", lock.lock_file) + with lock: + log.debug("Acquired file lock '%s'", lock.lock_file) + for path in local.glob("*"): + if path.is_dir(): + log.debug("Removing: %s", path) + rmtree(str(path)) + if path.is_file() and not path.name.endswith(".lock"): + log.debug("Removing: %s", path) + path.unlink() with https_connection(host) as client_session: _restore_umu( json,