aboutsummaryrefslogtreecommitdiff
path: root/sbolint
diff options
context:
space:
mode:
authorB. Watson <urchlay@slackware.uk>2023-05-13 02:09:43 -0400
committerB. Watson <urchlay@slackware.uk>2023-05-13 02:09:43 -0400
commitd95bccfe8259f87eee5c63b70d1d04e08f167659 (patch)
tree47831f9d58f16ebd9ef6ca82af752f5b5f5545b8 /sbolint
parenta94e13fb504736820205fe3d693af85645bff166 (diff)
downloadsbo-maintainer-tools-d95bccfe8259f87eee5c63b70d1d04e08f167659.tar.gz
sbolint: check for hidden and empty files/dirs.
Diffstat (limited to 'sbolint')
-rwxr-xr-xsbolint28
1 files changed, 27 insertions, 1 deletions
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";