Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(bundler): add provides, conflicts and replaces for deb and rpm #9942

Merged
merged 5 commits into from
Jun 4, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .changes/deb-rpm-provides-conflicts-replaces.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
'tauri-bundler': 'minor:feat'
'tauri-utils': 'minor:feat'
'tauri-cli': 'minor:feat'
'@tauri-apps/cli': '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 @@ -1335,6 +1335,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 @@ -1395,6 +1425,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 @@ -271,6 +271,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 @@ -299,6 +305,14 @@ pub struct RpmConfig {
pub license: Option<String>,
/// 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 All @@ -319,6 +333,9 @@ impl Default for RpmConfig {
Self {
license: None,
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 @@ -180,6 +180,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
31 changes: 31 additions & 0 deletions tooling/bundler/src/bundle/linux/rpm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,37 @@ pub fn bundle_project(settings: &Settings) -> crate::Result<Vec<PathBuf>> {
for dep in settings.rpm().depends.as_ref().cloned().unwrap_or_default() {
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() {
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 @@ -176,6 +176,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 @@ -205,6 +211,14 @@ pub struct RpmSettings {
pub license: Option<String>,
/// 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 @@ -1335,6 +1335,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 @@ -1395,6 +1425,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
6 changes: 6 additions & 0 deletions tooling/cli/src/interface/rust.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1145,6 +1145,9 @@ fn tauri_config_to_bundle_settings(
} else {
Some(depends_deb)
},
provides: config.deb.provides,
conflicts: config.deb.conflicts,
replaces: config.deb.replaces,
files: config.deb.files,
desktop_template: config.deb.desktop_template,
section: config.deb.section,
Expand All @@ -1158,6 +1161,9 @@ fn tauri_config_to_bundle_settings(
} else {
Some(depends_rpm)
},
provides: config.rpm.provides,
conflicts: config.rpm.conflicts,
obsoletes: config.rpm.obsoletes,
release: config.rpm.release,
epoch: config.rpm.epoch,
files: config.rpm.files,
Expand Down
Loading