Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
104 changes: 91 additions & 13 deletions tools/src/schedule/debian.rs
Original file line number Diff line number Diff line change
Expand Up @@ -295,28 +295,34 @@ impl SyncState {
SyncState::default()
}

fn get_mut_group(
fn create_release_group(
&mut self,
src: &DebianSourcePkg,
release: &str,
component: &str,
architecture: &str,
) -> &mut SourcePackageReport {
) -> &mut PackageReport {
let key = (
release.to_string(),
component.to_string(),
architecture.to_string(),
);
let report = self
.reports
.entry(key.clone())
.or_insert_with(|| PackageReport {
distribution: "debian".to_string(),
release: Some(release.to_string()),
component: Some(component.to_string()),
architecture: architecture.to_string(),
packages: Vec::new(),
});
self.reports.entry(key).or_insert_with(|| PackageReport {
distribution: "debian".to_string(),
release: Some(release.to_string()),
component: Some(component.to_string()),
architecture: architecture.to_string(),
packages: Vec::new(),
})
}

fn get_mut_group(
&mut self,
src: &DebianSourcePkg,
release: &str,
component: &str,
architecture: &str,
) -> &mut SourcePackageReport {
let report = self.create_release_group(release, component, architecture);

match report
.packages
Expand Down Expand Up @@ -392,6 +398,15 @@ impl SyncState {
Ok(())
}

/// Ensure all release groups are created, even if we never assign any packages to it.
/// If a release group doesn't have any packages, we still want to notify rebuilderd that
/// it's empty.
fn create_all_release_groups(&mut self, release: &str, component: &str, sync: &PkgsSync) {
for arch in &sync.architectures {
self.create_release_group(release, component, arch);
}
}

pub fn import_compressed_binary_package_file(
&mut self,
bytes: &[u8],
Expand All @@ -400,6 +415,7 @@ impl SyncState {
component: &str,
sync: &PkgsSync,
) -> Result<()> {
self.create_all_release_groups(release, component, sync);
for pkg in extract_pkgs_compressed::<DebianBinPkg>(bytes)? {
self.import_binary_pkg(pkg, sources, release, component, sync)?;
}
Expand All @@ -414,6 +430,7 @@ impl SyncState {
component: &str,
sync: &PkgsSync,
) -> Result<()> {
self.create_all_release_groups(release, component, sync);
for pkg in extract_pkgs_uncompressed::<DebianBinPkg, _>(bytes)? {
self.import_binary_pkg(pkg, sources, release, component, sync)?;
}
Expand Down Expand Up @@ -468,6 +485,41 @@ mod tests {
use super::*;
use std::io::Cursor;

#[test]
fn test_sync_empty_release() {
let mut state = SyncState::new();
state
.import_uncompressed_binary_package_file(
b"",
&SourcePkgBucket::new(),
"trixie-proposed-updates",
"main",
&PkgsSync {
distro: "debian".to_string(),
components: vec!["main".to_string()],
source: "http://deb.debian.org/debian".to_string(),
architectures: vec!["amd64".to_string()],
print_json: true,
maintainers: vec![],
releases: vec![],
pkgs: vec![],
excludes: vec![],
sync_method: None,
},
)
.unwrap();
assert_eq!(
state.to_vec(),
vec![PackageReport {
distribution: "debian".to_string(),
release: Some("trixie-proposed-updates".to_string()),
component: Some("main".to_string()),
architecture: "amd64".to_string(),
packages: vec![],
}]
);
}

#[test]
fn test_parse_bin_pkg_simple() {
let bytes = b"Package: sniffglue
Expand Down Expand Up @@ -1801,6 +1853,32 @@ SHA256: 89c378d37058ea2a6c5d4bb2c1d47c4810f7504bde9e4d8142ac9781ce9df002
},
);

reports.insert(
("sid".to_string(), "main".to_string(), "amd64".to_string()),
PackageReport {
distribution: "debian".to_string(),
release: Some("sid".to_string()),
component: Some("main".to_string()),
architecture: "amd64".to_string(),
packages: vec![],
},
);

reports.insert(
(
"testing".to_string(),
"main".to_string(),
"amd64".to_string(),
),
PackageReport {
distribution: "debian".to_string(),
release: Some("testing".to_string()),
component: Some("main".to_string()),
architecture: "amd64".to_string(),
packages: vec![],
},
);

assert_eq!(state, SyncState { reports });
}
}
Loading