feat(updater): gate auto-updater behind Cargo feature updater

Makes tauri-plugin-updater and tauri-plugin-process optional
dependencies enabled by a default-on `updater` Cargo feature.
Sandboxed packaging targets (Flatpak, Snap) will build with
`--no-default-features` to exclude the plugins entirely,
satisfying store policies that prohibit competing auto-updaters.

Changes:
- Cargo.toml: add `updater` feature; plugins are now optional deps
- lib.rs: gate plugin registration on the feature
- updates/mod.rs: is_auto_update_eligible() returns false when
  the feature is off (catch-all for unusual build configs)
- capabilities/default.json: remove updater/process permissions
- build.rs: emit capabilities/auto-updater.json only when the
  feature is enabled; remove it otherwise. The file is gitignored
  since it is fully build-driven.

cc
This commit is contained in:
vicrodh committed 2026-04-13 18:32:28 -06:00
1 parent 0dd0313087
commit 031da1792d
6 files changed
+62 -11

No files matched your search

+32
View File
@@ -1,3 +1,35 @@
use std::fs;
use std::path::Path;
/// Auto-updater capability, emitted to capabilities/ only when the `updater`
/// Cargo feature is active. Gitignored so Flatpak/Snap builds (which disable
/// the feature) never reference permissions for plugins that aren't linked.
const AUTO_UPDATER_CAPABILITY: &str = r#"{
"$schema": "../gen/schemas/desktop-schema.json",
"identifier": "auto-updater",
"description": "Permissions for the in-app auto-updater (macOS + Linux AppImage). Generated by build.rs when the `updater` Cargo feature is enabled.",
"windows": ["main", "miniplayer"],
"permissions": [
"updater:default",
"process:allow-restart"
]
}
"#;
fn main() {
let capability_path = Path::new("capabilities/auto-updater.json");
if cfg!(feature = "updater") {
if let Err(e) = fs::write(capability_path, AUTO_UPDATER_CAPABILITY) {
panic!("Failed to emit auto-updater capability: {e}");
}
} else if capability_path.exists() {
if let Err(e) = fs::remove_file(capability_path) {
panic!("Failed to remove stale auto-updater capability: {e}");
}
}
println!("cargo:rerun-if-changed=build.rs");
tauri_build::build()
}