Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: force reinstall of runtime #215

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion docs/umu.1.scd
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
25 changes: 23 additions & 2 deletions umu/umu_runtime.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -210,7 +210,28 @@ def setup_umu(
log.debug("Runtime Platform updates disabled")
return

find_obsolete()
# 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("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,
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)
Expand Down
33 changes: 0 additions & 33 deletions umu/umu_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@

from Xlib import display

from umu.umu_consts import STEAM_COMPAT, UMU_LOCAL
from umu.umu_log import log

ssl_context: SSLContext | None = None
Expand Down Expand Up @@ -173,38 +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",
}

# 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:
log.warning("'%s' is obsolete", file)

# $HOME/.local/share/Steam/compatibilitytool.d
if (launcher := STEAM_COMPAT.joinpath("ULWGL-Launcher")).is_dir():
log.warning("'%s' is obsolete", launcher)

# $HOME/.cache
if (cache := home.joinpath(".cache", "ULWGL")).is_dir():
log.warning("'%s' is obsolete", cache)

# $HOME/.local/share
if (ulwgl := home.joinpath(".local", "share", "ULWGL")).is_dir():
log.warning("'%s' is obsolete", ulwgl)


@contextmanager
def https_connection(host: str): # noqa: ANN201
"""Create an HTTPSConnection."""
Expand Down
Loading