Skip to content

Commit c7434e1

Browse files
committed
find-deps: fix multipie same file name not push to result
1 parent 6034686 commit c7434e1

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

find-deps/src/main.rs

+8-7
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use std::{
22
collections::HashMap,
33
io::BufRead,
44
path::{Path, PathBuf},
5-
process::{exit, Command},
5+
process::{Command, exit},
66
};
77

88
use anyhow::{Context, Result};
@@ -68,12 +68,12 @@ fn main() -> Result<()> {
6868
);
6969
}
7070

71-
let mut map: HashMap<String, String> = HashMap::new();
71+
let mut map: HashMap<String, Vec<String>> = HashMap::new();
7272

7373
for dep in deps {
7474
searcher::search("/var/lib/apt/lists", Mode::Provides, &dep, |(pkg, path)| {
7575
if path.ends_with(&format!("/{}", dep)) {
76-
map.insert(pkg, path);
76+
map.entry(pkg).or_default().push(path);
7777
}
7878
})
7979
.ok();
@@ -87,13 +87,14 @@ fn main() -> Result<()> {
8787
.filter(|x| !optenv32 || x.0.ends_with("+32"))
8888
.filter(|x| {
8989
(all_prefix || optenv32)
90-
|| Path::new(&x.1)
91-
.parent()
92-
.is_some_and(|x| x.to_string_lossy() == "/usr/lib")
90+
|| x.1.iter().map(|p| Path::new(p)).any(|x| {
91+
x.parent()
92+
.is_some_and(|x| x.to_string_lossy() == "/usr/lib")
93+
})
9394
})
9495
.for_each(|x| {
9596
if print_paths {
96-
println!("{} ({})", x.0, x.1)
97+
println!("{} [{}]", x.0, x.1.join(","))
9798
} else if oneline {
9899
print!("{} ", x.0);
99100
} else {

0 commit comments

Comments
 (0)