mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-12-06 21:15:43 +00:00
feat(bionic): DroidDeck-Bionic compatibility tool (exec shim, launcher, CI archive)
The CI build now also assembles DroidDeck-Bionic-<layer>-r<run>, a Steam compatibility tool in Proton's layout: the bionic layer (bin, lib, share), its prefix template (drives C: and Z: only), FEX 2611.1 with Android-built unix libraries, DXVK 2.4.1 gplasync and VKD3D-Proton 3.1 (DroidDeck components can swap these), and the runtime pack, as a .tar.xz with a sha512sum. All inputs are sha256-pinned. - execshim.c (runtime pack preload): from targetSdk 29 Android refuses execve() of app data files but the system linker still runs them, so execve()/posix_spawn() of a dynamic /data ELF with interpreter linker64 becomes "linker64 <file> args" and "#!" scripts start their interpreter; static ELFs pass through (Wine then falls back from wine-preloader to its loader). realpath/readlink of /proc/self/exe answer with the program linker64 runs, because wineserver finds its NLS files next to its executable. - tool/proton (guest): run/waitforexitandrun/runinprefix/getcompatpath/getnativepath; no-proot only; guest paths to Android paths via DDNATV_BINDS; hands over to bionic/launch.sh. - tool/launch.sh (Android sh): Steam/input variables kept, DroidDeck's chosen Turnip (Android half), Wayland adapter + gamescope WSI layer, ntsync, FEX, DXVK/VKD3D overrides, runtime-pack paths (no fontconfig), Steam pad as an Xbox 360 pad; prefix setup in compatdata/pfx (template for new prefixes, builtin links for this layer replacing other Protons' links and Wine builtin copies but keeping native DLLs, users/xuser linked to steamuser, black desktop); every start through linker64 + execshim; STEAM_GAME window tag; leftover cleanup. Tested by hand on a Pocket FIT (DroidDeck 0.7.1, no-proot) with a locally assembled copy of this layout: DroidDeck adopted the tool, Steam started DiRT Showdown on it, prefix set up in 38 s, benchmark completed, clean exit. Known: DiRT Showdown picks 1024x768 instead of its configured 1280x720 under this Wine (open).
This commit is contained in:
1 parent
19262fd7bd
commit
d9a788046b
8 files changed
+484
-2
No files matched your search
@@ -1,4 +1,4 @@
|
||||
name: Build bionic runtime pack
|
||||
name: Build bionic runtime pack and DroidDeck-Bionic tool
|
||||
|
||||
on:
|
||||
push:
|
||||
@@ -13,7 +13,7 @@ on:
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-24.04
|
||||
timeout-minutes: 30
|
||||
timeout-minutes: 45
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Host tools
|
||||
@@ -26,6 +26,7 @@ jobs:
|
||||
run: |
|
||||
set -euo pipefail
|
||||
export NDK="${ANDROID_NDK_LATEST_HOME:-${ANDROID_NDK_HOME:-$ANDROID_NDK_ROOT}}"
|
||||
export BUILD_NUMBER=${{ github.run_number }}
|
||||
tools/bionic-runtime/build.sh "$RUNNER_TEMP/bionic-runtime" "$PWD/out"
|
||||
- uses: actions/upload-artifact@v4
|
||||
with:
|
||||
|
||||
@@ -31,6 +31,15 @@ VULKAN_HEADERS_TAG=v1.4.341
|
||||
# The bionic DroidDeck-Proton layer the pack is made for: linked against (libwayland-client) and checked against, not packed.
|
||||
LAYER_URL=https://github.com/The412Banner/proton-wine/releases/download/build-bionic-layers-20261030-v16/DroidDeck-proton-11.0-12.8-arm64ec.wcp
|
||||
LAYER_SHA256=a5e05e35214f34603f8cf9a362bb6b4bce9f18d773ee689ecfaff6136a1e9003 # proton-wine 067c719d, layer v16
|
||||
LAYER_VERSION=12.8
|
||||
# Packed into the DroidDeck-Bionic tool next to the layer: FEX with Android-built unix libraries, and default
|
||||
# DXVK / VKD3D-Proton (DroidDeck components can swap these in files/lib/wine/{dxvk,vkd3d-proton} later).
|
||||
FEX_URL=https://github.com/The412Banner/Nightlies/releases/download/FEXCore-2611.1/FEXCore-2611.1-unix.wcp
|
||||
FEX_SHA256=caca997e5e077feb5d9b7cf0f2c680cd93b442278903e3f3e7b1bd9cd544770c
|
||||
DXVK_URL=https://github.com/The412Banner/Nightlies/releases/download/Dxvk-gplasync-Linux/dxvk-gplasync-2.4.1-1-pre-reg-linux.wcp
|
||||
DXVK_SHA256=379b5dcde331de45a5f0ac7775d2c657c9c1510616afb9143ab8cdfbfa8e5342
|
||||
VKD3D_URL=https://github.com/Droid-Deck/DroidDeck-Components/releases/download/linux-nightly/DD-vkd3d-proton-arm64ec-3.1%2B64-nightly.wcp
|
||||
VKD3D_SHA256=92b8aa023e5242a6f7a69770b808b213474de7869f0d387ea99867a59e539b4e
|
||||
|
||||
case "$(uname -s):$(uname -m)" in
|
||||
Linux:x86_64) NDK_HOST=linux-x86_64 ;;
|
||||
@@ -130,6 +139,7 @@ echo "== DroidDeck fake input (app/src/main/cpp/fakeinput_steam.cpp), heap-taggi
|
||||
"$CXX" -shared -fPIC -O2 -Wall -Wno-attributes -pthread -std=c++17 "$ROOT/app/src/main/cpp/fakeinput_steam.cpp" \
|
||||
-ldl -static-libstdc++ -o "$PACK/preload/libfakeinput.so"
|
||||
"$CC" -shared -fPIC -O2 -Wall "$HERE/notag.c" -ldl -o "$PACK/preload/libnotag.so"
|
||||
"$CC" -shared -fPIC -O2 -Wall "$HERE/execshim.c" -ldl -o "$PACK/preload/libexecshim.so"
|
||||
"$CC" -O2 -Wall "$HERE/gstag.c" -o "$PACK/bin/gstag"
|
||||
"$STRIP" --strip-unneeded "$PACK/layer/"*.so "$PACK/preload/"*.so "$PACK/bin/gstag"
|
||||
|
||||
@@ -151,3 +161,40 @@ cp "$HERE/NOTICE" "$PACK/NOTICE"
|
||||
tar --zstd -cf "$OUT/droiddeck-bionic-runtime-$REV.tar.zst" -C "$WORK" droiddeck-bionic-runtime
|
||||
(cd "$OUT" && sha256sum "droiddeck-bionic-runtime-$REV.tar.zst" > "droiddeck-bionic-runtime-$REV.tar.zst.sha256")
|
||||
du -sh "$PACK" "$OUT"/*.tar.zst
|
||||
|
||||
echo "== DroidDeck-Bionic tool: layer + this pack + FEX + DXVK/VKD3D + tool scripts, in Proton's layout"
|
||||
NAME="DroidDeck-Bionic-$LAYER_VERSION-r${BUILD_NUMBER:-0}"
|
||||
T="$WORK/tool/$NAME"
|
||||
mkdir -p "$T/files" "$T/bionic"
|
||||
tar --zstd -xf "$WORK/layer.wcp" -C "$T/files" bin lib share prefixPack.txz
|
||||
mkdir -p "$WORK/pfx" && tar -xJf "$T/files/prefixPack.txz" -C "$WORK/pfx" && rm "$T/files/prefixPack.txz"
|
||||
mv "$WORK/pfx/.wine" "$T/files/default_pfx"
|
||||
# the template's drives point into Winlator: keep C:, Z: is the Android root (Wine sees Android paths here)
|
||||
rm -f "$T/files/default_pfx/dosdevices/"* "$T/files/default_pfx/dosdevices/".[!.]*
|
||||
ln -s ../drive_c "$T/files/default_pfx/dosdevices/c:"
|
||||
ln -s / "$T/files/default_pfx/dosdevices/z:"
|
||||
for c in FEX:"$FEX_URL":"$FEX_SHA256" DXVK:"$DXVK_URL":"$DXVK_SHA256" VKD3D:"$VKD3D_URL":"$VKD3D_SHA256"; do
|
||||
n=${c%%:*}; rest=${c#*:}; sha=${rest##*:}; url=${rest%:*}
|
||||
fetch "$url" "$sha" "$WORK/$n.wcp"
|
||||
mkdir -p "$WORK/$n" && tar --zstd -xf "$WORK/$n.wcp" -C "$WORK/$n"
|
||||
done
|
||||
cp "$WORK/FEX/aarch64-unix/"*.so "$T/files/lib/wine/aarch64-unix/"
|
||||
cp "$WORK/FEX/system32/"*.dll "$T/files/lib/wine/aarch64-windows/"
|
||||
cp -r "$WORK/DXVK/files/lib/wine/dxvk" "$WORK/VKD3D/files/lib/wine/vkd3d-proton" "$T/files/lib/wine/"
|
||||
cp -a "$PACK" "$T/files/runtime"
|
||||
install -m 755 "$HERE/tool/proton" "$T/proton"
|
||||
install -m 755 "$HERE/tool/launch.sh" "$T/bionic/launch.sh"
|
||||
cp "$HERE/tool/desktop.reg" "$T/bionic/"
|
||||
cp "$HERE/tool/toolmanifest.vdf" "$T/"
|
||||
sed -e "s/@NAME@/$NAME/" -e "s/@DISPLAY@/DroidDeck-Bionic $LAYER_VERSION r${BUILD_NUMBER:-0}/" "$HERE/tool/compatibilitytool.vdf.in" > "$T/compatibilitytool.vdf"
|
||||
echo "$(date -u +%s) $NAME" > "$T/version"
|
||||
{
|
||||
echo "$NAME: DroidDeck runtime pack $REV + layer + FEX/DXVK/VKD3D"
|
||||
echo "fex $FEX_URL sha256 $FEX_SHA256"
|
||||
echo "dxvk $DXVK_URL sha256 $DXVK_SHA256"
|
||||
echo "vkd3d $VKD3D_URL sha256 $VKD3D_SHA256"
|
||||
} > "$T/SOURCES.txt"
|
||||
python3 "$HERE/check-needed.py" "$READELF" "$T/files" --available "$T/files/lib"
|
||||
tar -C "$WORK/tool" -cf - "$NAME" | xz -T0 -6 > "$OUT/$NAME-aarch64.tar.xz"
|
||||
(cd "$OUT" && sha512sum "$NAME-aarch64.tar.xz" > "$NAME-aarch64.sha512sum")
|
||||
du -sh "$T" "$OUT/$NAME-aarch64.tar.xz"
|
||||
@@ -0,0 +1,195 @@
|
||||
// execshim: preloaded into the bionic Wine processes. From targetSdk 29 Android refuses execve() of files in the
|
||||
// app's data directory, but the system linker still starts them: "/system/bin/linker64 <file> [args]". So an
|
||||
// execve()/posix_spawn() of a dynamic ELF under /data whose interpreter is /system/bin/linker64 becomes a linker64
|
||||
// start, and a "#!" script there becomes a start of its interpreter. Static ELFs (wine-preloader) and everything
|
||||
// else pass through unchanged: where Android refuses them, Wine falls back to its loader, as on any failed exec.
|
||||
// A program started that way sees /proc/self/exe as linker64; wineserver looks for its NLS files next to its own
|
||||
// executable (server/unicode.c get_nls_dir), so realpath()/readlink() of /proc/self/exe answer with the program
|
||||
// linker64 runs (the second /proc/self/cmdline entry).
|
||||
#define _GNU_SOURCE
|
||||
#include <dlfcn.h>
|
||||
#include <elf.h>
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <limits.h>
|
||||
#if __has_include(<spawn.h>)
|
||||
#include <spawn.h>
|
||||
#else // old Android headers (e.g. Termux's): bionic's own definitions, both opaque pointers
|
||||
typedef struct __posix_spawnattr *posix_spawnattr_t;
|
||||
typedef struct __posix_spawn_file_actions *posix_spawn_file_actions_t;
|
||||
#endif
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#define LINKER "/system/bin/linker64"
|
||||
|
||||
enum kind { PASS, VIA_LINKER, VIA_INTERP };
|
||||
|
||||
// What starting `path` needs; for scripts, the interpreter and its optional argument.
|
||||
static enum kind classify(const char *path, char *resolved, char *interp, char *iarg) {
|
||||
if (!path || !realpath(path, resolved) || strncmp(resolved, "/data/", 6) != 0) return PASS;
|
||||
int fd = open(resolved, O_RDONLY | O_CLOEXEC);
|
||||
if (fd < 0) return PASS;
|
||||
enum kind k = PASS;
|
||||
unsigned char head[256];
|
||||
ssize_t n = pread(fd, head, sizeof head, 0);
|
||||
if (n >= (ssize_t)sizeof(Elf64_Ehdr) && memcmp(head, ELFMAG, SELFMAG) == 0 && head[EI_CLASS] == ELFCLASS64) {
|
||||
Elf64_Ehdr eh;
|
||||
memcpy(&eh, head, sizeof eh);
|
||||
for (int i = 0; i < eh.e_phnum && k == PASS; i++) {
|
||||
Elf64_Phdr ph;
|
||||
if (pread(fd, &ph, sizeof ph, (off_t)(eh.e_phoff + (Elf64_Off)i * eh.e_phentsize)) != sizeof ph) break;
|
||||
if (ph.p_type != PT_INTERP || ph.p_filesz == 0 || ph.p_filesz >= PATH_MAX) continue;
|
||||
char name[PATH_MAX] = {0};
|
||||
if (pread(fd, name, ph.p_filesz, (off_t)ph.p_offset) == (ssize_t)ph.p_filesz && strcmp(name, LINKER) == 0)
|
||||
k = VIA_LINKER;
|
||||
}
|
||||
} else if (n > 2 && head[0] == '#' && head[1] == '!') {
|
||||
char line[256];
|
||||
size_t len = 0;
|
||||
for (ssize_t i = 2; i < n && head[i] != '\n' && len < sizeof line - 1; i++) line[len++] = (char)head[i];
|
||||
line[len] = 0;
|
||||
char *p = line;
|
||||
while (*p == ' ' || *p == '\t') p++;
|
||||
char *end = p;
|
||||
while (*end && *end != ' ' && *end != '\t') end++;
|
||||
char *rest = *end ? end + 1 : end;
|
||||
*end = 0;
|
||||
while (*rest == ' ' || *rest == '\t') rest++;
|
||||
size_t rl = strlen(rest);
|
||||
while (rl && (rest[rl - 1] == ' ' || rest[rl - 1] == '\t' || rest[rl - 1] == '\r')) rest[--rl] = 0;
|
||||
if (*p) {
|
||||
strcpy(interp, p);
|
||||
strcpy(iarg, rest);
|
||||
k = VIA_INTERP;
|
||||
}
|
||||
}
|
||||
close(fd);
|
||||
return k;
|
||||
}
|
||||
|
||||
static int argc_of(char *const argv[]) {
|
||||
int n = 0;
|
||||
while (argv && argv[n]) n++;
|
||||
return n;
|
||||
}
|
||||
|
||||
// New argv for the rewritten start; *file is what to start. NULL when nothing changes.
|
||||
static char **rewrite(const char *path, char *const argv[], const char **file, char *storage) {
|
||||
char *resolved = storage, *interp = storage + PATH_MAX, *iarg = storage + 2 * PATH_MAX;
|
||||
enum kind k = classify(path, resolved, interp, iarg);
|
||||
if (k == PASS) return NULL;
|
||||
int argc = argc_of(argv);
|
||||
char **out = calloc((size_t)argc + 4, sizeof *out);
|
||||
if (!out) return NULL;
|
||||
int j = 0;
|
||||
if (k == VIA_LINKER) {
|
||||
*file = LINKER;
|
||||
out[j++] = (char *)LINKER;
|
||||
out[j++] = resolved;
|
||||
} else {
|
||||
// the interpreter may itself live in app data
|
||||
char *iresolved = storage + 3 * PATH_MAX, *x = storage + 4 * PATH_MAX, *y = storage + 5 * PATH_MAX;
|
||||
if (classify(interp, iresolved, x, y) == VIA_LINKER) {
|
||||
*file = LINKER;
|
||||
out[j++] = (char *)LINKER;
|
||||
out[j++] = iresolved;
|
||||
} else {
|
||||
*file = interp;
|
||||
out[j++] = interp;
|
||||
}
|
||||
if (*iarg) out[j++] = iarg;
|
||||
out[j++] = resolved;
|
||||
}
|
||||
for (int i = 1; i < argc; i++) out[j++] = argv[i];
|
||||
out[j] = NULL;
|
||||
return out;
|
||||
}
|
||||
|
||||
static ssize_t (*real_readlink)(const char *, char *, size_t);
|
||||
|
||||
// The program linker64 runs, when this process is such a start; 0 otherwise.
|
||||
static int linker_program(char *out, size_t n) {
|
||||
if (!real_readlink) real_readlink = (ssize_t (*)(const char *, char *, size_t))dlsym(RTLD_NEXT, "readlink");
|
||||
char link[PATH_MAX];
|
||||
ssize_t l = real_readlink("/proc/self/exe", link, sizeof link - 1);
|
||||
if (l <= 0) return 0;
|
||||
link[l] = 0;
|
||||
const char *base = strrchr(link, '/'); // /system/bin/linker64 is a link into /apex/com.android.runtime/bin
|
||||
if (strcmp(base ? base + 1 : link, "linker64") != 0) return 0;
|
||||
int fd = open("/proc/self/cmdline", O_RDONLY | O_CLOEXEC);
|
||||
if (fd < 0) return 0;
|
||||
char buf[2 * PATH_MAX];
|
||||
ssize_t got = read(fd, buf, sizeof buf - 1);
|
||||
close(fd);
|
||||
if (got <= 0) return 0;
|
||||
buf[got] = 0;
|
||||
size_t first = strlen(buf);
|
||||
if ((ssize_t)first + 1 >= got || !buf[first + 1] || strlen(buf + first + 1) >= n) return 0;
|
||||
strcpy(out, buf + first + 1);
|
||||
return 1;
|
||||
}
|
||||
|
||||
char *realpath(const char *path, char *resolved) {
|
||||
static char *(*real)(const char *, char *);
|
||||
if (!real) real = (char *(*)(const char *, char *))dlsym(RTLD_NEXT, "realpath");
|
||||
char prog[PATH_MAX];
|
||||
if (path && strcmp(path, "/proc/self/exe") == 0 && linker_program(prog, sizeof prog)) return real(prog, resolved);
|
||||
return real(path, resolved);
|
||||
}
|
||||
|
||||
ssize_t readlink(const char *path, char *buf, size_t size) {
|
||||
char prog[PATH_MAX], full[PATH_MAX];
|
||||
if (path && strcmp(path, "/proc/self/exe") == 0 && linker_program(prog, sizeof prog)) {
|
||||
static char *(*real_rp)(const char *, char *);
|
||||
if (!real_rp) real_rp = (char *(*)(const char *, char *))dlsym(RTLD_NEXT, "realpath");
|
||||
if (real_rp(prog, full)) {
|
||||
size_t l = strlen(full);
|
||||
if (l > size) l = size;
|
||||
memcpy(buf, full, l);
|
||||
return (ssize_t)l;
|
||||
}
|
||||
}
|
||||
if (!real_readlink) real_readlink = (ssize_t (*)(const char *, char *, size_t))dlsym(RTLD_NEXT, "readlink");
|
||||
return real_readlink(path, buf, size);
|
||||
}
|
||||
|
||||
int execve(const char *path, char *const argv[], char *const envp[]) {
|
||||
static int (*real)(const char *, char *const[], char *const[]);
|
||||
if (!real) real = (int (*)(const char *, char *const[], char *const[]))dlsym(RTLD_NEXT, "execve");
|
||||
char storage[6 * PATH_MAX]; // stack only: this may run in posix_spawn's vfork-like child (where it passes)
|
||||
const char *file = path;
|
||||
char **args = rewrite(path, argv, &file, storage);
|
||||
int ret = real(file, args ? args : argv, envp);
|
||||
int saved = errno;
|
||||
free(args);
|
||||
errno = saved;
|
||||
return ret;
|
||||
}
|
||||
|
||||
int posix_spawn(pid_t *pid, const char *path, const posix_spawn_file_actions_t *actions,
|
||||
const posix_spawnattr_t *attr, char *const argv[], char *const envp[]) {
|
||||
static int (*real)(pid_t *, const char *, const posix_spawn_file_actions_t *, const posix_spawnattr_t *,
|
||||
char *const[], char *const[]);
|
||||
if (!real)
|
||||
real = (int (*)(pid_t *, const char *, const posix_spawn_file_actions_t *, const posix_spawnattr_t *,
|
||||
char *const[], char *const[]))dlsym(RTLD_NEXT, "posix_spawn");
|
||||
char storage[6 * PATH_MAX];
|
||||
const char *file = path;
|
||||
char **args = rewrite(path, argv, &file, storage);
|
||||
int ret = real(pid, file, actions, attr, args ? args : argv, envp);
|
||||
free(args);
|
||||
return ret;
|
||||
}
|
||||
|
||||
int posix_spawnp(pid_t *pid, const char *file, const posix_spawn_file_actions_t *actions,
|
||||
const posix_spawnattr_t *attr, char *const argv[], char *const envp[]) {
|
||||
static int (*real)(pid_t *, const char *, const posix_spawn_file_actions_t *, const posix_spawnattr_t *,
|
||||
char *const[], char *const[]);
|
||||
if (strchr(file, '/')) return posix_spawn(pid, file, actions, attr, argv, envp);
|
||||
if (!real)
|
||||
real = (int (*)(pid_t *, const char *, const posix_spawn_file_actions_t *, const posix_spawnattr_t *,
|
||||
char *const[], char *const[]))dlsym(RTLD_NEXT, "posix_spawnp");
|
||||
return real(pid, file, actions, attr, argv, envp);
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
"compatibilitytools"
|
||||
{
|
||||
"compat_tools"
|
||||
{
|
||||
"@NAME@"
|
||||
{
|
||||
"install_path" "."
|
||||
"display_name" "@DISPLAY@"
|
||||
"from_oslist" "windows"
|
||||
"to_oslist" "linux"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
Windows Registry Editor Version 5.00
|
||||
|
||||
; Wine's desktop as a black screen behind games: background colour, and no shell/taskbar or tray on the
|
||||
; "Default" virtual desktop launch.sh starts.
|
||||
[HKEY_CURRENT_USER\Control Panel\Colors]
|
||||
"Background"="0 0 0"
|
||||
|
||||
[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\ThemeManager\Control Panel\Colors]
|
||||
"Background"="0 0 0"
|
||||
|
||||
[HKEY_CURRENT_USER\Software\Wine\Explorer\Desktops\Default]
|
||||
"EnableShell"=dword:00000000
|
||||
"ShowSystray"=dword:00000000
|
||||
@@ -0,0 +1,162 @@
|
||||
#!/system/bin/sh
|
||||
# DroidDeck-Bionic launcher, Android side. ../proton calls it: launch.sh <verb> <compatdata dir> <exe> [args...]
|
||||
# Runs <exe> on the bionic Proton layer in ../files with the prefix <compatdata>/pfx, inside DroidDeck's
|
||||
# gamescope session. Every program from app data starts through /system/bin/linker64 (targetSdk 29+ refuses
|
||||
# execve of app data files); the runtime pack's execshim does the same for Wine's own starts.
|
||||
verb=$1; COMPAT=$2; EXE=$3
|
||||
shift 3
|
||||
TOOL=$(cd "$(dirname "$0")/.." && pwd)
|
||||
F=$TOOL/files
|
||||
PACK=$F/runtime
|
||||
ROOTFS=${DROIDDECK_BIONIC_ROOT:?started without DROIDDECK_BIONIC_ROOT}
|
||||
APP=${ROOTFS%/linuxfs}
|
||||
LINKER=/system/bin/linker64
|
||||
VERSION=$(awk '{print $2}' "$TOOL/version" 2>/dev/null)
|
||||
|
||||
mkdir -p "$COMPAT"
|
||||
LOG=$COMPAT/droiddeck-bionic.log
|
||||
[ "$verb" = runinprefix ] || { [ -f "$LOG" ] && mv -f "$LOG" "$LOG.1"; }
|
||||
exec >> "$LOG" 2>&1
|
||||
echo "$(date +%H:%M:%S) $verb $EXE ($VERSION, uid $(id -u))"
|
||||
|
||||
# Keep Steam's game identity and DroidDeck's input/display settings; drop the glibc guest's environment.
|
||||
for v in $(env | sed -n 's/^\([A-Za-z_][A-Za-z0-9_]*\)=.*/\1/p'); do
|
||||
case "$v" in
|
||||
SteamAppId|SteamGameId|SteamOverlayGameId|SteamClientLaunch|SteamEnv|SteamAppUser|SteamUser|STEAM_COMPAT_*) ;;
|
||||
ANDROID_*|BOOTCLASSPATH|DEX2OATBOOTCLASSPATH|SYSTEMSERVERCLASSPATH|EXTERNAL_STORAGE|ASEC_MOUNTPOINT) ;;
|
||||
FAKE_*|SDL_*|BL_WIDTH|BL_HEIGHT|BL_VK_DRIVER|WINEDLLOVERRIDES) ;;
|
||||
*) unset "$v" 2>/dev/null ;;
|
||||
esac
|
||||
done
|
||||
export PATH=/system/bin:/system/xbin
|
||||
export HOME=$COMPAT WINEPREFIX=$COMPAT/pfx TMPDIR=$ROOTFS/tmp LANG=en_US.UTF-8 DISPLAY=:0
|
||||
# Proton's user name: the same C:\users\steamuser (saves, settings) as DroidDeck-Proton in a shared prefix
|
||||
export USER=steamuser LOGNAME=steamuser
|
||||
|
||||
# Graphics: DroidDeck's chosen Turnip (its Android half) through Bannerlator's Wayland adapter, and gamescope's
|
||||
# WSI layer handing the swapchain to gamescope (zero copy).
|
||||
DRVDIR=$APP/graphics_driver/$(basename "$(dirname "${BL_VK_DRIVER:-/x/none/icd.json}")")
|
||||
if [ ! -f "$DRVDIR/libvulkan_freedreno.so" ]; then
|
||||
for d in "$APP"/graphics_driver/*/; do [ -f "$d/libvulkan_freedreno.so" ] && { DRVDIR=${d%/}; break; }; done
|
||||
fi
|
||||
echo "driver $DRVDIR"
|
||||
RTD=$APP/.wayland-rt
|
||||
export VK_ICD_FILENAMES=$PACK/adapter/icd.json ADRENOTOOLS_DRIVER_PATH=$DRVDIR/ ADRENOTOOLS_HOOKS_PATH=$PACK/lib
|
||||
export ADRENOTOOLS_DRIVER_NAME=libvulkan_freedreno.so
|
||||
export VK_ADD_IMPLICIT_LAYER_PATH=$PACK/layer ENABLE_GAMESCOPE_WSI=1 GAMESCOPE_WAYLAND_DISPLAY=gamescope-0
|
||||
export XDG_RUNTIME_DIR=$RTD DROIDDECK_WSI_BYPASS_CHECK_MS=100 GAMESCOPE_WSI_FORCE_BYPASS=1
|
||||
[ -e "$RTD/droiddeck-gamescope-limiter" ] && export GAMESCOPE_LIMITER_FILE=$RTD/droiddeck-gamescope-limiter
|
||||
|
||||
# Wine: DXVK/VKD3D over the builtins, X11 inside gamescope (winewayland would pick DroidDeck's compositor),
|
||||
# FEX for x86 code, userspace ntsync (no /dev/ntsync on Android), Valve's Android Steam client library.
|
||||
export WINEDLLOVERRIDES="${WINEDLLOVERRIDES:+$WINEDLLOVERRIDES;}d3d9,d3d10core,d3d11,dxgi,d3d12,d3d12core=n,b;winewayland.drv=d"
|
||||
export HODLL=libwow64fex.dll WINENTSYNC=1 WINEESYNC=1 WINEDEBUG=err+all,fixme-all
|
||||
export WINESTEAMCLIENTPATH64=$ROOTFS/root/.local/share/Steam/androidarm64/libsteamclient.so
|
||||
export DXVK_LOG_PATH=$COMPAT PULSE_SERVER=unix:$APP/pulseaudio/PS0
|
||||
export ANDROID_SYSVSHM_SERVER=$COMPAT/.no-sysvshm-server # its client faults on an unset name, inside a Wine lock
|
||||
|
||||
# The pack's imagefs libraries carry Winlator's prefix for plugins and X11 data. No FONTCONFIG_*: with the
|
||||
# imagefs fonts.conf (Android's /system/fonts) DiRT Showdown quit right after start.
|
||||
export GST_PLUGIN_SYSTEM_PATH=$PACK/lib/gstreamer-1.0 GST_REGISTRY=$COMPAT/gst-registry.bin GST_REGISTRY_FORK=no
|
||||
export XLOCALEDIR=$PACK/share/X11/locale XKB_CONFIG_ROOT=$PACK/share/X11/xkb
|
||||
export SSL_CERT_FILE=$PACK/etc/tls/cert.pem SSL_CERT_DIR=$PACK/etc/tls/certs OPENSSL_CONF=$PACK/etc/tls/openssl.cnf
|
||||
export WINE_ADDITIONAL_CERTS_DIR=$PACK/etc/tls/cert.pem
|
||||
|
||||
# Controller: the bionic winebus has no udev bus, so Steam's virtual pad is shown to it as an Xbox 360 pad;
|
||||
# Steam's ignore list names that id because of the built-in pad, which Wine does not see here.
|
||||
export FAKE_EVDEV_STEAM_PAD_AS_X360=1
|
||||
export SDL_GAMECONTROLLER_IGNORE_DEVICES="$(echo "${SDL_GAMECONTROLLER_IGNORE_DEVICES:-}" | sed -e 's#0x045e/0x028e,##' -e 's#,0x045e/0x028e$##')"
|
||||
|
||||
LIBS=$F/lib:$PACK/lib:/system/lib64
|
||||
PRELOAD=$PACK/preload/libexecshim.so:$PACK/preload/libnotag.so:$PACK/preload/libfakeinput.so
|
||||
wine_() { LD_LIBRARY_PATH=$LIBS LD_PRELOAD=$PRELOAD "$LINKER" "$F/lib/wine/aarch64-unix/wine" "$@"; }
|
||||
wineserver_() { LD_LIBRARY_PATH=$LIBS LD_PRELOAD=$PRELOAD "$LINKER" "$F/bin/wineserver" "$@"; }
|
||||
|
||||
is_builtin() { head -c 128 "$1" 2>/dev/null | grep -q "Wine builtin DLL"; }
|
||||
link_dir() { # src dst: links every file of src into dst; replaces links and Wine builtin copies, keeps native DLLs
|
||||
[ -d "$1" ] || return 0
|
||||
for f in "$1"/*; do
|
||||
[ -f "$f" ] || continue
|
||||
t=$2/${f##*/}
|
||||
if [ -L "$t" ]; then
|
||||
[ "$(readlink "$t")" = "$f" ] && continue
|
||||
rm -f "$t"
|
||||
elif [ -e "$t" ]; then
|
||||
is_builtin "$t" || continue
|
||||
rm -f "$t"
|
||||
fi
|
||||
ln -s "$f" "$t"
|
||||
done
|
||||
}
|
||||
winpath() { echo "Z:$1" | sed 's#/#\\#g'; }
|
||||
|
||||
# The prefix carries this tool's builtins when it was last set up by this version; another Proton (or an
|
||||
# older DroidDeck-Bionic) leaves its own links there, and the compatdata version file tells DroidDeck-Proton
|
||||
# to relink when it runs this prefix again.
|
||||
prepare_prefix() {
|
||||
P=$COMPAT/pfx
|
||||
if [ -f "$P/.droiddeck-bionic" ] && [ "$(cat "$P/.droiddeck-bionic")" = "$VERSION" ] && \
|
||||
[ "$(cat "$COMPAT/version" 2>/dev/null)" = "$VERSION" ]; then return 0; fi
|
||||
if [ ! -f "$P/system.reg" ]; then
|
||||
echo "$(date +%H:%M:%S) new prefix from the layer's template"
|
||||
mkdir -p "$P" && cp -a "$F/default_pfx/." "$P/"
|
||||
fi
|
||||
W=$P/drive_c/windows
|
||||
mkdir -p "$W/system32" "$W/syswow64" "$P/dosdevices"
|
||||
echo "$(date +%H:%M:%S) linking builtins"
|
||||
link_dir "$F/lib/wine/aarch64-windows" "$W/system32"
|
||||
link_dir "$F/lib/wine/i386-windows" "$W/syswow64"
|
||||
for c in dxvk vkd3d-proton; do
|
||||
link_dir "$F/lib/wine/$c/aarch64-windows" "$W/system32"
|
||||
link_dir "$F/lib/wine/$c/i386-windows" "$W/syswow64"
|
||||
done
|
||||
# This layer's Wine always uses the profile C:\users\xuser, Proton's is C:\users\steamuser: one links to the
|
||||
# other so saves and settings are the same whichever tool runs the game.
|
||||
U=$P/drive_c/users
|
||||
if [ -d "$U/steamuser" ] && [ ! -e "$U/xuser" ]; then ln -s steamuser "$U/xuser"
|
||||
elif [ -d "$U/xuser" ] && [ ! -L "$U/xuser" ] && [ ! -e "$U/steamuser" ]; then ln -s xuser "$U/steamuser"; fi
|
||||
[ -e "$P/dosdevices/c:" ] || ln -s ../drive_c "$P/dosdevices/c:"
|
||||
[ -e "$P/dosdevices/z:" ] || ln -s / "$P/dosdevices/z:"
|
||||
wine_ regedit /S "$(winpath "$TOOL/bionic/desktop.reg")"
|
||||
wineserver_ -w
|
||||
echo "$VERSION" > "$P/.droiddeck-bionic"
|
||||
echo "$VERSION" > "$COMPAT/version"
|
||||
echo "$(date +%H:%M:%S) prefix ready"
|
||||
}
|
||||
|
||||
stop_wine() { # wineserver -k, then whatever of this prefix is left (e.g. a game's crash reporter)
|
||||
wineserver_ -k 2>/dev/null
|
||||
sleep 1
|
||||
for p in /proc/[0-9]*; do
|
||||
tr '\0' '\n' < "$p/environ" 2>/dev/null | grep -qx "WINEPREFIX=$COMPAT/pfx" || continue
|
||||
[ "${p#/proc/}" = "$$" ] && continue
|
||||
echo "$(date +%H:%M:%S) left over: ${p#/proc/} $(cat "$p/comm" 2>/dev/null)"
|
||||
kill -9 "${p#/proc/}" 2>/dev/null
|
||||
done
|
||||
}
|
||||
|
||||
prepare_prefix
|
||||
cd "$(dirname "$EXE")" || exit 1
|
||||
|
||||
if [ "$verb" = runinprefix ]; then
|
||||
wine_ "$EXE" "$@"
|
||||
exit $?
|
||||
fi
|
||||
|
||||
name=${EXE##*/}
|
||||
comm=$(echo "$name" | cut -c1-15)
|
||||
game_pids() { grep -lx "$comm" /proc/[0-9]*/comm 2>/dev/null | cut -d/ -f3; }
|
||||
wine_ explorer /desktop=Default,${BL_WIDTH:-1280}x${BL_HEIGHT:-720} "$name" "$@" &
|
||||
WP=$!
|
||||
# Steam's overlay library marks a game's windows with the app ID Steam tracks (STEAM_GAME); that library is
|
||||
# glibc-only, so tag Wine's desktop window from outside, or gamescope never shows it.
|
||||
[ "${SteamAppId:-0}" != 0 ] && "$LINKER" "$PACK/bin/gstag" 0 "$SteamAppId" explorer.exe 86400 $WP > "$COMPAT/gstag.log" 2>&1 &
|
||||
trap 'echo "$(date +%H:%M:%S) stopped by Steam"; stop_wine; exit 0' TERM INT HUP
|
||||
n=0
|
||||
while [ $n -lt 90 ] && [ -z "$(game_pids)" ]; do sleep 1; n=$((n + 1)); done
|
||||
echo "$(date +%H:%M:%S) game process $(game_pids | tr '\n' ' ')after ${n}s"
|
||||
while [ -n "$(game_pids)" ]; do sleep 2; done
|
||||
echo "$(date +%H:%M:%S) game exited"
|
||||
stop_wine
|
||||
wait $WP
|
||||
echo "$(date +%H:%M:%S) done"
|
||||
@@ -0,0 +1,46 @@
|
||||
#!/bin/bash
|
||||
# DroidDeck-Bionic: a Steam compatibility tool that runs Windows games on the bionic (Android libc) Proton layer
|
||||
# under files/, outside the Linux userland. Steam calls it inside DroidDeck's no-proot guest; it turns guest paths
|
||||
# into Android paths and hands over to bionic/launch.sh, an Android /system/bin/sh script.
|
||||
# Verbs: run/waitforexitandrun (start the game), runinprefix (run a program in the prefix), getcompatpath/
|
||||
# getnativepath (path conversion); the rest are accepted and ignored.
|
||||
set -u
|
||||
verb=${1:-}
|
||||
[ $# -gt 0 ] && shift
|
||||
|
||||
if [ -z "${DDNATV_ROOT:-}" ]; then
|
||||
echo "DroidDeck-Bionic needs Settings > Run without proot" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# guest path -> Android path: the longest no-proot bind whose guest side starts the path, else inside the rootfs
|
||||
real() {
|
||||
local p="$1" best="" host="" b g h
|
||||
local -a binds
|
||||
IFS='|' read -r -a binds <<< "${DDNATV_BINDS:-}"
|
||||
for b in "${binds[@]}"; do
|
||||
h="${b%%:*}"; g="${b#*:}"
|
||||
case "$p" in "$g"|"$g"/*) [ ${#g} -gt ${#best} ] && { best="$g"; host="$h"; } ;; esac
|
||||
done
|
||||
if [ -n "$best" ]; then echo "$host${p#"$best"}"; return; fi
|
||||
case "$p" in /data/*|/storage/*|/sdcard/*|/system/*|/apex/*|/vendor/*) echo "$p" ;; *) echo "$DDNATV_ROOT$p" ;; esac
|
||||
}
|
||||
|
||||
here=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
|
||||
tool=$(real "$here")
|
||||
compat=$(real "${STEAM_COMPAT_DATA_PATH:-$HOME/.local/share/Steam/steamapps/compatdata/0}")
|
||||
|
||||
case "$verb" in
|
||||
run|waitforexitandrun|runinprefix)
|
||||
[ $# -gt 0 ] || exit 0
|
||||
exe=$(real "$1"); shift
|
||||
export DROIDDECK_BIONIC_ROOT="$DDNATV_ROOT"
|
||||
exec /system/bin/sh "$tool/bionic/launch.sh" "$verb" "$compat" "$exe" "$@" ;;
|
||||
getcompatpath)
|
||||
p=$(real "${1:-}")
|
||||
printf 'Z:%s\n' "${p//\//\\}" ;;
|
||||
getnativepath)
|
||||
p=${1:-}; p=${p#[Zz]:}; p=${p//\\//}
|
||||
echo "$p" ;;
|
||||
*) exit 0 ;;
|
||||
esac
|
||||
@@ -0,0 +1,5 @@
|
||||
"manifest"
|
||||
{
|
||||
"version" "2"
|
||||
"commandline" "/proton %verb%"
|
||||
}
|
||||
Reference in new issue
Block a user