mirror of
https://github.com/velopack/velopack.git
synced 2025-10-25 15:19:22 +00:00
Fix linux update issues
This commit is contained in:
@@ -13,6 +13,7 @@ pub fn apply_package_impl<'a>(root_path: &PathBuf, _app: &Manifest, pkg: &PathBu
|
||||
let manifest = bundle.read_manifest()?;
|
||||
let temp_path = format!("/var/tmp/velopack_{}", shared::random_string(8));
|
||||
let script_path = format!("/var/tmp/velopack_update_{}.sh", manifest.id);
|
||||
let root_path_string = root_path.to_string_lossy().to_string();
|
||||
|
||||
let action: Result<()> = (|| {
|
||||
info!("Extracting bundle to temp file: {}", temp_path);
|
||||
@@ -21,22 +22,22 @@ pub fn apply_package_impl<'a>(root_path: &PathBuf, _app: &Manifest, pkg: &PathBu
|
||||
info!("Chmod as executable");
|
||||
std::fs::set_permissions(&temp_path, <std::fs::Permissions as std::os::unix::fs::PermissionsExt>::from_mode(0o755))?;
|
||||
|
||||
info!("Moving temp file to target: {}", &root_path.to_string_lossy());
|
||||
info!("Moving temp file to target: {}", &root_path_string);
|
||||
// we use mv instead of fs::rename / fs::copy because rename fails cross-device
|
||||
// and copy fails if the process is running (presumably because rust opens the file for writing)
|
||||
// while mv works in both cases.
|
||||
let mv_args = vec!["-f", &temp_path, &root_path.to_string_lossy().to_string()];
|
||||
let mv_args = vec!["-f", &temp_path, &root_path_string];
|
||||
let mv_output = Command::new("mv").args(mv_args).output()?;
|
||||
|
||||
if mv_output.status.success() {
|
||||
info!("AppImage moved successfully to: {}", &root_path.to_string_lossy());
|
||||
info!("AppImage moved successfully to: {}", &root_path_string);
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
// if the operation failed, let's try again elevated with pkexec
|
||||
error!("An error occurred ({:?}), will attempt to elevate permissions and try again...", mv_output);
|
||||
dialogs::ask_user_to_elevate(&manifest)?;
|
||||
let script = format!("#!/bin/sh\nmv -f '{}' '{}'", temp_path, &root_path.to_string_lossy());
|
||||
let script = format!("#!/bin/sh\nmv -f '{}' '{}'", temp_path, &root_path_string);
|
||||
info!("Writing script for elevation: \n{}", script);
|
||||
fs::write(&script_path, script)?;
|
||||
std::fs::set_permissions(&script_path, <std::fs::Permissions as std::os::unix::fs::PermissionsExt>::from_mode(0o755))?;
|
||||
@@ -44,13 +45,11 @@ pub fn apply_package_impl<'a>(root_path: &PathBuf, _app: &Manifest, pkg: &PathBu
|
||||
info!("Attempting to elevate: pkexec {:?}", args);
|
||||
let elev_output = Command::new("pkexec").args(args).output()?;
|
||||
if elev_output.status.success() {
|
||||
info!("AppImage moved (elevated) to {}", &root_path.to_string_lossy());
|
||||
info!("AppImage moved (elevated) to {}", &root_path_string);
|
||||
return Ok(());
|
||||
} else {
|
||||
bail!("pkexec failed with status: {:?}", elev_output);
|
||||
}
|
||||
|
||||
bail!("Failed to move the AppImage to target, bailing...");
|
||||
})();
|
||||
let _ = fs::remove_file(&script_path);
|
||||
let _ = fs::remove_file(&temp_path);
|
||||
|
||||
@@ -35,7 +35,6 @@ impl RuntimeArch {
|
||||
|
||||
#[cfg(not(target_os = "windows"))]
|
||||
pub fn from_current_system() -> Option<Self> {
|
||||
use os_info;
|
||||
let info = os_info::get();
|
||||
let machine = info.architecture();
|
||||
if machine.is_none() {
|
||||
|
||||
Reference in New Issue
Block a user