11-pkglint-elf-in-usrshare.sh (1559B)
1# vim: set ts=4 sw=4 et: 2# 3# This hook executes the following tasks: 4# - Looks on all packages for binary files being installed to /usr/share 5# - Allows exceptions listed in $ignore_elf_files and $ignore_elf_dirs 6 7hook() { 8 local matches mime file f prune_expr dir 9 10 if [ ! -d ${PKGDESTDIR}/usr/share ]; then 11 return 0 12 fi 13 14 if [ "${ignore_elf_dirs}" ]; then 15 for dir in ${ignore_elf_dirs}; do 16 if ! [ "${prune_expr}" ]; then 17 prune_expr="( -path ${PKGDESTDIR}${dir}" 18 else 19 prune_expr+=" -o -path ${PKGDESTDIR}${dir}" 20 fi 21 done 22 prune_expr+=" ) -prune -o " 23 fi 24 25 # Find all binaries in /usr/share and add them to the pool 26 while read -r f; do 27 mime="${f##*:}" 28 mime="${mime// /}" 29 file="${f%:*}" 30 file="${file#${PKGDESTDIR}}" 31 case "${mime}" in 32 application/x-sharedlib*|\ 33 application/x-pie-executable*|\ 34 application/x-executable*) 35 if [[ ${ignore_elf_files} != *"${file}"* ]]; then 36 matches+=" ${file}" 37 fi 38 ;; 39 esac 40 done < <(find $PKGDESTDIR/usr/share $prune_expr -type f | file --mime-type --files-from -) 41 42 # Check passed if no packages in pool 43 if [ -z "$matches" ]; then 44 return 0 45 fi 46 47 msg_red "${pkgver}: ELF files found in /usr/share:\n" 48 for f in $matches; do 49 msg_red " ${f}\n" 50 done 51 msg_error "${pkgver}: cannot continue with installation!\n" 52}