Skip to content

Commit d1c0787

Browse files
committed
feat(cli): add RPM recommends, provides, conflicts, and obsoletes
Mirror DebSettings relation lists with RPM-native names. Debian Replaces maps to RPM Obsoletes.
1 parent 37c4c46 commit d1c0787

4 files changed

Lines changed: 85 additions & 1 deletion

File tree

packages/cli/schema.json

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2110,13 +2110,33 @@
21102110
"RpmSettings": {
21112111
"type": "object",
21122112
"properties": {
2113+
"conflicts": {
2114+
"description": "RPM package `Conflicts`.",
2115+
"type": [
2116+
"array",
2117+
"null"
2118+
],
2119+
"items": {
2120+
"type": "string"
2121+
}
2122+
},
21132123
"files": {
21142124
"description": "Extra files to add to the RPM payload.\nMaps the path in the package to the source path (relative to the crate directory).",
21152125
"type": "object",
21162126
"additionalProperties": {
21172127
"type": "string"
21182128
}
21192129
},
2130+
"obsoletes": {
2131+
"description": "RPM package `Obsoletes`. Closest equivalent of Debian `Replaces`.",
2132+
"type": [
2133+
"array",
2134+
"null"
2135+
],
2136+
"items": {
2137+
"type": "string"
2138+
}
2139+
},
21202140
"post_install_script": {
21212141
"description": "Script run after the package is installed (`%post`).",
21222142
"type": [
@@ -2145,6 +2165,26 @@
21452165
"null"
21462166
]
21472167
},
2168+
"provides": {
2169+
"description": "RPM package `Provides`.",
2170+
"type": [
2171+
"array",
2172+
"null"
2173+
],
2174+
"items": {
2175+
"type": "string"
2176+
}
2177+
},
2178+
"recommends": {
2179+
"description": "RPM package `Recommends`.",
2180+
"type": [
2181+
"array",
2182+
"null"
2183+
],
2184+
"items": {
2185+
"type": "string"
2186+
}
2187+
},
21482188
"requires": {
21492189
"description": "RPM package `Requires`.",
21502190
"type": [

packages/cli/src/bundler/linux.rs

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,8 @@ impl BundleContext<'_> {
222222
/// 6. Copy configured sidecar binaries into `/usr/bin` so RPM payloads match the
223223
/// other Linux formats.
224224
/// 7. Add custom files and maintainer scripts from `[bundle.rpm]`.
225-
/// 8. Attach `Requires` from `[bundle.rpm] requires`.
225+
/// 8. Attach `Requires`, `Recommends`, `Provides`, `Conflicts`, and `Obsoletes`
226+
/// from `[bundle.rpm]`.
226227
/// 9. Serialize the final package to disk and remove the temporary staging area.
227228
///
228229
/// The resulting artifact is written to `project_out_directory()/bundle/rpm`.
@@ -421,6 +422,26 @@ impl BundleContext<'_> {
421422
builder = builder.requires(rpm::Dependency::any(require));
422423
}
423424
}
425+
if let Some(recommends) = &rpm_settings.recommends {
426+
for recommend in recommends {
427+
builder = builder.recommends(rpm::Dependency::any(recommend));
428+
}
429+
}
430+
if let Some(provides) = &rpm_settings.provides {
431+
for provide in provides {
432+
builder = builder.provides(rpm::Dependency::any(provide));
433+
}
434+
}
435+
if let Some(conflicts) = &rpm_settings.conflicts {
436+
for conflict in conflicts {
437+
builder = builder.conflicts(rpm::Dependency::any(conflict));
438+
}
439+
}
440+
if let Some(obsoletes) = &rpm_settings.obsoletes {
441+
for obsolete in obsoletes {
442+
builder = builder.obsoletes(rpm::Dependency::any(obsolete));
443+
}
444+
}
424445

425446
let package = builder.build().context("Failed to build RPM package")?;
426447

packages/cli/src/config/bundle.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,18 @@ pub(crate) struct RpmSettings {
9999
/// RPM package `Requires`.
100100
#[serde(default)]
101101
pub requires: Option<Vec<String>>,
102+
/// RPM package `Recommends`.
103+
#[serde(default)]
104+
pub recommends: Option<Vec<String>>,
105+
/// RPM package `Provides`.
106+
#[serde(default)]
107+
pub provides: Option<Vec<String>>,
108+
/// RPM package `Conflicts`.
109+
#[serde(default)]
110+
pub conflicts: Option<Vec<String>>,
111+
/// RPM package `Obsoletes`. Closest equivalent of Debian `Replaces`.
112+
#[serde(default)]
113+
pub obsoletes: Option<Vec<String>>,
102114
/// Extra files to add to the RPM payload.
103115
/// Maps the path in the package to the source path (relative to the crate directory).
104116
#[serde(default)]

packages/cli/src/config/dioxus_config.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,12 +200,23 @@ mod tests {
200200
let source = r#"
201201
[bundle.rpm]
202202
requires = ["libxdo"]
203+
recommends = ["shared-mime-info"]
204+
provides = ["hotdog"]
205+
conflicts = ["hotdog-nightly"]
206+
obsoletes = ["hotdog-legacy"]
203207
pre_install_script = "rpm-pre.sh"
204208
"#;
205209

206210
let config: DioxusConfig = toml::from_str(source).expect("parse config");
207211
let rpm = config.bundle.rpm.unwrap();
208212
assert_eq!(rpm.requires.unwrap(), vec!["libxdo".to_string()]);
213+
assert_eq!(
214+
rpm.recommends.unwrap(),
215+
vec!["shared-mime-info".to_string()]
216+
);
217+
assert_eq!(rpm.provides.unwrap(), vec!["hotdog".to_string()]);
218+
assert_eq!(rpm.conflicts.unwrap(), vec!["hotdog-nightly".to_string()]);
219+
assert_eq!(rpm.obsoletes.unwrap(), vec!["hotdog-legacy".to_string()]);
209220
assert_eq!(
210221
rpm.pre_install_script.as_deref(),
211222
Some(std::path::Path::new("rpm-pre.sh"))

0 commit comments

Comments
 (0)