Skip to content

Commit

Permalink
bundler: Add RPM packaging
Browse files Browse the repository at this point in the history
  • Loading branch information
olivierlemasle committed Sep 28, 2023
1 parent 1bce739 commit 74cc9ab
Show file tree
Hide file tree
Showing 19 changed files with 1,421 additions and 164 deletions.
7 changes: 7 additions & 0 deletions .changes/bundler-rpm.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"tauri-bundler": 'patch:enhance'
"tauri-cli": 'patch:enhance'
"@tauri-apps/cli": 'patch:enhance'
---

Add RPM packaging
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ For **running** Tauri apps we support the below configurations (these are automa

### Features

- [x] Desktop Bundler (.app, .dmg, .deb, AppImage, .msi)
- [x] Desktop Bundler (.app, .dmg, .deb, .rpm, AppImage, .msi)
- [x] Self Updater
- [x] App Signing
- [x] Native Notifications (toast)
Expand Down
83 changes: 82 additions & 1 deletion core/tauri-config-schema/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@
"macOS": {
"minimumSystemVersion": "10.13"
},
"rpm": {
"epoch": 0,
"files": {},
"release": "1"
},
"targets": "all",
"updater": {
"active": false,
Expand Down Expand Up @@ -177,6 +182,11 @@
"macOS": {
"minimumSystemVersion": "10.13"
},
"rpm": {
"epoch": 0,
"files": {},
"release": "1"
},
"targets": "all",
"updater": {
"active": false,
Expand Down Expand Up @@ -879,7 +889,7 @@
"type": "boolean"
},
"targets": {
"description": "The bundle targets, currently supports [\"deb\", \"appimage\", \"nsis\", \"msi\", \"app\", \"dmg\", \"updater\"] or \"all\".",
"description": "The bundle targets, currently supports [\"deb\", \"rpm\", \"appimage\", \"nsis\", \"msi\", \"app\", \"dmg\", \"updater\"] or \"all\".",
"default": "all",
"allOf": [
{
Expand Down Expand Up @@ -976,6 +986,19 @@
}
]
},
"rpm": {
"description": "Configuration for the RPM bundle.",
"default": {
"epoch": 0,
"files": {},
"release": "1"
},
"allOf": [
{
"$ref": "#/definitions/RpmConfig"
}
]
},
"macOS": {
"description": "Configuration for the macOS bundles.",
"default": {
Expand Down Expand Up @@ -1093,6 +1116,13 @@
"deb"
]
},
{
"description": "The RPM bundle (.rpm).",
"type": "string",
"enum": [
"rpm"
]
},
{
"description": "The AppImage bundle (.appimage).",
"type": "string",
Expand Down Expand Up @@ -1272,6 +1302,57 @@
},
"additionalProperties": false
},
"RpmConfig": {
"description": "Configuration for RPM bundles.",
"type": "object",
"properties": {
"license": {
"description": "The package's license identifier. If not set, defaults to the license from the Cargo.toml file.",
"type": [
"string",
"null"
]
},
"depends": {
"description": "The list of RPM dependencies your application relies on.",
"type": [
"array",
"null"
],
"items": {
"type": "string"
}
},
"release": {
"description": "The RPM release tag.",
"default": "1",
"type": "string"
},
"epoch": {
"description": "The RPM epoch.",
"default": 0,
"type": "integer",
"format": "uint32",
"minimum": 0.0
},
"files": {
"description": "The files to include on the package.",
"default": {},
"type": "object",
"additionalProperties": {
"type": "string"
}
},
"desktopTemplate": {
"description": "Path to a custom desktop file Handlebars template.\n\nAvailable variables: `categories`, `comment` (optional), `exec`, `icon` and `name`.",
"type": [
"string",
"null"
]
}
},
"additionalProperties": false
},
"MacConfig": {
"description": "Configuration for the macOS bundles.\n\nSee more: https://tauri.app/v1/api/config#macconfig",
"type": "object",
Expand Down
55 changes: 54 additions & 1 deletion core/tauri-utils/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ impl Default for WindowUrl {
pub enum BundleType {
/// The debian bundle (.deb).
Deb,
/// The RPM bundle (.rpm).
Rpm,
/// The AppImage bundle (.appimage).
AppImage,
/// The Microsoft Installer bundle (.msi).
Expand All @@ -99,6 +101,7 @@ impl Display for BundleType {
"{}",
match self {
Self::Deb => "deb",
Self::Rpm => "rpm",
Self::AppImage => "appimage",
Self::Msi => "msi",
Self::Nsis => "nsis",
Expand Down Expand Up @@ -127,6 +130,7 @@ impl<'de> Deserialize<'de> for BundleType {
let s = String::deserialize(deserializer)?;
match s.to_lowercase().as_str() {
"deb" => Ok(Self::Deb),
"rpm" => Ok(Self::Rpm),
"appimage" => Ok(Self::AppImage),
"msi" => Ok(Self::Msi),
"nsis" => Ok(Self::Nsis),
Expand Down Expand Up @@ -282,6 +286,49 @@ pub struct DebConfig {
pub desktop_template: Option<PathBuf>,
}

/// Configuration for RPM bundles.
#[skip_serializing_none]
#[derive(Debug, PartialEq, Eq, Clone, Deserialize, Serialize)]
#[cfg_attr(feature = "schema", derive(JsonSchema))]
#[serde(rename_all = "camelCase", deny_unknown_fields)]
pub struct RpmConfig {
/// The package's license identifier. If not set, defaults to the license from
/// the Cargo.toml file.
pub license: Option<String>,
/// The list of RPM dependencies your application relies on.
pub depends: Option<Vec<String>>,
/// The RPM release tag.
#[serde(default = "default_release")]
pub release: String,
/// The RPM epoch.
#[serde(default)]
pub epoch: u32,
/// The files to include on the package.
#[serde(default)]
pub files: HashMap<PathBuf, PathBuf>,
/// Path to a custom desktop file Handlebars template.
///
/// Available variables: `categories`, `comment` (optional), `exec`, `icon` and `name`.
pub desktop_template: Option<PathBuf>,
}

impl Default for RpmConfig {
fn default() -> Self {
Self {
license: None,
depends: None,
release: default_release(),
epoch: 0,
files: Default::default(),
desktop_template: None,
}
}
}

fn default_release() -> String {
"1".into()
}

fn de_minimum_system_version<'de, D>(deserializer: D) -> Result<Option<String>, D::Error>
where
D: Deserializer<'de>,
Expand Down Expand Up @@ -766,7 +813,7 @@ pub struct BundleConfig {
/// Whether Tauri should bundle your application or just output the executable.
#[serde(default)]
pub active: bool,
/// The bundle targets, currently supports ["deb", "appimage", "nsis", "msi", "app", "dmg", "updater"] or "all".
/// The bundle targets, currently supports ["deb", "rpm", "appimage", "nsis", "msi", "app", "dmg", "updater"] or "all".
#[serde(default)]
pub targets: BundleTarget,
/// The application identifier in reverse domain name notation (e.g. `com.tauri.example`).
Expand Down Expand Up @@ -806,6 +853,9 @@ pub struct BundleConfig {
/// Configuration for the Debian bundle.
#[serde(default)]
pub deb: DebConfig,
/// Configuration for the RPM bundle.
#[serde(default)]
pub rpm: RpmConfig,
/// Configuration for the macOS bundles.
#[serde(rename = "macOS", default)]
pub macos: MacConfig,
Expand Down Expand Up @@ -2378,6 +2428,7 @@ mod build {
let long_description = quote!(None);
let appimage = quote!(Default::default());
let deb = quote!(Default::default());
let rpm = quote!(Default::default());
let macos = quote!(Default::default());
let external_bin = opt_vec_str_lit(self.external_bin.as_ref());
let windows = &self.windows;
Expand All @@ -2401,6 +2452,7 @@ mod build {
long_description,
appimage,
deb,
rpm,
macos,
external_bin,
windows,
Expand Down Expand Up @@ -2707,6 +2759,7 @@ mod test {
long_description: None,
appimage: Default::default(),
deb: Default::default(),
rpm: Default::default(),
macos: Default::default(),
external_bin: None,
windows: Default::default(),
Expand Down
1 change: 1 addition & 0 deletions tooling/bundler/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ regex = "1"
heck = "0.4"
ar = "0.9.0"
md5 = "0.7.0"
rpm = "0.12.1"

[lib]
name = "tauri_bundler"
Expand Down
2 changes: 1 addition & 1 deletion tooling/bundler/src/bundle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ pub use self::{
category::AppCategory,
settings::{
BundleBinary, BundleSettings, DebianSettings, MacOsSettings, PackageSettings, PackageType,
Settings, SettingsBuilder, UpdaterSettings,
RpmSettings, Settings, SettingsBuilder, UpdaterSettings,
},
};
#[cfg(target_os = "macos")]
Expand Down
6 changes: 4 additions & 2 deletions tooling/bundler/src/bundle/category.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,9 +142,11 @@ impl AppCategory {
}
}

/// Map an AppCategory to the closest set of GNOME desktop registered
/// Map an AppCategory to the closest set of Freedesktop registered
/// categories that matches that category.
pub fn gnome_desktop_categories(self) -> &'static str {
///
/// Cf https://specifications.freedesktop.org/menu-spec/latest/
pub fn freedesktop_categories(self) -> &'static str {
match &self {
AppCategory::Business => "Office;",
AppCategory::DeveloperTool => "Development;",
Expand Down
1 change: 0 additions & 1 deletion tooling/bundler/src/bundle/linux/appimage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ pub fn bundle_project(settings: &Settings) -> crate::Result<Vec<PathBuf>> {

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

let output_path = settings.project_out_directory().join("bundle/appimage");
if output_path.exists() {
Expand Down
Loading

0 comments on commit 74cc9ab

Please sign in to comment.