From 13e245159bbd700955d84fcfe563896875e66adf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Lidwin?= Date: Sun, 11 Aug 2024 17:33:44 +0200 Subject: [PATCH] [TECH]: ship comet's communication service dummy with Heroic (#3923) * tech: ship comet's communication service dummy with Heroic * improv: use winepath to get unix location * add ignoreLogging to runWineCommand allowing to bypass PROTON_LOG * fix: paralel downloads for comet components --- electron-builder.yml | 8 +++- meta/downloadHelperBinaries.ts | 26 ++++++++---- public/bin/.gitignore | 1 + src/backend/launcher.ts | 60 ++++++++++++++++++--------- src/backend/wine/runtimes/runtimes.ts | 10 +---- src/common/types.ts | 7 +--- 6 files changed, 69 insertions(+), 43 deletions(-) diff --git a/electron-builder.yml b/electron-builder.yml index 653b299400..26c0c292ae 100644 --- a/electron-builder.yml +++ b/electron-builder.yml @@ -40,7 +40,9 @@ mac: teamId: DLB2RYLUDX extendInfo: com.apple.security.cs.allow-jit: true - files: build/bin/*/darwin/* + files: + - build/bin/*/darwin/* + - build/bin/x64/win32/GalaxyCommunication.exe dmg: background: public/dmg.png @@ -63,7 +65,9 @@ linux: desktop: Name: Heroic Games Launcher Comment[de]: Ein Open Source Spielelauncher for GOG und Epic Games - files: build/bin/*/linux/* + files: + - build/bin/*/linux/* + - build/bin/x64/win32/GalaxyCommunication.exe snap: base: core20 diff --git a/meta/downloadHelperBinaries.ts b/meta/downloadHelperBinaries.ts index 0db6b29671..0e3057dfcf 100644 --- a/meta/downloadHelperBinaries.ts +++ b/meta/downloadHelperBinaries.ts @@ -22,10 +22,14 @@ const pathExists = async (path: string): Promise => async function downloadFile(url: string, dst: string) { const response = await fetch(url, { + keepalive: true, headers: { 'User-Agent': 'HeroicBinaryUpdater/1.0' } }) + if (response.status !== 200) { + throw Error(`Failed to download ${url}: ${response.status}`) + } await mkdir(dirname(dst), { recursive: true }) const fileStream = createWriteStream(dst, { flags: 'w' }) await finished(Readable.fromWeb(response.body).pipe(fileStream)) @@ -139,11 +143,19 @@ async function downloadNile() { } async function downloadComet() { - return downloadGithubAssets( - 'comet', - 'imLinguin/comet', - RELEASE_TAGS['comet'], - { + return Promise.all([ + downloadGithubAssets( + 'GalaxyCommunication', + 'imLinguin/comet', + RELEASE_TAGS['comet'], + { + x64: { + win32: 'GalaxyCommunication-dummy.exe' + }, + arm64: {} + } + ), + downloadGithubAssets('comet', 'imLinguin/comet', RELEASE_TAGS['comet'], { x64: { linux: 'comet-x86_64-unknown-linux-gnu', darwin: 'comet-x86_64-apple-darwin', @@ -152,8 +164,8 @@ async function downloadComet() { arm64: { darwin: 'comet-aarch64-apple-darwin' } - } - ) + }) + ]) } /** diff --git a/public/bin/.gitignore b/public/bin/.gitignore index 7e6ab417e0..b841a68597 100644 --- a/public/bin/.gitignore +++ b/public/bin/.gitignore @@ -6,4 +6,5 @@ **/nile.exe **/comet **/comet.exe +**/GalaxyCommunication.exe .release_tags diff --git a/src/backend/launcher.ts b/src/backend/launcher.ts index beb8cd2866..be17dff684 100644 --- a/src/backend/launcher.ts +++ b/src/backend/launcher.ts @@ -30,7 +30,8 @@ import { isSteamDeckGameMode, runtimePath, userHome, - defaultUmuPath + defaultUmuPath, + publicDir } from './constants' import { constructAndUpdateRPC, @@ -81,6 +82,7 @@ import { storeMap } from 'common/utils' import { runWineCommandOnGame } from './storeManagers/legendary/games' import { sendFrontendMessage } from './main_window' import { getUmuPath, isUmuSupported } from './utils/compatibility_layers' +import { copyFile } from 'fs/promises' async function prepareLaunch( gameSettings: GameSettings, @@ -372,26 +374,38 @@ async function prepareWineLaunch( } } - if (runner === 'gog' && experimentalFeatures?.cometSupport !== false) { - if (isOnline() && !(await isInstalled('comet_dummy_service'))) { - await download('comet_dummy_service') - } - const installerScript = join( - runtimePath, - 'comet_dummy_service', - 'install-dummy-service.bat' - ) - if (existsSync(installerScript)) { - await runWineCommand({ - commandParts: [installerScript], + try { + if (runner === 'gog' && experimentalFeatures?.cometSupport !== false) { + const communicationSource = join( + publicDir, + 'bin/x64/win32/GalaxyCommunication.exe' + ) + + const galaxyCommPath = + 'C:\\ProgramData\\GOG.com\\Galaxy\\redists\\GalaxyCommunication.exe' + const communicationDest = await getWinePath({ + path: galaxyCommPath, gameSettings, - protonVerb: 'runinprefix' + variant: 'unix' }) - } else { - logWarning( - "Comet dummy service isn't downloaded, online functionality may not work" - ) + + if (!existsSync(communicationDest)) { + mkdirSync(dirname(communicationDest), { recursive: true }) + await copyFile(communicationSource, communicationDest) + await runWineCommand({ + commandParts: [ + 'sc', + 'create', + 'GalaxyCommunication', + `binpath=${galaxyCommPath}` + ], + gameSettings, + protonVerb: 'runinprefix' + }) + } } + } catch (err) { + logError('Failed to install GalaxyCommunication dummy into the prefix') } // If DXVK/VKD3D installation is enabled, install it @@ -841,7 +855,8 @@ async function runWineCommand({ installFolderName, options, startFolder, - skipPrefixCheckIKnowWhatImDoing = false + skipPrefixCheckIKnowWhatImDoing = false, + ignoreLogging = false }: WineCommandArgs): Promise<{ stderr: string stdout: string @@ -896,6 +911,10 @@ async function runWineCommand({ PROTON_VERB: protonVerb } + if (ignoreLogging) { + delete env_vars['PROTON_LOG'] + } + const wineBin = wineVersion.bin.replaceAll("'", '') const umuSupported = await isUmuSupported(wineVersion.type) const runnerBin = umuSupported ? await getUmuPath() : wineBin @@ -1345,7 +1364,8 @@ async function getWinePath({ path ], wait: false, - protonVerb: 'runinprefix' + protonVerb: 'runinprefix', + ignoreLogging: true }) return stdout.trim() } diff --git a/src/backend/wine/runtimes/runtimes.ts b/src/backend/wine/runtimes/runtimes.ts index 6557da8534..543aefcbf5 100644 --- a/src/backend/wine/runtimes/runtimes.ts +++ b/src/backend/wine/runtimes/runtimes.ts @@ -19,15 +19,7 @@ async function _get(): Promise { if (!allRuntimes.data) { logError('Failed to fetch runtime list', LogPrefix.Runtime) } - const runtimes: Runtime[] = allRuntimes.data || [] - runtimes.push({ - id: 2000, - name: 'comet_dummy_service', - architecture: 'all', - created_at: '2024-07-27T19:35:07.389453Z', - url: 'https://github.com/imLinguin/comet/releases/download/v0.1.2/dummy-service.zip' - }) - return runtimes + return allRuntimes.data || [] } async function download(name: RuntimeName): Promise { diff --git a/src/common/types.ts b/src/common/types.ts index 4525603400..678c93f458 100644 --- a/src/common/types.ts +++ b/src/common/types.ts @@ -476,11 +476,7 @@ export interface Runtime { url: string } -export type RuntimeName = - | 'eac_runtime' - | 'battleye_runtime' - | 'comet_dummy_service' - | 'umu' +export type RuntimeName = 'eac_runtime' | 'battleye_runtime' | 'umu' export type RecentGame = { appName: string @@ -591,6 +587,7 @@ export type WineCommandArgs = { options?: CallRunnerOptions startFolder?: string skipPrefixCheckIKnowWhatImDoing?: boolean + ignoreLogging?: boolean } export interface SaveSyncArgs {