diff --git a/src/build/binary.rs b/src/build/binary.rs index 3d6d570..b85923f 100644 --- a/src/build/binary.rs +++ b/src/build/binary.rs @@ -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, diff --git a/src/build/changes.rs b/src/build/changes.rs index db37b77..5a41af2 100644 --- a/src/build/changes.rs +++ b/src/build/changes.rs @@ -87,6 +87,11 @@ pub struct ChangesInput { pub descriptions: Vec, /// Bug numbers collected from the changelog (`Closes` field), if any. pub closes: Option, + /// 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, /// 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 ".to_string()), + changed_by: Some("A B ".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 ".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()); diff --git a/src/build/mod.rs b/src/build/mod.rs index 30d1d54..cc631f6 100644 --- a/src/build/mod.rs +++ b/src/build/mod.rs @@ -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(),