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

Update launcher and packaging #95

Merged
merged 16 commits into from
Apr 25, 2024
Merged
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
10 changes: 5 additions & 5 deletions Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -109,14 +109,14 @@ $(OBJDIR)/.build-umu-launcher: | $(OBJDIR)
umu-launcher: $(OBJDIR)/.build-umu-launcher

umu-launcher-bin-install: umu-launcher
install -d $(DESTDIR)$(DATADIR)/$(INSTALLDIR)/umu-launcher
install -Dm 755 $(OBJDIR)/$(<)-run $(DESTDIR)$(DATADIR)/$(INSTALLDIR)/umu-launcher/umu-run
install -d $(DESTDIR)$(DATADIR)/steam/compatibilitytools.d/umu-launcher
install -Dm 755 $(OBJDIR)/$(<)-run $(DESTDIR)$(DATADIR)/steam/compatibilitytools.d/umu-launcher/umu-run

umu-launcher-dist-install:
$(info :: Installing umu-launcher )
install -d $(DESTDIR)$(DATADIR)/$(INSTALLDIR)/umu-launcher
install -Dm 644 umu/umu-launcher/compatibilitytool.vdf -t $(DESTDIR)$(DATADIR)/$(INSTALLDIR)/umu-launcher
install -Dm 644 umu/umu-launcher/toolmanifest.vdf -t $(DESTDIR)$(DATADIR)/$(INSTALLDIR)/umu-launcher
install -d $(DESTDIR)$(DATADIR)/steam/compatibilitytools.d/umu-launcher
install -Dm 644 umu/umu-launcher/compatibilitytool.vdf -t $(DESTDIR)$(DATADIR)/steam/compatibilitytools.d/umu-launcher
install -Dm 644 umu/umu-launcher/toolmanifest.vdf -t $(DESTDIR)$(DATADIR)/steam/compatibilitytools.d/umu-launcher

umu-launcher-install: umu-launcher-dist-install umu-launcher-bin-install

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ finish-args:
- --filesystem=xdg-data/applications:rw
- --filesystem=~/.steam:rw
- --filesystem=~/Games:rw
- --filesystem=~/.local/share:rw
- --filesystem=~/.local/share/Steam:rw
- --filesystem=~/.var/app/com.valvesoftware.Steam:rw
- --filesystem=~/.var/app/org.openwinecomponents.umu.umu-launcher:rw
- --filesystem=xdg-documents
Expand Down
1 change: 1 addition & 0 deletions umu/umu-launcher/toolmanifest.vdf
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@
"commandline" "/umu-run %verb%"
"version" "2"
"use_tool_subprocess_reaper" "1"
"unlisted" "1"
"compatmanager_layer_name" "umu-launcher"
}
13 changes: 2 additions & 11 deletions umu/umu_consts.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,6 @@ class Color(Enum):
DEBUG = "\u001b[35m"


class MODE(Enum):
"""Represent the permission to apply to a file."""

USER_RW = 0o0644
USER_RWX = 0o0755


SIMPLE_FORMAT = f"%(levelname)s: {Color.BOLD.value}%(message)s{Color.RESET.value}"

DEBUG_FORMAT = f"%(levelname)s [%(module)s.%(funcName)s:%(lineno)s]:{Color.BOLD.value}%(message)s{Color.RESET.value}" # noqa: E501
Expand All @@ -40,10 +33,8 @@ class MODE(Enum):
"getnativepath",
}

FLATPAK_ID = environ.get("FLATPAK_ID") if environ.get("FLATPAK_ID") else ""
FLATPAK_ID = environ.get("FLATPAK_ID") or ""

FLATPAK_PATH: Path = Path(environ.get("XDG_DATA_HOME"), "umu") if FLATPAK_ID else None

UMU_LOCAL: Path = (
FLATPAK_PATH if FLATPAK_PATH else Path.home().joinpath(".local", "share", "umu")
)
UMU_LOCAL: Path = FLATPAK_PATH or Path.home().joinpath(".local", "share", "umu")
44 changes: 0 additions & 44 deletions umu/umu_plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,19 +141,6 @@ def enable_steam_game_drive(env: Dict[str, str]) -> Dict[str, str]:
return env


def enable_reaper(env: Dict[str, str], command: List[str], local: Path) -> List[str]:
"""Enable Reaper to monitor and keep track of descendent processes."""
command.extend(
[
local.joinpath("reaper").as_posix(),
"UMU_ID=" + env["UMU_ID"],
"--",
]
)

return command


def enable_zenity(command: str, opts: List[str], msg: str) -> int:
"""Execute the command and pipe the output to Zenity.

Expand Down Expand Up @@ -195,34 +182,3 @@ def enable_zenity(command: str, opts: List[str], msg: str) -> int:
zenity_proc.stdin.close()

return zenity_proc.wait()


def enable_flatpak(
env: Dict[str, str], local: Path, command: List[str], verb: str, opts: List[str]
) -> List[str]:
"""Run umu in a Flatpak environment."""
bin: str = which("flatpak-spawn")

if not bin:
err: str = "flatpak-spawn not found\numu will fail to run the executable"
raise RuntimeError(err)

command.append(bin, "--host")
for key, val in env.items():
command.append(f"--env={key}={val}")

enable_reaper(env, command, local)

command.extend([local.joinpath("umu").as_posix(), "--verb", verb, "--"])
command.extend(
[
Path(env.get("PROTONPATH")).joinpath("proton").as_posix(),
verb,
env.get("EXE"),
]
)

if opts:
command.extend([*opts])

return command
22 changes: 14 additions & 8 deletions umu/umu_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
from umu_plugins import (
enable_steam_game_drive,
set_env_toml,
enable_reaper,
)


Expand Down Expand Up @@ -235,7 +234,11 @@ def set_env(


def build_command(
env: Dict[str, str], local: Path, command: List[str], opts: List[str] = None
env: Dict[str, str],
local: Path,
root: Path,
command: List[str],
opts: List[str] = None,
) -> List[str]:
"""Build the command to be executed."""
verb: str = env["PROTON_VERB"]
Expand All @@ -253,8 +256,13 @@ def build_command(
err: str = "The following file was not found in PROTONPATH: proton"
raise FileNotFoundError(err)

enable_reaper(env, command, local)

command.extend(
[
root.joinpath("reaper").as_posix(),
f"UMU_ID={env.get('UMU_ID')}",
"--",
]
)
command.extend([local.joinpath("umu").as_posix(), "--verb", verb, "--"])
command.extend(
[
Expand Down Expand Up @@ -322,9 +330,7 @@ def main() -> int: # noqa: D103
if FLATPAK_PATH and root == Path("/app/share/umu"):
log.debug("Flatpak environment detected")
log.debug("FLATPAK_ID: %s", FLATPAK_ID)
log.debug(
"The following path will be used to persist the runtime: %s", FLATPAK_PATH
)
log.debug("Persisting the runtime at: %s", FLATPAK_PATH)

# Setup the launcher and runtime files
# An internet connection is required for new setups
Expand Down Expand Up @@ -380,7 +386,7 @@ def main() -> int: # noqa: D103
executor.shutdown()

# Run
build_command(env, UMU_LOCAL, command, opts)
build_command(env, UMU_LOCAL, root, command, opts)
log.debug("%s", command)

return run(command, check=False).returncode
Expand Down
Loading