basic wineprefix install

This commit is contained in:
hippoz 2021-03-23 04:23:38 +02:00
commit bc00493659
Signed by: hippoz
GPG key ID: 7C52899193467641
7 changed files with 1328 additions and 0 deletions

1
.gitignore vendored Normal file
View file

@ -0,0 +1 @@
/target

1225
Cargo.lock generated Normal file

File diff suppressed because it is too large Load diff

15
Cargo.toml Normal file
View file

@ -0,0 +1,15 @@
[package]
name = "must"
version = "0.1.0"
authors = ["hippoz <paperplanelive@gmail.com>"]
edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
serde = { version = "1.0.125", features = ["derive"] }
dirs = "3.0.1"
confy = "0.4.0"
clap = "2"
which = "4.0.2"
reqwest = { version = "0.11.2", features = ["blocking"] }

25
src/config.rs Normal file
View file

@ -0,0 +1,25 @@
extern crate dirs;
extern crate confy;
extern crate serde;
use serde::{Serialize, Deserialize};
#[derive(Serialize, Deserialize)]
pub struct MustConfig {
pub wine_prefix_path: String
}
impl std::default::Default for MustConfig {
fn default() -> Self {
let mut home = dirs::data_dir().expect("err: conf: failed to get home folder");
home.push("must-prefix");
Self {
wine_prefix_path: home.to_str().expect("err: conf: failed to get home folder").to_string()
}
}
}
pub fn get_config() -> Result<MustConfig, confy::ConfyError> {
let cfg = confy::load("must-config")?;
Ok(cfg)
}

20
src/installctl.rs Normal file
View file

@ -0,0 +1,20 @@
use std::fs::File;
use std::io::Write;
pub fn download_game_binary() {
println!("info: dl: downloading game binary");
let body = reqwest::blocking::get("http://setup.roblox.com/Roblox.exe")
.expect("err: dl: failed to send request")
.bytes()
.expect("err: dl: failed to process data");
let mut dir = std::path::PathBuf::new();
dir.push("/tmp/");
dir.push("RobloxPlayerLauncher.exe");
let mut file = File::create(dir).expect("err: dl: failed to create output file inside temporary directory");
file.write_all(&body).expect("err: dl: failed to write downloaded data to file");
println!("info: dl: game binary downloaded to temporary directory");
}

23
src/main.rs Normal file
View file

@ -0,0 +1,23 @@
extern crate clap;
extern crate reqwest;
use clap::{App, SubCommand};
mod winectl;
mod installctl;
fn main() {
let matches = App::new("must")
.version("0.1.0")
.author("hippoz <kindahippoz@gmail.com>")
.about("Simplifies the process of installing and running Roblox on Linux using WINE")
.subcommand(SubCommand::with_name("up")
.about("Installs required software and prepares environment")
)
.get_matches();
if let Some(matches) = matches.subcommand_matches("up") {
installctl::download_game_binary();
winectl::wine_launch("/tmp/RobloxPlayerLauncher.exe");
}
}

19
src/winectl.rs Normal file
View file

@ -0,0 +1,19 @@
use std::process::Command;
use std::fs;
#[path = "config.rs"]
mod config;
pub fn wine_launch(program_path: &str) {
println!("info: wine_launch: looking for wine binary");
let wine_prefix = config::get_config().expect("err: wine_launch: failed to read config").wine_prefix_path;
let wine_binary = which::which("wine").expect("err: wine_launch: failed to get wine binary path");
println!("info: wine_launch: launching program {:?} with wine {:?} in {:?}", program_path, wine_binary.to_str(), wine_prefix.to_string());
fs::create_dir_all(&wine_prefix).expect("err: wine_launch: failed to create wineprefix");
Command::new(wine_binary)
.env("WINEPREFIX", wine_prefix)
.arg(program_path)
.spawn()
.expect("err: wine_launch: failed to launch wine");
println!("info: wine_launch: done");
}