Skip to content

Commit 065c509

Browse files
committed
Support syncing of Debian releases with no packages
1 parent ef69e72 commit 065c509

File tree

1 file changed

+86
-13
lines changed

1 file changed

+86
-13
lines changed

tools/src/schedule/debian.rs

Lines changed: 86 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -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
@@ -400,6 +406,9 @@ impl SyncState {
400406
component: &str,
401407
sync: &PkgsSync,
402408
) -> Result<()> {
409+
for arch in &sync.architectures {
410+
self.create_release_group(release, component, arch);
411+
}
403412
for pkg in extract_pkgs_compressed::<DebianBinPkg>(bytes)? {
404413
self.import_binary_pkg(pkg, sources, release, component, sync)?;
405414
}
@@ -414,6 +423,9 @@ impl SyncState {
414423
component: &str,
415424
sync: &PkgsSync,
416425
) -> Result<()> {
426+
for arch in &sync.architectures {
427+
self.create_release_group(release, component, arch);
428+
}
417429
for pkg in extract_pkgs_uncompressed::<DebianBinPkg, _>(bytes)? {
418430
self.import_binary_pkg(pkg, sources, release, component, sync)?;
419431
}
@@ -468,6 +480,41 @@ mod tests {
468480
use super::*;
469481
use std::io::Cursor;
470482

483+
#[test]
484+
fn test_sync_empty_release() {
485+
let mut state = SyncState::new();
486+
state
487+
.import_uncompressed_binary_package_file(
488+
b"",
489+
&SourcePkgBucket::new(),
490+
"trixie-proposed-updates",
491+
"main",
492+
&PkgsSync {
493+
distro: "debian".to_string(),
494+
components: vec!["main".to_string()],
495+
source: "http://deb.debian.org/debian".to_string(),
496+
architectures: vec!["amd64".to_string()],
497+
print_json: true,
498+
maintainers: vec![],
499+
releases: vec![],
500+
pkgs: vec![],
501+
excludes: vec![],
502+
sync_method: None,
503+
},
504+
)
505+
.unwrap();
506+
assert_eq!(
507+
state.to_vec(),
508+
vec![PackageReport {
509+
distribution: "debian".to_string(),
510+
release: Some("trixie-proposed-updates".to_string()),
511+
component: Some("main".to_string()),
512+
architecture: "amd64".to_string(),
513+
packages: vec![],
514+
}]
515+
);
516+
}
517+
471518
#[test]
472519
fn test_parse_bin_pkg_simple() {
473520
let bytes = b"Package: sniffglue
@@ -1801,6 +1848,32 @@ SHA256: 89c378d37058ea2a6c5d4bb2c1d47c4810f7504bde9e4d8142ac9781ce9df002
18011848
},
18021849
);
18031850

1851+
reports.insert(
1852+
("sid".to_string(), "main".to_string(), "amd64".to_string()),
1853+
PackageReport {
1854+
distribution: "debian".to_string(),
1855+
release: Some("sid".to_string()),
1856+
component: Some("main".to_string()),
1857+
architecture: "amd64".to_string(),
1858+
packages: vec![],
1859+
},
1860+
);
1861+
1862+
reports.insert(
1863+
(
1864+
"testing".to_string(),
1865+
"main".to_string(),
1866+
"amd64".to_string(),
1867+
),
1868+
PackageReport {
1869+
distribution: "debian".to_string(),
1870+
release: Some("testing".to_string()),
1871+
component: Some("main".to_string()),
1872+
architecture: "amd64".to_string(),
1873+
packages: vec![],
1874+
},
1875+
);
1876+
18041877
assert_eq!(state, SyncState { reports });
18051878
}
18061879
}

0 commit comments

Comments
 (0)