forked from mirrors/nixpkgs
auto-patchelf: don't use grep -q, as it causes Broken pipe (#56958)
This rare sitation was caught when building zoom-us package: ``` automatically fixing dependencies for ELF files /nix/store/71d65fplq44y9yn2fvkpn2d3hrszracd-auto-patchelf-hook/nix-support/setup-hook: line 213: echo: write error: Broken pipe /nix/store/71d65fplq44y9yn2fvkpn2d3hrszracd-auto-patchelf-hook/nix-support/setup-hook: line 210: echo: write error: Broken pipe ``` The worst is that derivation continued and resulted into broken package: https://github.com/NixOS/nixpkgs/pull/55566#issuecomment-470065690 I hope, replacing `grep -q` with `grep` will remove this race condition.
This commit is contained in:
parent
52c3ee6c4d
commit
de0612c46c
|
@ -15,8 +15,10 @@ isExecutable() {
|
|||
# *or* there is an INTERP section. This also catches position-independent
|
||||
# executables, as they typically have an INTERP section but their ELF type
|
||||
# is DYN.
|
||||
LANG=C readelf -h -l "$1" 2> /dev/null \
|
||||
| grep -q '^ *Type: *EXEC\>\|^ *INTERP\>'
|
||||
isExeResult="$(LANG=C readelf -h -l "$1" 2> /dev/null \
|
||||
| grep '^ *Type: *EXEC\>\|^ *INTERP\>')"
|
||||
# not using grep -q, because it can cause Broken pipe
|
||||
[ -n "$isExeResult" ]
|
||||
}
|
||||
|
||||
# We cache dependencies so that we don't need to search through all of them on
|
||||
|
@ -207,10 +209,11 @@ autoPatchelf() {
|
|||
isELF "$file" || continue
|
||||
segmentHeaders="$(LANG=C readelf -l "$file")"
|
||||
# Skip if the ELF file doesn't have segment headers (eg. object files).
|
||||
echo "$segmentHeaders" | grep -q '^Program Headers:' || continue
|
||||
# not using grep -q, because it can cause Broken pipe
|
||||
[ -n "$(echo "$segmentHeaders" | grep '^Program Headers:')" ] || continue
|
||||
if isExecutable "$file"; then
|
||||
# Skip if the executable is statically linked.
|
||||
echo "$segmentHeaders" | grep -q "^ *INTERP\\>" || continue
|
||||
[ -n "$(echo "$segmentHeaders" | grep "^ *INTERP\\>")" ] || continue
|
||||
fi
|
||||
autoPatchelfFile "$file"
|
||||
done < <(find "$@" ${norecurse:+-maxdepth 1} -type f -print0)
|
||||
|
|
Loading…
Reference in a new issue