Skip to content

Commit 253595a

Browse files
hjmallonolivierlemaslelucasfernog
authored
feat(bundler): Add RPM packaging, closes #4402 (#5202) (#9809)
* feat(bundler): Add RPM packaging * feat(bundler): Update 'rpm' to 0.13.1 * Fix fmt Co-authored-by: Olivier Lemasle <olivier.lemasle@apalia.net> Co-authored-by: Lucas Fernandes Nogueira <lucas@tauri.app>
1 parent a020828 commit 253595a

File tree

19 files changed

+1357
-147
lines changed

19 files changed

+1357
-147
lines changed

.changes/bundler-rpm.md

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
"tauri-bundler": 'minor:feat'
3+
"tauri-cli": 'minor:feat'
4+
"tauri-utils": 'minor:feat'
5+
"@tauri-apps/cli": 'minor:feat'
6+
---
7+
8+
Add RPM packaging

core/tauri-config-schema/schema.json

+82-1
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,11 @@
144144
"macOS": {
145145
"minimumSystemVersion": "10.13"
146146
},
147+
"rpm": {
148+
"epoch": 0,
149+
"files": {},
150+
"release": "1"
151+
},
147152
"targets": "all",
148153
"windows": {
149154
"allowDowngrades": true,
@@ -283,6 +288,11 @@
283288
"macOS": {
284289
"minimumSystemVersion": "10.13"
285290
},
291+
"rpm": {
292+
"epoch": 0,
293+
"files": {},
294+
"release": "1"
295+
},
286296
"targets": "all",
287297
"windows": {
288298
"allowDowngrades": true,
@@ -1046,7 +1056,7 @@
10461056
"type": "boolean"
10471057
},
10481058
"targets": {
1049-
"description": "The bundle targets, currently supports [\"deb\", \"appimage\", \"nsis\", \"msi\", \"app\", \"dmg\", \"updater\"] or \"all\".",
1059+
"description": "The bundle targets, currently supports [\"deb\", \"rpm\", \"appimage\", \"nsis\", \"msi\", \"app\", \"dmg\", \"updater\"] or \"all\".",
10501060
"default": "all",
10511061
"allOf": [
10521062
{
@@ -1134,6 +1144,19 @@
11341144
}
11351145
]
11361146
},
1147+
"rpm": {
1148+
"description": "Configuration for the RPM bundle.",
1149+
"default": {
1150+
"epoch": 0,
1151+
"files": {},
1152+
"release": "1"
1153+
},
1154+
"allOf": [
1155+
{
1156+
"$ref": "#/definitions/RpmConfig"
1157+
}
1158+
]
1159+
},
11371160
"macOS": {
11381161
"description": "Configuration for the macOS bundles.",
11391162
"default": {
@@ -1216,6 +1239,13 @@
12161239
"deb"
12171240
]
12181241
},
1242+
{
1243+
"description": "The RPM bundle (.rpm).",
1244+
"type": "string",
1245+
"enum": [
1246+
"rpm"
1247+
]
1248+
},
12191249
{
12201250
"description": "The AppImage bundle (.appimage).",
12211251
"type": "string",
@@ -1344,6 +1374,57 @@
13441374
},
13451375
"additionalProperties": false
13461376
},
1377+
"RpmConfig": {
1378+
"description": "Configuration for RPM bundles.",
1379+
"type": "object",
1380+
"properties": {
1381+
"license": {
1382+
"description": "The package's license identifier. If not set, defaults to the license from the Cargo.toml file.",
1383+
"type": [
1384+
"string",
1385+
"null"
1386+
]
1387+
},
1388+
"depends": {
1389+
"description": "The list of RPM dependencies your application relies on.",
1390+
"type": [
1391+
"array",
1392+
"null"
1393+
],
1394+
"items": {
1395+
"type": "string"
1396+
}
1397+
},
1398+
"release": {
1399+
"description": "The RPM release tag.",
1400+
"default": "1",
1401+
"type": "string"
1402+
},
1403+
"epoch": {
1404+
"description": "The RPM epoch.",
1405+
"default": 0,
1406+
"type": "integer",
1407+
"format": "uint32",
1408+
"minimum": 0.0
1409+
},
1410+
"files": {
1411+
"description": "The files to include on the package.",
1412+
"default": {},
1413+
"type": "object",
1414+
"additionalProperties": {
1415+
"type": "string"
1416+
}
1417+
},
1418+
"desktopTemplate": {
1419+
"description": "Path to a custom desktop file Handlebars template.\n\nAvailable variables: `categories`, `comment` (optional), `exec`, `icon` and `name`.",
1420+
"type": [
1421+
"string",
1422+
"null"
1423+
]
1424+
}
1425+
},
1426+
"additionalProperties": false
1427+
},
13471428
"MacConfig": {
13481429
"description": "Configuration for the macOS bundles.\n\nSee more: https://tauri.app/v1/api/config#macconfig",
13491430
"type": "object",

core/tauri-utils/src/config.rs

+54-1
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),
@@ -284,6 +288,49 @@ pub struct DebConfig {
284288
pub changelog: Option<PathBuf>,
285289
}
286290

291+
/// Configuration for RPM bundles.
292+
#[skip_serializing_none]
293+
#[derive(Debug, PartialEq, Eq, Clone, Deserialize, Serialize)]
294+
#[cfg_attr(feature = "schema", derive(JsonSchema))]
295+
#[serde(rename_all = "camelCase", deny_unknown_fields)]
296+
pub struct RpmConfig {
297+
/// The package's license identifier. If not set, defaults to the license from
298+
/// the Cargo.toml file.
299+
pub license: Option<String>,
300+
/// The list of RPM dependencies your application relies on.
301+
pub depends: Option<Vec<String>>,
302+
/// The RPM release tag.
303+
#[serde(default = "default_release")]
304+
pub release: String,
305+
/// The RPM epoch.
306+
#[serde(default)]
307+
pub epoch: u32,
308+
/// The files to include on the package.
309+
#[serde(default)]
310+
pub files: HashMap<PathBuf, PathBuf>,
311+
/// Path to a custom desktop file Handlebars template.
312+
///
313+
/// Available variables: `categories`, `comment` (optional), `exec`, `icon` and `name`.
314+
pub desktop_template: Option<PathBuf>,
315+
}
316+
317+
impl Default for RpmConfig {
318+
fn default() -> Self {
319+
Self {
320+
license: None,
321+
depends: None,
322+
release: default_release(),
323+
epoch: 0,
324+
files: Default::default(),
325+
desktop_template: None,
326+
}
327+
}
328+
}
329+
330+
fn default_release() -> String {
331+
"1".into()
332+
}
333+
287334
fn de_minimum_system_version<'de, D>(deserializer: D) -> Result<Option<String>, D::Error>
288335
where
289336
D: Deserializer<'de>,
@@ -681,7 +728,7 @@ pub struct BundleConfig {
681728
/// Whether Tauri should bundle your application or just output the executable.
682729
#[serde(default)]
683730
pub active: bool,
684-
/// The bundle targets, currently supports ["deb", "appimage", "nsis", "msi", "app", "dmg", "updater"] or "all".
731+
/// The bundle targets, currently supports ["deb", "rpm", "appimage", "nsis", "msi", "app", "dmg", "updater"] or "all".
685732
#[serde(default)]
686733
pub targets: BundleTarget,
687734
/// The application identifier in reverse domain name notation (e.g. `com.tauri.example`).
@@ -719,6 +766,9 @@ pub struct BundleConfig {
719766
/// Configuration for the Debian bundle.
720767
#[serde(default)]
721768
pub deb: DebConfig,
769+
/// Configuration for the RPM bundle.
770+
#[serde(default)]
771+
pub rpm: RpmConfig,
722772
/// Configuration for the macOS bundles.
723773
#[serde(rename = "macOS", default)]
724774
pub macos: MacConfig,
@@ -3546,6 +3596,7 @@ mod build {
35463596
let long_description = quote!(None);
35473597
let appimage = quote!(Default::default());
35483598
let deb = quote!(Default::default());
3599+
let rpm = quote!(Default::default());
35493600
let macos = quote!(Default::default());
35503601
let external_bin = opt_vec_str_lit(self.external_bin.as_ref());
35513602
let windows = &self.windows;
@@ -3565,6 +3616,7 @@ mod build {
35653616
long_description,
35663617
appimage,
35673618
deb,
3619+
rpm,
35683620
macos,
35693621
external_bin,
35703622
windows
@@ -4007,6 +4059,7 @@ mod test {
40074059
long_description: None,
40084060
appimage: Default::default(),
40094061
deb: Default::default(),
4062+
rpm: Default::default(),
40104063
macos: Default::default(),
40114064
external_bin: None,
40124065
windows: Default::default(),

tooling/bundler/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ regex = "1"
6565
heck = "0.5"
6666
ar = "0.9.0"
6767
md5 = "0.7.0"
68+
rpm = "0.14.0"
6869

6970
[lib]
7071
name = "tauri_bundler"

tooling/bundler/src/bundle.rs

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

tooling/bundler/src/bundle/category.rs

+4-2
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

-1
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)