mirror of
https://github.com/tauri-apps/plugins-workspace.git
synced 2026-04-25 11:46:06 +02:00
Merge branch 'feature/fallback_targets' of github.com:kandrelczyk/plugins-workspace into feature/fallback_targets
This commit is contained in:
+2
-1
@@ -55,4 +55,5 @@ pids
|
||||
*.sublime*
|
||||
.idea
|
||||
debug.log
|
||||
TODO.md
|
||||
TODO.md
|
||||
.aider.*
|
||||
|
||||
+10
-100
@@ -356,111 +356,21 @@ 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)
|
||||
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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[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)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
impl Updater {
|
||||
|
||||
pub async fn check(&self) -> Result<Option<Update>> {
|
||||
// we want JSON only
|
||||
|
||||
@@ -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| {
|
||||
|
||||
Reference in New Issue
Block a user