mirror of
https://github.com/yuzu-emu/liftinstall.git
synced 2024-11-22 09:55:40 +01:00
platform: fix build on Linux and update web-view
This commit is contained in:
parent
f2af419b95
commit
d236eeec0c
1311
Cargo.lock
generated
1311
Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
@ -8,7 +8,7 @@ description = "An adaptable installer for your application."
|
|||||||
build = "build.rs"
|
build = "build.rs"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
web-view = {git = "https://github.com/Boscop/web-view.git", rev = "555f422d09cbb94e82a728d47e9e07ca91963f6e"}
|
web-view = "0.4.0"
|
||||||
|
|
||||||
hyper = "0.11.27"
|
hyper = "0.11.27"
|
||||||
futures = "*"
|
futures = "*"
|
||||||
|
@ -328,7 +328,8 @@ impl InstallerFramework {
|
|||||||
x.to_str()
|
x.to_str()
|
||||||
.log_expect("Unable to convert argument to String")
|
.log_expect("Unable to convert argument to String")
|
||||||
.to_string()
|
.to_string()
|
||||||
}).collect();
|
})
|
||||||
|
.collect();
|
||||||
|
|
||||||
{
|
{
|
||||||
let new_app_file = match File::create(&args_file) {
|
let new_app_file = match File::create(&args_file) {
|
||||||
|
@ -17,7 +17,8 @@ pub fn setup_logger(file_name: String) -> Result<(), fern::InitError> {
|
|||||||
record.level(),
|
record.level(),
|
||||||
message
|
message
|
||||||
))
|
))
|
||||||
}).level(log::LevelFilter::Info)
|
})
|
||||||
|
.level(log::LevelFilter::Info)
|
||||||
.chain(io::stdout())
|
.chain(io::stdout())
|
||||||
.chain(fern::log_file(file_name)?)
|
.chain(fern::log_file(file_name)?)
|
||||||
.apply()?;
|
.apply()?;
|
||||||
|
40
src/main.rs
40
src/main.rs
@ -40,7 +40,7 @@ extern crate log;
|
|||||||
extern crate chrono;
|
extern crate chrono;
|
||||||
|
|
||||||
extern crate clap;
|
extern crate clap;
|
||||||
|
#[cfg(windows)]
|
||||||
extern crate winapi;
|
extern crate winapi;
|
||||||
|
|
||||||
mod archives;
|
mod archives;
|
||||||
@ -112,7 +112,8 @@ fn main() {
|
|||||||
.value_name("TARGET")
|
.value_name("TARGET")
|
||||||
.help("Launches the specified executable after checking for updates")
|
.help("Launches the specified executable after checking for updates")
|
||||||
.takes_value(true),
|
.takes_value(true),
|
||||||
).arg(
|
)
|
||||||
|
.arg(
|
||||||
Arg::with_name("swap")
|
Arg::with_name("swap")
|
||||||
.long("swap")
|
.long("swap")
|
||||||
.value_name("TARGET")
|
.value_name("TARGET")
|
||||||
@ -280,14 +281,15 @@ fn main() {
|
|||||||
let resizable = false;
|
let resizable = false;
|
||||||
let debug = true;
|
let debug = true;
|
||||||
|
|
||||||
run(
|
web_view::builder()
|
||||||
&format!("{} Installer", app_name),
|
.title(&format!("{} Installer", app_name))
|
||||||
Content::Url(http_address),
|
.content(Content::Url(http_address))
|
||||||
Some(size),
|
.size(size.0, size.1)
|
||||||
resizable,
|
.resizable(resizable)
|
||||||
debug,
|
.debug(debug)
|
||||||
|_| {},
|
.user_data(())
|
||||||
|wv, msg, _| {
|
.invoke_handler(|wv, msg| {
|
||||||
|
let mut cb_result = Ok(());
|
||||||
let command: CallbackType =
|
let command: CallbackType =
|
||||||
serde_json::from_str(msg).log_expect(&format!("Unable to parse string: {:?}", msg));
|
serde_json::from_str(msg).log_expect(&format!("Unable to parse string: {:?}", msg));
|
||||||
|
|
||||||
@ -304,15 +306,16 @@ fn main() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
#[cfg(not(windows))]
|
#[cfg(not(windows))]
|
||||||
let result =
|
let result = wv
|
||||||
wv.dialog(Dialog::ChooseDirectory, "Select a install directory...", "");
|
.dialog()
|
||||||
|
.choose_directory("Select a install directory...", "");
|
||||||
|
|
||||||
if !result.is_empty() {
|
if result.is_ok() {
|
||||||
let result = serde_json::to_string(&result)
|
let result = serde_json::to_string(&result.ok())
|
||||||
.log_expect("Unable to serialize response");
|
.log_expect("Unable to serialize response");
|
||||||
let command = format!("{}({});", callback_name, result);
|
let command = format!("{}({});", callback_name, result);
|
||||||
debug!("Injecting response: {}", command);
|
debug!("Injecting response: {}", command);
|
||||||
wv.eval(&command);
|
cb_result = wv.eval(&command);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
CallbackType::Log { msg, kind } => {
|
CallbackType::Log { msg, kind } => {
|
||||||
@ -326,7 +329,8 @@ fn main() {
|
|||||||
log!(target: "liftinstall::frontend-js", kind, "{}", msg);
|
log!(target: "liftinstall::frontend-js", kind, "{}", msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
cb_result
|
||||||
(),
|
})
|
||||||
);
|
.run()
|
||||||
|
.expect("Unable to launch Web UI!");
|
||||||
}
|
}
|
||||||
|
@ -3,8 +3,8 @@
|
|||||||
/// Basic definition of some running process.
|
/// Basic definition of some running process.
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct Process {
|
pub struct Process {
|
||||||
pub pid : usize,
|
pub pid: usize,
|
||||||
pub name : String
|
pub name: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
@ -23,14 +23,13 @@ mod natives {
|
|||||||
use std::process::Command;
|
use std::process::Command;
|
||||||
|
|
||||||
use winapi::shared::minwindef::{DWORD, FALSE, MAX_PATH};
|
use winapi::shared::minwindef::{DWORD, FALSE, MAX_PATH};
|
||||||
|
use winapi::um::processthreadsapi::OpenProcess;
|
||||||
|
use winapi::um::psapi::{
|
||||||
|
EnumProcessModulesEx, GetModuleFileNameExW, K32EnumProcesses, LIST_MODULES_ALL,
|
||||||
|
};
|
||||||
use winapi::um::winnt::{
|
use winapi::um::winnt::{
|
||||||
HANDLE, PROCESS_QUERY_INFORMATION, PROCESS_TERMINATE, PROCESS_VM_READ,
|
HANDLE, PROCESS_QUERY_INFORMATION, PROCESS_TERMINATE, PROCESS_VM_READ,
|
||||||
};
|
};
|
||||||
use winapi::um::processthreadsapi::{OpenProcess};
|
|
||||||
use winapi::um::psapi::{
|
|
||||||
K32EnumProcesses,
|
|
||||||
EnumProcessModulesEx, GetModuleFileNameExW, LIST_MODULES_ALL,
|
|
||||||
};
|
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
pub fn saveShortcut(
|
pub fn saveShortcut(
|
||||||
@ -149,9 +148,7 @@ mod natives {
|
|||||||
|
|
||||||
let size = ::std::mem::size_of::<DWORD>() * process_ids.len();
|
let size = ::std::mem::size_of::<DWORD>() * process_ids.len();
|
||||||
unsafe {
|
unsafe {
|
||||||
if K32EnumProcesses(process_ids.as_mut_ptr(),
|
if K32EnumProcesses(process_ids.as_mut_ptr(), size as DWORD, &mut cb_needed) == 0 {
|
||||||
size as DWORD,
|
|
||||||
&mut cb_needed) == 0 {
|
|
||||||
return vec![];
|
return vec![];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -160,7 +157,7 @@ mod natives {
|
|||||||
|
|
||||||
let mut processes = Vec::new();
|
let mut processes = Vec::new();
|
||||||
|
|
||||||
for i in 0 .. nb_processes {
|
for i in 0..nb_processes {
|
||||||
let pid = process_ids[i as usize];
|
let pid = process_ids[i as usize];
|
||||||
|
|
||||||
unsafe {
|
unsafe {
|
||||||
@ -169,20 +166,25 @@ mod natives {
|
|||||||
let mut process_name = [0u16; MAX_PATH + 1];
|
let mut process_name = [0u16; MAX_PATH + 1];
|
||||||
let mut cb_needed = 0;
|
let mut cb_needed = 0;
|
||||||
|
|
||||||
if EnumProcessModulesEx(process_handler,
|
if EnumProcessModulesEx(
|
||||||
&mut h_mod,
|
process_handler,
|
||||||
::std::mem::size_of::<DWORD>() as DWORD,
|
&mut h_mod,
|
||||||
&mut cb_needed,
|
::std::mem::size_of::<DWORD>() as DWORD,
|
||||||
LIST_MODULES_ALL) != 0 {
|
&mut cb_needed,
|
||||||
GetModuleFileNameExW(process_handler,
|
LIST_MODULES_ALL,
|
||||||
h_mod,
|
) != 0
|
||||||
process_name.as_mut_ptr(),
|
{
|
||||||
MAX_PATH as DWORD + 1);
|
GetModuleFileNameExW(
|
||||||
|
process_handler,
|
||||||
|
h_mod,
|
||||||
|
process_name.as_mut_ptr(),
|
||||||
|
MAX_PATH as DWORD + 1,
|
||||||
|
);
|
||||||
|
|
||||||
let mut pos = 0;
|
let mut pos = 0;
|
||||||
for x in process_name.iter() {
|
for x in process_name.iter() {
|
||||||
if *x == 0 {
|
if *x == 0 {
|
||||||
break
|
break;
|
||||||
}
|
}
|
||||||
pos += 1;
|
pos += 1;
|
||||||
}
|
}
|
||||||
@ -210,11 +212,11 @@ mod natives {
|
|||||||
use logging::LoggingErrors;
|
use logging::LoggingErrors;
|
||||||
|
|
||||||
pub fn create_shortcut(
|
pub fn create_shortcut(
|
||||||
name: &str,
|
_name: &str,
|
||||||
description: &str,
|
_description: &str,
|
||||||
target: &str,
|
_target: &str,
|
||||||
args: &str,
|
_args: &str,
|
||||||
working_dir: &str,
|
_working_dir: &str,
|
||||||
) -> Result<String, String> {
|
) -> Result<String, String> {
|
||||||
// TODO: no-op
|
// TODO: no-op
|
||||||
warn!("create_shortcut is stubbed!");
|
warn!("create_shortcut is stubbed!");
|
||||||
|
@ -62,7 +62,8 @@ impl WebServer {
|
|||||||
Ok(WebService {
|
Ok(WebService {
|
||||||
framework: framework.clone(),
|
framework: framework.clone(),
|
||||||
})
|
})
|
||||||
}).log_expect("Failed to bind to port");
|
})
|
||||||
|
.log_expect("Failed to bind to port");
|
||||||
|
|
||||||
server.run().log_expect("Failed to run HTTP server");
|
server.run().log_expect("Failed to run HTTP server");
|
||||||
});
|
});
|
||||||
|
@ -41,7 +41,8 @@ impl ReleaseSource for GithubReleases {
|
|||||||
.get(&format!(
|
.get(&format!(
|
||||||
"https://api.github.com/repos/{}/releases",
|
"https://api.github.com/repos/{}/releases",
|
||||||
config.repo
|
config.repo
|
||||||
)).header(USER_AGENT, "liftinstall (j-selby)")
|
))
|
||||||
|
.header(USER_AGENT, "liftinstall (j-selby)")
|
||||||
.send()
|
.send()
|
||||||
.map_err(|x| format!("Error while sending HTTP request: {:?}", x))?;
|
.map_err(|x| format!("Error while sending HTTP request: {:?}", x))?;
|
||||||
|
|
||||||
@ -87,14 +88,16 @@ impl ReleaseSource for GithubReleases {
|
|||||||
let string = match asset["name"].as_str() {
|
let string = match asset["name"].as_str() {
|
||||||
Some(v) => v,
|
Some(v) => v,
|
||||||
None => {
|
None => {
|
||||||
return Err("JSON payload missing information about release name".to_string())
|
return Err(
|
||||||
|
"JSON payload missing information about release name".to_string()
|
||||||
|
);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
let url = match asset["browser_download_url"].as_str() {
|
let url = match asset["browser_download_url"].as_str() {
|
||||||
Some(v) => v,
|
Some(v) => v,
|
||||||
None => {
|
None => {
|
||||||
return Err("JSON payload missing information about release URL".to_string())
|
return Err("JSON payload missing information about release URL".to_string());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -7,8 +7,8 @@ use tasks::TaskDependency;
|
|||||||
use tasks::TaskMessage;
|
use tasks::TaskMessage;
|
||||||
use tasks::TaskParamType;
|
use tasks::TaskParamType;
|
||||||
|
|
||||||
use native::Process;
|
|
||||||
use native::get_process_names;
|
use native::get_process_names;
|
||||||
|
use native::Process;
|
||||||
|
|
||||||
use std::process;
|
use std::process;
|
||||||
|
|
||||||
@ -23,7 +23,7 @@ impl Task for EnsureOnlyInstanceTask {
|
|||||||
) -> Result<TaskParamType, String> {
|
) -> Result<TaskParamType, String> {
|
||||||
assert_eq!(input.len(), 0);
|
assert_eq!(input.len(), 0);
|
||||||
|
|
||||||
let current_pid = process::id() as usize;
|
let current_pid = process::id() as usize;
|
||||||
for Process { pid, name } in get_process_names() {
|
for Process { pid, name } in get_process_names() {
|
||||||
if pid == current_pid {
|
if pid == current_pid {
|
||||||
continue;
|
continue;
|
||||||
|
Loading…
Reference in New Issue
Block a user