11-pkglint-elf-in-usrshare: allow explicit setting of exceptions

Co-authored-by: Piotr Wójcik <chocimier@tlen.pl>
This commit is contained in:
Helmut Pozimski 2020-07-16 19:44:01 +02:00 committed by Piotr
parent f431451ab0
commit e0979275b4
2 changed files with 28 additions and 5 deletions

View file

@ -623,6 +623,12 @@ the `$DESTDIR` which will not be scanned for runtime dependencies. This may be u
skip files which are not meant to be run or loaded on the host but are to be sent to some
target device or emulation.
- `ignore_elf_files` White space separated list of machine code files
in /usr/share directory specified by absolute path, which are expected and allowed.
- `ignore_elf_dirs` White space separated list of directories in /usr/share directory
specified by absolute path, which are expected and allowed to contain machine code files.
- `nocross` If set, cross compilation won't be allowed and will exit immediately.
This should be set to a string describing why it fails, or a link to a travis
buildlog demonstrating the failure.

View file

@ -2,26 +2,43 @@
#
# This hook executes the following tasks:
# - Looks on all packages for binary files being installed to /usr/share
# - Allows exceptions listed in $ignore_elf_files and $ignore_elf_dirs
hook() {
local matches mime file
local matches mime file f prune_expr dir
if [ ! -d ${PKGDESTDIR}/usr/share ]; then
return 0
fi
if [ "${ignore_elf_dirs}" ]; then
for dir in ${ignore_elf_dirs}; do
if ! [ "${prune_expr}" ]; then
prune_expr="( -path ${PKGDESTDIR}${dir}"
else
prune_expr+=" -o -path ${PKGDESTDIR}${dir}"
fi
done
prune_expr+=" ) -prune -o "
fi
# Find all binaries in /usr/share and add them to the pool
while read -r f; do
mime="${f##*:}"
mime="${mime// /}"
file="${f%:*}"
file="${file#${PKGDESTDIR}}"
case "${mime}" in
# Note application/x-executable is missing which is present in most Electron apps
application/x-sharedlib*|application/x-pie-executable*)
matches+=" ${file#$PKGDESTDIR}" ;;
if [[ ${ignore_elf_files} != *"${file}"* ]]; then
matches+=" ${file}"
fi
;;
esac
done < <(find $PKGDESTDIR/usr/share -type f | file --mime-type --files-from -)
done < <(find $PKGDESTDIR/usr/share $prune_expr -type f | file --mime-type --files-from -)
# Check passed if no packages in pool
if [ -z "$matches" ]; then
return 0
fi