Skip to content

Commit

Permalink
ports-mgmt/portlint: Update to 2.21.0
Browse files Browse the repository at this point in the history
* Soften the desktop-file-utils message [1]
* Avoid a bogus error on ports that append to DISTFILES. [2]
* Colorize output for warnings and errors. [3]

PR:		271623 [1]
		268681 [2]
		274981 [3]
Inspired by:	yuri [3]
  • Loading branch information
xorrkaz committed Nov 13, 2023
1 parent 0b3a7ac commit 045f999
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 13 deletions.
2 changes: 1 addition & 1 deletion ports-mgmt/portlint/Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
PORTNAME= portlint
PORTVERSION= 2.20.0
PORTVERSION= 2.21.0
CATEGORIES= ports-mgmt
MASTER_SITES= # none
DISTFILES= # none
Expand Down
37 changes: 25 additions & 12 deletions ports-mgmt/portlint/src/portlint.pl
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,13 @@
use strict;
use warnings;

BEGIN { $ENV{ NO_COLOR } = 1 if not -t STDOUT; }

use Getopt::Std;
use File::Find;
use IPC::Open2;
use File::Basename;
use Term::ANSIColor qw(:constants);
use POSIX qw(strftime);

sub perror($$$$);
Expand All @@ -48,7 +51,7 @@

# version variables
my $major = 2;
my $minor = 20;
my $minor = 21;
my $micro = 0;

# default setting - for FreeBSD
Expand Down Expand Up @@ -403,9 +406,13 @@ sub version {
print $msg, "\n";
}
}
printf("%d fatal %s and %d %s found.\n", $err, $errtext, $warn, $warntext);
if ($err > 0) {
print BRIGHT_RED sprintf("%d fatal %s and %d %s found.", $err, $errtext, $warn, $warntext), RESET, "\n";
} else {
print BRIGHT_YELLOW sprintf("%d fatal %s and %d %s found.", $err, $errtext, $warn, $warntext), RESET, "\n";
}
} else {
print "looks fine.\n";
print BRIGHT_GREEN "looks fine.", RESET, "\n";
}
exit $err;

Expand Down Expand Up @@ -810,8 +817,9 @@ sub checkplist {
}

if ($_ =~ m|\.desktop$| && $makevar{USES} !~ /\bdesktop-file-utils\b/) {
&perror("FATAL", $file, $., "this port installs .desktop files. ".
"Please add `desktop-file-utils` to USES.");
&perror("WARN", $file, $., "this port installs .desktop files. ".
"If the .desktop file(s) installed contain ``MimeType='', ".
"you must add `desktop-file-utils` to USES.");
}

if ($_ =~ m|^(%%([^%]+)%%)?.*\.mo$| && $makevar{USES} !~ /\bgettext\b/) {
Expand Down Expand Up @@ -1347,7 +1355,7 @@ sub checkmakefile {
my $tmp;
my $bogusdistfiles = 0;
my @varnames = ();
my($portname, $portversion, $distfiles, $distversionprefix, $distversion, $distversionsuffix, $distname, $extractsufx) = ('') x 8;
my($portname, $portversion, $distfiles, $all_distfiles, $distversionprefix, $distversion, $distversionsuffix, $distname, $extractsufx) = ('') x 9;
my $masterport = 0;
my $slaveport = 0;
my $use_gnome_hack = 0;
Expand Down Expand Up @@ -2169,6 +2177,7 @@ sub checkmakefile {
&& $curline !~ /^NO_CDROM(.)?=[^\n]+$i/m
&& $curline !~ /^MAINTAINER(.)?=[^\n]+$i/m
&& $curline !~ /^WWW(.)?=[^\n]+$i/m
&& $curline !~ /^CPE_VENDOR(.)?=[^\n]+$i/m
&& $curline !~ /^CATEGORIES(.)?=[^\n]+$i/m
&& $curline !~ /^(\w+)?USES(.)?=[^\n]+$i/m
&& $curline !~ /^WX_COMPS(.)?=[^\n]+$i/m
Expand Down Expand Up @@ -2889,7 +2898,8 @@ sub checkmakefile {
}

# check DISTFILES and related items.
$distfiles = $1 if ($tmp =~ /\nDISTFILES[+?]?=[ \t]*([^\n]+)\n/);
$distfiles = $1 if ($tmp =~ /\nDISTFILES[?]?=[ \t]*([^\n]+)\n/);
$all_distfiles = $1 if ($tmp =~ /\nDISTFILES[+?]?=[ \t]*([^\n]+)\n/);
$portname = $makevar{PORTNAME};
$portversion = $makevar{PORTVERSION};
$distversionprefix = $makevar{DISTVERSIONPREFIX};
Expand All @@ -2901,7 +2911,7 @@ sub checkmakefile {
# check bogus EXTRACT_SUFX.
if ($extractsufx ne '') {
print "OK: seen EXTRACT_SUFX, checking value.\n" if ($verbose);
if ($distfiles ne '') {
if ($all_distfiles ne '') {
&perror("WARN", $file, -1, "no need to define EXTRACT_SUFX if ".
"DISTFILES is defined.");
}
Expand Down Expand Up @@ -3105,7 +3115,7 @@ sub checkmakefile {
$bogusdistfiles++;
print "OK: seen DISTFILES with single item, checking value.\n"
if ($verbose);
&perror("WARN", $file, -1, "use of DISTFILES with single file ".
&perror("WARN", $file, -1, "use of DISTFILES with single file is ".
"discouraged. distribution filename should be set by ".
"DISTNAME and EXTRACT_SUFX.");
if ($distfiles eq (($distname ne '') ? $distname : "$portname-$portversion") . $extractsufx) {
Expand Down Expand Up @@ -3661,18 +3671,21 @@ sub checkmakefile {

sub perror($$$$) {
my($type, $file, $line, $msg) = @_;
my $color;

if ($type eq 'FATAL') {
$err++;
$color = BRIGHT_RED;
} else {
$warn++;
$color = BRIGHT_YELLOW;
}
if ($grouperrs) {
$msg = '%%LINES%%' . $msg;
if ($file ne "") {
$msg = $file . ": " . $msg;
}
$msg = $type . ": " . $msg;
$msg = $color . $type . RESET . ": " . $msg;
if (!$errcache{$msg}) {
push @errlst, $msg;
}
Expand All @@ -3686,8 +3699,8 @@ ($$$$)
if ($file ne "") {
$msg = $file . ": " . $msg;
}
$msg = $type . ": " . $msg;
print $msg . "\n";
$msg = ": " . $msg;
print $color, $type, RESET, $msg . "\n";
}
}

Expand Down

0 comments on commit 045f999

Please sign in to comment.