Skip to content

Commit 00ce9f0

Browse files
runner: Add function to initialize a prefix
1 parent e30183c commit 00ce9f0

File tree

4 files changed

+49
-2
lines changed

4 files changed

+49
-2
lines changed

src/runner/mod.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,4 +207,12 @@ pub trait Runner {
207207
let executable_path = self.info().executable_path();
208208
executable_path.exists() && executable_path.is_file()
209209
}
210+
211+
/// Initialize a prefix at the specified path using the runner's executable.
212+
///
213+
/// # Arguments
214+
///
215+
/// * `prefix` - Path where the new prefix should be created. The directory will be
216+
/// created if it doesn't exist.
217+
fn initialize(&self, prefix: impl AsRef<Path>) -> Result<(), Error>;
210218
}

src/runner/proton.rs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
use super::{Runner, RunnerInfo, Wine};
2-
use std::path::{Path, PathBuf};
2+
use std::{
3+
path::{Path, PathBuf},
4+
process::Command,
5+
};
36

47
/// Proton runner implementation
58
///
@@ -41,4 +44,16 @@ impl Runner for Proton {
4144
fn info_mut(&mut self) -> &mut RunnerInfo {
4245
&mut self.info
4346
}
47+
48+
fn initialize(&self, prefix: impl AsRef<Path>) -> Result<(), crate::Error> {
49+
Command::new(self.info().executable_path())
50+
.arg("run")
51+
.arg("wineboot")
52+
.env("WINEPREFIX", prefix.as_ref())
53+
.env("STEAM_COMPAT_DATA_PATH", prefix.as_ref())
54+
.env("STEAM_COMPAT_CLIENT_INSTALL_PATH", "")
55+
.output()?;
56+
57+
Ok(())
58+
}
4459
}

src/runner/umu.rs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
use super::{Proton, Runner, RunnerInfo, Wine};
2-
use std::path::{Path, PathBuf};
2+
use std::{
3+
path::{Path, PathBuf},
4+
process::Command,
5+
};
36

47
/// UMU (Unified Launcher) runner implementation
58
///
@@ -48,4 +51,14 @@ impl Runner for UMU {
4851
fn info_mut(&mut self) -> &mut RunnerInfo {
4952
&mut self.info
5053
}
54+
55+
fn initialize(&self, prefix: impl AsRef<Path>) -> Result<(), crate::Error> {
56+
let proton_path = self.proton.as_ref().unwrap().info().directory();
57+
Command::new(self.info().executable_path())
58+
.arg("wineboot") // This is wrong but it'll anyways initialize the prefix
59+
.env("WINEPREFIX", prefix.as_ref())
60+
.env("PROTONPATH", proton_path)
61+
.output()?;
62+
Ok(())
63+
}
5164
}

src/runner/wine.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use super::{Runner, RunnerInfo};
22
use std::path::{Path, PathBuf};
3+
use std::process::Command;
34

45
/// Wine runner implementation
56
///
@@ -58,4 +59,14 @@ impl Runner for Wine {
5859
fn info_mut(&mut self) -> &mut RunnerInfo {
5960
&mut self.info
6061
}
62+
63+
fn initialize(&self, prefix: impl AsRef<Path>) -> Result<(), crate::Error> {
64+
Command::new(self.info().executable_path())
65+
.arg("wineboot")
66+
.arg("--init")
67+
.env("WINEPREFIX", prefix.as_ref())
68+
.output()?;
69+
70+
Ok(())
71+
}
6172
}

0 commit comments

Comments
 (0)