mirror of
https://github.com/NixOS/nixpkgs.git
synced 2026-06-05 21:03:40 +00:00
make-initrd-ng: suppress spurious glibc dependency warnings
In Nix, glibc libraries lack rpath entries pointing to themselves, so libc.so.6 and ld-linux-*.so.* can never be resolved through rpath alone during initrd generation. They are always present in the initrd through other paths (the ELF interpreter and other binaries' rpath entries). The scripted initrd builder (stage-1.nix findLibs) already skips ld*.so.? for the same reason. This brings make-initrd-ng in line with that precedent. Also removes two unused imports (PermissionsExt, Command) and moves the remaining warning output from stdout to stderr. Closes #463894 Closes #282145 Closes #399281
This commit is contained in:
@@ -5,9 +5,7 @@ use std::fs;
|
||||
use std::hash::Hash;
|
||||
use std::iter::FromIterator;
|
||||
use std::os::unix;
|
||||
use std::os::unix::fs::PermissionsExt;
|
||||
use std::path::{Component, Path, PathBuf};
|
||||
use std::process::Command;
|
||||
|
||||
use libc::umask;
|
||||
|
||||
@@ -159,13 +157,22 @@ fn add_dependencies<P: AsRef<Path> + AsRef<OsStr> + std::fmt::Debug>(
|
||||
}
|
||||
}
|
||||
if !found {
|
||||
// glibc makes it tricky to make this an error because
|
||||
// none of the files have a useful rpath.
|
||||
println!(
|
||||
"Warning: Couldn't satisfy dependency {} for {:?}",
|
||||
line,
|
||||
OsStr::new(&source)
|
||||
);
|
||||
// In Nix, glibc's own libraries lack rpath entries pointing to
|
||||
// themselves, so the dynamic linker (ld-linux-*.so.*) and libc.so.*
|
||||
// can never be resolved through rpath alone. They are always present
|
||||
// in the initrd: the linker via elf.interpreter above, and libc via
|
||||
// at least one binary's rpath. Suppress these known-benign cases.
|
||||
// See also: the ld*.so.? skip in stage-1.nix findLibs.
|
||||
let is_glibc_runtime = (line.starts_with("ld-") && line.contains(".so"))
|
||||
|| line.starts_with("libc.so");
|
||||
|
||||
if !is_glibc_runtime {
|
||||
eprintln!(
|
||||
"Warning: Couldn't satisfy dependency {} for {:?}",
|
||||
line,
|
||||
OsStr::new(&source)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user