forked from matteo/sysroot-cleaner
fix: only warn on missing library, but process the rest
If a library is not found for a given binary, keep processing the rest of libraries in the DSO resolver. This avoids removing other, required DSOs by still adding them to the graph. Additionally, bump deps to fix a Rust Analyzer error with newer Rust versions, and run `cargo clippy`.
This commit is contained in:
parent
c9e39e284c
commit
f2fc705fa0
4 changed files with 150 additions and 102 deletions
|
@ -194,30 +194,28 @@ impl Runner {
|
|||
Box::new(move |path| {
|
||||
let size = Self::get_file_size(path)?;
|
||||
log::info!("moving {} to {} ({})", path.display(), dest.display(), size);
|
||||
Self::move_preserve(&path, &dest)?;
|
||||
Self::move_preserve(path, &dest)?;
|
||||
Ok(size)
|
||||
})
|
||||
}
|
||||
} else if args.dry_run {
|
||||
Box::new(|path| {
|
||||
let ty = if path.is_symlink() {
|
||||
"symlink"
|
||||
} else {
|
||||
"regular file"
|
||||
};
|
||||
let size = Self::get_file_size(path)?;
|
||||
log::info!("(dry-run) would remove {} {} ({})", ty, path.display(), size);
|
||||
Ok(size)
|
||||
})
|
||||
} else {
|
||||
if args.dry_run {
|
||||
Box::new(|path| {
|
||||
let ty = if path.is_symlink() {
|
||||
"symlink"
|
||||
} else {
|
||||
"regular file"
|
||||
};
|
||||
let size = Self::get_file_size(path)?;
|
||||
log::info!("(dry-run) would remove {} {} ({})", ty, path.display(), size);
|
||||
Ok(size)
|
||||
})
|
||||
} else {
|
||||
Box::new(move |path| {
|
||||
let size = Self::get_file_size(path)?;
|
||||
log::info!("removing {} ({})", path.display(), size);
|
||||
std::fs::remove_file(&path)?;
|
||||
Ok(size)
|
||||
})
|
||||
}
|
||||
Box::new(move |path| {
|
||||
let size = Self::get_file_size(path)?;
|
||||
log::info!("removing {} ({})", path.display(), size);
|
||||
std::fs::remove_file(path)?;
|
||||
Ok(size)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -239,7 +237,7 @@ impl Runner {
|
|||
if let Some(parent) = abs_dest.parent() {
|
||||
std::fs::create_dir_all(parent)?;
|
||||
}
|
||||
match std::fs::rename(&src, &abs_dest) {
|
||||
match std::fs::rename(src, &abs_dest) {
|
||||
Err(err) if err.raw_os_error() == Some(EXDEV) => {
|
||||
log::trace!(
|
||||
"different filesystems, falling back to copying {} to {}",
|
||||
|
|
|
@ -62,7 +62,7 @@ impl Cleaner for DsoCleaner {
|
|||
// that also its dependencies will not be kept.
|
||||
if decision.action != Action::Remove {
|
||||
state.process_path(&decision.path).unwrap_or_else(|e| {
|
||||
log::warn!(
|
||||
log::error!(
|
||||
"{}: {} (this might produce wrong results!)",
|
||||
decision.path.display(),
|
||||
e
|
||||
|
@ -92,12 +92,12 @@ impl Cleaner for DsoCleaner {
|
|||
}
|
||||
|
||||
if let Some(dot) = &self.output_dot {
|
||||
state.debug_print_graph(&dot)?;
|
||||
state.debug_print_graph(dot)?;
|
||||
}
|
||||
|
||||
let mut dfs = Dfs::empty(&state.graph);
|
||||
dfs.stack = inodes_to_keep.into_iter().collect();
|
||||
while let Some(_) = dfs.next(&state.graph) {}
|
||||
while dfs.next(&state.graph).is_some() {}
|
||||
|
||||
for (inode, paths) in state.paths_map.into_iter() {
|
||||
let action = if !dfs.discovered.contains(&inode) {
|
||||
|
@ -219,7 +219,7 @@ impl State {
|
|||
continue 'next_lib;
|
||||
}
|
||||
|
||||
anyhow::bail!("{}: unable to find library {}", path.display(), library);
|
||||
log::warn!("{}: unable to find library {}, ignoring (this might produce wrong results)!", path.display(), library);
|
||||
}
|
||||
|
||||
Ok(())
|
||||
|
@ -267,10 +267,8 @@ impl State {
|
|||
&|_, _| { String::new() },
|
||||
&|_, n| {
|
||||
let paths = self.paths_map.get(&n.id()).unwrap();
|
||||
let first_path = paths.iter().next().expect(&format!(
|
||||
"dso: you have a path map with an empty entry for inode {}",
|
||||
n.id()
|
||||
));
|
||||
let first_path = paths.iter().next().unwrap_or_else(|| panic!("dso: you have a path map with an empty entry for inode {}",
|
||||
n.id()));
|
||||
format!(
|
||||
"label = \"({}, {})\"",
|
||||
n.weight(),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue