diff options
author | B. Watson <urchlay@slackware.uk> | 2023-06-21 16:01:22 -0400 |
---|---|---|
committer | B. Watson <urchlay@slackware.uk> | 2023-06-21 16:01:22 -0400 |
commit | 98744785306943953361eb3d43d800df2b3ac5fd (patch) | |
tree | 5600d6187a69b0a862cd3e05711ab107704a68b3 | |
parent | 919b0a7dfa853bb2bc448956992bc427c17f9a3d (diff) | |
download | sbo-maintainer-tools-98744785306943953361eb3d43d800df2b3ac5fd.tar.gz |
sbopkglint: add static library test.
-rw-r--r-- | NEWS | 2 | ||||
-rw-r--r-- | TODO | 9 | ||||
-rw-r--r-- | sbopkglint.d/75-static_libs.t.sh | 34 |
3 files changed, 36 insertions, 9 deletions
@@ -10,6 +10,8 @@ sbopkglint: - Shared libraries are now checked for +x permission. - Option bundling is now supported (e.g. -ki is the same as -k -i). - Long names for all options (see --help or man page). +- New static library test (permissions, ownership, validity, plus a + note if there's also a shared version of the same lib). sbolint: - Warning: -n option has changed meaning! It used to mean "no warnings", @@ -1,17 +1,8 @@ -TODO: sbolint should check that gtk-update-icon-cache is guarded by - 'if [ -e usr/share/icons/hicolor/icon-theme.cache'. -TODO: check for "if [ -x /usr/bin/whatever ]" in doinst.sh, warn - if missing. this could be an ill-defined mess. TODO: sbopkglint could complain if the SlackBuild sets SLKCFLAGS but there's no native code. Future test ideas: -- static libraries? some packages ship these because upstream doesn't - support shared libs, though. maybe only complain if libfoo.so.* and - libfoo.a both exist (if we have a shared lib, we shouldn't also have - a static one). Maybe this should be a disable-able warning? - - duplicate files, maybe the error message could suggest a "ln -s" command to use if the file really does need to appear in multiple dirs. diff --git a/sbopkglint.d/75-static_libs.t.sh b/sbopkglint.d/75-static_libs.t.sh new file mode 100644 index 0000000..b0cdcdd --- /dev/null +++ b/sbopkglint.d/75-static_libs.t.sh @@ -0,0 +1,34 @@ +#!/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. + +for libdir in lib lib64 usr/lib usr/lib64; do + if [ -d $libdir ]; then + find_warnfiles "bad static library ownership (should be root:root):" \ + $libdir -mindepth 1 -maxdepth 1 -name '*.a' \! \( -user root -a -group root \) + find_warnfiles "bad static library permissions (should be 0644 or 0444):" \ + $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 -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 |