From d95bccfe8259f87eee5c63b70d1d04e08f167659 Mon Sep 17 00:00:00 2001 From: "B. Watson" Date: Sat, 13 May 2023 02:09:43 -0400 Subject: sbolint: check for hidden and empty files/dirs. --- sbolint | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/sbolint b/sbolint index 748410c..4d445f5 100755 --- a/sbolint +++ b/sbolint @@ -172,6 +172,11 @@ For all builds: =item - +The directory may not contain empty directories, empty (0-byte) files, or +hidden files/directories (named with a leading B<.>). + +=item - + The SlackBuild, .info, README files must have Unix \n line endings (not DOS \r\n), and the last line of each must have a \n. @@ -620,6 +625,7 @@ sub run_checks { \&check_info, \&check_script, \&check_images, + \&check_empty_hidden, ); # we only care about the junkfiles check for tarballs; don't @@ -1339,11 +1345,31 @@ sub check_script { } } +sub findem { + my ($findcmd, $errmsg) = @_; + open my $fh, "-|", "$findcmd"; + while(<$fh>) { + chomp; + s,^\./,,; + log_error("$errmsg: $_"); + } + close $fh; +} + +# empty/hidden files/dirs. +sub check_empty_hidden { + findem("find . -type d -a -empty", "empty directory"); + findem("find . -type f -a -empty", "empty file"); + findem("find . -type d -a -name '.*' -a ! -name . -a ! -name ..", "hidden directory"); + findem("find . -type f -a -name '.*'", "hidden file"); +} + # stuff like editor backups and dangling symlinks. # maybe *any* symlinks? # ELF objects are bad, too. # Big-ass files... # directories are OK, but hidden dirs are not. +# note that this check only gets called when checking a tarball (not a dir). sub check_junkfiles { my @sources = split(/\s+/, $info{DOWNLOAD} . " " . $info{DOWNLOAD_x86_64}); s,.*/,, for @sources; @@ -1356,7 +1382,7 @@ sub check_junkfiles { FILE: while(<$fh>) { chomp; my ($file, $type) = split /: */, $_, 2; - $file =~ s,\./,,; + $file =~ s,^\./,,; # skip the files caught by other checks next if $file eq "$buildname.SlackBuild"; -- cgit v1.2.3