Skip to content

Commit

Permalink
feat(bundler): added provides, conflicts and replaces for deb and rpm (
Browse files Browse the repository at this point in the history
…#9331)

* feat(bundler): added provides, conflicts and replaces for deb and rpm packages

* added change file

* update .changes/deb-rpm-provides-conflicts-replaces.md according to review

Co-authored-by: Amr Bashir <amr.bashir2015@gmail.com>

* inlined provides/conflicts/replaces(obsoletes) variables

* fmt
  • Loading branch information
mariotaku authored Apr 3, 2024
1 parent 2f20fdf commit 36b4c12
Show file tree
Hide file tree
Showing 8 changed files with 224 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .changes/deb-rpm-provides-conflicts-replaces.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'tauri-bundler': 'minor:feat'
'tauri-utils': 'minor:feat'
---

Added support for `provides`, `conflicts` and `replaces` (`obsoletes` for RPM) options for `bundler > deb` and `bundler > rpm` configs.
60 changes: 60 additions & 0 deletions core/tauri-config-schema/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -2422,6 +2422,36 @@
"type": "string"
}
},
"provides": {
"description": "The list of dependencies the package provides.",
"type": [
"array",
"null"
],
"items": {
"type": "string"
}
},
"conflicts": {
"description": "The list of package conflicts.",
"type": [
"array",
"null"
],
"items": {
"type": "string"
}
},
"replaces": {
"description": "The list of package replaces.",
"type": [
"array",
"null"
],
"items": {
"type": "string"
}
},
"files": {
"description": "The files to include on the package.",
"default": {},
Expand Down Expand Up @@ -2503,6 +2533,36 @@
"type": "string"
}
},
"provides": {
"description": "The list of RPM dependencies your application provides.",
"type": [
"array",
"null"
],
"items": {
"type": "string"
}
},
"conflicts": {
"description": "The list of RPM dependencies your application conflicts with. They must not be present in order for the package to be installed.",
"type": [
"array",
"null"
],
"items": {
"type": "string"
}
},
"obsoletes": {
"description": "The list of RPM dependencies your application supersedes - if this package is installed, packages listed as “obsoletes” will be automatically removed (if they are present).",
"type": [
"array",
"null"
],
"items": {
"type": "string"
}
},
"release": {
"description": "The RPM release tag.",
"default": "1",
Expand Down
17 changes: 17 additions & 0 deletions core/tauri-utils/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,12 @@ pub struct AppImageConfig {
pub struct DebConfig {
/// The list of deb dependencies your application relies on.
pub depends: Option<Vec<String>>,
/// The list of dependencies the package provides.
pub provides: Option<Vec<String>>,
/// The list of package conflicts.
pub conflicts: Option<Vec<String>>,
/// The list of package replaces.
pub replaces: Option<Vec<String>>,
/// The files to include on the package.
#[serde(default)]
pub files: HashMap<PathBuf, PathBuf>,
Expand Down Expand Up @@ -384,6 +390,14 @@ pub struct LinuxConfig {
pub struct RpmConfig {
/// The list of RPM dependencies your application relies on.
pub depends: Option<Vec<String>>,
/// The list of RPM dependencies your application provides.
pub provides: Option<Vec<String>>,
/// The list of RPM dependencies your application conflicts with. They must not be present
/// in order for the package to be installed.
pub conflicts: Option<Vec<String>>,
/// The list of RPM dependencies your application supersedes - if this package is installed,
/// packages listed as “obsoletes” will be automatically removed (if they are present).
pub obsoletes: Option<Vec<String>>,
/// The RPM release tag.
#[serde(default = "default_release")]
pub release: String,
Expand Down Expand Up @@ -420,6 +434,9 @@ impl Default for RpmConfig {
fn default() -> Self {
Self {
depends: None,
provides: None,
conflicts: None,
obsoletes: None,
release: default_release(),
epoch: 0,
files: Default::default(),
Expand Down
27 changes: 27 additions & 0 deletions tooling/bundler/src/bundle/linux/debian.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,33 @@ fn generate_control_file(
if !dependencies.is_empty() {
writeln!(file, "Depends: {}", dependencies.join(", "))?;
}
let provides = settings
.deb()
.provides
.as_ref()
.cloned()
.unwrap_or_default();
if !provides.is_empty() {
writeln!(file, "Provides: {}", provides.join(", "))?;
}
let conflicts = settings
.deb()
.conflicts
.as_ref()
.cloned()
.unwrap_or_default();
if !conflicts.is_empty() {
writeln!(file, "Conflicts: {}", conflicts.join(", "))?;
}
let replaces = settings
.deb()
.replaces
.as_ref()
.cloned()
.unwrap_or_default();
if !replaces.is_empty() {
writeln!(file, "Replaces: {}", replaces.join(", "))?;
}
let mut short_description = settings.short_description().trim();
if short_description.is_empty() {
short_description = "(none)";
Expand Down
33 changes: 33 additions & 0 deletions tooling/bundler/src/bundle/linux/rpm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,39 @@ pub fn bundle_project(settings: &Settings) -> crate::Result<Vec<PathBuf>> {
builder = builder.requires(Dependency::any(dep));
}

// Add provides
for dep in settings
.rpm()
.provides
.as_ref()
.cloned()
.unwrap_or_default()
{
builder = builder.provides(Dependency::any(dep));
}

// Add conflicts
for dep in settings
.rpm()
.conflicts
.as_ref()
.cloned()
.unwrap_or_default()
{
builder = builder.conflicts(Dependency::any(dep));
}

// Add obsoletes
for dep in settings
.rpm()
.obsoletes
.as_ref()
.cloned()
.unwrap_or_default()
{
builder = builder.obsoletes(Dependency::any(dep));
}

// Add binaries
for bin in settings.binaries() {
let src = settings.binary_path(bin);
Expand Down
14 changes: 14 additions & 0 deletions tooling/bundler/src/bundle/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,12 @@ pub struct DebianSettings {
// OS-specific settings:
/// the list of debian dependencies.
pub depends: Option<Vec<String>>,
/// the list of dependencies the package provides.
pub provides: Option<Vec<String>>,
/// the list of package conflicts.
pub conflicts: Option<Vec<String>>,
/// the list of package replaces.
pub replaces: Option<Vec<String>>,
/// List of custom files to add to the deb package.
/// Maps the path on the debian package to the path of the file to include (relative to the current working directory).
pub files: HashMap<PathBuf, PathBuf>,
Expand Down Expand Up @@ -214,6 +220,14 @@ pub struct AppImageSettings {
pub struct RpmSettings {
/// The list of RPM dependencies your application relies on.
pub depends: Option<Vec<String>>,
/// The list of RPM dependencies your application provides.
pub provides: Option<Vec<String>>,
/// The list of RPM dependencies your application conflicts with. They must not be present
/// in order for the package to be installed.
pub conflicts: Option<Vec<String>>,
/// The list of RPM dependencies your application supersedes - if this package is installed,
/// packages listed as “obsoletes” will be automatically removed (if they are present).
pub obsoletes: Option<Vec<String>>,
/// The RPM release tag.
pub release: String,
/// The RPM epoch.
Expand Down
60 changes: 60 additions & 0 deletions tooling/cli/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -2422,6 +2422,36 @@
"type": "string"
}
},
"provides": {
"description": "The list of dependencies the package provides.",
"type": [
"array",
"null"
],
"items": {
"type": "string"
}
},
"conflicts": {
"description": "The list of package conflicts.",
"type": [
"array",
"null"
],
"items": {
"type": "string"
}
},
"replaces": {
"description": "The list of package replaces.",
"type": [
"array",
"null"
],
"items": {
"type": "string"
}
},
"files": {
"description": "The files to include on the package.",
"default": {},
Expand Down Expand Up @@ -2503,6 +2533,36 @@
"type": "string"
}
},
"provides": {
"description": "The list of RPM dependencies your application provides.",
"type": [
"array",
"null"
],
"items": {
"type": "string"
}
},
"conflicts": {
"description": "The list of RPM dependencies your application conflicts with. They must not be present in order for the package to be installed.",
"type": [
"array",
"null"
],
"items": {
"type": "string"
}
},
"obsoletes": {
"description": "The list of RPM dependencies your application supersedes - if this package is installed, packages listed as “obsoletes” will be automatically removed (if they are present).",
"type": [
"array",
"null"
],
"items": {
"type": "string"
}
},
"release": {
"description": "The RPM release tag.",
"default": "1",
Expand Down
7 changes: 7 additions & 0 deletions tooling/cli/src/interface/rust.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1208,6 +1208,7 @@ fn tauri_config_to_bundle_settings(
.unwrap_or(BundleResources::List(Vec::new()));
#[allow(unused_mut)]
let mut depends_deb = config.linux.deb.depends.unwrap_or_default();

#[allow(unused_mut)]
let mut depends_rpm = config.linux.rpm.depends.unwrap_or_default();

Expand Down Expand Up @@ -1330,6 +1331,9 @@ fn tauri_config_to_bundle_settings(
} else {
Some(depends_deb)
},
provides: config.linux.deb.provides,
conflicts: config.linux.deb.conflicts,
replaces: config.linux.deb.replaces,
files: config.linux.deb.files,
desktop_template: config.linux.deb.desktop_template,
section: config.linux.deb.section,
Expand All @@ -1349,6 +1353,9 @@ fn tauri_config_to_bundle_settings(
} else {
Some(depends_rpm)
},
provides: config.linux.rpm.provides,
conflicts: config.linux.rpm.conflicts,
obsoletes: config.linux.rpm.obsoletes,
release: config.linux.rpm.release,
epoch: config.linux.rpm.epoch,
files: config.linux.rpm.files,
Expand Down

0 comments on commit 36b4c12

Please sign in to comment.