From 37ec6294f834960469a933f7d219d13bd496a7c9 Mon Sep 17 00:00:00 2001 From: jLynx Date: Mon, 4 Nov 2024 10:29:36 +1300 Subject: [PATCH] Removed gz support --- plugins/updater/src/updater.rs | 50 ++++++++-------------------------- 1 file changed, 12 insertions(+), 38 deletions(-) diff --git a/plugins/updater/src/updater.rs b/plugins/updater/src/updater.rs index 9307a9bc..a4d08206 100644 --- a/plugins/updater/src/updater.rs +++ b/plugins/updater/src/updater.rs @@ -760,11 +760,9 @@ impl Update { /// ### Expected structure: /// ├── [AppName]_[version]_amd64.AppImage.tar.gz # GZ generated by tauri-bundler /// │ └──[AppName]_[version]_amd64.AppImage # Application AppImage - /// ├── [AppName]_[version]_amd64.deb.tar.gz # GZ generated by tauri-bundler - /// │ └──[AppName]_[version]_amd64.deb # Debian package /// ├── [AppName]_[version]_amd64.deb # Debian package /// └── ... - /// + /// fn install_inner(&self, bytes: &[u8]) -> Result<()> { if self.is_deb_package() { self.install_deb_update(bytes) @@ -795,7 +793,7 @@ impl Update { let mut perms = tmp_dir_metadata.permissions(); perms.set_mode(0o700); std::fs::set_permissions(tmp_dir.path(), perms)?; - + let tmp_app_image = &tmp_dir.path().join("current_app.AppImage"); let permissions = std::fs::metadata(&self.extract_path)?.permissions(); @@ -855,46 +853,22 @@ impl Update { } fn install_deb_update(&self, bytes: &[u8]) -> Result<()> { - use flate2::read::GzDecoder; - // Create a temporary directory let tmp_dir = tempfile::Builder::new() .prefix("tauri_deb_update") .tempdir_in("/tmp")?; - + let deb_path = tmp_dir.path().join("package.deb"); - - // Check if we need to extract from tar.gz first - if infer::archive::is_gz(bytes) { - let decoder = GzDecoder::new(Cursor::new(bytes)); - let mut archive = tar::Archive::new(decoder); - - // Look for .deb file in archive - let mut found_deb = false; - for mut entry in archive.entries()?.flatten() { - if let Ok(path) = entry.path() { - if path.extension() == Some(OsStr::new("deb")) { - entry.unpack(&deb_path)?; - found_deb = true; - break; - } - } - } - - if !found_deb { - return Err(Error::BinaryNotFoundInArchive); - } - } else { - // Direct .deb file - std::fs::write(&deb_path, bytes)?; - } - + + // Direct .deb file + std::fs::write(&deb_path, bytes)?; + // Try different privilege escalation methods let installation_result = self.try_install_with_privileges(&deb_path); - + // Clean up let _ = std::fs::remove_file(&deb_path); - + installation_result } @@ -937,7 +911,7 @@ impl Update { .args([ "--password", "--title=Authentication Required", - "--text=Enter your password to install the update:" + "--text=Enter your password to install the update:", ]) .output()?; @@ -949,11 +923,11 @@ impl Update { } fn install_with_sudo(&self, deb_path: &Path, password: &str) -> Result { - use std::process::{Command, Stdio}; use std::io::Write; + use std::process::{Command, Stdio}; let mut child = Command::new("sudo") - .arg("-S") // read password from stdin + .arg("-S") // read password from stdin .arg("dpkg") .arg("-i") .arg(deb_path)