From 9de0af33720b559d6121ea94fd96227811f824d9 Mon Sep 17 00:00:00 2001 From: "B. Watson" Date: Fri, 16 Jun 2023 04:57:30 -0400 Subject: sbopkglint: spaces in filenames WIP #2. --- sbopkglint.d/10-docs.t.sh | 37 ++++++++++++++++++++----------------- 1 file changed, 20 insertions(+), 17 deletions(-) (limited to 'sbopkglint.d') diff --git a/sbopkglint.d/10-docs.t.sh b/sbopkglint.d/10-docs.t.sh index 9fbcbd7..f99a42a 100644 --- a/sbopkglint.d/10-docs.t.sh +++ b/sbopkglint.d/10-docs.t.sh @@ -28,25 +28,28 @@ DOCDIR=usr/doc/$PRGNAM-$VERSION # so just don't do anything if it's missing. if [ -d "$DOCDIR" ]; then - badpermfiles="$( find $DOCDIR -mindepth 1 -type f -a \! -perm -444 )" - badpermdirs="$( find $DOCDIR -mindepth 1 -type d -a \! -perm 0755 )" - badowners="$( find $DOCDIR -mindepth 1 -user root -a -group root -o -print )" - empty="$( find $DOCDIR -mindepth 1 -maxdepth 1 -empty )" - bogus="$( find $DOCDIR -mindepth 1 -maxdepth 1 -type f -a \( -name INSTALL -o -name INSTALL.\* \) )" + find_warnfiles "bad file perms (should be 644, or at least 444) in doc dir:" \ + $DOCDIR -mindepth 1 -type f -a \! -perm -444 + find_warnfiles "bad directory perms (should be 755) in doc dir:" \ + $DOCDIR -mindepth 1 -type d -a \! -perm 0755 + find_warnfiles "bad ownership (should be root:root) in doc dir:" \ + $DOCDIR -mindepth 1 \! \( -user root -a -group root \) + find_warnfiles "empty files/dirs in doc dir:" \ + $DOCDIR -mindepth 1 -maxdepth 1 -empty - files="$( find $DOCDIR -type f -perm /111 )" - for f in $files; do - head -1 $f | grep -q '^#!' && continue; # script file, +x is OK - badpermfiles+=" $f" + # 20230616 bkw: this handles spaces in filenames, but it will choke on + # embedded backslashes. doubt that will be a real problem. + find $DOCDIR -type f -perm /111 -print | while read f; do + head -1 "$f" | grep -q '^#!' && continue; # script file, +x is OK + ls -ld "$f" >> .bad.$$ done - [ -n "$badpermfiles" ] && warn "bad file perms (should be 644, or at least 444) in doc dir:" && ls -l $badpermfiles - [ -n "$badpermdirs" ] && warn "bad directory perms (should be 755) in doc dir:" && ls -ld $badpermdirs - [ -n "$badowners" ] && warn "bad ownership (should be root:root) in doc dir:" && ls -ld $badowners - [ -n "$empty" ] && warn "empty files/dirs in doc dir: $empty" + [ -s .bad.$$ ] && warn "bad file perms (should be 644, or at least 444) in doc dir:" && cat .bad.$$ + rm -f .bad.$$ - if [ -z "$INSTALL_DOCS_OK" -a -n "$bogus" ]; then - for i in $bogus; do + if [ -z "$INSTALL_DOCS_OK" ]; then + for i in $DOCDIR/INSTALL*; do + [ -e "$i" ] || continue if grep -q 'generic installation instructions' $i || \ grep -q 'instructions are generic' $i then @@ -77,5 +80,5 @@ fi # allow /usr/doc/HTML to exist, though we don't check its contents here. # this is the standard location for KDE5 help files. -baddocs="$( find usr/doc -mindepth 1 -maxdepth 1 \! -name $PRGNAM-$VERSION \! -name HTML )" -[ -n "$baddocs" ] && warn "docs outside of $DOCDIR:" && ls -ld $baddocs +find_warnfiles "docs outside of $DOCDIR:" \ + usr/doc -mindepth 1 -maxdepth 1 \! -name $PRGNAM-$VERSION \! -name HTML -- cgit v1.2.3