Skip to content

Commit

Permalink
feat(bundler): Add RPM packaging, closes tauri-apps#4402 (tauri-apps#…
Browse files Browse the repository at this point in the history
…5202)

* feat(bundler): Add RPM packaging

* feat(bundler): Update 'rpm' to 0.13.1

* Fix fmt
  • Loading branch information
olivierlemasle authored and hjmallon committed May 21, 2024
1 parent d78fa20 commit 202cdcc
Show file tree
Hide file tree
Showing 19 changed files with 1,357 additions and 147 deletions.
8 changes: 8 additions & 0 deletions .changes/bundler-rpm.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
"tauri-bundler": 'patch:minor'
"tauri-cli": 'patch:minor'
"tauri-utils": 'patch:minor'
"@tauri-apps/cli": 'patch:minor'
---

Add RPM packaging
83 changes: 82 additions & 1 deletion core/tauri-config-schema/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,11 @@
"macOS": {
"minimumSystemVersion": "10.13"
},
"rpm": {
"epoch": 0,
"files": {},
"release": "1"
},
"targets": "all",
"windows": {
"allowDowngrades": true,
Expand Down Expand Up @@ -283,6 +288,11 @@
"macOS": {
"minimumSystemVersion": "10.13"
},
"rpm": {
"epoch": 0,
"files": {},
"release": "1"
},
"targets": "all",
"windows": {
"allowDowngrades": true,
Expand Down Expand Up @@ -1046,7 +1056,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 @@ -1134,6 +1144,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 @@ -1216,6 +1239,13 @@
"deb"
]
},
{
"description": "The RPM bundle (.rpm).",
"type": "string",
"enum": [
"rpm"
]
},
{
"description": "The AppImage bundle (.appimage).",
"type": "string",
Expand Down Expand Up @@ -1344,6 +1374,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 @@ -284,6 +288,49 @@ pub struct DebConfig {
pub changelog: 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 @@ -681,7 +728,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 @@ -719,6 +766,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 @@ -3546,6 +3596,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 @@ -3565,6 +3616,7 @@ mod build {
long_description,
appimage,
deb,
rpm,
macos,
external_bin,
windows
Expand Down Expand Up @@ -4007,6 +4059,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 @@ -65,6 +65,7 @@ regex = "1"
heck = "0.5"
ar = "0.9.0"
md5 = "0.7.0"
rpm = "0.14.0"

[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 202cdcc

Please sign in to comment.