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: automatically use the correct runtime #201

Closed
wants to merge 24 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
090f87a
__init__: add variable of slr variant
R1kaB3rN Oct 2, 2024
477a27f
umu_consts: delete config file constant
R1kaB3rN Oct 2, 2024
d0aa652
umu_runtime: reference slr variant variable
R1kaB3rN Oct 2, 2024
a639729
Makefile: delete version target
R1kaB3rN Oct 2, 2024
3352e4b
umu_test: update tests
R1kaB3rN Oct 2, 2024
615d3ab
__init__: add runtime metadata
R1kaB3rN Oct 5, 2024
2eb6b82
umu_runtime: refer to metadata for latest runtime
R1kaB3rN Oct 5, 2024
dcb2e19
umu_util: add functions to handle *.vdf text files
R1kaB3rN Oct 5, 2024
f64a426
umu_run: auto change to intended proton runtime
R1kaB3rN Oct 5, 2024
94c4f16
umu_run: warn of mismatching compatibility tools
R1kaB3rN Oct 5, 2024
0279368
umu_test: add tests for vdf-related functions
R1kaB3rN Oct 5, 2024
7140512
umu_runtime: update log statements
R1kaB3rN Oct 5, 2024
342ffe5
umu_run: update log statements
R1kaB3rN Oct 5, 2024
c5563e0
umu_run: delete removing .ref each launch
R1kaB3rN Oct 5, 2024
99a358d
umu_runtime: support restoring obsolete runtimes
R1kaB3rN Oct 5, 2024
96176fe
umu_runtime: update comment
R1kaB3rN Oct 5, 2024
09aa8f7
umu_runtime: change identifiers
R1kaB3rN Oct 5, 2024
ab04f8f
umu_runtime: fix bug when making request on update
R1kaB3rN Oct 5, 2024
798d39c
umu_runtime: log statements
R1kaB3rN Oct 5, 2024
ddd614e
umu_runtime: fix detection for obsolete runtimes
R1kaB3rN Oct 5, 2024
7a7456f
umu_run: update debug statements
R1kaB3rN Oct 5, 2024
678cdb8
umu_test: fix test
R1kaB3rN Oct 6, 2024
76764b0
umu_runtime: fix runtime install paths
R1kaB3rN Oct 6, 2024
5651f07
umu_test_plugins: update tests
R1kaB3rN Oct 6, 2024
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
28 changes: 6 additions & 22 deletions Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -46,21 +46,6 @@ fix_shebangs:
find $(DESTDIR) -type f -name "*.sh" -exec sed -i '1s|^#!/usr/bin/env sh|#!$(SHELL_INTERPRETER)|' {} \;
find $(DESTDIR) -type f -name "umu-run" -exec sed -i '1s|^#!/usr/bin/env sh|#!$(SHELL_INTERPRETER)|' {} \;

# 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 )
Expand All @@ -79,7 +64,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 $(@)
Expand All @@ -93,9 +78,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)
Expand Down Expand Up @@ -148,15 +133,15 @@ $(OBJDIR):
.PHONY: clean
clean:
$(info :: Cleaning source directory )
@rm -rf -v $(OBJDIR) umu/umu_version.json ./$(RELEASEDIR) $(RELEASEDIR).tar.gz
@rm -rf -v $(OBJDIR) ./$(RELEASEDIR) $(RELEASEDIR).tar.gz


RELEASEDIR := $(PROJECT)-$(shell git describe --abbrev=0)
$(RELEASEDIR):
mkdir -p $(@)

.PHONY: release
release: $(RELEASEDIR) | version zipapp
release: $(RELEASEDIR) | zipapp
$(info :: Creating source distribution for release )
mkdir -p $(<)
rm -rf umu/__pycache__
Expand All @@ -177,11 +162,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
Expand Down
5 changes: 5 additions & 0 deletions umu/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,6 @@
__version__ = "1.1.1" # noqa: D104
__pressure_vessel_runtime__ = ("steamrt3", "sniper", "1628350")
__pressure_vessel_runtimes__ = (
("steamrt3", "sniper", "1628350"),
("steamrt2", "soldier", "1391110"),
)
2 changes: 0 additions & 2 deletions umu/umu_consts.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import os
from pathlib import Path

CONFIG = "umu_version.json"

STEAM_COMPAT: Path = Path.home().joinpath(
".local", "share", "Steam", "compatibilitytools.d"
)
Expand Down
59 changes: 53 additions & 6 deletions umu/umu_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
from Xlib.protocol.rq import Event
from Xlib.xobject.drawable import Window

from umu import __pressure_vessel_runtime__
from umu.umu_consts import (
PR_SET_CHILD_SUBREAPER,
PROTON_VERBS,
Expand All @@ -51,6 +52,8 @@
from umu.umu_util import (
get_libc,
get_library_paths,
get_vdf_value,
get_vdfs,
is_installed_verb,
is_winetricks_verb,
xdisplay,
Expand Down Expand Up @@ -733,6 +736,7 @@ def main() -> int: # noqa: D103
"UMU_RUNTIME_UPDATE": "",
}
opts: list[str] = []
runtime_platform: Path = UMU_LOCAL / __pressure_vessel_runtime__[0]
prereq: bool = False
root: Traversable

Expand Down Expand Up @@ -804,7 +808,11 @@ def main() -> int: # noqa: D103

# Setup the launcher and runtime files
future: Future = thread_pool.submit(
setup_umu, root, UMU_LOCAL, thread_pool
setup_umu,
root,
UMU_LOCAL,
__pressure_vessel_runtime__,
thread_pool,
)

if isinstance(args, Namespace):
Expand Down Expand Up @@ -840,8 +848,51 @@ def main() -> int: # noqa: D103
):
sys.exit(1)

# Get Proton's required compatibility tool in its .vdf file.
# The App ID is the runtime that it's built against
toolappid_proton: str = get_vdf_value(
Path(env["PROTONPATH"], "toolmanifest.vdf"), "require_tool_appid"
)
has_matching_compat_tools: bool = False

# Since it's common for people to change Proton versions, verify we're
# using Proton's intended runtime and auto change to it if downloaded
for file in get_vdfs(UMU_LOCAL, "**/steampipe/app_build*.vdf"):
if get_vdf_value(file, "appid") == toolappid_proton:
runtime_platform: Path = file.parent.parent
log.debug("App ID (Proton): %s", toolappid_proton)
log.debug("Steam Linux Runtime: %s", file.parent.parent.name)
log.console(
f"Using {Path(env['PROTONPATH']).name} with "
f"{runtime_platform.name}"
)
has_matching_compat_tools = True
break

# Warn if compatibility tools mismatch (e.g., using proton 7 with sniper)
# Assuming our parser is correct, at this point, the user is probably
# trying to use a proton without its required runtime. This may happen if
# we did not bump the runtime in time because, at the time of this writing,
# we're currently assuming the usage of sniper. In this case, just warn
# them and opt not to set an appropriate proton for the user to avoid the
# risk of breaking users' pfxs
if not has_matching_compat_tools:
log.warning("Compatibility tools mismatch")
log.warning(
"'%s' is not a required compatibility tool for '%s'",
runtime_platform,
env["PROTONPATH"],
)
log.warning(
"Prefix '%s' was created with compatibility tool %s",
env["WINEPREFIX"],
Path(env["PROTONPATH"], "version").read_text(encoding="utf-8"),
)

# Build the command
command: tuple[Path | str, ...] = build_command(env, UMU_LOCAL, opts)
command: tuple[Path | str, ...] = build_command(
env, runtime_platform, opts
)
log.debug("%s", command)

# Run the command
Expand All @@ -858,7 +909,3 @@ def main() -> int: # noqa: D103
sys.exit(e.code)
except BaseException as e:
log.exception(e)
finally:
UMU_LOCAL.joinpath(".ref").unlink(
missing_ok=True
) # Cleanup .ref file on every exit
Loading
Loading