mirror of
https://github.com/yuzu-emu/liftinstall.git
synced 2024-11-25 20:15:42 +01:00
Launch existing maintenance tool if it exists in the default install folder
This commit is contained in:
parent
732e344605
commit
6cae746192
31
src/main.rs
31
src/main.rs
@ -65,11 +65,13 @@ mod tasks;
|
|||||||
use installer::InstallerFramework;
|
use installer::InstallerFramework;
|
||||||
|
|
||||||
use logging::LoggingErrors;
|
use logging::LoggingErrors;
|
||||||
|
use std::path::PathBuf;
|
||||||
|
|
||||||
use clap::App;
|
use clap::App;
|
||||||
use clap::Arg;
|
use clap::Arg;
|
||||||
|
|
||||||
use config::BaseAttributes;
|
use config::BaseAttributes;
|
||||||
|
use std::process::{Command, Stdio, exit};
|
||||||
|
|
||||||
static RAW_CONFIG: &'static str = include_str!(concat!(env!("OUT_DIR"), "/bootstrap.toml"));
|
static RAW_CONFIG: &'static str = include_str!(concat!(env!("OUT_DIR"), "/bootstrap.toml"));
|
||||||
|
|
||||||
@ -106,12 +108,12 @@ fn main() {
|
|||||||
|
|
||||||
info!("{} installer", app_name);
|
info!("{} installer", app_name);
|
||||||
|
|
||||||
// Handle self-updating if needed
|
|
||||||
let current_exe = std::env::current_exe().log_expect("Current executable could not be found");
|
let current_exe = std::env::current_exe().log_expect("Current executable could not be found");
|
||||||
let current_path = current_exe
|
let current_path = current_exe
|
||||||
.parent()
|
.parent()
|
||||||
.log_expect("Parent directory of executable could not be found");
|
.log_expect("Parent directory of executable could not be found");
|
||||||
|
|
||||||
|
// Handle self-updating if needed
|
||||||
self_update::perform_swap(¤t_exe, matches.value_of("swap"));
|
self_update::perform_swap(¤t_exe, matches.value_of("swap"));
|
||||||
if let Some(new_matches) = self_update::check_args(reinterpret_app, current_path) {
|
if let Some(new_matches) = self_update::check_args(reinterpret_app, current_path) {
|
||||||
matches = new_matches;
|
matches = new_matches;
|
||||||
@ -119,15 +121,42 @@ fn main() {
|
|||||||
self_update::cleanup(current_path);
|
self_update::cleanup(current_path);
|
||||||
|
|
||||||
// Load in metadata + setup the installer framework
|
// Load in metadata + setup the installer framework
|
||||||
|
let mut fresh_install = false;
|
||||||
let metadata_file = current_path.join("metadata.json");
|
let metadata_file = current_path.join("metadata.json");
|
||||||
let mut framework = if metadata_file.exists() {
|
let mut framework = if metadata_file.exists() {
|
||||||
info!("Using pre-existing metadata file: {:?}", metadata_file);
|
info!("Using pre-existing metadata file: {:?}", metadata_file);
|
||||||
InstallerFramework::new_with_db(config, current_path).log_expect("Unable to parse metadata")
|
InstallerFramework::new_with_db(config, current_path).log_expect("Unable to parse metadata")
|
||||||
} else {
|
} else {
|
||||||
info!("Starting fresh install");
|
info!("Starting fresh install");
|
||||||
|
fresh_install = true;
|
||||||
InstallerFramework::new(config)
|
InstallerFramework::new(config)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// check for existing installs if we are running as a fresh install
|
||||||
|
let installed_path = PathBuf::from(framework.get_default_path().unwrap());
|
||||||
|
if fresh_install && installed_path.join("metadata.json").exists() {
|
||||||
|
info!("Existing install detected! Trying to launch this install instead");
|
||||||
|
// Generate installer path
|
||||||
|
let platform_extension = if cfg!(windows) {
|
||||||
|
"maintenancetool.exe"
|
||||||
|
} else {
|
||||||
|
"maintenancetool"
|
||||||
|
};
|
||||||
|
let existing = installed_path.join(platform_extension).into_os_string().into_string();
|
||||||
|
if existing.is_ok() {
|
||||||
|
info!("Launching {:?}", existing);
|
||||||
|
let success = Command::new(existing.unwrap())
|
||||||
|
.stdout(Stdio::null())
|
||||||
|
.stderr(Stdio::null())
|
||||||
|
.spawn();
|
||||||
|
if success.is_ok() {
|
||||||
|
exit(0);
|
||||||
|
} else {
|
||||||
|
error!("Unable to start existing yuzu maintenance tool. Launching old one instead");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
let is_launcher = if let Some(string) = matches.value_of("launcher") {
|
let is_launcher = if let Some(string) = matches.value_of("launcher") {
|
||||||
framework.is_launcher = true;
|
framework.is_launcher = true;
|
||||||
framework.launcher_path = Some(string.to_string());
|
framework.launcher_path = Some(string.to_string());
|
||||||
|
@ -30,7 +30,7 @@ mod natives {
|
|||||||
HANDLE, PROCESS_QUERY_INFORMATION, PROCESS_TERMINATE, PROCESS_VM_READ,
|
HANDLE, PROCESS_QUERY_INFORMATION, PROCESS_TERMINATE, PROCESS_VM_READ,
|
||||||
};
|
};
|
||||||
|
|
||||||
use widestring::{U16CString, U16CStr};
|
use widestring::{U16CString};
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
pub fn saveShortcut(
|
pub fn saveShortcut(
|
||||||
@ -65,7 +65,7 @@ mod natives {
|
|||||||
exe_path: &str,
|
exe_path: &str,
|
||||||
) -> Result<String, String> {
|
) -> Result<String, String> {
|
||||||
let mut cmd_path = [0u16; MAX_PATH + 1];
|
let mut cmd_path = [0u16; MAX_PATH + 1];
|
||||||
let result = unsafe { getDesktopFolder(cmd_path.as_mut_ptr()) };
|
let _result = unsafe { getDesktopFolder(cmd_path.as_mut_ptr()) };
|
||||||
let source_path = format!(
|
let source_path = format!(
|
||||||
"{}\\{}.lnk",
|
"{}\\{}.lnk",
|
||||||
String::from_utf16_lossy(&cmd_path[..count_u16(&cmd_path)]).as_str(),
|
String::from_utf16_lossy(&cmd_path[..count_u16(&cmd_path)]).as_str(),
|
||||||
@ -96,7 +96,7 @@ mod natives {
|
|||||||
#[allow(unsafe_code)]
|
#[allow(unsafe_code)]
|
||||||
fn create_shortcut_inner(
|
fn create_shortcut_inner(
|
||||||
source_file: String,
|
source_file: String,
|
||||||
name: &str,
|
_name: &str,
|
||||||
description: &str,
|
description: &str,
|
||||||
target: &str,
|
target: &str,
|
||||||
args: &str,
|
args: &str,
|
||||||
|
@ -13,17 +13,15 @@ use config::PackageDescription;
|
|||||||
|
|
||||||
use logging::LoggingErrors;
|
use logging::LoggingErrors;
|
||||||
|
|
||||||
use native::create_desktop_shortcut;
|
|
||||||
|
|
||||||
pub struct LaunchOnExitTask {}
|
pub struct LaunchOnExitTask {}
|
||||||
|
|
||||||
impl Task for LaunchOnExitTask {
|
impl Task for LaunchOnExitTask {
|
||||||
|
|
||||||
fn execute(
|
fn execute(
|
||||||
&mut self,
|
&mut self,
|
||||||
mut input: Vec<TaskParamType>,
|
_: Vec<TaskParamType>,
|
||||||
context: &mut InstallerFramework,
|
context: &mut InstallerFramework,
|
||||||
messenger: &dyn Fn(&TaskMessage),
|
_: &dyn Fn(&TaskMessage),
|
||||||
) -> Result<TaskParamType, String> {
|
) -> Result<TaskParamType, String> {
|
||||||
let pkg = &context.database.packages.first();
|
let pkg = &context.database.packages.first();
|
||||||
if pkg.is_none() {
|
if pkg.is_none() {
|
||||||
|
Loading…
Reference in New Issue
Block a user