Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .SRCINFO
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ pkgbase = vortex-linux
source = 0041-linux-plugin-folder-prefix.patch
source = 0042-linux-wine-prefix-setting.patch
source = 0043-linux-steam-prefix-any-library.patch
source = 0044-linux-prefix-deployment-drive.patch
source = vortex.sh
source = vortex.desktop
source = README.md
Expand Down Expand Up @@ -158,6 +159,7 @@ pkgbase = vortex-linux
sha512sums = SKIP
sha512sums = SKIP
sha512sums = SKIP
sha512sums = SKIP
sha512sums = 935db5c6cee19f2c016e67168bfae7b491044735de76c673abb3b125dd325fd5e779d7efe12ba80178d46689ae70a25e558a3fa846417d44c5f4ca256e7f4bf2
sha512sums = e3f31d298a2b674b54c7fc89fb3f06d9645fc5879a54f2ebf2ea20e9ee7ae55f1bfe3284c1f90a591d6be2d6bcd251790ddc27771d65303e7a6a56d331df4632
sha512sums = 2161dfa1cf027cdc074de7195b5f206b17ebd829ae415b9e7c9ee5f06d3952b6583030022dbe0d6e9221b5c577c411d7cd5322241f6d2299d9c886641215699b
Expand Down
2 changes: 2 additions & 0 deletions PKGBUILD
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ _patches=(
'0041-linux-plugin-folder-prefix.patch'
'0042-linux-wine-prefix-setting.patch'
'0043-linux-steam-prefix-any-library.patch'
'0044-linux-prefix-deployment-drive.patch'
)

source=(
Expand Down Expand Up @@ -223,6 +224,7 @@ sha512sums=(
'SKIP'
'SKIP'
'SKIP'
'SKIP'
# Keep integrity checks for binaries downloaded outside this repository.
'935db5c6cee19f2c016e67168bfae7b491044735de76c673abb3b125dd325fd5e779d7efe12ba80178d46689ae70a25e558a3fa846417d44c5f4ca256e7f4bf2'
'e3f31d298a2b674b54c7fc89fb3f06d9645fc5879a54f2ebf2ea20e9ee7ae55f1bfe3284c1f90a591d6be2d6bcd251790ddc27771d65303e7a6a56d331df4632'
Expand Down
366 changes: 366 additions & 0 deletions patches/0044-linux-prefix-deployment-drive.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,366 @@
diff --git a/src/renderer/src/extensions/gamemode_management/util/discovery.ts b/src/renderer/src/extensions/gamemode_management/util/discovery.ts
--- a/src/renderer/src/extensions/gamemode_management/util/discovery.ts
+++ b/src/renderer/src/extensions/gamemode_management/util/discovery.ts
@@ -22,6 +22,7 @@ import type { Normalize } from "../../../util/getNormalizeFunc";
import getNormalizeFunc from "../../../util/getNormalizeFunc";
import { getVolumePath } from "../../../util/getVolumePath";
import getVortexPath from "../../../util/getVortexPath";
+import { resolveCaseInsensitiveSync } from "../../../util/linuxCompatibility";
import { resolveNativeExecutable, resolvePlatformPath } from "../../../util/nativeExecutable";
import StarterInfo from "../../../util/StarterInfo";
import { getSafe } from "../../../util/storeHelper";
@@ -756,7 +757,10 @@ export async function suggestStagingPath(api: IExtensionApi, gameId: string): Pr
}
};

- await idModPath(modPaths[""]);
+ // On Linux, a mod path below a Windows user folder is deployed into the
+ // game's Wine/Proton prefix: suggest a folder on the drive of that prefix.
+ const modPath = resolveCaseInsensitiveSync(modPaths[""]);
+ await idModPath(modPath);
const statUserData = await fs.statAsync(getVortexPath("userData"));

let suggestion: string;
@@ -766,7 +770,7 @@ export async function suggestStagingPath(api: IExtensionApi, gameId: string): Pr
suggestion = path.join("{USERDATA}", "{game}", "mods");
} else {
// different drives, suggest path on same drive
- const volume = getVolumePath(modPaths[""]);
+ const volume = getVolumePath(modPath);
suggestion = path.join(volume, state.settings.mods.suggestInstallPathDirectory, "{game}");
}

diff --git a/src/renderer/src/extensions/hardlink_activator/index.ts b/src/renderer/src/extensions/hardlink_activator/index.ts
--- a/src/renderer/src/extensions/hardlink_activator/index.ts
+++ b/src/renderer/src/extensions/hardlink_activator/index.ts
@@ -13,6 +13,7 @@ import type { IGame } from "../../types/IGame";
import type { IState } from "../../types/IState";
import * as fs from "../../util/fs";
import { getVolumePath } from "../../util/getVolumePath";
+import { resolveCaseInsensitiveSync } from "../../util/linuxCompatibility";
import { installPathForGame } from "../../util/selectors";
import { assertPathWritable, getPathDevice } from "../../util/volume";
import type { IDiscoveryResult } from "../gamemode_management/types/IDiscoveryResult";
@@ -86,15 +87,29 @@ class DeploymentMethod extends LinkingDeployment {
return undefined;
}

+ const installationPath = installPathForGame(state, gameId);
+
+ // On Linux, a mod path below a Windows user folder (AppData, Documents, ...)
+ // is deployed into the game's Wine/Proton prefix, not into the Linux folder
+ // the game extension names. Check the folders deployment actually uses.
+ let modPath: string;
+ let stagingPath: string;
+ try {
+ modPath = resolveCaseInsensitiveSync(modPaths[typeId]);
+ stagingPath = resolveCaseInsensitiveSync(installationPath);
+ } catch (err) {
+ return { description: () => getErrorMessageOrDefault(err) };
+ }
+
try {
// A deployment path may legitimately not exist until the first file is
// deployed. In that case its nearest existing parent determines whether
// Vortex can create it.
- assertPathWritable(modPaths[typeId]);
+ assertPathWritable(modPath);
} catch {
log("info", "hardlink deployment not supported due to lack of write access", {
typeId,
- path: modPaths[typeId],
+ path: modPath,
});
return {
description: (t) => t("Can't write to output directory."),
@@ -105,28 +120,26 @@ class DeploymentMethod extends LinkingDeployment {
'write permission to "{{modPath}}".',
{
replace: {
- modPath: modPaths[typeId],
+ modPath,
},
},
),
};
}

- const installationPath = installPathForGame(state, gameId);
-
try {
- if (getPathDevice(installationPath) !== getPathDevice(modPaths[typeId])) {
+ if (getPathDevice(stagingPath) !== getPathDevice(modPath)) {
// hard links work only on the same drive
return {
description: (t) => t("Works only if mods are installed on the same drive as the game."),
order: 5,
solution: (t) => {
- let displayPath = modPaths[typeId];
+ let displayPath = modPath;
try {
- displayPath = getVolumePath(modPaths[typeId]);
+ displayPath = getVolumePath(modPath);
} catch {
log("warn", "Failed to resolve volume path", {
- path: modPaths[typeId],
+ path: modPath,
});
}
return t(
@@ -158,7 +171,7 @@ class DeploymentMethod extends LinkingDeployment {
// this can happen when managing the the game for the first time
log("info", "failed to stat. directory missing?", {
dir1: installationPath || "undefined",
- dir2: modPaths[typeId],
+ dir2: modPath,
err: util.inspect(err),
});
return {
diff --git a/src/renderer/src/extensions/hardlink_activator/prefixDeploymentTarget.test.ts b/src/renderer/src/extensions/hardlink_activator/prefixDeploymentTarget.test.ts
new file mode 100644
--- /dev/null
+++ b/src/renderer/src/extensions/hardlink_activator/prefixDeploymentTarget.test.ts
@@ -0,0 +1,129 @@
+import * as fs from "node:fs";
+import * as os from "node:os";
+import * as path from "node:path";
+
+import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
+
+import { makeRealDeploymentMethod } from "../../test-utils/builders";
+import {
+ resetCompatibilityPathCache,
+ setCompatibilityGameProvider,
+} from "../../util/compatibilityPaths";
+import type * as selectors from "../../util/selectors";
+import type * as volume from "../../util/volume";
+import type * as modSelectors from "../mod_management/selectors";
+import moveInit from "../move_activator";
+import hardlinkInit from "./index";
+
+// Real devices can't be created in a test: every path below one of these roots
+// counts as the staging folder's drive, anything else as another drive.
+const fixture = vi.hoisted(() => ({
+ stagingDrive: [] as string[],
+ staging: "",
+ modPaths: {} as Record<string, string>,
+}));
+
+vi.mock("../../util/volume", async (original) => {
+ const actual = await original<typeof volume>();
+ const nodePath = await import("node:path");
+ return {
+ ...actual,
+ getPathDevice: (input: string) =>
+ fixture.stagingDrive.some((root) => input === root || input.startsWith(root + nodePath.sep))
+ ? 1
+ : 2,
+ };
+});
+
+vi.mock("../gamemode_management/util/getGame", () => ({
+ getGame: () => ({ id: "baldursgate3", getModPaths: () => fixture.modPaths }),
+}));
+
+vi.mock("../../util/selectors", async (original) => ({
+ ...(await original<typeof selectors>()),
+ installPathForGame: () => fixture.staging,
+}));
+
+vi.mock("../mod_management/selectors", async (original) => ({
+ ...(await original<typeof modSelectors>()),
+ installPathForGame: () => fixture.staging,
+}));
+
+const identity = (input: string) => input;
+const GAME = "baldursgate3";
+
+describe.runIf(process.platform === "linux")(
+ "deployment methods on a mod path inside the game's prefix",
+ () => {
+ let home: string;
+ let prefix: string;
+ let gameDir: string;
+ let linuxModPath: string;
+ let state: any;
+
+ beforeEach(() => {
+ home = fs.mkdtempSync(path.join(os.tmpdir(), "vortex-prefix-target-"));
+ prefix = path.join(home, "steamapps/compatdata/1086940/pfx");
+ gameDir = path.join(home, "steamapps/common/Baldurs Gate 3");
+ fixture.staging = path.join(home, "staging/baldursgate3");
+ // what the game extension asks for: AppData\Local as Vortex maps it on Linux
+ linuxModPath = path.join(home, "Local/Larian Studios/Baldur's Gate 3/Mods");
+ fixture.modPaths = { "": linuxModPath };
+
+ // the game ran once through Proton, so its profile folder exists in the prefix
+ fs.mkdirSync(
+ path.join(prefix, "drive_c/users/steamuser/AppData/Local/Larian Studios/Baldur's Gate 3"),
+ { recursive: true },
+ );
+ fs.mkdirSync(gameDir, { recursive: true });
+ fs.mkdirSync(fixture.staging, { recursive: true });
+ // the staging folder, the game and the prefix share one drive; home is another
+ fixture.stagingDrive = [path.join(home, "staging"), path.join(home, "steamapps")];
+
+ vi.stubEnv("VORTEX_LINUX_APPDATA", path.join(home, ".config"));
+ vi.stubEnv("VORTEX_LINUX_LOCAL_APPDATA", path.join(home, "Local"));
+ vi.stubEnv("VORTEX_LINUX_DOCUMENTS", path.join(home, "Documents"));
+ vi.stubEnv("VORTEX_COMPAT_PREFIXES", "");
+ setCompatibilityGameProvider(() => ({ path: gameDir, environment: { WINEPREFIX: prefix } }));
+
+ state = { settings: { gameMode: { discovered: { [GAME]: { path: gameDir } } } } };
+ });
+
+ afterEach(() => {
+ setCompatibilityGameProvider(undefined);
+ resetCompatibilityPathCache();
+ vi.unstubAllEnvs();
+ fs.rmSync(home, { force: true, recursive: true });
+ });
+
+ it.each([
+ ["hardlink", hardlinkInit],
+ ["move", moveInit],
+ ])("%s deployment compares the staging drive with the prefix", (_name, init) => {
+ const method = makeRealDeploymentMethod({} as any, init);
+
+ expect(method.isSupported(state, GAME, "")).toBeUndefined();
+ });
+
+ it("still refuses hardlinks when the prefix is on another drive than staging", () => {
+ fixture.stagingDrive = [path.join(home, "staging")];
+ const method = makeRealDeploymentMethod({} as any, hardlinkInit);
+
+ const reason = method.isSupported(state, GAME, "");
+
+ expect(reason?.description(identity as any)).toMatch(/same drive/);
+ });
+
+ it("reports a missing prefix instead of a write permission problem", () => {
+ setCompatibilityGameProvider(() => ({
+ path: gameDir,
+ environment: { WINEPREFIX: path.join(home, "missing") },
+ }));
+ const method = makeRealDeploymentMethod({} as any, hardlinkInit);
+
+ const reason = method.isSupported(state, GAME, "");
+
+ expect(reason?.description(identity as any)).toMatch(/unavailable/);
+ });
+ },
+);
diff --git a/src/renderer/src/extensions/mod_management/views/Settings.tsx b/src/renderer/src/extensions/mod_management/views/Settings.tsx
--- a/src/renderer/src/extensions/mod_management/views/Settings.tsx
+++ b/src/renderer/src/extensions/mod_management/views/Settings.tsx
@@ -49,6 +49,7 @@ import * as fs from "../../../util/fs";
import getNormalizeFunc from "../../../util/getNormalizeFunc";
import { getVolumePath } from "../../../util/getVolumePath";
import getVortexPath from "../../../util/getVortexPath";
+import { resolveCaseInsensitiveSync } from "../../../util/linuxCompatibility";
import { log } from "../../../util/log";
import { showError } from "../../../util/message";
import opn from "../../../util/opn";
@@ -1054,7 +1055,9 @@ class Settings extends ComponentEx<IProps, IComponentState> {
try {
// stat the volume root rather than the full mod path — the mod directory
// may not exist yet (e.g. first-time setup), but we only need the device id
- const volume = getVolumePath(modPaths[""]);
+ // On Linux, a mod path below a Windows user folder is deployed into the
+ // game's Wine/Proton prefix: suggest a folder on the drive of that prefix.
+ const volume = getVolumePath(resolveCaseInsensitiveSync(modPaths[""]));
const [modPathStats, userDataStats] = await Promise.all([
fs.statAsync(volume),
window.api.app.getPath("userData").then((userDataPath) => fs.statAsync(userDataPath)),
diff --git a/src/renderer/src/extensions/move_activator/index.ts b/src/renderer/src/extensions/move_activator/index.ts
--- a/src/renderer/src/extensions/move_activator/index.ts
+++ b/src/renderer/src/extensions/move_activator/index.ts
@@ -1,6 +1,7 @@
import * as path from "path";
import * as util from "util";

+import { getErrorMessageOrDefault } from "@vortex/shared";
import PromiseBB from "bluebird";
import type { TFunction } from "i18next";
import type { IEntry } from "turbowalk";
@@ -12,6 +13,7 @@ import type { IGame } from "../../types/IGame";
import { UserCanceled } from "../../util/CustomErrors";
import * as fs from "../../util/fs";
import { getVolumePath } from "../../util/getVolumePath";
+import { resolveCaseInsensitiveSync } from "../../util/linuxCompatibility";
import { log } from "../../util/log";
import { assertPathWritable, getPathDevice } from "../../util/volume";
import type { IDiscoveryResult } from "../gamemode_management/types/IDiscoveryResult";
@@ -90,14 +92,28 @@ class DeploymentMethod extends LinkingDeployment {
};
}

+ // On Linux, a mod path below a Windows user folder (AppData, Documents, ...)
+ // is deployed into the game's Wine/Proton prefix, not into the Linux folder
+ // the game extension names. Check the folders deployment actually uses.
+ let modPath: string = modPaths[typeId];
+ let stagingPath: string;
+ try {
+ if (modPath !== undefined) {
+ modPath = resolveCaseInsensitiveSync(modPath);
+ }
+ stagingPath = resolveCaseInsensitiveSync(instPath);
+ } catch (err) {
+ return { description: () => getErrorMessageOrDefault(err) };
+ }
+
try {
// The output directory is commonly created during the first deployment.
// Its existing parent is the relevant permission boundary until then.
- assertPathWritable(modPaths[typeId]);
+ assertPathWritable(modPath);
} catch (err) {
log("info", "move deployment not supported due to lack of write access", {
typeId,
- path: modPaths[typeId],
+ path: modPath,
});
return {
description: (t) => t("Can't write to output directory"),
@@ -108,7 +124,7 @@ class DeploymentMethod extends LinkingDeployment {
'be given write permission to "{{modPath}}".',
{
replace: {
- modPath: modPaths[typeId],
+ modPath,
},
},
),
@@ -116,19 +132,19 @@ class DeploymentMethod extends LinkingDeployment {
}

try {
- if (getPathDevice(instPath) !== getPathDevice(modPaths[typeId])) {
+ if (getPathDevice(stagingPath) !== getPathDevice(modPath)) {
// actually we could support this but it would be so slow it wouldn't make sense

return {
description: (t) => t("Works only if mods are installed on the same drive as the game"),
order: 8,
solution: (t) => {
- let displayPath = modPaths[typeId];
+ let displayPath = modPath;
try {
- displayPath = getVolumePath(modPaths[typeId]);
+ displayPath = getVolumePath(modPath);
} catch (err) {
log("warn", "Failed to resolve volume path", {
- path: modPaths[typeId],
+ path: modPath,
});
}
return t(
@@ -160,7 +176,7 @@ class DeploymentMethod extends LinkingDeployment {
// this can happen when managing the the game for the first time
log("info", "failed to stat. directory missing?", {
dir1: instPath || "undefined",
- dir2: modPaths[typeId],
+ dir2: modPath,
err: util.inspect(err),
});
return {