limine: update to 8.6.0.
[void-pkg.git] / common / hooks / post-install / 11-pkglint-elf-in-usrshare.sh
blob729f5203b89740983f8ba8591565dad0ad2ad7b8
1 # vim: set ts=4 sw=4 et:
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
7 hook() {
8 local matches mime file f prune_expr dir
10 if [ ! -d ${PKGDESTDIR}/usr/share ]; then
11 return 0
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}"
21 done
22 prune_expr+=" ) -prune -o "
25 # Find all binaries in /usr/share and add them to the pool
26 while read -r f; do
27 mime="${f##*: }"
28 file="${f%:*}"
29 file="${file#${PKGDESTDIR}}"
30 case "${mime}" in
31 application/x-sharedlib*|\
32 application/x-pie-executable*|\
33 application/x-executable*)
34 if [[ ${ignore_elf_files} != *"${file}"* ]]; then
35 matches+=" ${file}"
38 esac
39 done < <(find $PKGDESTDIR/usr/share $prune_expr -type f | file --no-pad --mime-type --files-from -)
41 # Check passed if no packages in pool
42 if [ -z "$matches" ]; then
43 return 0
46 msg_red "${pkgver}: ELF files found in /usr/share:\n"
47 for f in $matches; do
48 msg_red " ${f}\n"
49 done
50 msg_error "${pkgver}: cannot continue with installation!\n"