#!/bin/sh # sbopkglint test, must be sourced by sbopkglint (not run standalone). # PKG, PRGNAM, VERSION, ARCH are set by sbopkglint. also the current # directory is the root of the installed package tree. ######################################################################## # checks permissions and ownership of static libraries lib dirs. # checks that static libraries actually *are* static libraries. # if the package includes both a static and shared library, a note is # triggered, suggesting removal of the static lib. this is not an error. # TODO: this will give us file's idea of what's inside a .a archive: # $ bsdtar -xOf /usr/lib64/libz.a '*.*' | file -b - # ELF 64-bit LSB relocatable, x86-64, version 1 (SYSV), not stripped # For 32-bit: # ELF 32-bit LSB relocatable, Intel 80386, version 1 (SYSV), not stripped # 'not stripped' is *correct*, don't complain about it! actually maybe # it should complain if it *is* stripped, since # Armed with this knowledge, we can do the same kind of arch checks for # static libs as we do for shared (32-bit belongs in lib, 64 in lib64, # arch of the static lib should match package's ARCH, etc). for libdir in lib lib64 usr/lib usr/lib64; do if [ -d $libdir ]; then find_warnfiles "bad static library ownership (should be root:root):" \ -L $libdir -mindepth 1 -maxdepth 1 -name '*.a' \! \( -user root -a -group root \) find_warnfiles "bad static library permissions (should be 0644 or 0444):" \ -L $libdir -mindepth 1 -maxdepth 1 -name '*.a' \! \( -perm 444 -o -perm 644 \) find $libdir -mindepth 1 -maxdepth 1 -name '*.a' | while read static; do ftype="$( file -L -b --mime-type "$static" )" case "$ftype" in "application/x-archive") ;; # OK *) warn "$static is not a valid static library. MIME type is '$ftype'." ;; esac shared=$libdir/"$( basename "$static" .a)".so if [ -e "$shared" ]; then shname="$( basename "$shared" )" stname="$( basename "$static" )" note "$libdir has both $shname and $stname; unless it's needed by a dependee, consider removing $stname" fi done fi done