@@ -295,28 +295,34 @@ impl SyncState {
295295 SyncState :: default ( )
296296 }
297297
298- fn get_mut_group (
298+ fn create_release_group (
299299 & mut self ,
300- src : & DebianSourcePkg ,
301300 release : & str ,
302301 component : & str ,
303302 architecture : & str ,
304- ) -> & mut SourcePackageReport {
303+ ) -> & mut PackageReport {
305304 let key = (
306305 release. to_string ( ) ,
307306 component. to_string ( ) ,
308307 architecture. to_string ( ) ,
309308 ) ;
310- let report = self
311- . reports
312- . entry ( key. clone ( ) )
313- . or_insert_with ( || PackageReport {
314- distribution : "debian" . to_string ( ) ,
315- release : Some ( release. to_string ( ) ) ,
316- component : Some ( component. to_string ( ) ) ,
317- architecture : architecture. to_string ( ) ,
318- packages : Vec :: new ( ) ,
319- } ) ;
309+ self . reports . entry ( key) . or_insert_with ( || PackageReport {
310+ distribution : "debian" . to_string ( ) ,
311+ release : Some ( release. to_string ( ) ) ,
312+ component : Some ( component. to_string ( ) ) ,
313+ architecture : architecture. to_string ( ) ,
314+ packages : Vec :: new ( ) ,
315+ } )
316+ }
317+
318+ fn get_mut_group (
319+ & mut self ,
320+ src : & DebianSourcePkg ,
321+ release : & str ,
322+ component : & str ,
323+ architecture : & str ,
324+ ) -> & mut SourcePackageReport {
325+ let report = self . create_release_group ( release, component, architecture) ;
320326
321327 match report
322328 . packages
@@ -392,6 +398,15 @@ impl SyncState {
392398 Ok ( ( ) )
393399 }
394400
401+ /// Ensure all release groups are created, even if we never assign any packages to it.
402+ /// If a release group doesn't have any packages, we still want to notify rebuilderd that
403+ /// it's empty.
404+ fn create_all_release_groups ( & mut self , release : & str , component : & str , sync : & PkgsSync ) {
405+ for arch in & sync. architectures {
406+ self . create_release_group ( release, component, arch) ;
407+ }
408+ }
409+
395410 pub fn import_compressed_binary_package_file (
396411 & mut self ,
397412 bytes : & [ u8 ] ,
@@ -400,6 +415,7 @@ impl SyncState {
400415 component : & str ,
401416 sync : & PkgsSync ,
402417 ) -> Result < ( ) > {
418+ self . create_all_release_groups ( release, component, sync) ;
403419 for pkg in extract_pkgs_compressed :: < DebianBinPkg > ( bytes) ? {
404420 self . import_binary_pkg ( pkg, sources, release, component, sync) ?;
405421 }
@@ -414,6 +430,7 @@ impl SyncState {
414430 component : & str ,
415431 sync : & PkgsSync ,
416432 ) -> Result < ( ) > {
433+ self . create_all_release_groups ( release, component, sync) ;
417434 for pkg in extract_pkgs_uncompressed :: < DebianBinPkg , _ > ( bytes) ? {
418435 self . import_binary_pkg ( pkg, sources, release, component, sync) ?;
419436 }
@@ -468,6 +485,41 @@ mod tests {
468485 use super :: * ;
469486 use std:: io:: Cursor ;
470487
488+ #[ test]
489+ fn test_sync_empty_release ( ) {
490+ let mut state = SyncState :: new ( ) ;
491+ state
492+ . import_uncompressed_binary_package_file (
493+ b"" ,
494+ & SourcePkgBucket :: new ( ) ,
495+ "trixie-proposed-updates" ,
496+ "main" ,
497+ & PkgsSync {
498+ distro : "debian" . to_string ( ) ,
499+ components : vec ! [ "main" . to_string( ) ] ,
500+ source : "http://deb.debian.org/debian" . to_string ( ) ,
501+ architectures : vec ! [ "amd64" . to_string( ) ] ,
502+ print_json : true ,
503+ maintainers : vec ! [ ] ,
504+ releases : vec ! [ ] ,
505+ pkgs : vec ! [ ] ,
506+ excludes : vec ! [ ] ,
507+ sync_method : None ,
508+ } ,
509+ )
510+ . unwrap ( ) ;
511+ assert_eq ! (
512+ state. to_vec( ) ,
513+ vec![ PackageReport {
514+ distribution: "debian" . to_string( ) ,
515+ release: Some ( "trixie-proposed-updates" . to_string( ) ) ,
516+ component: Some ( "main" . to_string( ) ) ,
517+ architecture: "amd64" . to_string( ) ,
518+ packages: vec![ ] ,
519+ } ]
520+ ) ;
521+ }
522+
471523 #[ test]
472524 fn test_parse_bin_pkg_simple ( ) {
473525 let bytes = b"Package: sniffglue
@@ -1801,6 +1853,32 @@ SHA256: 89c378d37058ea2a6c5d4bb2c1d47c4810f7504bde9e4d8142ac9781ce9df002
18011853 } ,
18021854 ) ;
18031855
1856+ reports. insert (
1857+ ( "sid" . to_string ( ) , "main" . to_string ( ) , "amd64" . to_string ( ) ) ,
1858+ PackageReport {
1859+ distribution : "debian" . to_string ( ) ,
1860+ release : Some ( "sid" . to_string ( ) ) ,
1861+ component : Some ( "main" . to_string ( ) ) ,
1862+ architecture : "amd64" . to_string ( ) ,
1863+ packages : vec ! [ ] ,
1864+ } ,
1865+ ) ;
1866+
1867+ reports. insert (
1868+ (
1869+ "testing" . to_string ( ) ,
1870+ "main" . to_string ( ) ,
1871+ "amd64" . to_string ( ) ,
1872+ ) ,
1873+ PackageReport {
1874+ distribution : "debian" . to_string ( ) ,
1875+ release : Some ( "testing" . to_string ( ) ) ,
1876+ component : Some ( "main" . to_string ( ) ) ,
1877+ architecture : "amd64" . to_string ( ) ,
1878+ packages : vec ! [ ] ,
1879+ } ,
1880+ ) ;
1881+
18041882 assert_eq ! ( state, SyncState { reports } ) ;
18051883 }
18061884}
0 commit comments