mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-12-06 04:55:44 +00:00
Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5ca58f6fbe |
No files matched your search
@@ -30,6 +30,11 @@ FEX_APPID = "3127680"
|
|||||||
SNIPER_APPID = "1628350"
|
SNIPER_APPID = "1628350"
|
||||||
INSTALL_DIRS = {FEX_APPID: "FEX-Emu", SNIPER_APPID: "SteamLinuxRuntime_sniper"}
|
INSTALL_DIRS = {FEX_APPID: "FEX-Emu", SNIPER_APPID: "SteamLinuxRuntime_sniper"}
|
||||||
MARKER = ".droiddeck-fex"
|
MARKER = ".droiddeck-fex"
|
||||||
|
# Without Steam's FEX and runtime: DroidDeck's own FEX build in /usr/local (the x86-64 client's,
|
||||||
|
# with GL/Vulkan thunks) and a plain x86 root - FEX's Ubuntu image unpacked - marked complete here.
|
||||||
|
OWN_ROOTFS = "/opt/droiddeck-fex/rootfs"
|
||||||
|
OWN_ROOTFS_DONE = ".droiddeck-complete"
|
||||||
|
SYSTEM_PREFIXES = ("/usr/local", "/usr")
|
||||||
LAYOUT = 1
|
LAYOUT = 1
|
||||||
GUEST_LIBDIRS = (("x86_64", "lib/x86_64-linux-gnu"), ("i386", "lib/i386-linux-gnu"))
|
GUEST_LIBDIRS = (("x86_64", "lib/x86_64-linux-gnu"), ("i386", "lib/i386-linux-gnu"))
|
||||||
PRELOAD_NAMES = ("libblsession.so", "libfakeinput.so")
|
PRELOAD_NAMES = ("libblsession.so", "libfakeinput.so")
|
||||||
@@ -142,7 +147,7 @@ def fex_install():
|
|||||||
tool = app_dir(FEX_APPID)
|
tool = app_dir(FEX_APPID)
|
||||||
if tool:
|
if tool:
|
||||||
prefixes += [(os.path.join(tool, sub), True) for sub in ("usr", "", "files/usr", "files")]
|
prefixes += [(os.path.join(tool, sub), True) for sub in ("usr", "", "files/usr", "files")]
|
||||||
prefixes.append(("/usr", False))
|
prefixes += [(prefix, False) for prefix in SYSTEM_PREFIXES]
|
||||||
for prefix, portable in prefixes:
|
for prefix, portable in prefixes:
|
||||||
binary = next((os.path.join(prefix, "bin", name) for name in ("FEX", "FEXInterpreter")
|
binary = next((os.path.join(prefix, "bin", name) for name in ("FEX", "FEXInterpreter")
|
||||||
if os.access(os.path.join(prefix, "bin", name), os.X_OK)), None)
|
if os.access(os.path.join(prefix, "bin", name), os.X_OK)), None)
|
||||||
@@ -179,6 +184,13 @@ def runtime_platform():
|
|||||||
return max(platforms, key=platform_version, default=None)
|
return max(platforms, key=platform_version, default=None)
|
||||||
|
|
||||||
|
|
||||||
|
def own_rootfs():
|
||||||
|
if os.path.isfile(os.path.join(OWN_ROOTFS, OWN_ROOTFS_DONE)) and \
|
||||||
|
os.path.isfile(os.path.join(OWN_ROOTFS, "lib/x86_64-linux-gnu/libc.so.6")):
|
||||||
|
return OWN_ROOTFS
|
||||||
|
return None
|
||||||
|
|
||||||
|
|
||||||
def unescape(raw):
|
def unescape(raw):
|
||||||
return ESCAPE.sub(lambda match: bytes([int(match.group(1), 8)]), raw)
|
return ESCAPE.sub(lambda match: bytes([int(match.group(1), 8)]), raw)
|
||||||
|
|
||||||
@@ -308,6 +320,7 @@ def request_install():
|
|||||||
|
|
||||||
|
|
||||||
def describe(fex, platform):
|
def describe(fex, platform):
|
||||||
|
# platform: Steam's sniper platform folder, or the own root when Steam's runtime is absent.
|
||||||
return {
|
return {
|
||||||
"fex": fex["bin"] if fex else None,
|
"fex": fex["bin"] if fex else None,
|
||||||
"server": fex["server"] if fex else None,
|
"server": fex["server"] if fex else None,
|
||||||
@@ -322,7 +335,7 @@ def describe(fex, platform):
|
|||||||
def prepare():
|
def prepare():
|
||||||
with locked():
|
with locked():
|
||||||
fex = fex_install()
|
fex = fex_install()
|
||||||
platform = runtime_platform()
|
platform = runtime_platform() or own_rootfs()
|
||||||
status = describe(fex, platform)
|
status = describe(fex, platform)
|
||||||
if not status["ready"]:
|
if not status["ready"]:
|
||||||
missing = []
|
missing = []
|
||||||
@@ -341,9 +354,12 @@ def prepare():
|
|||||||
"the Steam client was asked to install it" if requested else "open Steam once and it is installed for you"))
|
"the Steam client was asked to install it" if requested else "open Steam once and it is installed for you"))
|
||||||
write_if_changed(STATUS_FILE, json.dumps(status, indent=2) + "\n")
|
write_if_changed(STATUS_FILE, json.dumps(status, indent=2) + "\n")
|
||||||
return None
|
return None
|
||||||
root = os.path.join(platform, "files")
|
if platform == OWN_ROOTFS:
|
||||||
if materialize(platform):
|
root = OWN_ROOTFS
|
||||||
say("prepared %s as the x86 runtime" % os.path.basename(platform))
|
else:
|
||||||
|
root = os.path.join(platform, "files")
|
||||||
|
if materialize(platform):
|
||||||
|
say("prepared %s as the x86 runtime" % os.path.basename(platform))
|
||||||
install_preloads(root)
|
install_preloads(root)
|
||||||
write_config(fex, root)
|
write_config(fex, root)
|
||||||
fex["rootfs"] = root
|
fex["rootfs"] = root
|
||||||
|
|||||||
@@ -245,6 +245,28 @@ class PrepareTest(FexTestCase):
|
|||||||
self.assertFalse((self.home / ".config/droiddeck/fex-wanted").exists())
|
self.assertFalse((self.home / ".config/droiddeck/fex-wanted").exists())
|
||||||
self.assertEqual(self.quiet(FEX["prepare"])[1], "")
|
self.assertEqual(self.quiet(FEX["prepare"])[1], "")
|
||||||
|
|
||||||
|
def test_the_own_build_and_root_stand_in_for_steams(self):
|
||||||
|
local = self.tmp / "usr-local"
|
||||||
|
self.write(local / "bin/FEX", elf(183), 0o755)
|
||||||
|
self.write(local / "bin/FEXServer", elf(183), 0o755)
|
||||||
|
(local / "lib/fex-emu/HostThunks").mkdir(parents=True)
|
||||||
|
(local / "share/fex-emu/GuestThunks").mkdir(parents=True)
|
||||||
|
self.write(local / "share/fex-emu/ThunksDB.json", "{}")
|
||||||
|
root = self.tmp / "own-rootfs"
|
||||||
|
self.write(root / "lib/x86_64-linux-gnu/libc.so.6", elf(62))
|
||||||
|
with mock.patch.dict(G, {"SYSTEM_PREFIXES": (str(local),), "OWN_ROOTFS": str(root),
|
||||||
|
"steam_running": lambda: False}):
|
||||||
|
# An unpack that did not finish is not a root.
|
||||||
|
self.assertIsNone(self.quiet(FEX["prepare"])[0])
|
||||||
|
self.write(root / ".droiddeck-complete")
|
||||||
|
fex, said = self.quiet(FEX["prepare"])
|
||||||
|
self.assertEqual((fex["bin"], fex["rootfs"], fex["portable"]), (str(local / "bin/FEX"), str(root), False))
|
||||||
|
self.assertNotIn("prepared", said)
|
||||||
|
status = json.loads((self.home / ".local/share/droiddeck-fex/status.json").read_text())
|
||||||
|
self.assertEqual((status["ready"], status["runtime"], status["thunks"]), (True, str(root), True))
|
||||||
|
config = json.loads((self.home / ".local/share/droiddeck-fex/config/Config.json").read_text())
|
||||||
|
self.assertEqual(config["Config"]["RootFS"], str(root))
|
||||||
|
|
||||||
def test_status_refreshes_what_the_app_reads_once_steam_installed_fex(self):
|
def test_status_refreshes_what_the_app_reads_once_steam_installed_fex(self):
|
||||||
with mock.patch.dict(G, {"steam_running": lambda: False}):
|
with mock.patch.dict(G, {"steam_running": lambda: False}):
|
||||||
self.quiet(FEX["prepare"])
|
self.quiet(FEX["prepare"])
|
||||||
|
|||||||
Reference in new issue
Block a user