|
|
@ -757,11 +757,15 @@ impl Update {
|
|
|
|
target_os = "openbsd"
|
|
|
|
target_os = "openbsd"
|
|
|
|
))]
|
|
|
|
))]
|
|
|
|
impl Update {
|
|
|
|
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<()> {
|
|
|
|
fn install_inner(&self, bytes: &[u8]) -> Result<()> {
|
|
|
|
log::warn!("=========== UPDATE ==================");
|
|
|
|
|
|
|
|
log::warn!("Starting Linux update installation");
|
|
|
|
|
|
|
|
log::warn!("Extract path: {:?}", self.extract_path);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if self.is_deb_package() {
|
|
|
|
if self.is_deb_package() {
|
|
|
|
self.install_deb_update(bytes)
|
|
|
|
self.install_deb_update(bytes)
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
@ -849,11 +853,8 @@ impl Update {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
fn install_deb_update(&self, bytes: &[u8]) -> Result<()> {
|
|
|
|
fn install_deb_update(&self, bytes: &[u8]) -> Result<()> {
|
|
|
|
use std::process::Command;
|
|
|
|
|
|
|
|
use flate2::read::GzDecoder;
|
|
|
|
use flate2::read::GzDecoder;
|
|
|
|
|
|
|
|
|
|
|
|
log::warn!("Starting DEB package installation");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 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")
|
|
|
@ -863,7 +864,6 @@ impl Update {
|
|
|
|
|
|
|
|
|
|
|
|
// Check if we need to extract from tar.gz first
|
|
|
|
// Check if we need to extract from tar.gz first
|
|
|
|
if infer::archive::is_gz(bytes) {
|
|
|
|
if infer::archive::is_gz(bytes) {
|
|
|
|
log::warn!("Detected tar.gz archive, extracting DEB package...");
|
|
|
|
|
|
|
|
let decoder = GzDecoder::new(Cursor::new(bytes));
|
|
|
|
let decoder = GzDecoder::new(Cursor::new(bytes));
|
|
|
|
let mut archive = tar::Archive::new(decoder);
|
|
|
|
let mut archive = tar::Archive::new(decoder);
|
|
|
|
|
|
|
|
|
|
|
@ -872,7 +872,6 @@ impl Update {
|
|
|
|
for mut entry in archive.entries()?.flatten() {
|
|
|
|
for mut entry in archive.entries()?.flatten() {
|
|
|
|
if let Ok(path) = entry.path() {
|
|
|
|
if let Ok(path) = entry.path() {
|
|
|
|
if path.extension() == Some(OsStr::new("deb")) {
|
|
|
|
if path.extension() == Some(OsStr::new("deb")) {
|
|
|
|
log::warn!("Found DEB package in archive, extracting to: {}", deb_path.display());
|
|
|
|
|
|
|
|
entry.unpack(&deb_path)?;
|
|
|
|
entry.unpack(&deb_path)?;
|
|
|
|
found_deb = true;
|
|
|
|
found_deb = true;
|
|
|
|
break;
|
|
|
|
break;
|
|
|
@ -886,12 +885,9 @@ impl Update {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
// Direct .deb file
|
|
|
|
// Direct .deb file
|
|
|
|
log::warn!("Writing DEB package directly to: {}", deb_path.display());
|
|
|
|
|
|
|
|
std::fs::write(&deb_path, bytes)?;
|
|
|
|
std::fs::write(&deb_path, bytes)?;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
log::warn!("Preparing to install DEB package from: {}", deb_path.display());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 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);
|
|
|
|
|
|
|
|
|
|
|
@ -910,7 +906,6 @@ impl Update {
|
|
|
|
.status()
|
|
|
|
.status()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if status.success() {
|
|
|
|
if status.success() {
|
|
|
|
log::warn!("Successfully installed update using pkexec");
|
|
|
|
|
|
|
|
return Ok(());
|
|
|
|
return Ok(());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -918,13 +913,11 @@ impl Update {
|
|
|
|
// 2. Try zenity for a more user-friendly graphical sudo experience
|
|
|
|
// 2. Try zenity for a more user-friendly graphical sudo experience
|
|
|
|
if let Ok(password) = self.get_password_graphically() {
|
|
|
|
if let Ok(password) = self.get_password_graphically() {
|
|
|
|
if self.install_with_sudo(deb_path, &password)? {
|
|
|
|
if self.install_with_sudo(deb_path, &password)? {
|
|
|
|
log::warn!("Successfully installed update using sudo (graphical)");
|
|
|
|
|
|
|
|
return Ok(());
|
|
|
|
return Ok(());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 3. Final fallback: terminal sudo
|
|
|
|
// 3. Final fallback: terminal sudo
|
|
|
|
log::warn!("Falling back to terminal sudo for installation");
|
|
|
|
|
|
|
|
let status = std::process::Command::new("sudo")
|
|
|
|
let status = std::process::Command::new("sudo")
|
|
|
|
.arg("dpkg")
|
|
|
|
.arg("dpkg")
|
|
|
|
.arg("-i")
|
|
|
|
.arg("-i")
|
|
|
|