diff --git a/.changes/add-section-priority-changelog.md b/.changes/add-section-priority-changelog.md new file mode 100644 index 000000000000..8a15551b2549 --- /dev/null +++ b/.changes/add-section-priority-changelog.md @@ -0,0 +1,5 @@ +--- +"tauri-bundler": patch:feat +--- + +Add `priority`, `section` and `changelog` options in Debian config. diff --git a/core/tauri-config-schema/schema.json b/core/tauri-config-schema/schema.json index af0ca7635b00..ef718f93b195 100644 --- a/core/tauri-config-schema/schema.json +++ b/core/tauri-config-schema/schema.json @@ -1320,6 +1320,27 @@ "string", "null" ] + }, + "section": { + "description": "Define the section in Debian Control file. See : https://www.debian.org/doc/debian-policy/ch-archive.html#s-subsections", + "type": [ + "string", + "null" + ] + }, + "priority": { + "description": "Change the priority of the Debian Package. By default, it is set to `optional`. Recognized Priorities as of now are : `required`, `important`, `standard`, `optional`, `extra`", + "type": [ + "string", + "null" + ] + }, + "changelog": { + "description": "Path of the uncompressed Changelog file, to be stored at /usr/share/doc/package-name/changelog.gz. See https://www.debian.org/doc/debian-policy/ch-docs.html#changelog-files-and-release-notes", + "type": [ + "string", + "null" + ] } }, "additionalProperties": false diff --git a/core/tauri-utils/src/config.rs b/core/tauri-utils/src/config.rs index 87ede1b870ec..9e673c2079bb 100644 --- a/core/tauri-utils/src/config.rs +++ b/core/tauri-utils/src/config.rs @@ -280,6 +280,14 @@ pub struct DebConfig { /// /// Available variables: `categories`, `comment` (optional), `exec`, `icon` and `name`. pub desktop_template: Option, + /// Define the section in Debian Control file. See : https://www.debian.org/doc/debian-policy/ch-archive.html#s-subsections + pub section: Option, + /// Change the priority of the Debian Package. By default, it is set to `optional`. + /// Recognized Priorities as of now are : `required`, `important`, `standard`, `optional`, `extra` + pub priority: Option, + /// Path of the uncompressed Changelog file, to be stored at /usr/share/doc/package-name/changelog.gz. See + /// https://www.debian.org/doc/debian-policy/ch-docs.html#changelog-files-and-release-notes + pub changelog: Option, } fn de_minimum_system_version<'de, D>(deserializer: D) -> Result, D::Error> diff --git a/tooling/bundler/src/bundle/linux/debian.rs b/tooling/bundler/src/bundle/linux/debian.rs index 28300d4dc7ca..23b76af95dd8 100644 --- a/tooling/bundler/src/bundle/linux/debian.rs +++ b/tooling/bundler/src/bundle/linux/debian.rs @@ -135,10 +135,30 @@ pub fn generate_data( let icons = generate_icon_files(settings, &data_dir).with_context(|| "Failed to create icon files")?; generate_desktop_file(settings, &data_dir).with_context(|| "Failed to create desktop file")?; + generate_changelog_file(settings, &data_dir) + .with_context(|| "Failed to create changelog.gz file")?; Ok((data_dir, icons)) } +/// Generate the Changelog file by compressing, to be stored at /usr/share/doc/package-name/changelog.gz. See +/// https://www.debian.org/doc/debian-policy/ch-docs.html#changelog-files-and-release-notes +fn generate_changelog_file(settings: &Settings, data_dir: &Path) -> crate::Result<()> { + if let Some(changelog_src_path) = &settings.deb().changelog { + let mut src_file = File::open(changelog_src_path)?; + let bin_name = settings.main_binary_name(); + let dest_path = data_dir.join(format!("usr/share/doc/{}/changelog.gz", bin_name)); + + let changelog_file = common::create_file(&dest_path)?; + let mut gzip_encoder = GzEncoder::new(changelog_file, Compression::new(9)); + io::copy(&mut src_file, &mut gzip_encoder)?; + + let mut changelog_file = gzip_encoder.finish()?; + changelog_file.flush()?; + } + Ok(()) +} + /// Generate the application desktop file and store it under the `data_dir`. fn generate_desktop_file(settings: &Settings, data_dir: &Path) -> crate::Result<()> { let bin_name = settings.main_binary_name(); @@ -212,6 +232,14 @@ fn generate_control_file( writeln!(file, "Installed-Size: {}", total_dir_size(data_dir)? / 1024)?; let authors = settings.authors_comma_separated().unwrap_or_default(); writeln!(file, "Maintainer: {}", authors)?; + if let Some(section) = &settings.deb().section { + writeln!(file, "Section: {}", section)?; + } + if let Some(priority) = &settings.deb().priority { + writeln!(file, "Priority: {}", priority)?; + } else { + writeln!(file, "Priority: optional")?; + } if !settings.homepage_url().is_empty() { writeln!(file, "Homepage: {}", settings.homepage_url())?; } @@ -236,7 +264,6 @@ fn generate_control_file( writeln!(file, " {}", line)?; } } - writeln!(file, "Priority: optional")?; file.flush()?; Ok(()) } diff --git a/tooling/bundler/src/bundle/settings.rs b/tooling/bundler/src/bundle/settings.rs index 09936a74fb03..1eed1163f2e7 100644 --- a/tooling/bundler/src/bundle/settings.rs +++ b/tooling/bundler/src/bundle/settings.rs @@ -185,6 +185,14 @@ pub struct DebianSettings { #[doc = include_str!("./linux/templates/main.desktop")] /// ``` pub desktop_template: Option, + /// Define the section in Debian Control file. See : https://www.debian.org/doc/debian-policy/ch-archive.html#s-subsections + pub section: Option, + /// Change the priority of the Debian Package. By default, it is set to `optional`. + /// Recognized Priorities as of now are : `required`, `important`, `standard`, `optional`, `extra` + pub priority: Option, + /// Path of the uncompressed Changelog file, to be stored at /usr/share/doc/package-name/changelog.gz. See + /// https://www.debian.org/doc/debian-policy/ch-docs.html#changelog-files-and-release-notes + pub changelog: Option, } /// The macOS bundle settings. diff --git a/tooling/cli/schema.json b/tooling/cli/schema.json index af0ca7635b00..ef718f93b195 100644 --- a/tooling/cli/schema.json +++ b/tooling/cli/schema.json @@ -1320,6 +1320,27 @@ "string", "null" ] + }, + "section": { + "description": "Define the section in Debian Control file. See : https://www.debian.org/doc/debian-policy/ch-archive.html#s-subsections", + "type": [ + "string", + "null" + ] + }, + "priority": { + "description": "Change the priority of the Debian Package. By default, it is set to `optional`. Recognized Priorities as of now are : `required`, `important`, `standard`, `optional`, `extra`", + "type": [ + "string", + "null" + ] + }, + "changelog": { + "description": "Path of the uncompressed Changelog file, to be stored at /usr/share/doc/package-name/changelog.gz. See https://www.debian.org/doc/debian-policy/ch-docs.html#changelog-files-and-release-notes", + "type": [ + "string", + "null" + ] } }, "additionalProperties": false diff --git a/tooling/cli/src/interface/rust.rs b/tooling/cli/src/interface/rust.rs index 02fb0c058a3d..d6244ad32ae8 100644 --- a/tooling/cli/src/interface/rust.rs +++ b/tooling/cli/src/interface/rust.rs @@ -1101,6 +1101,9 @@ fn tauri_config_to_bundle_settings( }, files: config.deb.files, desktop_template: config.deb.desktop_template, + section: config.deb.section, + priority: config.deb.priority, + changelog: config.deb.changelog, }, macos: MacOsSettings { frameworks: config.macos.frameworks,