Skip to content

Commit 091100a

Browse files
feat(bundler): Add RPM packaging, closes #4402 (#5202)
* feat(bundler): Add RPM packaging * feat(bundler): Update 'rpm' to 0.13.1 * Fix fmt
1 parent 7e4580a commit 091100a

File tree

20 files changed

+1419
-161
lines changed

20 files changed

+1419
-161
lines changed

.changes/bundler-rpm.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
"tauri-bundler": 'patch:enhance'
3+
"tauri-cli": 'patch:enhance'
4+
"@tauri-apps/cli": 'patch:enhance'
5+
---
6+
7+
Add RPM packaging

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ npm create tauri-app@latest
3131

3232
The list of Tauri's features includes, but is not limited to:
3333

34-
- Built-in app bundler to create app bundles in formats like `.app`, `.dmg`, `.deb`, `.AppImage` and Windows installers like `.exe` (via NSIS) and `.msi` (via WiX).
34+
- Built-in app bundler to create app bundles in formats like `.app`, `.dmg`, `.deb`, `.rpm`, `.AppImage` and Windows installers like `.exe` (via NSIS) and `.msi` (via WiX).
3535
- Built-in self updater (desktop only)
3636
- System tray icons
3737
- Native notifications

core/tauri-config-schema/schema.json

Lines changed: 82 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,11 @@
5757
"macOS": {
5858
"minimumSystemVersion": "10.13"
5959
},
60+
"rpm": {
61+
"epoch": 0,
62+
"files": {},
63+
"release": "1"
64+
},
6065
"targets": "all",
6166
"updater": {
6267
"active": false,
@@ -205,6 +210,11 @@
205210
"macOS": {
206211
"minimumSystemVersion": "10.13"
207212
},
213+
"rpm": {
214+
"epoch": 0,
215+
"files": {},
216+
"release": "1"
217+
},
208218
"targets": "all",
209219
"updater": {
210220
"active": false,
@@ -933,7 +943,7 @@
933943
"type": "boolean"
934944
},
935945
"targets": {
936-
"description": "The bundle targets, currently supports [\"deb\", \"appimage\", \"nsis\", \"msi\", \"app\", \"dmg\", \"updater\"] or \"all\".",
946+
"description": "The bundle targets, currently supports [\"deb\", \"rpm\", \"appimage\", \"nsis\", \"msi\", \"app\", \"dmg\", \"updater\"] or \"all\".",
937947
"default": "all",
938948
"allOf": [
939949
{
@@ -1031,6 +1041,19 @@
10311041
}
10321042
]
10331043
},
1044+
"rpm": {
1045+
"description": "Configuration for the RPM bundle.",
1046+
"default": {
1047+
"epoch": 0,
1048+
"files": {},
1049+
"release": "1"
1050+
},
1051+
"allOf": [
1052+
{
1053+
"$ref": "#/definitions/RpmConfig"
1054+
}
1055+
]
1056+
},
10341057
"dmg": {
10351058
"description": "DMG-specific settings.",
10361059
"default": {
@@ -1170,6 +1193,13 @@
11701193
"deb"
11711194
]
11721195
},
1196+
{
1197+
"description": "The RPM bundle (.rpm).",
1198+
"type": "string",
1199+
"enum": [
1200+
"rpm"
1201+
]
1202+
},
11731203
{
11741204
"description": "The AppImage bundle (.appimage).",
11751205
"type": "string",
@@ -1368,6 +1398,57 @@
13681398
},
13691399
"additionalProperties": false
13701400
},
1401+
"RpmConfig": {
1402+
"description": "Configuration for RPM bundles.",
1403+
"type": "object",
1404+
"properties": {
1405+
"license": {
1406+
"description": "The package's license identifier. If not set, defaults to the license from the Cargo.toml file.",
1407+
"type": [
1408+
"string",
1409+
"null"
1410+
]
1411+
},
1412+
"depends": {
1413+
"description": "The list of RPM dependencies your application relies on.",
1414+
"type": [
1415+
"array",
1416+
"null"
1417+
],
1418+
"items": {
1419+
"type": "string"
1420+
}
1421+
},
1422+
"release": {
1423+
"description": "The RPM release tag.",
1424+
"default": "1",
1425+
"type": "string"
1426+
},
1427+
"epoch": {
1428+
"description": "The RPM epoch.",
1429+
"default": 0,
1430+
"type": "integer",
1431+
"format": "uint32",
1432+
"minimum": 0.0
1433+
},
1434+
"files": {
1435+
"description": "The files to include on the package.",
1436+
"default": {},
1437+
"type": "object",
1438+
"additionalProperties": {
1439+
"type": "string"
1440+
}
1441+
},
1442+
"desktopTemplate": {
1443+
"description": "Path to a custom desktop file Handlebars template.\n\nAvailable variables: `categories`, `comment` (optional), `exec`, `icon` and `name`.",
1444+
"type": [
1445+
"string",
1446+
"null"
1447+
]
1448+
}
1449+
},
1450+
"additionalProperties": false
1451+
},
13711452
"DmgConfig": {
13721453
"description": "Configuration for Apple Disk Image (.dmg) bundles.\n\nSee more: https://tauri.app/v1/api/config#dmgconfig",
13731454
"type": "object",

core/tauri-utils/src/config.rs

Lines changed: 54 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,8 @@ impl Default for WindowUrl {
7878
pub enum BundleType {
7979
/// The debian bundle (.deb).
8080
Deb,
81+
/// The RPM bundle (.rpm).
82+
Rpm,
8183
/// The AppImage bundle (.appimage).
8284
AppImage,
8385
/// The Microsoft Installer bundle (.msi).
@@ -99,6 +101,7 @@ impl Display for BundleType {
99101
"{}",
100102
match self {
101103
Self::Deb => "deb",
104+
Self::Rpm => "rpm",
102105
Self::AppImage => "appimage",
103106
Self::Msi => "msi",
104107
Self::Nsis => "nsis",
@@ -127,6 +130,7 @@ impl<'de> Deserialize<'de> for BundleType {
127130
let s = String::deserialize(deserializer)?;
128131
match s.to_lowercase().as_str() {
129132
"deb" => Ok(Self::Deb),
133+
"rpm" => Ok(Self::Rpm),
130134
"appimage" => Ok(Self::AppImage),
131135
"msi" => Ok(Self::Msi),
132136
"nsis" => Ok(Self::Nsis),
@@ -282,6 +286,49 @@ pub struct DebConfig {
282286
pub desktop_template: Option<PathBuf>,
283287
}
284288

289+
/// Configuration for RPM bundles.
290+
#[skip_serializing_none]
291+
#[derive(Debug, PartialEq, Eq, Clone, Deserialize, Serialize)]
292+
#[cfg_attr(feature = "schema", derive(JsonSchema))]
293+
#[serde(rename_all = "camelCase", deny_unknown_fields)]
294+
pub struct RpmConfig {
295+
/// The package's license identifier. If not set, defaults to the license from
296+
/// the Cargo.toml file.
297+
pub license: Option<String>,
298+
/// The list of RPM dependencies your application relies on.
299+
pub depends: Option<Vec<String>>,
300+
/// The RPM release tag.
301+
#[serde(default = "default_release")]
302+
pub release: String,
303+
/// The RPM epoch.
304+
#[serde(default)]
305+
pub epoch: u32,
306+
/// The files to include on the package.
307+
#[serde(default)]
308+
pub files: HashMap<PathBuf, PathBuf>,
309+
/// Path to a custom desktop file Handlebars template.
310+
///
311+
/// Available variables: `categories`, `comment` (optional), `exec`, `icon` and `name`.
312+
pub desktop_template: Option<PathBuf>,
313+
}
314+
315+
impl Default for RpmConfig {
316+
fn default() -> Self {
317+
Self {
318+
license: None,
319+
depends: None,
320+
release: default_release(),
321+
epoch: 0,
322+
files: Default::default(),
323+
desktop_template: None,
324+
}
325+
}
326+
}
327+
328+
fn default_release() -> String {
329+
"1".into()
330+
}
331+
285332
/// Position coordinates struct.
286333
#[derive(Default, Debug, PartialEq, Eq, Clone, Deserialize, Serialize)]
287334
#[cfg_attr(feature = "schema", derive(JsonSchema))]
@@ -885,7 +932,7 @@ pub struct BundleConfig {
885932
/// Whether Tauri should bundle your application or just output the executable.
886933
#[serde(default)]
887934
pub active: bool,
888-
/// The bundle targets, currently supports ["deb", "appimage", "nsis", "msi", "app", "dmg", "updater"] or "all".
935+
/// The bundle targets, currently supports ["deb", "rpm", "appimage", "nsis", "msi", "app", "dmg", "updater"] or "all".
889936
#[serde(default)]
890937
pub targets: BundleTarget,
891938
/// The application identifier in reverse domain name notation (e.g. `com.tauri.example`).
@@ -925,6 +972,9 @@ pub struct BundleConfig {
925972
/// Configuration for the Debian bundle.
926973
#[serde(default)]
927974
pub deb: DebConfig,
975+
/// Configuration for the RPM bundle.
976+
#[serde(default)]
977+
pub rpm: RpmConfig,
928978
/// DMG-specific settings.
929979
#[serde(default)]
930980
pub dmg: DmgConfig,
@@ -2518,6 +2568,7 @@ mod build {
25182568
let long_description = quote!(None);
25192569
let appimage = quote!(Default::default());
25202570
let deb = quote!(Default::default());
2571+
let rpm = quote!(Default::default());
25212572
let dmg = quote!(Default::default());
25222573
let macos = quote!(Default::default());
25232574
let external_bin = opt_vec_str_lit(self.external_bin.as_ref());
@@ -2542,6 +2593,7 @@ mod build {
25422593
long_description,
25432594
appimage,
25442595
deb,
2596+
rpm,
25452597
dmg,
25462598
macos,
25472599
external_bin,
@@ -2851,6 +2903,7 @@ mod test {
28512903
long_description: None,
28522904
appimage: Default::default(),
28532905
deb: Default::default(),
2906+
rpm: Default::default(),
28542907
dmg: Default::default(),
28552908
macos: Default::default(),
28562909
external_bin: None,

tooling/bundler/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ regex = "1"
6666
heck = "0.4"
6767
ar = "0.9.0"
6868
md5 = "0.7.0"
69+
rpm = "0.13.1"
6970

7071
[lib]
7172
name = "tauri_bundler"

tooling/bundler/src/bundle.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ pub use self::{
2121
category::AppCategory,
2222
settings::{
2323
BundleBinary, BundleSettings, DebianSettings, DmgSettings, MacOsSettings, PackageSettings,
24-
PackageType, Position, Settings, SettingsBuilder, Size, UpdaterSettings,
24+
PackageType, Position, RpmSettings, Settings, SettingsBuilder, Size, UpdaterSettings,
2525
},
2626
};
2727
#[cfg(target_os = "macos")]

tooling/bundler/src/bundle/category.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,9 +142,11 @@ impl AppCategory {
142142
}
143143
}
144144

145-
/// Map an AppCategory to the closest set of GNOME desktop registered
145+
/// Map an AppCategory to the closest set of Freedesktop registered
146146
/// categories that matches that category.
147-
pub fn gnome_desktop_categories(self) -> &'static str {
147+
///
148+
/// Cf https://specifications.freedesktop.org/menu-spec/latest/
149+
pub fn freedesktop_categories(self) -> &'static str {
148150
match &self {
149151
AppCategory::Business => "Office;",
150152
AppCategory::DeveloperTool => "Development;",

tooling/bundler/src/bundle/linux/appimage.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ pub fn bundle_project(settings: &Settings) -> crate::Result<Vec<PathBuf>> {
3131

3232
// generate deb_folder structure
3333
let (_, icons) = debian::generate_data(settings, &package_dir)?;
34-
let icons: Vec<debian::DebIcon> = icons.into_iter().collect();
3534

3635
let output_path = settings.project_out_directory().join("bundle/appimage");
3736
if output_path.exists() {

0 commit comments

Comments
 (0)