build: emit Launchpad-Bugs-Fixed in .changes like Ubuntu's dpkg
Ubuntu's dpkg inserts the field right after 'Closes' in both the .changes and the changelog. Emitting it closes the gap with dpkg-genchanges output and gives the put mistake guards something to read.
This commit is contained in:
1 parent
ef9c6d4f93
commit
8fceb13bcf
3 files changed
+50
-1
No files matched your search
@@ -313,6 +313,7 @@ pub fn generate_binary_metadata(
|
||||
changed_by: Some(changed_by),
|
||||
descriptions,
|
||||
closes: entry.closes.clone(),
|
||||
launchpad_bugs_fixed: entry.lp_bugs.clone(),
|
||||
changes_field: entry.changes_field.clone(),
|
||||
checksums,
|
||||
files_list,
|
||||
|
||||
+48
-1
@@ -87,6 +87,11 @@ pub struct ChangesInput {
|
||||
pub descriptions: Vec<String>,
|
||||
/// Bug numbers collected from the changelog (`Closes` field), if any.
|
||||
pub closes: Option<String>,
|
||||
/// Launchpad bug numbers collected from `LP: #NNN` changelog mentions
|
||||
/// (`Launchpad-Bugs-Fixed` field), if any. Ubuntu's vendor extension
|
||||
/// to the `.changes` format, emitted after `Closes` like Ubuntu's
|
||||
/// dpkg does.
|
||||
pub launchpad_bugs_fixed: Option<String>,
|
||||
/// Rendered `Changes` field value from the changelog entry.
|
||||
pub changes_field: String,
|
||||
/// Computed artifact checksums (dsc, tarballs, debs, buildinfo).
|
||||
@@ -170,6 +175,9 @@ pub fn render_changes(input: &ChangesInput) -> Paragraph {
|
||||
if let Some(closes) = &input.closes {
|
||||
p.set("Closes", closes);
|
||||
}
|
||||
if let Some(bugs) = &input.launchpad_bugs_fixed {
|
||||
p.set("Launchpad-Bugs-Fixed", bugs);
|
||||
}
|
||||
p.set("Changes", &input.changes_field);
|
||||
|
||||
if !input.checksums.is_empty() {
|
||||
@@ -238,6 +246,42 @@ mod tests {
|
||||
assert!(!is_debian_tarball_or_diff("pkg_1.0.tar.xz"));
|
||||
}
|
||||
|
||||
/// The Ubuntu vendor field `Launchpad-Bugs-Fixed` renders right after
|
||||
/// `Closes`, like Ubuntu's dpkg orders it.
|
||||
#[test]
|
||||
fn launchpad_bugs_fixed_renders_after_closes() {
|
||||
let checksums = FileChecksums::new();
|
||||
let input = ChangesInput {
|
||||
date: "Sat, 22 Aug 2026 10:00:00 +0000".to_string(),
|
||||
source: "pkg".to_string(),
|
||||
binaries: vec![],
|
||||
binary_only: false,
|
||||
built_for_profiles: vec![],
|
||||
architecture: "source".to_string(),
|
||||
version: "1.0-1".to_string(),
|
||||
distribution: "unstable".to_string(),
|
||||
urgency: "medium".to_string(),
|
||||
maintainer: Some("A B <a@b.c>".to_string()),
|
||||
changed_by: Some("A B <a@b.c>".to_string()),
|
||||
descriptions: vec![],
|
||||
closes: Some("42".to_string()),
|
||||
launchpad_bugs_fixed: Some("99 1234".to_string()),
|
||||
changes_field: "pkg (1.0-1) unstable; urgency=medium\n.\n * Fix.".to_string(),
|
||||
checksums,
|
||||
files_list: FilesList::default(),
|
||||
};
|
||||
|
||||
let p = render_changes(&input);
|
||||
let keys: Vec<&str> = p.iter().map(|(k, _)| k).collect();
|
||||
let closes_idx = keys.iter().position(|k| *k == "Closes").unwrap();
|
||||
let bugs_idx = keys
|
||||
.iter()
|
||||
.position(|k| *k == "Launchpad-Bugs-Fixed")
|
||||
.unwrap();
|
||||
assert!(bugs_idx == closes_idx + 1, "unexpected order: {keys:?}");
|
||||
assert_eq!(p.get("Launchpad-Bugs-Fixed"), Some("99 1234"));
|
||||
}
|
||||
|
||||
/// Build a minimal changelog entry for one source/version pair.
|
||||
fn entry(src: &str, ver: &str) -> ChangelogEntry {
|
||||
crate::debian::changelog::parse_changelog_entries_from_str(
|
||||
@@ -345,6 +389,7 @@ mod tests {
|
||||
changed_by: Some("A B <a@b.c>".to_string()),
|
||||
descriptions: vec![],
|
||||
closes: None,
|
||||
launchpad_bugs_fixed: None,
|
||||
changes_field: "pkg (1.0) unstable; urgency=medium\n.\n * Something.".to_string(),
|
||||
checksums,
|
||||
files_list,
|
||||
@@ -370,8 +415,10 @@ mod tests {
|
||||
"Files"
|
||||
]
|
||||
);
|
||||
// No Binary / Description / Checksums-Md5 for source-only uploads.
|
||||
// No Binary / Description / Checksums-Md5 / Launchpad-Bugs-Fixed
|
||||
// for source-only uploads without bug references.
|
||||
assert!(p.get("Binary").is_none());
|
||||
assert!(p.get("Launchpad-Bugs-Fixed").is_none());
|
||||
assert!(p.get("Description").is_none());
|
||||
assert!(p.get("Checksums-Md5").is_none());
|
||||
|
||||
|
||||
@@ -632,6 +632,7 @@ pub fn run_source_build(
|
||||
changed_by: Some(changed_by.clone()),
|
||||
descriptions: Vec::new(),
|
||||
closes: entry.closes.clone(),
|
||||
launchpad_bugs_fixed: entry.lp_bugs.clone(),
|
||||
changes_field: entry.changes_field.clone(),
|
||||
checksums: checksums.clone(),
|
||||
files_list: changes_files.clone(),
|
||||
|
||||
Reference in new issue
Block a user