Skip to content

Commit f2ff9c2

Browse files
authored
[Linux] Flatpak preparations (#515)
* WIP: added flatpak config * feat: added new flatpak config * chore: updated scripts * chore: process update * feat: updated scripts, packages and build file * update yml * chore: update config folders * chore: updated yaml and scripts * fix: custom wine search * fix: config path * feat: updated build file and scripts * chore: remove unused files * fix: config path * feat: updated build file * fix: native games should work now * fix: variables and local yml * feat: add gamemode to build file and fix flatpak home * fix: flatpak id * fix: steam compat folder and app name * fix: uncessary variable * chore: prettierignore * Delete .nvmrc * chore: update lint workflow * fix: lint
1 parent e60a7c6 commit f2ff9c2

12 files changed

Lines changed: 327 additions & 27 deletions

File tree

.github/workflows/lint.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
- uses: actions/checkout@v2
1313
- uses: actions/setup-node@v2
1414
with:
15-
node-version: '14'
15+
node-version: '16'
1616
- name: Install modules.
1717
run: yarn
1818
- name: Lint code.

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,4 @@ public/**/*.js
2929
downloads*.json
3030

3131
flatpak/build
32-
flatpak/.flatpak-builder
32+
.flatpak-builder

.prettierignore

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,4 @@ build
44
coverage
55
public/index.html
66
public/locales/
7-
flatpak/**/*
8-
flatpak/.flatpak-builder/
7+
flatpak

electron/constants.ts

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@ import {
88
logInfo,
99
LogPrefix
1010
} from './logger/logger'
11-
import { env, execPath } from 'process'
11+
import { env } from 'process'
12+
import { app } from 'electron'
13+
import { existsSync } from 'graceful-fs'
1214

1315
const configStore = new Store({
1416
cwd: 'store'
@@ -51,23 +53,20 @@ function getGOGdlBin() {
5153
const isMac = platform() === 'darwin'
5254
const isWindows = platform() === 'win32'
5355
const isLinux = platform() == 'linux'
54-
const isFlatpak = execPath === '/app/main/heroic'
56+
const isFlatpak = Boolean(env.FLATPAK_ID)
5557
const currentGameConfigVersion: GameConfigVersion = 'v0'
5658
const currentGlobalConfigVersion: GlobalConfigVersion = 'v0'
5759
const flatPakHome = env.XDG_DATA_HOME?.replace('/data', '') || homedir()
5860
const home = isFlatpak ? flatPakHome : homedir()
59-
const legendaryConfigPath = isFlatpak
60-
? `${home}/config/legendary`
61-
: `${home}/.config/legendary`
62-
const heroicFolder = isFlatpak
63-
? `${home}/config/heroic/`
64-
: `${home}/.config/heroic/`
61+
const configFolder = app.getPath('appData')
62+
const legendaryConfigPath = `${configFolder}/legendary`
63+
const heroicFolder = `${configFolder}/heroic`
6564
const { currentLogFile: currentLogFile, lastLogFile: lastLogFile } =
6665
createNewLogFileAndClearOldOnces()
67-
const heroicConfigPath = `${heroicFolder}config.json`
68-
const heroicGamesConfigPath = `${heroicFolder}GamesConfig/`
69-
const heroicToolsPath = `${heroicFolder}tools`
70-
const heroicIconFolder = `${heroicFolder}icons`
66+
const heroicConfigPath = `${heroicFolder}/config.json`
67+
const heroicGamesConfigPath = `${heroicFolder}/GamesConfig/`
68+
const heroicToolsPath = `${heroicFolder}/tools`
69+
const heroicIconFolder = `${heroicFolder}/icons`
7170
const userInfo = `${legendaryConfigPath}/user.json`
7271
const heroicInstallPath = isWindows
7372
? `${home}\\Games\\Heroic`
@@ -79,6 +78,7 @@ const iconDark = fixAsarPath(join(__dirname, '/icon-dark.png'))
7978
const iconLight = fixAsarPath(join(__dirname, '/icon-light.png'))
8079
const installed = `${legendaryConfigPath}/installed.json`
8180
const libraryPath = `${legendaryConfigPath}/metadata/`
81+
const steamCompatFolder: string = getSteamCompatFolder()
8282
const fallBackImage = 'fallback'
8383
const epicLoginUrl =
8484
'https://www.epicgames.com/id/login?redirectUrl=https%3A%2F%2Fwww.epicgames.com%2Fid%2Fapi%2Fredirect'
@@ -128,6 +128,13 @@ function fixAsarPath(origin: string): string {
128128
return origin
129129
}
130130

131+
function getSteamCompatFolder() {
132+
if (existsSync(`${home}/.var/app/com.valvesoftware.Steam/.steam/steam`)) {
133+
return `${home}/.var/app/com.valvesoftware.Steam/.steam/steam`
134+
}
135+
return `${home}/.steam/steam`
136+
}
137+
131138
const MAX_BUFFER = 25 * 1024 * 1024 // 25MB should be safe enough for big installations even on really slow internet
132139

133140
const execOptions = {
@@ -157,6 +164,7 @@ export {
157164
iconDark,
158165
iconLight,
159166
installed,
167+
isFlatpak,
160168
isMac,
161169
isWindows,
162170
isLinux,
@@ -172,5 +180,6 @@ export {
172180
fallBackImage,
173181
userInfo,
174182
weblateUrl,
175-
wikiLink
183+
wikiLink,
184+
steamCompatFolder
176185
}

electron/gog/setup.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import { GameInfo } from '../types'
1313
import { execAsync } from '../utils'
1414
import { GameConfig } from '../game_config'
1515
import { logError, logInfo, LogPrefix, logWarning } from '../logger/logger'
16-
import { home, isWindows } from '../constants'
16+
import { home, isWindows, steamCompatFolder } from '../constants'
1717
import ini from 'ini'
1818
/**
1919
* Handles setup instructions like create folders, move files, run exe, create registry entry etc...
@@ -42,7 +42,7 @@ async function setup(appName: string): Promise<void> {
4242
isCrossover && crossoverBottle ? `CX_BOTTLE=${crossoverBottle}` : ''
4343
const isProton = gameSettings.wineVersion.type === 'proton'
4444
const prefix = isProton
45-
? `STEAM_COMPAT_CLIENT_INSTALL_PATH=${home}/.steam/steam STEAM_COMPAT_DATA_PATH='${gameSettings.winePrefix
45+
? `STEAM_COMPAT_CLIENT_INSTALL_PATH=${steamCompatFolder} STEAM_COMPAT_DATA_PATH='${gameSettings.winePrefix
4646
.replaceAll("'", '')
4747
.replace('~', home)}'`
4848
: `WINEPREFIX="${gameSettings.winePrefix

electron/launcher.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ import {
1111
home,
1212
execOptions,
1313
legendaryBin,
14-
gogdlBin
14+
gogdlBin,
15+
steamCompatFolder
1516
} from './constants'
1617
import { execAsync, isEpicServiceOffline, isOnline } from './utils'
1718
import { logError, logInfo, LogPrefix, logWarning } from './logger/logger'
@@ -254,7 +255,7 @@ async function launch(
254255
? 'DRI_PRIME=1 __NV_PRIME_RENDER_OFFLOAD=1 __GLX_VENDOR_LIBRARY_NAME=nvidia'
255256
: '',
256257
proton: isProton
257-
? `STEAM_COMPAT_CLIENT_INSTALL_PATH=${home}/.steam/steam STEAM_COMPAT_DATA_PATH='${winePrefix
258+
? `STEAM_COMPAT_CLIENT_INSTALL_PATH=${steamCompatFolder} STEAM_COMPAT_DATA_PATH='${winePrefix
258259
.replaceAll("'", '')
259260
.replace('~', home)}'`
260261
: ''
Lines changed: 145 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,145 @@
1+
id: com.heroicgameslauncher.hgl
2+
sdk: org.freedesktop.Sdk
3+
runtime: org.freedesktop.Platform
4+
runtime-version: '21.08'
5+
base: org.electronjs.Electron2.BaseApp
6+
base-version: '21.08'
7+
command: heroic-run
8+
separate-locales: false
9+
10+
sdk-extensions:
11+
- org.freedesktop.Sdk.Compat.i386
12+
- org.freedesktop.Sdk.Extension.toolchain-i386
13+
14+
finish-args:
15+
- --share=ipc
16+
- --share=network
17+
- --socket=x11
18+
- --socket=wayland
19+
- --socket=pulseaudio
20+
- --allow=multiarch
21+
- --allow=devel
22+
- --device=all
23+
- --talk-name=org.freedesktop.Notifications
24+
- --persist=.wine
25+
- --filesystem=home
26+
- --filesystem=xdg-data/Steam:ro
27+
- --filesystem=~/.var/app/com.valvesoftware.Steam:ro
28+
- --require-version=1.1.2
29+
- --env=XDG_CONFIG_DIRS=/etc/xdg:/usr/lib/x86_64-linux-gnu/GL:/usr/lib/i386-linux-gnu/GL
30+
- --env=GST_PLUGIN_SYSTEM_PATH=/app/lib/gstreamer-1.0:/app/lib32/gstreamer-1.0:/usr/lib/extensions/gstreamer-1.0:/usr/lib/x86_64-linux-gnu/gstreamer-1.0:/usr/lib/i386-linux-gnu/gstreamer-1.0
31+
32+
add-extensions:
33+
org.freedesktop.Platform.Compat.i386:
34+
directory: lib/i386-linux-gnu
35+
version: '21.08'
36+
37+
org.freedesktop.Platform.Compat.i386.Debug:
38+
directory: lib/debug/lib/i386-linux-gnu
39+
version: '21.08'
40+
no-autodownload: true
41+
42+
org.freedesktop.Platform.GL32:
43+
directory: lib/i386-linux-gnu/GL
44+
version: '1.4'
45+
versions: 21.08;1.4
46+
subdirectories: true
47+
no-autodownload: true
48+
autodelete: false
49+
add-ld-path: lib
50+
merge-dirs: vulkan/icd.d;glvnd/egl_vendor.d;OpenCL/vendors;lib/dri;lib/d3d;vulkan/explicit_layer.d;vulkan/implicit_layer.d
51+
download-if: active-gl-driver
52+
enable-if: active-gl-driver
53+
54+
modules:
55+
56+
# --- Tools ---
57+
- name: unappimage
58+
buildsystem: simple
59+
build-commands:
60+
- make -C squashfs-tools -j ${FLATPAK_BUILDER_N_JOBS} install INSTALL_DIR=/app/bin
61+
sources:
62+
- type: git
63+
url: https://github.com/refi64/unappimage
64+
commit: d7f86f2a0d7ec3a69211125207d5f127386b849a
65+
66+
- name: vulkan-tools
67+
buildsystem: cmake-ninja
68+
config-opts:
69+
- -DGLSLANG_INSTALL_DIR=/app
70+
- -DVULKAN_HEADERS_INSTALL_DIR=/app
71+
- -DCMAKE_BUILD_TYPE=Release
72+
sources:
73+
- type: archive
74+
url: https://github.com/KhronosGroup/Vulkan-Tools/archive/refs/tags/v1.2.186.tar.gz
75+
sha256: 8ba0e21e8de0b70d31985d251d11150efee71266875262798784e9d1ec9b717b
76+
77+
- name: gamemode
78+
buildsystem: meson
79+
config-opts: &gamemode_opts
80+
- -Dwith-systemd=false
81+
- -Dwith-daemon=false
82+
- -Dwith-examples=false
83+
- -Dwith-util=false
84+
- -Dwith-sd-bus-provider=no-daemon
85+
sources: &gamemode_sources
86+
- type: archive
87+
url: https://github.com/FeralInteractive/gamemode/releases/download/1.6.1/gamemode-1.6.1.tar.xz
88+
sha256: 10c2a3f142eae472f5a09e42616e38c666c05b25ca3e61e562a543bb3fda66c5
89+
90+
- name: gamemode-32bit
91+
build-options:
92+
arch:
93+
x86_64: &compat_i386_opts
94+
buildsystem: meson
95+
config-opts: *gamemode_opts
96+
sources: *gamemode_sources
97+
98+
- name: gamemoderun
99+
buildsystem: simple
100+
build-commands:
101+
- install -Dm755 data/gamemoderun -t /app/bin
102+
sources: *gamemode_sources
103+
104+
# --- Heroic ---
105+
- name: heroic
106+
buildsystem: simple
107+
build-commands:
108+
- unappimage Heroic-2.2.1.AppImage
109+
- rm Heroic-2.2.1.AppImage
110+
- mv squashfs-root /app/bin/heroic
111+
- install -D heroic-run -t /app/bin
112+
sources:
113+
- type: script
114+
dest-filename: heroic-run
115+
commands:
116+
- zypak-wrapper /app/bin/heroic/heroic "$@"
117+
118+
- type: file
119+
filename: Heroic-2.2.1.AppImage
120+
url: https://github.com/Heroic-Games-Launcher/HeroicGamesLauncher/releases/download/v2.2.1/Heroic-2.2.1.AppImage
121+
sha256: cf3c5fdde3357d459356dcf3001730966a6d36e09541a7efa2d9db3a20b3bb47
122+
123+
- name: platform-bootstrap
124+
buildsystem: simple
125+
build-commands:
126+
- |
127+
set -e
128+
mkdir -p /app/bin
129+
mkdir -p /app/lib/i386-linux-gnu
130+
mkdir -p /app/lib/debug/lib/i386-linux-gnu
131+
mkdir -p /app/lib/i386-linux-gnu/GL
132+
mkdir -p /app/lib/i386-linux-gnu/dri/intel-vaapi-driver
133+
cp /usr/bin/addr2line /app/bin/
134+
cp /usr/lib/x86_64-linux-gnu/libbfd-*.so /app/lib/
135+
install -Dm644 -t /app/etc ld.so.conf
136+
mkdir -p /app/lib{,32}/ffmpeg
137+
mkdir -p /app/utils /app/share/vulkan
138+
ln -srv /app/{utils/,}share/vulkan/explicit_layer.d
139+
ln -srv /app/{utils/,}share/vulkan/implicit_layer.d
140+
mkdir -p /app/links/lib
141+
ln -srv /app/lib /app/links/lib/x86_64-linux-gnu
142+
ln -srv /app/lib32 /app/links/lib/i386-linux-gnu
143+
sources:
144+
- type: file
145+
path: ld.so.conf

flatpak/ld.so.conf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# We just make any GL32 extension have higher priority
2+
include /run/flatpak/ld.so.conf.d/app-*-org.freedesktop.Platform.GL32.*.conf
3+
/app/lib32
4+
/app/lib/i386-linux-gnu
5+
/lib64

0 commit comments

Comments
 (0)