mirror of
https://github.com/tauri-apps/tauri.git
synced 2024-12-18 16:11:38 +03:00
feat: Add Section, Priority and Changelog options (#8620)
* Init section, priority and changelog * Add section. priority and changelog support * fix variable name * Add .changes file * Fix Formatting * Apply suggestions from code review
This commit is contained in:
parent
4926648751
commit
7aa30dec85
5
.changes/add-section-priority-changelog.md
Normal file
5
.changes/add-section-priority-changelog.md
Normal file
@ -0,0 +1,5 @@
|
||||
---
|
||||
"tauri-bundler": patch:feat
|
||||
---
|
||||
|
||||
Add `priority`, `section` and `changelog` options in Debian config.
|
@ -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
|
||||
|
@ -280,6 +280,14 @@ pub struct DebConfig {
|
||||
///
|
||||
/// Available variables: `categories`, `comment` (optional), `exec`, `icon` and `name`.
|
||||
pub desktop_template: Option<PathBuf>,
|
||||
/// Define the section in Debian Control file. See : https://www.debian.org/doc/debian-policy/ch-archive.html#s-subsections
|
||||
pub section: Option<String>,
|
||||
/// 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<String>,
|
||||
/// 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<PathBuf>,
|
||||
}
|
||||
|
||||
fn de_minimum_system_version<'de, D>(deserializer: D) -> Result<Option<String>, D::Error>
|
||||
|
@ -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(())
|
||||
}
|
||||
|
@ -185,6 +185,14 @@ pub struct DebianSettings {
|
||||
#[doc = include_str!("./linux/templates/main.desktop")]
|
||||
/// ```
|
||||
pub desktop_template: Option<PathBuf>,
|
||||
/// Define the section in Debian Control file. See : https://www.debian.org/doc/debian-policy/ch-archive.html#s-subsections
|
||||
pub section: Option<String>,
|
||||
/// 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<String>,
|
||||
/// 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<PathBuf>,
|
||||
}
|
||||
|
||||
/// The macOS bundle settings.
|
||||
|
@ -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
|
||||
|
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user