Skip to content

Commit a1c706c

Browse files
authored
Merge pull request #147 from jspricke/support_binNMU
Support binNMUs in Debian (Closes #4)
2 parents 455997a + 5a42e24 commit a1c706c

File tree

1 file changed

+26
-9
lines changed

1 file changed

+26
-9
lines changed

tools/src/schedule/debian.rs

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ use std::collections::HashMap;
77
use std::io::BufReader;
88
use std::io::prelude::*;
99

10+
pub const BIN_NMU_PREFIX: &str = "+b";
11+
1012
// TODO: support more archs
1113
pub fn any_architectures() -> Vec<String> {
1214
vec![
@@ -32,9 +34,17 @@ impl SourcePkgBucket {
3234
}
3335
}
3436

35-
pub fn get(&self, pkg: &DebianBinPkg) -> Result<&DebianSourcePkg> {
37+
pub fn get(&self, pkg: &DebianBinPkg) -> Result<DebianSourcePkg> {
3638
let (name, version) = &pkg.source;
37-
let list = self.pkgs.get(name)
39+
let bin_nmu = pkg
40+
.version
41+
.rfind(BIN_NMU_PREFIX)
42+
.map(|idx| pkg.version.split_at(idx).1)
43+
.filter(|num| num[BIN_NMU_PREFIX.len()..].parse::<u64>().is_ok())
44+
.unwrap_or("");
45+
let list = self
46+
.pkgs
47+
.get(name)
3848
.with_context(|| anyhow!("No source package found with name: {:?}", name))?;
3949

4050
// we currently track if the version was set explicitly or implicitly, keeping track just in case
@@ -45,7 +55,9 @@ impl SourcePkgBucket {
4555

4656
for src in list {
4757
if src.version == *version {
48-
return Ok(src);
58+
let mut src_cpy = src.clone();
59+
src_cpy.version.push_str(bin_nmu);
60+
return Ok(src_cpy);
4961
}
5062
}
5163

@@ -59,7 +71,7 @@ pub enum VersionConstraint {
5971
Implicit(String),
6072
}
6173

62-
#[derive(Debug, PartialEq, Eq)]
74+
#[derive(Debug, PartialEq, Eq, Clone)]
6375
pub struct DebianSourcePkg {
6476
pub base: String,
6577
pub binary: Vec<String>,
@@ -366,7 +378,7 @@ pub async fn sync(sync: &PkgsSync) -> Result<Vec<PkgGroup>> {
366378
let src = sources.get(&pkg)?;
367379
debug!("Matched binary package to source package: {:?} {:?}", src.base, src.version);
368380

369-
out.push(src, pkg, &sync.source, sync.distro.clone(), sync.suite.clone());
381+
out.push(&src, pkg, &sync.source, sync.distro.clone(), sync.suite.clone());
370382
}
371383
}
372384
}
@@ -1015,21 +1027,26 @@ Section: mail
10151027
let cursor = Cursor::new(bytes);
10161028
let src_pkgs = extract_pkgs_uncompressed::<DebianSourcePkg, _>(cursor).unwrap();
10171029

1030+
let mut sources = SourcePkgBucket::new();
1031+
for pkg in src_pkgs {
1032+
sources.push(pkg);
1033+
}
1034+
10181035
let mut state = SyncState::new();
10191036
for bin in bin_pkgs {
1020-
state.push(&src_pkgs[0], bin, "https://deb.debian.org/debian", "debian".to_string(), "main".to_string());
1037+
let src = sources.get(&bin).unwrap();
1038+
state.push(&src, bin, "https://deb.debian.org/debian", "debian".to_string(), "main".to_string());
10211039
}
10221040

10231041
let mut groups = HashMap::new();
10241042
groups.insert("courier".to_string(), vec![
10251043
PkgGroup {
10261044
name: "courier".to_string(),
1027-
version: "1.0.16-3".to_string(),
1045+
version: "1.0.16-3+b1".to_string(),
10281046
distro: "debian".to_string(),
10291047
suite: "main".to_string(),
10301048
architecture: "amd64".to_string(),
1031-
// TODO: correct buildinfo file is https://buildinfos.debian.net/buildinfo-pool/c/courier/courier_1.0.16-3+b1_amd64.buildinfo
1032-
input_url: Some("https://buildinfos.debian.net/buildinfo-pool/c/courier/courier_1.0.16-3_amd64.buildinfo".to_string()),
1049+
input_url: Some("https://buildinfos.debian.net/buildinfo-pool/c/courier/courier_1.0.16-3+b1_amd64.buildinfo".to_string()),
10331050
artifacts: vec![
10341051
PkgArtifact {
10351052
name: "courier-base".to_string(),

0 commit comments

Comments
 (0)