From ecdd88685078da6de7f65c684bc5d3f59d09a9f9 Mon Sep 17 00:00:00 2001 From: "B. Watson" Date: Wed, 21 Jun 2023 04:34:31 -0400 Subject: sbolint: bad icon cache check, Getopt::Long support. --- sbolint | 71 +++++++++++++++++++++++++++++++++++++---------------------------- 1 file changed, 41 insertions(+), 30 deletions(-) (limited to 'sbolint') diff --git a/sbolint b/sbolint index 1b9d61b..c9767b4 100755 --- a/sbolint +++ b/sbolint @@ -11,7 +11,7 @@ sbolint - check SlackBuild directories or tarballs for common errors. =head1 SYNOPSIS -B [--help | --man | --version ] | [-a] [-q] [-u] [-n] [-r] [-c] [-m] [build [build ...]] +B [--help | --man | --version ] | [-a] [-q] [-u] [-e] [-n] [-r] [-c] [-m] [build [build ...]] =head1 DESCRIPTION @@ -47,45 +47,51 @@ code, unless something really is wrong with it. =head1 OPTIONS -Do not bundle options. Use e.g. B<-q -r>, not B<-qr>. +Bundling options is supported, e.g. B<-qr> is the same as B<-q -r>. =over 4 -=item B<-a> +=item B<-a>, B<--all> Check all builds in the git repository. This must be run from within a git tree (e.g. one made with "git clone"). This option also turns on -B<-q> (quiet). +B<-q> (quiet). Also, if standard output is a terminal, B +will exit with a message telling you to redirect standard output to +a file. -=item B<-q> +=item B<-q>, B<--quiet> Quiet. Suppresses 'xxx checks out OK' and the total errors/warnings summary. -=item B<-u> +=item B<-u>, B<--url-head> URL check. Uses B to make HTTP HEAD requests for the B, B, and B links. This won't guarantee that the links are good, but some kinds of failure (e.g. site down, 404) -means they're definitely bad. Unfortunately a lot of sites have stopped +mean they're definitely bad. Unfortunately a lot of sites have stopped responding to HEAD requests in the name of "security", so your mileage may vary. -=item B<-n> +=item B<-e>, B<--no-warnings> -Suppress all warnings. Only errors will be listed. This also affects the +Suppress all warnings and notes. Only errors will be listed. This also affects the exit status (see below). -=item B<-r> +=item B<-r>, B<--no-readme> Suppress the warning about README lines being too long. Other warnings will still be emitted. -=item B<-c> +=item B<-n>, B<--no-notes> + +Suppress notes. Only errors and warnings will be listed. + +=item B<-c>, B<--color> Always use colorful text, even if standard output is not a terminal. The default is to auto-detect. -=item B<-m> +=item B<-m>, B<--mono>, B<--no-color> Don't use color, even if standard output is a terminal. @@ -280,6 +286,8 @@ exit status will be 0 if there are no errors. Exit status 1 indicates there was at least one warning or error (or, with B<-n>, at least one error). +Notes do not affect the exit status. + Any other exit status means sbolint itself failed somehow (e.g. called with nonexistent filename). @@ -297,7 +305,9 @@ B(1), B, B(1), B(8), B(1) =cut +# These perl modules ship with Slackware's perl package. use POSIX qw/getcwd/; +use Getopt::Long qw/:config gnu_getopt no_require_order/; @boilerplate = ( qr/#\s*REMOVE THIS ENTIRE BLOCK OF TEXT/, @@ -341,22 +351,20 @@ our %info = (); # has to be global, check_info sets it, check_script needs it $color_output = -t STDOUT; -while(@ARGV && ($ARGV[0] =~ /^-/)) { - my $opt = shift; - $opt =~ /^-a/ && do { $recursive_git = 1; next; }; - $opt =~ /^-u/ && do { $url_head = 1; next; }; - $opt =~ /^-d/ && do { $url_download = 1; next; }; - $opt =~ /^--?q(uiet)?/ && do { $quiet = 1; next; }; - $opt =~ /^-$/ && do { $stdin = 1; next; }; - $opt =~ /^--?ver(sion)?/ && do { print "$VERSION\n"; exit 0; }; - $opt =~ /^-n$/ && do { $nowarn = 1; next; }; - $opt =~ /^-r$/ && do { $suppress_readme_len = 1; next; }; - $opt =~ /^(?:--doc|-?-h(elp)?)$/ && do { exec("perldoc $0"); }; - $opt =~ /^--man$/ && do { exec("pod2man --stderr -s1 -cSBoStuff -r$VERSION $0"); }; - $opt =~ /^-c|--colou?r(?:=[y|a]|$)/ && do { $color_output = 1; next; }; - $opt =~ /^-m|--colou?r=n|--no-colou?r/ && do { $color_output = 0; next; }; - die_usage("Unrecognized option '$opt'"); -} +GetOptions( + "all|a" => \$recursive_git, + "url-head|u" => \$url_head, + "download|d" => \$url_download, + "quiet|q" => \$quiet, + "version|v" => sub { print "$VERSION\n"; exit 0; }, + "no-warnings|e" => sub { $nowarn = 1; $nonote = 1;}, + "no-notes|n" => \$nonote, + "no-readme|r" => \$suppress_readme_len, + "doc|help|h" => sub { exec("perldoc $0"); }, + "man" => sub { exec("pod2man --stderr -s1 -cSBoStuff -r$VERSION $0"); }, + "color|colour|c" => sub { $color_output = 1; }, + "mono|no-color|no-colour|m" => sub { $color_output = 0; }, +) or die_usage("Error in command line options"); if($color_output) { $red = "\x1b[1;31m"; @@ -495,7 +503,7 @@ sub log_warning { } sub log_note { - return if $nowarn; + return if $nowarn || $nonote; logmsg($green . "NOTE" . $color_off, @_); } @@ -1518,7 +1526,10 @@ sub check_doinst { if(!$pp_defined) { log_error("$file:$lineno: 'preserve_perms' function used, but not defined."); } - } elsif(m,-e\s+usr/share/icons/[^/]*/icon-theme\.cache,) { + } elsif(m,-e\s+(\/)?usr/share/icons/[^/]*/icon-theme\.cache,) { + if(defined $1) { + log_error("$file:$lineno: bad icon cache check (/usr/, should be usr/)"); + } $icon_theme_check = $lineno; } elsif(m,usr/bin/gtk-update-icon-cache.*usr/share/icons,) { if(!$icon_theme_check) { -- cgit v1.2.3