From 6dea12a0677a905cb1f14969fe05c53e7cd717c6 Mon Sep 17 00:00:00 2001 From: Amr Bashir Date: Mon, 21 Oct 2024 21:38:14 +0300 Subject: [PATCH] feat(bundler): add `recommends` for deb and rpm (#11402) closes #10351 --- .changes/bundler-linux-recommends.md | 6 ++++++ .../tauri-bundler/src/bundle/linux/debian.rs | 9 +++++++++ crates/tauri-bundler/src/bundle/linux/rpm.rs | 11 ++++++++++ crates/tauri-bundler/src/bundle/settings.rs | 4 ++++ crates/tauri-cli/config.schema.json | 20 +++++++++++++++++++ crates/tauri-cli/src/interface/rust.rs | 2 ++ .../schemas/config.schema.json | 20 +++++++++++++++++++ crates/tauri-utils/src/config.rs | 5 +++++ 8 files changed, 77 insertions(+) create mode 100644 .changes/bundler-linux-recommends.md diff --git a/.changes/bundler-linux-recommends.md b/.changes/bundler-linux-recommends.md new file mode 100644 index 000000000000..13a18b9f8025 --- /dev/null +++ b/.changes/bundler-linux-recommends.md @@ -0,0 +1,6 @@ +--- +"tauri-bundler": "patch:feat" +--- + +Add `bundle > linux > deb > recommends` and `bundle > linux > rpm > recommends` fields to declare a strong, but not absolute, dependency for your `.deb` and `.rpm` packages. + diff --git a/crates/tauri-bundler/src/bundle/linux/debian.rs b/crates/tauri-bundler/src/bundle/linux/debian.rs index 34c8f94aed2c..87172386afe3 100644 --- a/crates/tauri-bundler/src/bundle/linux/debian.rs +++ b/crates/tauri-bundler/src/bundle/linux/debian.rs @@ -198,6 +198,15 @@ fn generate_control_file( if !dependencies.is_empty() { writeln!(file, "Depends: {}", dependencies.join(", "))?; } + let dependencies = settings + .deb() + .recommends + .as_ref() + .cloned() + .unwrap_or_default(); + if !dependencies.is_empty() { + writeln!(file, "Recommends: {}", dependencies.join(", "))?; + } let provides = settings .deb() .provides diff --git a/crates/tauri-bundler/src/bundle/linux/rpm.rs b/crates/tauri-bundler/src/bundle/linux/rpm.rs index 8167d391c858..06cbc953dfa1 100644 --- a/crates/tauri-bundler/src/bundle/linux/rpm.rs +++ b/crates/tauri-bundler/src/bundle/linux/rpm.rs @@ -84,6 +84,17 @@ pub fn bundle_project(settings: &Settings) -> crate::Result> { builder = builder.provides(Dependency::any(dep)); } + // Add recommends + for dep in settings + .rpm() + .recommends + .as_ref() + .cloned() + .unwrap_or_default() + { + builder = builder.recommends(Dependency::any(dep)); + } + // Add conflicts for dep in settings .rpm() diff --git a/crates/tauri-bundler/src/bundle/settings.rs b/crates/tauri-bundler/src/bundle/settings.rs index d9acaed5fb3b..610c6e749f1e 100644 --- a/crates/tauri-bundler/src/bundle/settings.rs +++ b/crates/tauri-bundler/src/bundle/settings.rs @@ -170,6 +170,8 @@ pub struct DebianSettings { // OS-specific settings: /// the list of debian dependencies. pub depends: Option>, + /// the list of debian dependencies recommendations. + pub recommends: Option>, /// the list of dependencies the package provides. pub provides: Option>, /// the list of package conflicts. @@ -222,6 +224,8 @@ pub struct AppImageSettings { pub struct RpmSettings { /// The list of RPM dependencies your application relies on. pub depends: Option>, + /// the list of of RPM dependencies your application recommends. + pub recommends: Option>, /// The list of RPM dependencies your application provides. pub provides: Option>, /// The list of RPM dependencies your application conflicts with. They must not be present diff --git a/crates/tauri-cli/config.schema.json b/crates/tauri-cli/config.schema.json index 1f08ccfbed78..a05ba79935ed 100644 --- a/crates/tauri-cli/config.schema.json +++ b/crates/tauri-cli/config.schema.json @@ -2574,6 +2574,16 @@ "type": "string" } }, + "recommends": { + "description": "The list of deb dependencies your application recommends.", + "type": [ + "array", + "null" + ], + "items": { + "type": "string" + } + }, "provides": { "description": "The list of dependencies the package provides.", "type": [ @@ -2685,6 +2695,16 @@ "type": "string" } }, + "recommends": { + "description": "The list of RPM dependencies your application recommends.", + "type": [ + "array", + "null" + ], + "items": { + "type": "string" + } + }, "provides": { "description": "The list of RPM dependencies your application provides.", "type": [ diff --git a/crates/tauri-cli/src/interface/rust.rs b/crates/tauri-cli/src/interface/rust.rs index b343bbb4a377..9abbd6c412d9 100644 --- a/crates/tauri-cli/src/interface/rust.rs +++ b/crates/tauri-cli/src/interface/rust.rs @@ -1346,6 +1346,7 @@ fn tauri_config_to_bundle_settings( } else { Some(depends_deb) }, + recommends: config.linux.deb.recommends, provides: config.linux.deb.provides, conflicts: config.linux.deb.conflicts, replaces: config.linux.deb.replaces, @@ -1368,6 +1369,7 @@ fn tauri_config_to_bundle_settings( } else { Some(depends_rpm) }, + recommends: config.linux.rpm.recommends, provides: config.linux.rpm.provides, conflicts: config.linux.rpm.conflicts, obsoletes: config.linux.rpm.obsoletes, diff --git a/crates/tauri-schema-generator/schemas/config.schema.json b/crates/tauri-schema-generator/schemas/config.schema.json index 1f08ccfbed78..a05ba79935ed 100644 --- a/crates/tauri-schema-generator/schemas/config.schema.json +++ b/crates/tauri-schema-generator/schemas/config.schema.json @@ -2574,6 +2574,16 @@ "type": "string" } }, + "recommends": { + "description": "The list of deb dependencies your application recommends.", + "type": [ + "array", + "null" + ], + "items": { + "type": "string" + } + }, "provides": { "description": "The list of dependencies the package provides.", "type": [ @@ -2685,6 +2695,16 @@ "type": "string" } }, + "recommends": { + "description": "The list of RPM dependencies your application recommends.", + "type": [ + "array", + "null" + ], + "items": { + "type": "string" + } + }, "provides": { "description": "The list of RPM dependencies your application provides.", "type": [ diff --git a/crates/tauri-utils/src/config.rs b/crates/tauri-utils/src/config.rs index 10f926f24032..3780079bf1e5 100644 --- a/crates/tauri-utils/src/config.rs +++ b/crates/tauri-utils/src/config.rs @@ -331,6 +331,8 @@ pub struct AppImageConfig { pub struct DebConfig { /// The list of deb dependencies your application relies on. pub depends: Option>, + /// The list of deb dependencies your application recommends. + pub recommends: Option>, /// The list of dependencies the package provides. pub provides: Option>, /// The list of package conflicts. @@ -398,6 +400,8 @@ pub struct LinuxConfig { pub struct RpmConfig { /// The list of RPM dependencies your application relies on. pub depends: Option>, + /// The list of RPM dependencies your application recommends. + pub recommends: Option>, /// The list of RPM dependencies your application provides. pub provides: Option>, /// The list of RPM dependencies your application conflicts with. They must not be present @@ -442,6 +446,7 @@ impl Default for RpmConfig { fn default() -> Self { Self { depends: None, + recommends: None, provides: None, conflicts: None, obsoletes: None,