Skip to content

Commit

Permalink
0.14.3 - merge arches too
Browse files Browse the repository at this point in the history
  • Loading branch information
cyr committed Oct 31, 2024
1 parent d79a43e commit b93f46a
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 20 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "aptmirs"
description = "A simple tool for mirroring apt/deb repositories"
version = "0.14.2"
version = "0.14.3"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
Expand Down
46 changes: 28 additions & 18 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,26 +57,41 @@ fn merge_similar(mut mirrors: Vec<MirrorOpts>) -> Vec<MirrorOpts> {

mirrors.sort();

let merged_mirrors = mirrors.into_iter().fold(Vec::new(), |mut a: Vec<MirrorOpts>, mut v| {
let merged_mirrors = mirrors.into_iter().fold(Vec::new(), |mut a: Vec<MirrorOpts>, mut new| {
if let Some(last) = a.last_mut() {
if last == &v {
last.components.append(&mut v.components);
last.debian_installer_arch.append(&mut v.debian_installer_arch);
if last == &new {
for component in new.components {
if !last.components.contains(&component) {
last.components.push(component);
}
}

for arch in new.arch {
if !last.arch.contains(&arch) {
last.arch.push(arch);
}
}

for di_arch in new.debian_installer_arch {
if !last.debian_installer_arch.contains(&di_arch) {
last.debian_installer_arch.push(di_arch);
}
}

last.udeb |= v.udeb;
last.packages |= v.packages;
last.source |= v.source;
last.udeb |= new.udeb;
last.packages |= new.packages;
last.source |= new.source;

last.pgp_verify |= v.pgp_verify;
last.pgp_verify |= new.pgp_verify;

if let Some(pgp_pub_key) = v.pgp_pub_key.take() {
if let Some(pgp_pub_key) = new.pgp_pub_key.take() {
last.pgp_pub_key = Some(pgp_pub_key)
}
} else {
a.push(v)
a.push(new)
}
} else {
a.push(v);
a.push(new);
}

a
Expand Down Expand Up @@ -106,18 +121,13 @@ impl Ord for MirrorOpts {
ord => return ord
}

match self.suite.cmp(&other.suite) {
Ordering::Equal => {}
ord => return ord
}

self.arch.cmp(&other.arch)
self.suite.cmp(&other.suite)
}
}

impl PartialEq for MirrorOpts {
fn eq(&self, other: &Self) -> bool {
self.url == other.url && self.suite == other.suite && self.arch == other.arch
self.url == other.url && self.suite == other.suite
}
}

Expand Down

0 comments on commit b93f46a

Please sign in to comment.