From 045f9995fb3624885bdae850d12eca43f7625732 Mon Sep 17 00:00:00 2001 From: Joe Marcus Clarke Date: Mon, 13 Nov 2023 14:02:19 -0500 Subject: ports-mgmt/portlint: Update to 2.21.0 * 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] --- ports-mgmt/portlint/src/portlint.pl | 37 +++++++++++++++++++++++++------------ 1 file changed, 25 insertions(+), 12 deletions(-) (limited to 'ports-mgmt/portlint/src') diff --git a/ports-mgmt/portlint/src/portlint.pl b/ports-mgmt/portlint/src/portlint.pl index a9918a4e2b36..f8d7185e8827 100644 --- a/ports-mgmt/portlint/src/portlint.pl +++ b/ports-mgmt/portlint/src/portlint.pl @@ -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($$$$); @@ -48,7 +51,7 @@ $portdir = '.'; # version variables my $major = 2; -my $minor = 20; +my $minor = 21; my $micro = 0; # default setting - for FreeBSD @@ -403,9 +406,13 @@ if ($err || $warn) { 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; @@ -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/) { @@ -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; @@ -2169,6 +2177,7 @@ xargs xmkmf && $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 @@ -2889,7 +2898,8 @@ DIST_SUBDIR EXTRACT_ONLY } # 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}; @@ -2901,7 +2911,7 @@ DIST_SUBDIR EXTRACT_ONLY # 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."); } @@ -3105,7 +3115,7 @@ DIST_SUBDIR EXTRACT_ONLY $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) { @@ -3661,18 +3671,21 @@ TEST_DEPENDS FETCH_DEPENDS DEPENDS_TARGET 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; } @@ -3686,8 +3699,8 @@ sub perror($$$$) { if ($file ne "") { $msg = $file . ": " . $msg; } - $msg = $type . ": " . $msg; - print $msg . "\n"; + $msg = ": " . $msg; + print $color, $type, RESET, $msg . "\n"; } } -- cgit v1.2.3