mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-21 05:46:03 +00:00
fix(epic): start parent-checking Epic titles under an EpicGamesLauncher.exe stand-in and stage their Rockstar SDK (#2932)
* fix(epic): start Epic titles that check their parent under an EpicGamesLauncher.exe stand-in Rockstar's launcher only accepts an Epic copy of GTA V when a process named EpicGamesLauncher.exe started it. DroidDeck's Epic client is a Linux program, so the launcher logged "Epic Games Launcher not detected as parent process", failed to relaunch through Epic and showed the game as unowned. - tools/epic-launcher: a small Windows EpicGamesLauncher.exe that starts the game with the rest of its own command line, unchanged, waits for it and returns its exit code. It ships as the epic add-on pack. - The Epic .droiddeck-launch.bat runs the game through it for Epic titles known to need it (GTA V, GTA V Enhanced, RDR2, RDR, GTA SA DE, Returnal, Phantom Blade: Executioners), or for any Epic game whose per-game environment sets DD_EPIC_PARENT=1; DD_EPIC_PARENT=0 turns it off. Those titles also start without Steam's SteamAppId. Without the staged stand-in the game starts directly, as before. - Steam launch options now reach Epic games (%*). - The launch hook fetches the pack when such a title finds it missing. - Rockstar's launcher found no Social Club SDK in the prefix and ran Social-Club-Setup.exe /silent, which never exits under Wine. For Epic titles that carry a Rockstar SDK installer, the hook now extracts the SDK from the launcher's own Redistributables copy (the version the launcher compares against) or, before the launcher is installed, from the game's copy, and registers it. It re-extracts when that installer changes and leaves the Rockstar Games Launcher key alone, so PlayGTAV still installs the launcher on first start. * fix(epic): fetch the parent stand-in exactly when the game will use it; keep Cargo output out of source digests The launch hook runs before droiddeck-game-env applies per-game variables, so it now resolves DD_EPIC_PARENT through droiddeck-game-env's own apply_config and game_id: an unlisted title with DD_EPIC_PARENT=1 fetches the pack, a listed title with DD_EPIC_PARENT=0 no longer waits for it. runtime_inputs no longer hashes the target directory beside a Cargo.toml under its source paths, so a local cargo build of a Windows helper does not fail verify(). tools/epic-launcher gets the same .gitignore as the other helpers. * fix(epic): a DD_EPIC_PARENT in the game's sidecar env decides the stand-in fetch too The .bat sets the sidecar's env before it reads DD_EPIC_PARENT, so that value overrides the game environment there; the launch hook now gives it the same precedence when deciding whether to fetch the pack. * test(epic): keep an inherited DD_EPIC_PARENT out of the launch hook tests --------- Co-authored-by: MaxsTechReview <maxjividen@gmail.com>
This commit is contained in:
1 parent
9925873764
commit
367151be2c
22 files changed
+543
-29
No files matched your search
@@ -440,6 +440,13 @@ if [[ "${DROIDDECK_SKIP_RUST:-0}" != 1 ]]; then
|
||||
CARGO_TARGET_DIR="${cache_dir}/rockstar-target" bash tools/rockstar-launcher/build.sh "${rockstar_out}"
|
||||
save_step rockstar "${rockstar_key}" "${rockstar_out}"
|
||||
fi
|
||||
epic_out="${linuxfs_dir}/usr/local/lib/droiddeck-epic"
|
||||
epic_key=$(inputs_hash "x86_64-pc-windows-gnu" tools/epic-launcher/src tools/epic-launcher/Cargo.toml tools/epic-launcher/Cargo.lock tools/epic-launcher/build.sh)
|
||||
if ! restore_step epic "${epic_key}" "${epic_out}"; then
|
||||
command -v x86_64-w64-mingw32-gcc >/dev/null 2>&1 || { echo "x86_64-w64-mingw32-gcc is required for EpicGamesLauncher.exe." >&2; exit 1; }
|
||||
CARGO_TARGET_DIR="${cache_dir}/epic-target" bash tools/epic-launcher/build.sh "${epic_out}"
|
||||
save_step epic "${epic_key}" "${epic_out}"
|
||||
fi
|
||||
fi
|
||||
python3 tools/powervr/fetch.py
|
||||
bash tools/packs/build.sh app/build/packs
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
/target/
|
||||
Generated
+7
@@ -0,0 +1,7 @@
|
||||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
version = 4
|
||||
|
||||
[[package]]
|
||||
name = "droiddeck-epic-launcher"
|
||||
version = "0.1.0"
|
||||
@@ -0,0 +1,16 @@
|
||||
[package]
|
||||
name = "droiddeck-epic-launcher"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
license = "GPL-3.0-only"
|
||||
publish = false
|
||||
|
||||
[[bin]]
|
||||
name = "EpicGamesLauncher"
|
||||
path = "src/main.rs"
|
||||
|
||||
[profile.release]
|
||||
opt-level = "s"
|
||||
lto = true
|
||||
panic = "abort"
|
||||
strip = true
|
||||
@@ -0,0 +1,13 @@
|
||||
# Epic Games Launcher parent stand-in
|
||||
|
||||
`EpicGamesLauncher.exe` starts the game named by its first argument as its own child, passes the rest of its command line to the game unchanged, waits for the game and returns its exit code.
|
||||
|
||||
Some Epic titles only accept a launch whose parent process is named `EpicGamesLauncher.exe`. Rockstar's launcher logs `Epic Games Launcher not detected as parent process.` and then treats the Epic copy as unowned. In DroidDeck the Epic client is a Linux program, so it can never be that parent. The check matches the process name, not its path: Heroic's stand-in works from `C:\windows\command` and from the game folder.
|
||||
|
||||
`StoreLaunch` writes the Epic `.droiddeck-launch.bat` to run the game through this executable for the titles in `EPIC_PARENT_TITLES`, or for any Epic game whose per-game environment sets `DD_EPIC_PARENT=1`. `DD_EPIC_PARENT=0` turns it off. Without the staged executable the game starts directly, as before.
|
||||
|
||||
`build.sh` builds it with the GNU Windows target for the `epic` add-on pack. The app fetches the pack when it starts signed in to Epic, or when a launch that needs it finds it missing, and stages it in the Linux runtime at `/usr/local/lib/droiddeck-epic`.
|
||||
|
||||
```sh
|
||||
cargo test --locked --manifest-path tools/epic-launcher/Cargo.toml
|
||||
```
|
||||
Executable
+9
@@ -0,0 +1,9 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
here=$(cd "$(dirname "$0")" && pwd)
|
||||
out=${1:-"$here/../../app/src/main/assets/linuxfs/usr/local/lib/droiddeck-epic"}
|
||||
target=x86_64-pc-windows-gnu
|
||||
rustup target add "$target" >/dev/null 2>&1 || true
|
||||
cargo build --manifest-path "$here/Cargo.toml" --release --locked --target "$target"
|
||||
mkdir -p "$out"
|
||||
install -m644 "${CARGO_TARGET_DIR:-$here/target}/$target/release/EpicGamesLauncher.exe" "$out/EpicGamesLauncher.exe"
|
||||
@@ -0,0 +1,110 @@
|
||||
const QUOTE: u16 = b'"' as u16;
|
||||
const BACKSLASH: u16 = b'\\' as u16;
|
||||
|
||||
fn blank(c: u16) -> bool {
|
||||
c == b' ' as u16 || c == b'\t' as u16
|
||||
}
|
||||
|
||||
fn trim_start(line: &[u16]) -> &[u16] {
|
||||
let start = line.iter().position(|&c| !blank(c)).unwrap_or(line.len());
|
||||
&line[start..]
|
||||
}
|
||||
|
||||
/// Splits this program's command line into the game executable that follows the program name and
|
||||
/// the rest of the line, which reaches the game unchanged.
|
||||
pub fn split(line: &[u16]) -> Option<(Vec<u16>, &[u16])> {
|
||||
let mut quoted = false;
|
||||
let mut end = line.len();
|
||||
for (i, &c) in line.iter().enumerate() {
|
||||
if c == QUOTE {
|
||||
quoted = !quoted;
|
||||
} else if blank(c) && !quoted {
|
||||
end = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
let rest = trim_start(&line[end..]);
|
||||
let mut exe = Vec::new();
|
||||
let mut quoted = false;
|
||||
let mut slashes = 0;
|
||||
let mut end = rest.len();
|
||||
for (i, &c) in rest.iter().enumerate() {
|
||||
if c == BACKSLASH {
|
||||
slashes += 1;
|
||||
continue;
|
||||
}
|
||||
if c == QUOTE {
|
||||
exe.extend(std::iter::repeat(BACKSLASH).take(slashes / 2));
|
||||
if slashes % 2 == 1 {
|
||||
exe.push(QUOTE);
|
||||
} else {
|
||||
quoted = !quoted;
|
||||
}
|
||||
} else if blank(c) && !quoted {
|
||||
exe.extend(std::iter::repeat(BACKSLASH).take(slashes));
|
||||
end = i;
|
||||
slashes = 0;
|
||||
break;
|
||||
} else {
|
||||
exe.extend(std::iter::repeat(BACKSLASH).take(slashes));
|
||||
exe.push(c);
|
||||
}
|
||||
slashes = 0;
|
||||
}
|
||||
exe.extend(std::iter::repeat(BACKSLASH).take(slashes));
|
||||
if exe.is_empty() {
|
||||
return None;
|
||||
}
|
||||
Some((exe, trim_start(&rest[end..])))
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::split;
|
||||
|
||||
fn wide(s: &str) -> Vec<u16> {
|
||||
s.encode_utf16().collect()
|
||||
}
|
||||
|
||||
fn parts(line: &str) -> Option<(String, String)> {
|
||||
let line = wide(line);
|
||||
split(&line).map(|(exe, rest)| (String::from_utf16(&exe).unwrap(), String::from_utf16(rest).unwrap()))
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_game_gets_the_rest_of_the_line_exactly_as_written() {
|
||||
assert_eq!(
|
||||
parts(r#""Z:\usr\local\lib\droiddeck-epic\EpicGamesLauncher.exe" "Z:\root\Games\Stores\Epic\Grand Theft Auto V\PlayGTAV.exe" -AUTH_LOGIN=unused -epicusername="A B" -nobattleye"#),
|
||||
Some((
|
||||
r"Z:\root\Games\Stores\Epic\Grand Theft Auto V\PlayGTAV.exe".into(),
|
||||
r#"-AUTH_LOGIN=unused -epicusername="A B" -nobattleye"#.into()
|
||||
))
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_game_without_arguments_gets_none() {
|
||||
assert_eq!(parts(r#"EpicGamesLauncher.exe "C:\Games\x.exe" "#), Some((r"C:\Games\x.exe".into(), String::new())));
|
||||
assert_eq!(parts(r"EpicGamesLauncher.exe C:\Games\x.exe"), Some((r"C:\Games\x.exe".into(), String::new())));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_program_name_follows_its_own_quoting_rules() {
|
||||
assert_eq!(parts("\"C:\\a b\\\"EpicGamesLauncher.exe\tgame.exe -x"), Some(("game.exe".into(), "-x".into())));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_executable_follows_the_argument_quoting_rules() {
|
||||
assert_eq!(parts(r#"e "C:\dir with\"part\"s\x.exe" -y"#), Some((r#"C:\dir with"part"s\x.exe"#.into(), "-y".into())));
|
||||
assert_eq!(parts(r#"e C:\a"b c"\x.exe -y"#), Some((r"C:\ab c\x.exe".into(), "-y".into())));
|
||||
assert_eq!(parts(r"e C:\games\ -y"), Some((r"C:\games\".into(), "-y".into())));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_missing_executable_is_refused() {
|
||||
assert_eq!(parts("EpicGamesLauncher.exe"), None);
|
||||
assert_eq!(parts("EpicGamesLauncher.exe "), None);
|
||||
assert_eq!(parts(r#"EpicGamesLauncher.exe "" -x"#), None);
|
||||
assert_eq!(parts(""), None);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
#[cfg(windows)]
|
||||
fn main() {
|
||||
use std::ffi::OsString;
|
||||
use std::os::windows::ffi::OsStringExt;
|
||||
use std::os::windows::process::CommandExt;
|
||||
|
||||
#[link(name = "kernel32")]
|
||||
extern "system" {
|
||||
fn GetCommandLineW() -> *const u16;
|
||||
}
|
||||
|
||||
let line = unsafe {
|
||||
let start = GetCommandLineW();
|
||||
let mut len = 0;
|
||||
while *start.add(len) != 0 {
|
||||
len += 1;
|
||||
}
|
||||
std::slice::from_raw_parts(start, len)
|
||||
};
|
||||
let Some((exe, rest)) = droiddeck_epic_launcher::split(line) else {
|
||||
eprintln!("usage: EpicGamesLauncher.exe <game.exe> [arguments]");
|
||||
std::process::exit(2);
|
||||
};
|
||||
let exe = OsString::from_wide(&exe);
|
||||
let mut command = std::process::Command::new(&exe);
|
||||
if !rest.is_empty() {
|
||||
command.raw_arg(OsString::from_wide(rest));
|
||||
}
|
||||
match command.status() {
|
||||
Ok(status) => std::process::exit(status.code().unwrap_or(1)),
|
||||
Err(error) => {
|
||||
eprintln!("EpicGamesLauncher: could not start {}: {error}", exe.to_string_lossy());
|
||||
std::process::exit(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(not(windows))]
|
||||
fn main() {
|
||||
eprintln!("EpicGamesLauncher.exe runs on Windows or Wine");
|
||||
std::process::exit(1);
|
||||
}
|
||||
@@ -5,6 +5,7 @@ import binascii
|
||||
import json
|
||||
import os
|
||||
import re
|
||||
import runpy
|
||||
import shlex
|
||||
import shutil
|
||||
import stat
|
||||
@@ -337,6 +338,13 @@ UBISOFT_INSTALLER_URL = "https://static3.cdn.ubi.com/orbit/launcher_installer/Ub
|
||||
ROCKSTAR_SERVICE = Path("/usr/local/lib/droiddeck-rockstar")
|
||||
SERVICE_WAIT = 300.0
|
||||
ROCKSTAR_FOLDER = "drive_c/Program Files/Rockstar Games/Launcher"
|
||||
EPIC_SDK_SETUP = ROCKSTAR_FOLDER + "/Redistributables/SocialClub/Social-Club-Setup.exe"
|
||||
SDK_SOURCE = ".droiddeck-sdk-source"
|
||||
SDK_SETUP_LIMIT = 256 * 1024 * 1024
|
||||
EPIC_PARENT = Path("/usr/local/lib/droiddeck-epic/EpicGamesLauncher.exe")
|
||||
EPIC_PARENT_ON = 'set "DD_P=1"'
|
||||
EPIC_PARENT_SWITCH = "DD_EPIC_PARENT"
|
||||
EPIC_SERVICE_WAIT = 60.0
|
||||
ROCKSTAR_TITLES = {"gta3": "Grand Theft Auto III", "gtavc": "Grand Theft Auto: Vice City", "gtasa": "GTA: San Andreas",
|
||||
"gta4": "Grand Theft Auto IV", "lanoire": "LANoireMTL"}
|
||||
|
||||
@@ -394,10 +402,9 @@ def rockstar_sdk(folder, sidecar):
|
||||
return False
|
||||
|
||||
|
||||
def rockstar_registry(folder, title, compat_data, proton, sdk_arch=None):
|
||||
def rockstar_registry(folder, title, compat_data, proton, sdk_arch=None, launcher=True):
|
||||
pfx = Path(compat_data) / "pfx"
|
||||
launcher = r"C:\Program Files\Rockstar Games\Launcher"
|
||||
values = [(r"Rockstar Games\Launcher", launcher)]
|
||||
values = [(r"Rockstar Games\Launcher", r"C:\Program Files\Rockstar Games\Launcher")] if launcher else []
|
||||
if title:
|
||||
values.append(("Rockstar Games\\" + title, windows_path(str(folder))))
|
||||
entries = [("Software\\" + view + key, value) for view in ("", "Wow6432Node\\") for key, value in values]
|
||||
@@ -420,23 +427,29 @@ def rockstar_registry(folder, title, compat_data, proton, sdk_arch=None):
|
||||
return result.returncode == 0
|
||||
|
||||
|
||||
def rockstar_runtime(folder, exe, compat_data, arch):
|
||||
def rockstar_runtime(folder, exe, compat_data, arch, installer=None):
|
||||
if arch == "x86":
|
||||
rockstar_runtime(folder, exe, compat_data, "x64")
|
||||
rockstar_runtime(folder, exe, compat_data, "x64", installer)
|
||||
pfx = Path(compat_data) / "pfx"
|
||||
target = pfx / "drive_c" / ("Program Files (x86)" if arch == "x86" else "Program Files") / "Rockstar Games/Social Club"
|
||||
if not target.resolve().is_relative_to(pfx.resolve()):
|
||||
raise ValueError("invalid Social Club destination")
|
||||
required = ("socialclub.dll", "socialclub.pak") + (("SocialClubHelper.exe",) if arch == "x64" else ())
|
||||
marker = target / ".droiddeck-installing"
|
||||
if all((target / name).is_file() for name in required) and not marker.exists():
|
||||
source_file, stamp = target / SDK_SOURCE, None
|
||||
if installer is not None:
|
||||
info = installer.stat()
|
||||
stamp = "%d %d %s" % (info.st_size, info.st_mtime_ns, installer)
|
||||
current = stamp is None or source_file.is_file() and not source_file.is_symlink() and source_file.read_text(errors="replace") == stamp
|
||||
if all((target / name).is_file() for name in required) and not marker.exists() and current:
|
||||
return "present"
|
||||
root = folder.resolve()
|
||||
installers = [base / sub / "Social-Club-Setup.exe" for base in (root, exe.parent)
|
||||
for sub in ("Redistributables", "Installers")]
|
||||
installer = next((p for p in installers if p.is_file() and p.resolve().is_relative_to(root) and p.stat().st_size <= 256 * 1024 * 1024), None)
|
||||
if installer is None:
|
||||
return "game-runtime"
|
||||
root = folder.resolve()
|
||||
installers = [base / sub / "Social-Club-Setup.exe" for base in (root, exe.parent)
|
||||
for sub in ("Redistributables", "Installers")]
|
||||
installer = next((p for p in installers if p.is_file() and p.resolve().is_relative_to(root) and p.stat().st_size <= SDK_SETUP_LIMIT), None)
|
||||
if installer is None:
|
||||
return "game-runtime"
|
||||
tool = shutil.which("7z")
|
||||
if not tool:
|
||||
return "no-unpacker"
|
||||
@@ -488,15 +501,67 @@ def rockstar_runtime(folder, exe, compat_data, arch):
|
||||
raise
|
||||
os.replace(stage_path, output)
|
||||
marker.unlink()
|
||||
if stamp is not None:
|
||||
source_file.unlink(missing_ok=True)
|
||||
source_file.write_text(stamp)
|
||||
return "installed"
|
||||
|
||||
|
||||
def fetch_service(service, store, launch_dir, ask_app=None):
|
||||
def epic_parent_switch(sidecar, env=None):
|
||||
own = sidecar.get("env") if isinstance(sidecar.get("env"), dict) else {}
|
||||
if EPIC_PARENT_SWITCH in own:
|
||||
return str(own[EPIC_PARENT_SWITCH]).replace('"', "")
|
||||
env = os.environ if env is None else env
|
||||
try:
|
||||
game_env = runpy.run_path(str(Path(__file__).resolve().with_name("droiddeck-game-env")))
|
||||
try:
|
||||
config = json.loads((Path(env.get("HOME") or "/root") / ".config/droiddeck/game-environment.json").read_text(encoding="utf-8"))
|
||||
except FileNotFoundError:
|
||||
config = {"version": 1}
|
||||
env = game_env["apply_config"](env, config, game_env["game_id"](env))
|
||||
except (OSError, ValueError, KeyError, TypeError, AttributeError):
|
||||
pass
|
||||
return env.get(EPIC_PARENT_SWITCH, "")
|
||||
|
||||
|
||||
def wants_epic_parent(folder, switch):
|
||||
if switch in ("0", "1"):
|
||||
return switch == "1"
|
||||
try:
|
||||
return EPIC_PARENT_ON in (folder / LAUNCHER).read_text(errors="replace").splitlines()
|
||||
except OSError:
|
||||
return False
|
||||
|
||||
|
||||
def epic_rockstar_sdk(folder, sidecar, compat_data, proton):
|
||||
if not compat_data:
|
||||
return None
|
||||
pfx = Path(compat_data) / "pfx"
|
||||
root = folder.resolve()
|
||||
exe = (folder / str(sidecar.get("exe") or "").replace("\\", "/")).resolve()
|
||||
if not exe.is_relative_to(root):
|
||||
return None
|
||||
setups = [(pfx / EPIC_SDK_SETUP, pfx)] + [(base / sub / "Social-Club-Setup.exe", root) for base in (root, exe.parent)
|
||||
for sub in ("Redistributables", "Installers")]
|
||||
setup = next((path for path, inside in setups if path.is_file() and path.resolve().is_relative_to(inside.resolve())
|
||||
and path.stat().st_size <= SDK_SETUP_LIMIT), None)
|
||||
if setup is None:
|
||||
return None
|
||||
made = "present" if (pfx / "user.reg").is_file() else create_prefix(compat_data, proton)
|
||||
if made not in ("created", "present"):
|
||||
return "prefix-" + made
|
||||
state = rockstar_runtime(folder, exe, compat_data, "x64", setup)
|
||||
if state in ("present", "installed") and not rockstar_registry(folder, None, compat_data, proton, sdk_arch="x64", launcher=False):
|
||||
return state + " registry-unavailable"
|
||||
return state
|
||||
|
||||
|
||||
def fetch_service(service, store, launch_dir, ask_app=None, timeout=SERVICE_WAIT):
|
||||
if service.is_file():
|
||||
return True
|
||||
if not launch_dir:
|
||||
return False
|
||||
answer = (ask_app or ask)(Path(launch_dir) / "stores", {"op": "store-service", "store": store}, timeout=SERVICE_WAIT)
|
||||
answer = (ask_app or ask)(Path(launch_dir) / "stores", {"op": "store-service", "store": store}, timeout=timeout)
|
||||
return isinstance(answer, dict) and bool(answer.get("ok")) and service.is_file()
|
||||
|
||||
|
||||
@@ -1650,6 +1715,15 @@ def main(argv):
|
||||
pass
|
||||
log("ubisoft %s: not prepared (%s), starting directly" % (game, e))
|
||||
if store == "epic":
|
||||
try:
|
||||
if launch_dir and not EPIC_PARENT.is_file() and wants_epic_parent(folder, epic_parent_switch(sidecar)):
|
||||
got = fetch_service(EPIC_PARENT, "epic", launch_dir, timeout=EPIC_SERVICE_WAIT)
|
||||
log("epic parent stand-in: " + ("staged" if got else "unavailable"))
|
||||
sdk = epic_rockstar_sdk(folder, sidecar, compat_data, os.environ.get("DD_STORE_PROTON", ""))
|
||||
except (OSError, ValueError, subprocess.TimeoutExpired) as error:
|
||||
sdk = "failed (%s)" % type(error).__name__
|
||||
if sdk:
|
||||
log("epic rockstar sdk: " + sdk)
|
||||
handled = os.environ.get(EPIC_HANDLED) == "1" and (folder / EPIC_ARGS).is_file()
|
||||
if not handled:
|
||||
drop_stale(folder)
|
||||
|
||||
@@ -98,6 +98,7 @@ pack powervr "$repo/app/src/main/assets/hybris" runtime.tzst version.txt
|
||||
[ ! -f "$linuxfs/droiddeck-ubisoft/droiddeck-upc.exe" ] || pack ubisoft "$linuxfs/droiddeck-ubisoft" droiddeck-upc.exe
|
||||
[ ! -f "$linuxfs/droiddeck-rockstar/Launcher64.exe" ] || pack rockstar "$linuxfs/droiddeck-rockstar" Launcher32.exe Launcher64.exe
|
||||
[ ! -f "$linuxfs/droiddeck-dirt/ws2_32.dll" ] || pack dirt "$linuxfs/droiddeck-dirt" ws2_32.dll
|
||||
[ ! -f "$linuxfs/droiddeck-epic/EpicGamesLauncher.exe" ] || pack epic "$linuxfs/droiddeck-epic" EpicGamesLauncher.exe
|
||||
|
||||
mkdir "$work/butler"
|
||||
fetch "https://broth.itch.zone/butler/linux-arm64/${BUTLER_VERSION}/archive/default" \
|
||||
|
||||
@@ -15,18 +15,18 @@ MANIFEST = Path('app/build/runtime-inputs.json')
|
||||
PACKS = Path('app/build/packs')
|
||||
PACKED = {'assets/linuxfs/usr/local/lib/droiddeck-xbox/': 'xbox', 'assets/linuxfs/usr/local/lib/droiddeck-comet/': 'comet',
|
||||
'assets/linuxfs/usr/local/lib/droiddeck-ubisoft/': 'ubisoft', 'assets/linuxfs/usr/local/lib/droiddeck-rockstar/': 'rockstar',
|
||||
'assets/linuxfs/usr/local/lib/droiddeck-dirt/': 'dirt',
|
||||
'assets/linuxfs/usr/local/lib/droiddeck-dirt/': 'dirt', 'assets/linuxfs/usr/local/lib/droiddeck-epic/': 'epic',
|
||||
'assets/directaudio/': 'directaudio', 'assets/hybris/': 'powervr'}
|
||||
# DrWeb flags proot itself as Tool.Linux.Proot; the app runs the pack's copy through Android's linker.
|
||||
PACKED_FILES = {'lib/arm64-v8a/libproot.so': ('proot', 'libproot.so')}
|
||||
# The loader is execve'd, which targetSdk 29+ allows only from the APK's native library directory.
|
||||
PROOT_LOADER = {'lib/arm64-v8a/libproot-loader.so': 'libproot-loader.so'}
|
||||
PACKED_LIBRARIES = ['lib/arm64-v8a/libopencv_java4.so', 'lib/arm64-v8a/libmediapipe_tasks_jni.so']
|
||||
PACK_NAMES = ['proot', 'directaudio', 'tracking', 'xbox', 'comet', 'butler', 'powervr', 'ubisoft', 'rockstar', 'dirt']
|
||||
PACK_NAMES = ['proot', 'directaudio', 'tracking', 'xbox', 'comet', 'butler', 'powervr', 'ubisoft', 'rockstar', 'dirt', 'epic']
|
||||
SOURCE_PATHS = ['app/build.gradle', 'app/src/main/cpp/fakeinput_steam.cpp', 'app/src/main/assets/pulseaudio.tzst',
|
||||
'tools/linuxfs', 'tools/proot', 'tools/aaudio-sink', 'tools/directaudio', 'tools/packs',
|
||||
'tools/gamescope/release.env', 'tools/droiddeck-esync/release.env',
|
||||
'tools/mangoapp', 'tools/msitools', 'tools/pipewire', 'tools/comet', 'tools/xbox', 'tools/dirt-ws2', 'tools/ubisoft-launcher', 'tools/rockstar-launcher', 'tools/components', 'tools/ci', 'tools/build_local.sh',
|
||||
'tools/mangoapp', 'tools/msitools', 'tools/pipewire', 'tools/comet', 'tools/xbox', 'tools/dirt-ws2', 'tools/ubisoft-launcher', 'tools/rockstar-launcher', 'tools/epic-launcher', 'tools/components', 'tools/ci', 'tools/build_local.sh',
|
||||
'tools/powervr', 'tools/hybris', 'tools/dxvk', 'tools/vulkan-wsi',
|
||||
'tools/release/runtime_inputs.py', 'app/src/main/assets/desktop-removal',
|
||||
'tools/quest', 'tools/vr/src', 'tools/vr/driver_droiddeck', 'tools/vr/layer', 'tools/vr/build.sh',
|
||||
@@ -49,12 +49,15 @@ def digest(path):
|
||||
|
||||
|
||||
def sources(root):
|
||||
files = []
|
||||
files, builds = [], set()
|
||||
for name in SOURCE_PATHS:
|
||||
path = root / name
|
||||
files.extend(path.rglob('*') if path.is_dir() else [path])
|
||||
if path.is_dir():
|
||||
builds.update(manifest.parent / 'target' for manifest in path.rglob('Cargo.toml'))
|
||||
return {path.relative_to(root).as_posix(): digest(path) for path in sorted(set(files))
|
||||
if path.is_file() and '__pycache__' not in path.parts and path.suffix != '.pyc'}
|
||||
if path.is_file() and '__pycache__' not in path.parts and path.suffix != '.pyc'
|
||||
and not any(build in path.parents for build in builds)}
|
||||
|
||||
|
||||
def outputs(root):
|
||||
@@ -227,7 +230,7 @@ def windows_binaries(package):
|
||||
def check_apk(apk, root=ROOT):
|
||||
data = verify(root)
|
||||
packs = {name: pack_digests(root, name) for name in PACK_NAMES
|
||||
if name not in ('ubisoft', 'rockstar', 'dirt') or (root / PACKS / (name + '.tar.zst')).is_file()}
|
||||
if name not in ('ubisoft', 'rockstar', 'dirt', 'epic') or (root / PACKS / (name + '.tar.zst')).is_file()}
|
||||
for name, rel in PROOT_LOADER.items():
|
||||
if packs['proot'].get(rel) != data['outputs'][name]['sha256']:
|
||||
raise ValueError('Add-on pack proot is missing or has a stale ' + rel)
|
||||
|
||||
@@ -137,6 +137,19 @@ class RuntimeInputsTest(unittest.TestCase):
|
||||
with self.assertRaisesRegex(ValueError, 'sources changed'):
|
||||
runtime.verify(self.root)
|
||||
|
||||
def test_cargo_output_beside_a_windows_helper_is_not_a_source(self):
|
||||
crate = self.root / 'tools/epic-launcher'
|
||||
(crate / 'src').mkdir(parents=True)
|
||||
(crate / 'Cargo.toml').write_text('[package]\n')
|
||||
(crate / 'src/lib.rs').write_text('old')
|
||||
runtime.record(self.root)
|
||||
(crate / 'target/debug').mkdir(parents=True)
|
||||
(crate / 'target/debug/build.log').write_text('local cargo test')
|
||||
runtime.verify(self.root)
|
||||
(crate / 'src/lib.rs').write_text('new')
|
||||
with self.assertRaisesRegex(ValueError, 'sources changed'):
|
||||
runtime.verify(self.root)
|
||||
|
||||
def test_missing_quest_driver_cannot_be_attested(self):
|
||||
(self.root / 'app/build/prepared-assets/graphics_driver/adrenotools-turnip25.1.0-quest1.tzst').unlink()
|
||||
with self.assertRaisesRegex(ValueError, 'quest1.tzst'):
|
||||
@@ -248,6 +261,21 @@ class RuntimeInputsTest(unittest.TestCase):
|
||||
runtime.check_apk(apk, self.root)
|
||||
runtime.check_apk(self.current_apk(self.root / 'current.apk'), self.root)
|
||||
|
||||
def test_an_apk_still_carrying_the_epic_parent_stand_in_is_rejected(self):
|
||||
epic = self.root / 'app/src/main/assets/linuxfs/usr/local/lib/droiddeck-epic'
|
||||
epic.mkdir(parents=True)
|
||||
(epic / 'EpicGamesLauncher.exe').write_bytes(b'MZ parent')
|
||||
self.packs()
|
||||
name = 'assets/linuxfs/usr/local/lib/droiddeck-epic/EpicGamesLauncher.exe'
|
||||
self.assertIn(name, runtime.outputs(self.root))
|
||||
apk = self.current_apk(self.root / 'bundled.apk', {name: b'MZ parent'})
|
||||
with self.assertRaisesRegex(ValueError, 'epic pack provides'):
|
||||
runtime.check_apk(apk, self.root)
|
||||
runtime.check_apk(self.current_apk(self.root / 'current.apk'), self.root)
|
||||
self.pack('epic', {'EpicGamesLauncher.exe': b'MZ older parent'})
|
||||
with self.assertRaisesRegex(ValueError, 'epic is missing or has a stale'):
|
||||
runtime.check_apk(self.current_apk(self.root / 'current.apk'), self.root)
|
||||
|
||||
def test_an_apk_still_carrying_the_powervr_runtime_is_rejected(self):
|
||||
apk = self.current_apk(self.root / 'bundled.apk', {'assets/hybris/runtime.tzst': b'runtime'})
|
||||
with self.assertRaisesRegex(ValueError, 'powervr pack provides'):
|
||||
|
||||
@@ -292,5 +292,150 @@ class RockstarLaunch(unittest.TestCase):
|
||||
self.assertIn('Grand Theft Auto: Vice City', text)
|
||||
|
||||
|
||||
SDK_FILES = {'socialclub.dll': b'sdk dll', 'socialclub.pak': b'sdk pak', 'SocialClubHelper.exe': b'sdk helper'}
|
||||
|
||||
|
||||
class EpicRockstarLaunch(unittest.TestCase):
|
||||
def setUp(self):
|
||||
temp = tempfile.TemporaryDirectory()
|
||||
self.addCleanup(temp.cleanup)
|
||||
self.root = Path(temp.name)
|
||||
self.folder = self.root / 'Grand Theft Auto V'
|
||||
self.folder.mkdir()
|
||||
(self.folder / 'PlayGTAV.exe').write_bytes(b'MZ')
|
||||
self.sidecar = {'store': 'epic', 'id': '9d2d0eb64d5c44529cece33fe2a46482', 'title': 'Grand Theft Auto V', 'exe': 'PlayGTAV.exe'}
|
||||
(self.folder / '.droiddeck-store.json').write_text(json.dumps(self.sidecar))
|
||||
self.prefix = self.root / 'prefix'
|
||||
(self.prefix / 'pfx').mkdir(parents=True)
|
||||
(self.prefix / 'pfx/user.reg').write_text('WINE REGISTRY Version 2\n')
|
||||
(self.prefix / 'pfx/system.reg').write_text('WINE REGISTRY Version 2\n')
|
||||
self.sdk = self.prefix / 'pfx/drive_c/Program Files/Rockstar Games/Social Club'
|
||||
self.unpacked = []
|
||||
|
||||
def unpacker(self, command, **kwargs):
|
||||
if command[1] == 'l':
|
||||
listing = ''.join('Path = x64/%s\nSize = %d\n\n' % (name, len(data)) for name, data in SDK_FILES.items())
|
||||
return type('Listing', (), {'returncode': 0, 'stdout': listing.encode()})()
|
||||
self.unpacked.append(Path(command[-2]))
|
||||
out = Path(next(arg[2:] for arg in command if arg.startswith('-o'))) / 'x64'
|
||||
out.mkdir(parents=True)
|
||||
for name, data in SDK_FILES.items():
|
||||
(out / name).write_bytes(data + b' from ' + Path(command[-2]).read_bytes())
|
||||
return type('Done', (), {'returncode': 0})()
|
||||
|
||||
def stage(self):
|
||||
with patch.object(store.shutil, 'which', return_value='/bin/7z'), patch.object(store.subprocess, 'run', side_effect=self.unpacker), \
|
||||
patch.object(store, 'wait_for_server', return_value=True), \
|
||||
patch.object(store, 'create_prefix', side_effect=AssertionError('the prefix already exists')):
|
||||
return store.epic_rockstar_sdk(self.folder, self.sidecar, str(self.prefix), '')
|
||||
|
||||
def test_the_launchers_own_sdk_installer_is_staged_so_it_never_runs_it(self):
|
||||
setup = self.prefix / 'pfx' / store.EPIC_SDK_SETUP
|
||||
setup.parent.mkdir(parents=True)
|
||||
setup.write_bytes(b'launcher setup')
|
||||
(self.folder / 'Installers').mkdir()
|
||||
(self.folder / 'Installers/Social-Club-Setup.exe').write_bytes(b'older game setup')
|
||||
self.assertEqual('installed', self.stage())
|
||||
self.assertEqual([setup], self.unpacked)
|
||||
self.assertEqual(b'sdk dll from launcher setup', (self.sdk / 'socialclub.dll').read_bytes())
|
||||
text = (self.prefix / 'pfx/system.reg').read_text()
|
||||
self.assertIn(r'[Software\\Wow6432Node\\Rockstar Games\\Rockstar Games Social Club]', text)
|
||||
self.assertIn(r'"InstallFolder"="C:\\Program Files\\Rockstar Games\\Social Club"', text)
|
||||
self.assertNotIn(r'Rockstar Games\\Launcher]', text)
|
||||
self.assertEqual('present', self.stage())
|
||||
self.assertEqual([setup], self.unpacked)
|
||||
|
||||
def test_an_updated_launcher_installer_is_staged_again(self):
|
||||
setup = self.prefix / 'pfx' / store.EPIC_SDK_SETUP
|
||||
setup.parent.mkdir(parents=True)
|
||||
setup.write_bytes(b'launcher setup')
|
||||
self.assertEqual('installed', self.stage())
|
||||
setup.write_bytes(b'newer launcher setup')
|
||||
self.assertEqual('installed', self.stage())
|
||||
self.assertEqual(b'sdk dll from newer launcher setup', (self.sdk / 'socialclub.dll').read_bytes())
|
||||
|
||||
def test_before_the_launcher_is_installed_the_games_installer_is_used(self):
|
||||
(self.folder / 'Redistributables').mkdir()
|
||||
(self.folder / 'Redistributables/Social-Club-Setup.exe').write_bytes(b'game setup')
|
||||
self.assertEqual('installed', self.stage())
|
||||
self.assertEqual(b'sdk dll from game setup', (self.sdk / 'socialclub.dll').read_bytes())
|
||||
self.assertNotIn(r'Rockstar Games\\Launcher]', (self.prefix / 'pfx/system.reg').read_text())
|
||||
|
||||
def test_other_epic_games_are_left_alone(self):
|
||||
self.assertIsNone(self.stage())
|
||||
self.assertEqual([], self.unpacked)
|
||||
self.assertFalse(self.sdk.exists())
|
||||
self.assertEqual('WINE REGISTRY Version 2\n', (self.prefix / 'pfx/system.reg').read_text())
|
||||
|
||||
def test_an_installer_linked_from_outside_the_game_is_ignored(self):
|
||||
outside = self.root / 'outside.exe'
|
||||
outside.write_bytes(b'not the game')
|
||||
(self.folder / 'Installers').mkdir()
|
||||
(self.folder / 'Installers/Social-Club-Setup.exe').symlink_to(outside)
|
||||
self.assertIsNone(self.stage())
|
||||
self.assertEqual([], self.unpacked)
|
||||
|
||||
def game_environment(self, shared=None, games=None):
|
||||
config = self.root / 'home/.config/droiddeck/game-environment.json'
|
||||
config.parent.mkdir(parents=True, exist_ok=True)
|
||||
config.write_text(json.dumps({'version': 1, 'shared': shared or {}, 'games': games or {}}))
|
||||
|
||||
def launch(self, bat, parent, compat_data=''):
|
||||
(self.folder / '.droiddeck-launch.bat').write_text(bat)
|
||||
calls = []
|
||||
env = {'DD_LAUNCH_DIR': str(self.root / 'launch'), 'STEAM_COMPAT_DATA_PATH': compat_data, 'HOME': str(self.root / 'home'),
|
||||
'DD_EPIC_PARENT': ''}
|
||||
with patch.dict(os.environ, env), patch.object(store, 'EPIC_PARENT', parent), \
|
||||
patch.object(store, 'client_wanted', return_value=False), \
|
||||
patch.object(store, 'ask', side_effect=lambda channel, request, timeout=0, claim=False: calls.append((request['op'], timeout)) or {'ok': False}):
|
||||
store.main([str(self.folder / '.droiddeck-launch.bat')])
|
||||
return calls
|
||||
|
||||
def test_a_title_that_needs_the_parent_fetches_the_stand_in_before_its_code(self):
|
||||
bat = '@echo off\r\nsetlocal\r\nset "DD_P=1"\r\n'
|
||||
calls = self.launch(bat, self.root / 'missing/EpicGamesLauncher.exe')
|
||||
self.assertEqual([('store-service', store.EPIC_SERVICE_WAIT), 'epic-code', 'cloud-down'],
|
||||
[calls[0]] + [op for op, _ in calls[1:]])
|
||||
staged = self.root / 'EpicGamesLauncher.exe'
|
||||
staged.write_bytes(b'MZ')
|
||||
self.assertEqual(['epic-code', 'cloud-down'], [op for op, _ in self.launch(bat, staged)])
|
||||
|
||||
def test_other_epic_games_do_not_fetch_the_stand_in(self):
|
||||
bat = '@echo off\r\nsetlocal\r\nset "DD_P="\r\nif "%DD_EPIC_PARENT%"=="1" set "DD_P=1"\r\n'
|
||||
calls = self.launch(bat, self.root / 'missing/EpicGamesLauncher.exe')
|
||||
self.assertEqual(['epic-code', 'cloud-down'], [op for op, _ in calls])
|
||||
|
||||
def test_the_games_own_switch_decides_whether_the_stand_in_is_fetched(self):
|
||||
compat_data = str(self.root / 'compatdata/4089453117')
|
||||
missing = self.root / 'missing/EpicGamesLauncher.exe'
|
||||
self.game_environment(games={'4089453117': {'DD_EPIC_PARENT': '1'}})
|
||||
self.assertEqual('store-service', self.launch('@echo off\r\nset "DD_P="\r\n', missing, compat_data)[0][0])
|
||||
self.game_environment(games={'4089453117': {'DD_EPIC_PARENT': '0'}})
|
||||
self.assertEqual(['epic-code', 'cloud-down'], [op for op, _ in self.launch('@echo off\r\nset "DD_P=1"\r\n', missing, compat_data)])
|
||||
self.game_environment(games={'4089453117': {'DD_EPIC_PARENT': None}}, shared={'DD_EPIC_PARENT': '0'})
|
||||
self.assertEqual('store-service', self.launch('@echo off\r\nset "DD_P=1"\r\n', missing, compat_data)[0][0])
|
||||
|
||||
def test_the_sidecars_own_environment_wins_like_it_does_in_the_batch(self):
|
||||
compat_data = str(self.root / 'compatdata/4089453117')
|
||||
missing = self.root / 'missing/EpicGamesLauncher.exe'
|
||||
sidecar = self.folder / '.droiddeck-store.json'
|
||||
sidecar.write_text(json.dumps(dict(self.sidecar, env={'DD_EPIC_PARENT': '1'})))
|
||||
self.assertEqual('store-service', self.launch('@echo off\r\nset "DD_P="\r\n', missing, compat_data)[0][0])
|
||||
self.game_environment(games={'4089453117': {'DD_EPIC_PARENT': '1'}})
|
||||
sidecar.write_text(json.dumps(dict(self.sidecar, env={'DD_EPIC_PARENT': '"0"'})))
|
||||
self.assertEqual(['epic-code', 'cloud-down'], [op for op, _ in self.launch('@echo off\r\nset "DD_P=1"\r\n', missing, compat_data)])
|
||||
|
||||
def test_the_switch_is_read_the_way_the_game_will_see_it(self):
|
||||
env = {'HOME': str(self.root / 'home'), 'STEAM_COMPAT_DATA_PATH': str(self.root / 'compatdata/4089453117')}
|
||||
self.assertEqual('', store.epic_parent_switch({}, env))
|
||||
self.assertEqual('1', store.epic_parent_switch({}, dict(env, DD_EPIC_PARENT='1')))
|
||||
self.game_environment(shared={'DD_EPIC_PARENT': '1'}, games={'4089453117': {'DD_EPIC_PARENT': '0'}, '7': {'DD_EPIC_PARENT': '1'}})
|
||||
self.assertEqual('0', store.epic_parent_switch({}, env))
|
||||
self.assertEqual('1', store.epic_parent_switch({'env': {'DD_EPIC_PARENT': '1'}}, env))
|
||||
self.assertEqual('1', store.epic_parent_switch({}, dict(env, STEAM_COMPAT_DATA_PATH=str(self.root / 'compatdata/12'))))
|
||||
(self.root / 'home/.config/droiddeck/game-environment.json').write_text('{"version": 9}')
|
||||
self.assertEqual('1', store.epic_parent_switch({}, dict(env, DD_EPIC_PARENT='1')))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
Reference in new issue
Block a user