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 RPM packaging, closes #4402 #5202

Merged
merged 3 commits into from
Dec 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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 @@ -31,7 +31,7 @@ npm create tauri-app@latest

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

- 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).
- 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).
- Built-in self updater (desktop only)
- System tray icons
- Native notifications
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 @@ -57,6 +57,11 @@
"macOS": {
"minimumSystemVersion": "10.13"
},
"rpm": {
"epoch": 0,
"files": {},
"release": "1"
},
"targets": "all",
"updater": {
"active": false,
Expand Down Expand Up @@ -205,6 +210,11 @@
"macOS": {
"minimumSystemVersion": "10.13"
},
"rpm": {
"epoch": 0,
"files": {},
"release": "1"
},
"targets": "all",
"updater": {
"active": false,
Expand Down Expand Up @@ -933,7 +943,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 @@ -1031,6 +1041,19 @@
}
]
},
"rpm": {
"description": "Configuration for the RPM bundle.",
"default": {
"epoch": 0,
"files": {},
"release": "1"
},
"allOf": [
{
"$ref": "#/definitions/RpmConfig"
}
]
},
"dmg": {
"description": "DMG-specific settings.",
"default": {
Expand Down Expand Up @@ -1170,6 +1193,13 @@
"deb"
]
},
{
"description": "The RPM bundle (.rpm).",
"type": "string",
"enum": [
"rpm"
]
},
{
"description": "The AppImage bundle (.appimage).",
"type": "string",
Expand Down Expand Up @@ -1368,6 +1398,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
},
"DmgConfig": {
"description": "Configuration for Apple Disk Image (.dmg) bundles.\n\nSee more: https://tauri.app/v1/api/config#dmgconfig",
"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()
}

/// Position coordinates struct.
#[derive(Default, Debug, PartialEq, Eq, Clone, Deserialize, Serialize)]
#[cfg_attr(feature = "schema", derive(JsonSchema))]
Expand Down Expand Up @@ -885,7 +932,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 @@ -925,6 +972,9 @@ pub struct BundleConfig {
/// Configuration for the Debian bundle.
#[serde(default)]
pub deb: DebConfig,
/// Configuration for the RPM bundle.
#[serde(default)]
pub rpm: RpmConfig,
/// DMG-specific settings.
#[serde(default)]
pub dmg: DmgConfig,
Expand Down Expand Up @@ -2518,6 +2568,7 @@ mod build {
let long_description = quote!(None);
let appimage = quote!(Default::default());
let deb = quote!(Default::default());
let rpm = quote!(Default::default());
let dmg = quote!(Default::default());
let macos = quote!(Default::default());
let external_bin = opt_vec_str_lit(self.external_bin.as_ref());
Expand All @@ -2542,6 +2593,7 @@ mod build {
long_description,
appimage,
deb,
rpm,
dmg,
macos,
external_bin,
Expand Down Expand Up @@ -2851,6 +2903,7 @@ mod test {
long_description: None,
appimage: Default::default(),
deb: Default::default(),
rpm: Default::default(),
dmg: Default::default(),
macos: Default::default(),
external_bin: None,
Expand Down
1 change: 1 addition & 0 deletions tooling/bundler/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ regex = "1"
heck = "0.4"
ar = "0.9.0"
md5 = "0.7.0"
rpm = "0.13.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, DmgSettings, MacOsSettings, PackageSettings,
PackageType, Position, Settings, SettingsBuilder, Size, UpdaterSettings,
PackageType, Position, RpmSettings, Settings, SettingsBuilder, Size, 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