|
|
|
@ -356,112 +356,22 @@ pub struct Updater {
|
|
|
|
|
current_exe_args: Vec<OsString>,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// 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<Option<Installer>> {
|
|
|
|
|
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<Option<Installer>> {
|
|
|
|
|
|
|
|
|
|
Ok(Some(Installer::Msi))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[cfg(target_os = "macos")]
|
|
|
|
|
impl Updater {
|
|
|
|
|
fn get_updater_installer(&self) -> Result<Option<Installer>> {
|
|
|
|
|
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<Option<Update>> {
|
|
|
|
|
// we want JSON only
|
|
|
|
|
let mut headers = self.headers.clone();
|
|
|
|
|