abuild: fix race when stripping

scanelf may pick up tempfiles created by strip or setfattr since it runs
in spearate process and pipes the out to a subshell. This causes a race
and may lead to the while loop attempt to strip seomthing that no longer
exists.

We fix that by test if file exists before try manipulate it. We could
have written he file list to a temp file first, but this way we benefit
from multiple cores working in parallel.
This commit is contained in:
Natanael Copa 2018-05-31 16:37:31 +02:00
parent 75b8cacaf0
commit c0a862930c

View File

@ -2247,6 +2247,10 @@ stripbin() {
msg "Stripping binaries" msg "Stripping binaries"
scanelf --recursive --nobanner --osabi --etype "ET_DYN,ET_EXEC" . \ scanelf --recursive --nobanner --osabi --etype "ET_DYN,ET_EXEC" . \
| while read type osabi filename; do | while read type osabi filename; do
# scanelf may have picked up a temp file so verify that file still exists
[ -e "$filename" ] || continue
[ "$osabi" != "STANDALONE" ] || continue [ "$osabi" != "STANDALONE" ] || continue
local XATTR=$(getfattr --match="" --dump "${filename}") local XATTR=$(getfattr --match="" --dump "${filename}")
"${stripcmd}" "${filename}" "${stripcmd}" "${filename}"