From d8db6d94b71ebd63491c7c3c9e11ade54160218e Mon Sep 17 00:00:00 2001 From: "B. Watson" Date: Sat, 4 Mar 2023 02:21:24 -0500 Subject: sbopkglint: check paths for man pages. --- sbopkglint.d/05-basic-sanity.t.sh | 2 +- sbopkglint.d/30-manpages.t.sh | 30 +++++++++++++++++++++++------- 2 files changed, 24 insertions(+), 8 deletions(-) diff --git a/sbopkglint.d/05-basic-sanity.t.sh b/sbopkglint.d/05-basic-sanity.t.sh index b879729..7e8349b 100644 --- a/sbopkglint.d/05-basic-sanity.t.sh +++ b/sbopkglint.d/05-basic-sanity.t.sh @@ -25,7 +25,7 @@ baddirs="usr/local usr/share/doc usr/share/man usr/etc usr/share/info usr/X11 us # these directories may only contain files with +x permissions. in # other words, no non-executable files may live here. note that # bindirs is a subset of fileonlydirs. -bindirs="bin usr/bin sbin usr/sbin" +bindirs="bin usr/bin sbin usr/sbin usr/games" # these directories may exist, but must contain only files or symlinks, # and must be mode 0755, root:root. I thought usr/share/pixmaps diff --git a/sbopkglint.d/30-manpages.t.sh b/sbopkglint.d/30-manpages.t.sh index e0978b3..30c3841 100644 --- a/sbopkglint.d/30-manpages.t.sh +++ b/sbopkglint.d/30-manpages.t.sh @@ -67,13 +67,25 @@ check_gzipped_page() { # called for paths like /usr/man/de. right now, it accepts names like # xx_XX or xx.UTF-8, or actually anything whose first 2 characters match -# one of the dirs in /usr/share/locale. could use some refining. I don't -# even know if the *.UTF-8 or *.ISO8859-1 dirs get searched by man-db. +# one of the dirs in /usr/share/locale. could use some refining. +# these dir names can have an optional country code, and/or optional +# encoding. so all these are valid: +# de de_DE de.UTF-8 de_DE.UTF-8 de.ISO8859-1 de_DE.ISO8859-1 +# this code doesn't attempt to validate the country code (e.g. de_JP +# would be "German as written in Japan", there's no such thing), and +# it doesn't attempt to check encodings for existence or even plausibility. # Note that slackware's own libcdio-paranoia install man pages in # /usr/man/jp, which is invalid. check_locale_dir() { - l="$( echo "$1" | sed 's,^.*/\(..\).*$,\1,' )" - [ -e /usr/share/locale/"$l" ] || warn "bad locale dir in /usr/man: $l" + if [ "$ALL_LOCALES" = "" ]; then + ALL_LOCALES=$( l=$( locale -a|grep -v '^[A-Z]'|sed 's,[^a-z].*$,,'|sort -u ); echo $l ) + fi + + ldir="$( echo "$1" | cut -d/ -f3 )" + l="$( echo "$ldir" | sed 's,^\(..\).*,\1,' )" + if ! echo $ALL_LOCALES | grep -q "\\<$l\\>"; then + warn "invalid locale '$ldir' in path $1" + fi } if [ -d usr/man ]; then @@ -81,11 +93,15 @@ if [ -d usr/man ]; then find usr/man -mindepth 1 -type d > .mandirs.$$ while read d; do + [ "$( stat -c '%a %U %G' "$d" )" != "755 root root" ] && BADDIRPERMS+="$d " case "$d" in - usr/man/man[1-9n]|usr/man/*/man[1-9n]) - [ "$( stat -c '%a %U %G' "$d" )" != "755 root root" ] && BADDIRPERMS+="$d " + usr/man/*/*/*|usr/man/man[1-9ln]/*|usr/man/man) + BADDIRS+="$d " ;; + usr/man/man[1-9n]) + ;; + usr/man/*) + check_locale_dir "$d" ;; - usr/man/??*) check_locale_dir "$d" ;; *) BADDIRS+="$d " ;; esac done < .mandirs.$$ -- cgit v1.2.3