brp-verify_elf: select ELF files with signle file(1) invocation
Also, move RPM_VERIFY_ELF_SKIPLIST logic from verify-elf to brp-verify_elf, since RPM_VERIFY_ELF_TOPDIR is already there. Normally, verify-elf should be a standalone program (available for users). It's just not quite ready yet.
This commit is contained in:
parent
4fda20af28
commit
f82116d5f9
@ -120,6 +120,7 @@ done
|
||||
[ -z "$RPM_VERIFY_ELF_UNRESOLVED" ] || VERIFY_ELF_UNRESOLVED="$RPM_VERIFY_ELF_UNRESOLVED"
|
||||
|
||||
: ${RPM_VERIFY_ELF_TOPDIR:=}
|
||||
: ${RPM_VERIFY_ELF_SKIPLIST:=}
|
||||
[ -d "$RPM_BUILD_ROOT$RPM_VERIFY_ELF_TOPDIR" ] || exit 0
|
||||
|
||||
echo "Verifying ELF objects in $RPM_BUILD_ROOT$RPM_VERIFY_ELF_TOPDIR (arch=$VERIFY_ELF_ARCH,fhs=$VERIFY_ELF_FHS,rpath=$VERIFY_ELF_RPATH,stack=$VERIFY_ELF_STACK,textrel=$VERIFY_ELF_TEXTREL,unresolved=$VERIFY_ELF_UNRESOLVED)"
|
||||
@ -129,4 +130,18 @@ RPM_VERIFY_ELF_LDD_RPATH="$("$dump_ld_config" '' "$RPM_BUILD_ROOT")"
|
||||
RPM_VERIFY_ELF_LDD_RPATH="$RPM_VERIFY_ELF_LDD_RPATH /$RPM_LIB $RPM_LIBDIR $("$dump_ld_config")"
|
||||
export RPM_VERIFY_ELF_LDD_RPATH
|
||||
|
||||
find .$RPM_VERIFY_ELF_TOPDIR -type f -print0 |xargs -r0 @RPMCONFIGDIR@/verify-elf
|
||||
find .$RPM_VERIFY_ELF_TOPDIR -type f |
|
||||
file -NF$'\t' -f - |
|
||||
while IFS=$'\t' read -r f t; do
|
||||
case " $t" in
|
||||
*' ELF '*) ;;
|
||||
*) continue ;;
|
||||
esac
|
||||
for skip in $RPM_VERIFY_ELF_SKIPLIST; do
|
||||
case "${f#.}" in
|
||||
$skip) continue 2 ;;
|
||||
esac
|
||||
done
|
||||
printf '%s\n' "$f"
|
||||
done |
|
||||
@RPMCONFIGDIR@/verify-elf
|
||||
|
@ -22,8 +22,6 @@
|
||||
. @RPMCONFIGDIR@/functions
|
||||
ValidateBuildRoot
|
||||
|
||||
: ${RPM_VERIFY_ELF_SKIPLIST:=}
|
||||
|
||||
elf_ldd='@RPMCONFIGDIR@/ldd'
|
||||
|
||||
lookup_path()
|
||||
@ -40,29 +38,25 @@ lookup_path()
|
||||
}
|
||||
|
||||
rc=0
|
||||
for f in "$@"; do
|
||||
if [ ! -f "$f" ]; then
|
||||
Info "ERROR: $f: file unavailable"
|
||||
|
||||
VerifyELF()
|
||||
{
|
||||
f="$1"
|
||||
|
||||
if ! t=$(file -b "$f"); then
|
||||
Info "ERROR: ${t:-$f: file type not available}"
|
||||
rc=1
|
||||
continue
|
||||
fi
|
||||
|
||||
if ! objdump_info=$(objdump -p "$f"); then
|
||||
Info "WARNING: $f: objdump failed"
|
||||
continue
|
||||
fi
|
||||
|
||||
fname="${f#$RPM_BUILD_ROOT}"
|
||||
fname="${fname#.}"
|
||||
|
||||
if [ -n "$RPM_VERIFY_ELF_SKIPLIST" ]; then
|
||||
for skip in $RPM_VERIFY_ELF_SKIPLIST; do
|
||||
if [ -z "${fname##$skip}" ]; then
|
||||
continue 2
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
t="$(file -b "$f")"
|
||||
[ -z "${t##ELF *}" -o -z "${t##* ELF *}" ] || continue
|
||||
|
||||
objdump_info=$(objdump -p "$f") || continue
|
||||
|
||||
if [ -n "$VERIFY_ELF_ARCH" -a "$RPM_TARGET_ARCH" = noarch ]; then
|
||||
[ "$VERIFY_ELF_ARCH" = relaxed ] && prefix=WARNING || prefix=ERROR
|
||||
[ "$VERIFY_ELF_ARCH" = relaxed ] || rc=1
|
||||
@ -207,6 +201,16 @@ END {
|
||||
break
|
||||
done
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
if [ $# -gt 0 ]; then
|
||||
for f; do
|
||||
VerifyELF "$f"
|
||||
done
|
||||
else
|
||||
while read -r f; do
|
||||
VerifyELF "$f"
|
||||
done
|
||||
fi
|
||||
|
||||
exit $rc
|
||||
|
Loading…
Reference in New Issue
Block a user