diff --git a/.gitignore b/.gitignore index 72e5a397..0abc00bd 100644 --- a/.gitignore +++ b/.gitignore @@ -55,4 +55,5 @@ pids *.sublime* .idea debug.log -TODO.md \ No newline at end of file +TODO.md +.aider.* diff --git a/plugins/updater/src/updater.rs b/plugins/updater/src/updater.rs index 9e568ceb..d7a2e547 100644 --- a/plugins/updater/src/updater.rs +++ b/plugins/updater/src/updater.rs @@ -356,112 +356,22 @@ pub struct Updater { current_exe_args: Vec, } -/// Linux (AppImage and Deb) -#[cfg(any( - target_os = "linux", - target_os = "dragonfly", - target_os = "freebsd", - target_os = "netbsd", - target_os = "openbsd" -))] -impl Updater { - - fn is_deb_package(&self) -> bool { - // First check if we're in a typical Debian installation path - let in_system_path = self.extract_path - .to_str() - .map(|p| p.starts_with("/usr")) - .unwrap_or(false); - - if !in_system_path { - return false; - } - // Then verify it's actually a Debian-based system by checking for dpkg - let dpkg_exists = std::path::Path::new("/var/lib/dpkg").exists(); - let apt_exists = std::path::Path::new("/etc/apt").exists(); - // Additional check for the package in dpkg database - let package_in_dpkg = if let Ok(output) = std::process::Command::new("dpkg") - .args(["-S", &self.extract_path.to_string_lossy()]) - .output() - { - output.status.success() - } else { - false - }; - - // Consider it a deb package only if: - // 1. We're in a system path AND - // 2. We have Debian package management tools AND - // 3. The binary is tracked by dpkg - dpkg_exists && apt_exists && package_in_dpkg - } - fn is_rpm_package(&self) -> bool { - // First check if we're in a typical RPM installation path - let in_system_path = self.extract_path - .to_str() - .map(|p| p.starts_with("/usr")) - .unwrap_or(false); - - if !in_system_path { - return false; - } - - // Then verify it's actually a Debian-based system by checking for dpkg - let rpm_exists = std::path::Path::new("/var/lib/rpm").exists(); - let etc_rpm_exists = std::path::Path::new("/etc/rpm").exists(); - - // Additional check for the package in dpkg database - let package_in_rpm = if let Ok(output) = std::process::Command::new("rpm") - .args(["-qf", &self.extract_path.to_string_lossy()]) - .output() - { - output.status.success() - } else { - false - }; - - // Consider it a deb package only if: - // 1. We're in a system path AND - // 2. We have RPM package management tools AND - // 3. The binary is tracked by rpm - rpm_exists && etc_rpm_exists && package_in_rpm - } - - fn get_updater_installer(&self) -> Result> { - if std::env::var_os("APPIMAGE").is_some() { - Ok(Some(Installer::AppImage)) - } else if self.is_deb_package() { - Ok(Some(Installer::Deb)) - } else if self.is_rpm_package() { - Ok(Some(Installer::Rpm)) - } else { - Err(Error::UnknownInstaller) - } - } -} - -#[cfg(target_os = "windows")] impl Updater { - fn get_updater_installer(&self) -> Result> { - Ok(Some(Installer::Msi)) - } - -} - -#[cfg(target_os = "macos")] -impl Updater { fn get_updater_installer(&self) -> Result> { - Ok(None) + match tauri::__TAURI_BUNDLE_TYPE { + "DEB_BUNDLE" => Ok(Some(Installer::Deb)), + "RPM_BUNDLE" => Ok(Some(Installer::Rpm)), + "APP_BUNDLE" => Ok(Some(Installer::AppImage)), + "MSI_BUNDLE" => Ok(Some(Installer::Msi)), + "NSS_BUNDLE" => Ok(Some(Installer::Nsis)), + _ => Err(Error::UnknownInstaller) + } } -} - -impl Updater { - pub async fn check(&self) -> Result> { // we want JSON only let mut headers = self.headers.clone(); diff --git a/plugins/updater/tests/app-updater/src/main.rs b/plugins/updater/tests/app-updater/src/main.rs index bbe398b5..5f5566f8 100644 --- a/plugins/updater/tests/app-updater/src/main.rs +++ b/plugins/updater/tests/app-updater/src/main.rs @@ -9,7 +9,6 @@ use tauri_plugin_updater::UpdaterExt; fn main() { #[allow(unused_mut)] let mut context = tauri::generate_context!(); - tauri::Builder::default() .plugin(tauri_plugin_updater::Builder::new().build()) .setup(|app| {