3 # This script scans $(HOST_DIR)/{bin,sbin} for all ELF files, and checks
4 # they have an RPATH to $(HOST_DIR)/usr/lib if they need libraries from
7 # Override the user's locale so we are sure we can parse the output of
8 # readelf(1) and file(1)
16 # Remove duplicate and trailing '/' for proper match
17 hostdir
="$( sed -r -e 's:/+:/:g; s:/$::;' <<<"${hostdir}" )"
21 elf_needs_rpath
"${file}" "${hostdir}" ||
continue
22 check_elf_has_rpath
"${file}" "${hostdir}" && continue
23 if [ ${ret} -eq 0 ]; then
26 printf "*** ERROR: package %s installs executables without proper RPATH:\n" "${pkg}"
28 printf "*** %s\n" "${file}"
29 done < <( find "${hostdir}"/{,usr
/}{bin
,sbin
} -type f
-exec file {} + 2>/dev
/null \
30 |
sed -r -e '/^([^:]+):.*\<ELF\>.*\<executable\>.*/!d' \
43 [ -e "${hostdir}/usr/lib/${lib}" ] && return 0
44 done < <( readelf
-d "${file}" \
45 |
sed -r -e '/^.* \(NEEDED\) .*Shared library: \[(.+)\]$/!d;' \
52 check_elf_has_rpath
() {
58 for dir
in ${rpath//:/ }; do
59 # Remove duplicate and trailing '/' for proper match
60 dir
="$( sed -r -e 's:/+:/:g; s:/$::;' <<<"${dir}" )"
61 [ "${dir}" = "${hostdir}/usr/lib" ] && return 0
63 done < <( readelf
-d "${file}" \
64 |
sed -r -e '/.* \(R(UN)?PATH\) +Library r(un)?path: \[(.+)\]$/!d' \