Removed gz support

pull/1991/head
jLynx 9 months ago
parent 4d4f2f8901
commit 37ec6294f8

@ -760,11 +760,9 @@ impl Update {
/// ### Expected structure: /// ### Expected structure:
/// ├── [AppName]_[version]_amd64.AppImage.tar.gz # GZ generated by tauri-bundler /// ├── [AppName]_[version]_amd64.AppImage.tar.gz # GZ generated by tauri-bundler
/// │ └──[AppName]_[version]_amd64.AppImage # Application AppImage /// │ └──[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 /// ├── [AppName]_[version]_amd64.deb # Debian package
/// └── ... /// └── ...
/// ///
fn install_inner(&self, bytes: &[u8]) -> Result<()> { fn install_inner(&self, bytes: &[u8]) -> Result<()> {
if self.is_deb_package() { if self.is_deb_package() {
self.install_deb_update(bytes) self.install_deb_update(bytes)
@ -795,7 +793,7 @@ impl Update {
let mut perms = tmp_dir_metadata.permissions(); let mut perms = tmp_dir_metadata.permissions();
perms.set_mode(0o700); perms.set_mode(0o700);
std::fs::set_permissions(tmp_dir.path(), perms)?; std::fs::set_permissions(tmp_dir.path(), perms)?;
let tmp_app_image = &tmp_dir.path().join("current_app.AppImage"); let tmp_app_image = &tmp_dir.path().join("current_app.AppImage");
let permissions = std::fs::metadata(&self.extract_path)?.permissions(); let permissions = std::fs::metadata(&self.extract_path)?.permissions();
@ -855,46 +853,22 @@ impl Update {
} }
fn install_deb_update(&self, bytes: &[u8]) -> Result<()> { fn install_deb_update(&self, bytes: &[u8]) -> Result<()> {
use flate2::read::GzDecoder;
// Create a temporary directory // Create a temporary directory
let tmp_dir = tempfile::Builder::new() let tmp_dir = tempfile::Builder::new()
.prefix("tauri_deb_update") .prefix("tauri_deb_update")
.tempdir_in("/tmp")?; .tempdir_in("/tmp")?;
let deb_path = tmp_dir.path().join("package.deb"); let deb_path = tmp_dir.path().join("package.deb");
// Check if we need to extract from tar.gz first // Direct .deb file
if infer::archive::is_gz(bytes) { std::fs::write(&deb_path, 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)?;
}
// Try different privilege escalation methods // Try different privilege escalation methods
let installation_result = self.try_install_with_privileges(&deb_path); let installation_result = self.try_install_with_privileges(&deb_path);
// Clean up // Clean up
let _ = std::fs::remove_file(&deb_path); let _ = std::fs::remove_file(&deb_path);
installation_result installation_result
} }
@ -937,7 +911,7 @@ impl Update {
.args([ .args([
"--password", "--password",
"--title=Authentication Required", "--title=Authentication Required",
"--text=Enter your password to install the update:" "--text=Enter your password to install the update:",
]) ])
.output()?; .output()?;
@ -949,11 +923,11 @@ impl Update {
} }
fn install_with_sudo(&self, deb_path: &Path, password: &str) -> Result<bool> { fn install_with_sudo(&self, deb_path: &Path, password: &str) -> Result<bool> {
use std::process::{Command, Stdio};
use std::io::Write; use std::io::Write;
use std::process::{Command, Stdio};
let mut child = Command::new("sudo") let mut child = Command::new("sudo")
.arg("-S") // read password from stdin .arg("-S") // read password from stdin
.arg("dpkg") .arg("dpkg")
.arg("-i") .arg("-i")
.arg(deb_path) .arg(deb_path)

Loading…
Cancel
Save