Skip to content

Commit 7aa30de

Browse files
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
1 parent 4926648 commit 7aa30de

File tree

7 files changed

+94
-1
lines changed

7 files changed

+94
-1
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"tauri-bundler": patch:feat
3+
---
4+
5+
Add `priority`, `section` and `changelog` options in Debian config.

core/tauri-config-schema/schema.json

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1320,6 +1320,27 @@
13201320
"string",
13211321
"null"
13221322
]
1323+
},
1324+
"section": {
1325+
"description": "Define the section in Debian Control file. See : https://www.debian.org/doc/debian-policy/ch-archive.html#s-subsections",
1326+
"type": [
1327+
"string",
1328+
"null"
1329+
]
1330+
},
1331+
"priority": {
1332+
"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`",
1333+
"type": [
1334+
"string",
1335+
"null"
1336+
]
1337+
},
1338+
"changelog": {
1339+
"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",
1340+
"type": [
1341+
"string",
1342+
"null"
1343+
]
13231344
}
13241345
},
13251346
"additionalProperties": false

core/tauri-utils/src/config.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,14 @@ pub struct DebConfig {
280280
///
281281
/// Available variables: `categories`, `comment` (optional), `exec`, `icon` and `name`.
282282
pub desktop_template: Option<PathBuf>,
283+
/// Define the section in Debian Control file. See : https://www.debian.org/doc/debian-policy/ch-archive.html#s-subsections
284+
pub section: Option<String>,
285+
/// Change the priority of the Debian Package. By default, it is set to `optional`.
286+
/// Recognized Priorities as of now are : `required`, `important`, `standard`, `optional`, `extra`
287+
pub priority: Option<String>,
288+
/// Path of the uncompressed Changelog file, to be stored at /usr/share/doc/package-name/changelog.gz. See
289+
/// https://www.debian.org/doc/debian-policy/ch-docs.html#changelog-files-and-release-notes
290+
pub changelog: Option<PathBuf>,
283291
}
284292

285293
fn de_minimum_system_version<'de, D>(deserializer: D) -> Result<Option<String>, D::Error>

tooling/bundler/src/bundle/linux/debian.rs

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,10 +135,30 @@ pub fn generate_data(
135135
let icons =
136136
generate_icon_files(settings, &data_dir).with_context(|| "Failed to create icon files")?;
137137
generate_desktop_file(settings, &data_dir).with_context(|| "Failed to create desktop file")?;
138+
generate_changelog_file(settings, &data_dir)
139+
.with_context(|| "Failed to create changelog.gz file")?;
138140

139141
Ok((data_dir, icons))
140142
}
141143

144+
/// Generate the Changelog file by compressing, to be stored at /usr/share/doc/package-name/changelog.gz. See
145+
/// https://www.debian.org/doc/debian-policy/ch-docs.html#changelog-files-and-release-notes
146+
fn generate_changelog_file(settings: &Settings, data_dir: &Path) -> crate::Result<()> {
147+
if let Some(changelog_src_path) = &settings.deb().changelog {
148+
let mut src_file = File::open(changelog_src_path)?;
149+
let bin_name = settings.main_binary_name();
150+
let dest_path = data_dir.join(format!("usr/share/doc/{}/changelog.gz", bin_name));
151+
152+
let changelog_file = common::create_file(&dest_path)?;
153+
let mut gzip_encoder = GzEncoder::new(changelog_file, Compression::new(9));
154+
io::copy(&mut src_file, &mut gzip_encoder)?;
155+
156+
let mut changelog_file = gzip_encoder.finish()?;
157+
changelog_file.flush()?;
158+
}
159+
Ok(())
160+
}
161+
142162
/// Generate the application desktop file and store it under the `data_dir`.
143163
fn generate_desktop_file(settings: &Settings, data_dir: &Path) -> crate::Result<()> {
144164
let bin_name = settings.main_binary_name();
@@ -212,6 +232,14 @@ fn generate_control_file(
212232
writeln!(file, "Installed-Size: {}", total_dir_size(data_dir)? / 1024)?;
213233
let authors = settings.authors_comma_separated().unwrap_or_default();
214234
writeln!(file, "Maintainer: {}", authors)?;
235+
if let Some(section) = &settings.deb().section {
236+
writeln!(file, "Section: {}", section)?;
237+
}
238+
if let Some(priority) = &settings.deb().priority {
239+
writeln!(file, "Priority: {}", priority)?;
240+
} else {
241+
writeln!(file, "Priority: optional")?;
242+
}
215243
if !settings.homepage_url().is_empty() {
216244
writeln!(file, "Homepage: {}", settings.homepage_url())?;
217245
}
@@ -236,7 +264,6 @@ fn generate_control_file(
236264
writeln!(file, " {}", line)?;
237265
}
238266
}
239-
writeln!(file, "Priority: optional")?;
240267
file.flush()?;
241268
Ok(())
242269
}

tooling/bundler/src/bundle/settings.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,14 @@ pub struct DebianSettings {
185185
#[doc = include_str!("./linux/templates/main.desktop")]
186186
/// ```
187187
pub desktop_template: Option<PathBuf>,
188+
/// Define the section in Debian Control file. See : https://www.debian.org/doc/debian-policy/ch-archive.html#s-subsections
189+
pub section: Option<String>,
190+
/// Change the priority of the Debian Package. By default, it is set to `optional`.
191+
/// Recognized Priorities as of now are : `required`, `important`, `standard`, `optional`, `extra`
192+
pub priority: Option<String>,
193+
/// Path of the uncompressed Changelog file, to be stored at /usr/share/doc/package-name/changelog.gz. See
194+
/// https://www.debian.org/doc/debian-policy/ch-docs.html#changelog-files-and-release-notes
195+
pub changelog: Option<PathBuf>,
188196
}
189197

190198
/// The macOS bundle settings.

tooling/cli/schema.json

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1320,6 +1320,27 @@
13201320
"string",
13211321
"null"
13221322
]
1323+
},
1324+
"section": {
1325+
"description": "Define the section in Debian Control file. See : https://www.debian.org/doc/debian-policy/ch-archive.html#s-subsections",
1326+
"type": [
1327+
"string",
1328+
"null"
1329+
]
1330+
},
1331+
"priority": {
1332+
"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`",
1333+
"type": [
1334+
"string",
1335+
"null"
1336+
]
1337+
},
1338+
"changelog": {
1339+
"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",
1340+
"type": [
1341+
"string",
1342+
"null"
1343+
]
13231344
}
13241345
},
13251346
"additionalProperties": false

tooling/cli/src/interface/rust.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1101,6 +1101,9 @@ fn tauri_config_to_bundle_settings(
11011101
},
11021102
files: config.deb.files,
11031103
desktop_template: config.deb.desktop_template,
1104+
section: config.deb.section,
1105+
priority: config.deb.priority,
1106+
changelog: config.deb.changelog,
11041107
},
11051108
macos: MacOsSettings {
11061109
frameworks: config.macos.frameworks,

0 commit comments

Comments
 (0)