aboutsummaryrefslogtreecommitdiff
path: root/sbolint
diff options
context:
space:
mode:
Diffstat (limited to 'sbolint')
-rwxr-xr-xsbolint63
1 files changed, 53 insertions, 10 deletions
diff --git a/sbolint b/sbolint
index 9951c2c..fd761ae 100755
--- a/sbolint
+++ b/sbolint
@@ -88,6 +88,8 @@ B<sbopkglint>.
=head1 OPTIONS
+Do not bundle options. Use e.g. B<-q -r>, not B<-qr>.
+
=over 4
=item B<-a>
@@ -110,9 +112,23 @@ may vary.
=item B<-n>
-Suppress warnings. Only errors will be listed. This also affects the
+Suppress all warnings. Only errors will be listed. This also affects the
exit status (see below).
+=item B<-r>
+
+Suppress the warning about README lines being too long. Other warnings
+will still be emitted.
+
+=item B<-c>
+
+Always use colorful text, even if standard output is not a terminal. The default is to
+auto-detect.
+
+=item B<-m>
+
+Don't use color, even if standard output is a terminal.
+
=back
=head1 CHECKS
@@ -147,21 +163,21 @@ Archive must contain I<dirname/dirname.SlackBuild>.
=item -
-Any files other than the .SlackBuild, .info, slack-desc, and README are
+Any files in the archive other than the .SlackBuild, .info, slack-desc, and README are
checked for permissions (should be 0644) and excessive size.
=item -
-The source archive(s) must not exist. Also sbolint attempts to detect
+The source archive(s) must not exist in the archive. Also sbolint attempts to detect
extracted source trees (but isn't all that good at it).
=item -
-"Junk" files such as editor backups, core dumps,
+"Junk" files such as editor backups and core dumps must not exist in the archive.
=item -
-Files named 'build.log*' or 'strace.out*' must not exist. The B<sbrun>
+Files named 'build.log*' or 'strace.out*' must not exist in the archive. The B<sbrun>
tool creates these.
=back
@@ -339,6 +355,8 @@ our %info = (); # has to be global, check_info sets it, check_script needs it
#check_github_url("testing", $_) for @ARGV;
#exit 0;
+$color_output = -t STDOUT;
+
while(@ARGV && ($ARGV[0] =~ /^-/)) {
my $opt = shift;
$opt =~ /^-a/ && do { $recursive_git = 1; next; };
@@ -352,9 +370,23 @@ while(@ARGV && ($ARGV[0] =~ /^-/)) {
$opt =~ /^-r$/ && do { $suppress_readme_len = 1; next; };
$opt =~ /^--doc$/ && 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'");
}
+if($color_output) {
+ $red = "\x1b[1;31m";
+ $yellow = "\x1b[1;33m";
+ $green = "\x1b[1;32m";
+ $color_off = "\x1b[0m";
+} else {
+ $red = "";
+ $yellow = "";
+ $green = "";
+ $color_off = "";
+}
+
if($url_head && $url_download) {
die_usage("-u and -d options are mutually exclusive");
}
@@ -405,9 +437,9 @@ for(@ARGV) {
if(!$quiet) {
if($errcount == 0 and $warncount == 0) {
- print "$SELF: $buildname checks out OK\n";
+ print "$SELF: $buildname checks out " . $green . "OK" . $color_off . "\n";
} else {
- print "$SELF: $buildname: errors $errcount, warnings $warncount\n";
+ print "$SELF: $buildname: " . $red . "errors $errcount" . $color_off . ", " . $yellow . "warnings $warncount" . $color_off . "\n";
}
}
}
@@ -436,16 +468,21 @@ sub logmsg {
}
sub log_error {
- logmsg("ERR", @_);
+ logmsg($red . "ERR" . $color_off, @_);
$errcount++;
}
sub log_warning {
return if $nowarn;
- logmsg("WARN", @_);
+ logmsg($yellow . "WARN" . $color_off, @_);
$warncount++;
}
+sub log_note {
+ return if $nowarn;
+ logmsg($green . "NOTE" . $color_off, @_);
+}
+
sub usage {
if(@_) {
warn "$SELF: $_\n" for @_;
@@ -455,7 +492,7 @@ sub usage {
$SELF v$VERSION - check SlackBuilds.org scripts for common problems.
-Usage: $SELF [-q] [-u] [-n] [-r] <build <build ...>>
+Usage: $SELF [-q] [-u] [-n] [-r] [-c | -m] <build <build ...>>
Usage: $SELF --help | --man
builds may be directories or tarballs. If no build arguments given,
@@ -469,6 +506,8 @@ Options:
-u URL Check: use HTTP HEAD request to verify download/homepage URLs exist.
-n Suppress warnings, log only errors.
-r Suppress warning about README lines being too long.
+-c Always use color, even if stdout is not a tty.
+-m Do not use color, even if stdout is a tty.
--doc See the full documentation, in your pager.
--man Convert the full documentation to a man page, on stdout.
@@ -1297,6 +1336,10 @@ sub check_script {
if(/-march=['"]?i[34]86/) {
$old_flags = $lineno;
}
+
+ if(/^[^#]*\bpython\b/) {
+ log_note("$file:$lineno: suggest replacing 'python' with 'python2' for future-proofing");
+ }
}
if(not defined($prgnam)) {