From f04e33a32b883c688cfee61e57262384fc8d5a87 Mon Sep 17 00:00:00 2001 From: "B. Watson" Date: Fri, 16 Jun 2023 19:00:59 -0400 Subject: sbopkglint: spaces in filenames WIP #3. --- sbopkglint.d/25-lafiles.t.sh | 13 +++++++------ sbopkglint.d/35-desktop.t.sh | 36 ++++++++++++++++++++++++++---------- 2 files changed, 33 insertions(+), 16 deletions(-) diff --git a/sbopkglint.d/25-lafiles.t.sh b/sbopkglint.d/25-lafiles.t.sh index d4c56f7..39b1ac1 100644 --- a/sbopkglint.d/25-lafiles.t.sh +++ b/sbopkglint.d/25-lafiles.t.sh @@ -10,13 +10,14 @@ # they're not allowed directly in /lib /lib64 /usr/lib /usr/lib64, but # they're OK in subdirectories (e.g. /usr/lib64/appname/plugins/foo.la). -for i in lib lib64 usr/lib usr/lib64; do - [ -d "$i" ] || continue - found="$( find $i -maxdepth 1 -name '*.la' )" - [ -n "$found" ] && LAFILES+="$found " +for i in lib/*.la lib64/*.la usr/lib/*.la usr/lib64/*.la; do + [ -e "$i" ] || continue + ls -ld "$i" >> .lafiles.$$ done -if [ -n "$LAFILES" ]; then +if [ -s .lafiles.$$ ]; then warn "package contains .la files:" - ls -l $LAFILES + cat .lafiles.$$ fi + +rm -f .lafiles.$$ diff --git a/sbopkglint.d/35-desktop.t.sh b/sbopkglint.d/35-desktop.t.sh index 3c482ac..7b6b8f4 100644 --- a/sbopkglint.d/35-desktop.t.sh +++ b/sbopkglint.d/35-desktop.t.sh @@ -14,12 +14,14 @@ # are not checked for content). see: # https://specifications.freedesktop.org/mime-apps-spec/mime-apps-spec-latest.html -BADPERMS="" -BADDESKTOP="" -NONDESKTOP="" - check_desktop_dir() { local dir="$1" + + if [ -f "$dir" ]; then + warn "$dir exists, but is a file, not a directory!" + return + fi + [ -d "$dir" ] || return for f in $dir/*; do @@ -28,11 +30,13 @@ check_desktop_dir() { [ "$f" = "usr/share/applications/mimeinfo.cache" ] && continue [ "$f" = "usr/share/applications/screensavers" ] && continue - [ "$( stat -Lc '%a %U %G' "$f" )" = "644 root root" ] || BADPERMS+="$f " + [ "$( stat -Lc '%a %U %G' "$f" )" = "644 root root" ] || \ + ls -ld "$f" >> .badperms.$$ + case "$f" in - *.desktop) desktop-file-validate "$f" || BADDESKTOP+="$f " ;; + *.desktop) desktop-file-validate "$f" || ls -ld "$f" >> .baddtop.$$ ;; *-mimeapps.list) ;; # OK, ignore - *) NONDESKTOP+="$f " ;; + *) ls -ld "$f" >> .nondtop.$$ ;; esac done } @@ -41,7 +45,19 @@ for dir in usr/share/applications usr/share/applications/screensavers; do check_desktop_dir "$dir" done +if [ -s .badperms.$$ ]; then + warn "bad permissions/owner on .desktop files (should be 0644 root:root):" + cat .badperms.$$ +fi + +if [ -s .baddtop.$$ ]; then + warn ".desktop files fail to validate:" + cat .baddtop.$$ +fi + +if [ -s .nondtop.$$ ]; then + warn "unknown file (not .desktop) in desktop dir:" + cat .nondtop.$$ +fi -[ -n "$BADPERMS" ] && warn "bad permissions/owner on .desktop files (should be 0644 root:root):" && ls -ld $BADPERMS -[ -n "$BADDESKTOP" ] && warn ".desktop files fail to validate:" && ls -ld $BADDESKTOP -[ -n "$NONDESKTOP" ] && warn "unknown file (not .desktop) in desktop dir:" && ls -ld $NONDESKTOP +rm -f .badperms.$$ .baddtop.$$ .nondtop.$$ -- cgit v1.2.3