diff options
author | Joe Marcus Clarke <marcus@FreeBSD.org> | 2003-11-17 20:17:46 +0000 |
---|---|---|
committer | Joe Marcus Clarke <marcus@FreeBSD.org> | 2003-11-17 20:17:46 +0000 |
commit | 1f93b36619d5f56a56153328d54b294db333c3df (patch) | |
tree | 151231957004048c248f0a01415fd078b46d059a /ports-mgmt | |
parent | ca27c348e14b78c0a5496f0d650f2c0d7472a242 (diff) | |
download | ports-1f93b36619d5f56a56153328d54b294db333c3df.tar.gz ports-1f93b36619d5f56a56153328d54b294db333c3df.zip |
Notes
Diffstat (limited to 'ports-mgmt')
-rw-r--r-- | ports-mgmt/portlint/Makefile | 6 | ||||
-rw-r--r-- | ports-mgmt/portlint/pkg-plist | 1 | ||||
-rw-r--r-- | ports-mgmt/portlint/src/portlint.pl | 120 | ||||
-rw-r--r-- | ports-mgmt/portlint/src/portlintgrep.pl | 53 |
4 files changed, 135 insertions, 45 deletions
diff --git a/ports-mgmt/portlint/Makefile b/ports-mgmt/portlint/Makefile index fac1be4e1dee..5b788582c495 100644 --- a/ports-mgmt/portlint/Makefile +++ b/ports-mgmt/portlint/Makefile @@ -8,7 +8,7 @@ # PORTNAME= portlint -PORTVERSION= 2.4.8 +PORTVERSION= 2.5.0 CATEGORIES= devel MASTER_SITES= # none DISTFILES= # none @@ -33,9 +33,13 @@ pre-patch: post-patch: @${REINPLACE_CMD} -e 's|/usr/bin/perl|${PERL}|' ${WRKSRC}/portlint.pl + @${REINPLACE_CMD} -e 's|/usr/bin/perl|${PERL}|' \ + ${WRKSRC}/portlintgrep.pl do-install: ${INSTALL_SCRIPT} ${WRKSRC}/portlint.pl ${PREFIX}/bin/portlint ${INSTALL_MAN} ${WRKSRC}/portlint.1 ${MAN1PREFIX}/man/man1 + ${MKDIR} ${EXAMPLESDIR} + ${INSTALL_SCRIPT} ${WRKSRC}/portlintgrep.pl ${EXAMPLESDIR}/portlintgrep .include <bsd.port.mk> diff --git a/ports-mgmt/portlint/pkg-plist b/ports-mgmt/portlint/pkg-plist index 39ff07b136f0..969617b9e2d5 100644 --- a/ports-mgmt/portlint/pkg-plist +++ b/ports-mgmt/portlint/pkg-plist @@ -1 +1,2 @@ bin/portlint +%%EXAMPLESDIR%%/portlintgrep diff --git a/ports-mgmt/portlint/src/portlint.pl b/ports-mgmt/portlint/src/portlint.pl index e68d26b9c163..671b150cf7b7 100644 --- a/ports-mgmt/portlint/src/portlint.pl +++ b/ports-mgmt/portlint/src/portlint.pl @@ -17,7 +17,7 @@ # OpenBSD and NetBSD will be accepted. # # $FreeBSD$ -# $Id: portlint.pl,v 1.26 2003/11/15 22:08:28 marcus Exp $ +# $Id: portlint.pl,v 1.27 2003/11/17 20:00:17 marcus Exp $ # use vars qw/ $opt_a $opt_A $opt_b $opt_c $opt_h $opt_t $opt_v $opt_M $opt_N $opt_B $opt_V /; @@ -39,8 +39,8 @@ $portdir = '.'; # version variables my $major = 2; -my $minor = 4; -my $micro = 8; +my $minor = 5; +my $micro = 0; sub l { '[{(]'; } sub r { '[)}]'; } @@ -171,8 +171,8 @@ my @varlist = qw( PORTNAME PORTVERSION PORTREVISION PORTEPOCH PKGNAME PKGNAMEPREFIX PKGNAMESUFFIX DISTNAME DISTFILES CATEGORIES MASTERDIR MAINTAINER MASTER_SITES WRKDIR WRKSRC NO_WRKSUBDIR PATCHDIR SCRIPTDIR FILESDIR - PKGDIR COMMENT DESCR PLIST PKGINSTALL PKGDEINSTALL PKGREQ PKGMESSAGE - MD5_FILE .CURDIR INSTALLS_SHLIB + PKGDIR COMMENT DESCR PLIST PKGCATEGORY PKGINSTALL PKGDEINSTALL + PKGREQ PKGMESSAGE MD5_FILE .CURDIR INSTALLS_SHLIB ); my $cmd = join(' -V ', "make $makeenv MASTER_SITE_BACKUP=''", @varlist); @@ -453,17 +453,19 @@ sub checkplist { if ($_ =~ /^\@(cwd|cd)[ \t]+(\S+)/) { $curdir = $2; } elsif ($_ =~ /^\@unexec[ \t]+rm[ \t]/) { - if ($_ !~ /%D/) { - &perror("WARN: pkg-plist:$. use \"%D\" to specify prefix."); + if ($_ !~ /%[DB]/) { + &perror("WARN: pkg-plist:$. use \"%D\" or \"%B\" to ". + "specify prefix."); } - if ($_ !~ /true$/) { - &perror("WARN: pkg-plist:$. add \"2>&1 ". - ">/dev/null || true\" ". - "to \"\@unexec rm\"."); + if ($_ !~ /true$/ && $_ !~ /rm -f/) { + &perror("WARN: pkg-plist:$. add \"2>&1 ". + ">/dev/null || true\" ". + "to \"\@unexec rm\"."); } } elsif ($_ =~ /^\@unexec[ \t]+rmdir/) { - if ($_ !~ /%D/) { - &perror("WARN: pkg-plist:$. use \"%D\" to specify prefix."); + if ($_ !~ /%[DB]/) { + &perror("WARN: pkg-plist:$. use \"%D\" or \"%B\" to ". + "specify prefix."); } if ($_ !~ /true$/) { &perror("WARN: pkg-plist:$. use \"\@dirrm\" ". @@ -852,9 +854,8 @@ sub checkmakefile { if ($verbose); $i = "\n" x ($contblank + 2); if ($whole =~ /$i/) { - my @linesbefore = split(/\n/, $`); &perror("FATAL: contiguous blank lines (> $contblank lines) found ". - "in $file at line " . ($#linesbefore + 1) . "."); + "in $file at line " . (&linenumber($`)) . "."); } # @@ -864,7 +865,7 @@ sub checkmakefile { print "OK: checking for \$(VARIABLE).\n" if ($verbose); if ($whole =~ /\$\([\w\d]+\)/) { &perror("WARN: use \${VARIABLE}, instead of ". - "\$(VARIABLE)."); + "\$(VARIABLE) at line " . (&linenumber($`)) . "."); } } @@ -898,7 +899,8 @@ sub checkmakefile { @other_early); while ($whole =~ /^($earlypattern)[+?:!]?=/gmo) { - &perror("FATAL: $1 is set after including bsd.port.pre.mk."); + &perror("FATAL: $1 is set at line " . (&linenumber($`)) . " after ". + "including bsd.port.pre.mk."); } } @@ -916,7 +918,8 @@ sub checkmakefile { # print "OK: checking for USE_* as a user-settable option.\n" if ($verbose); while ($whole =~ /\n\s*\.\s*(?:el)?if[^\n]*?\b(\w*USE_)(\w+)(?\![^\n]*\n#?\.error)/g) { - &perror("WARN: is $1$2 a user-settable option? ". + my $lineno = &linenumber($`); + &perror("WARN: is $1$2 a user-settable option at line $lineno? ". "Consider using WITH_$2 instead.") if ($1.$2 ne 'USE_GCC'); } @@ -924,8 +927,9 @@ sub checkmakefile { # # whole file: NO_CHECKSUM # - $whole =~ s/\n#[^\n]*/\n/g; - $whole =~ s/\n\n+/\n/g; + # XXX Don't compress newlines since it messes up line number calculation. + #$whole =~ s/\n#[^\n]*/\n/g; + #$whole =~ s/\n\n+/\n/g; print "OK: checking NO_CHECKSUM.\n" if ($verbose); if ($whole =~ /\nNO_CHECKSUM/) { &perror("FATAL: use of NO_CHECKSUM discouraged. ". @@ -954,7 +958,8 @@ sub checkmakefile { } print "OK: checking for use of NOPORTDOCS.\n" if ($verbose); if ($whole =~ /NOPORTSDOC/) { - &perror("WARN: NOPORTSDOC found. Do you mean NOPORTDOCS?"); + &perror("WARN: NOPORTSDOC found at " . (&linenumber($`)) . ". Do you ". + "mean NOPORTDOCS?"); } if ($sharedocused && $whole !~ /defined\s*\(?NOPORTDOCS\)?/ && $whole !~ /def\s*\(?NOPORTDOCS\)?/ @@ -981,46 +986,55 @@ ldconfig ln md5 mkdir mv patch perl rm rmdir ruby sed sh touch tr which xargs xm $cmdnames{'python'} = '${PYTHON_CMD}'; $cmdnames{'strip'} = '${STRIP_CMD}'; foreach my $i (qw(aclocal autoconf autoheader automake autoreconf autoupdate autoscan ifnames libtool libtoolize)) { - $autocmdnames{$i} = "\$\{" . ( ( $i !~ /auto|aclocal/ ) ? "AUTO" : "" ) . "\U$i\E\}"; + $autocmdnames{$i} = "\$\{" . ( ( $i !~ /auto|aclocal|libtool/ ) ? "AUTO" : "" ) . "\U$i\E\}"; } # # ignore parameter string to echo command. # note that we leave the command as is, since we need to check the # use of echo itself. $j = $whole; - $j =~ s/([ \t][\@\-]{0,2})(echo|\$[\{\(]ECHO[\}\)]|\$[\{\(]ECHO_MSG[\}\)])[ \t]+("(\\'|\\"|[^"])*"|'(\\'|\\"|[^'])*')[ \t]*[;\n]/$1$2;/; #" + $j =~ s/([ \t][\@\-]{0,2})(echo|\$[\{\(]ECHO[\}\)]|\$[\{\(]ECHO_MSG[\}\)])[ \t]+("(\\'|\\"|[^"])*"|'(\\'|\\"|[^'])*')[ \t]*[;\n]/$1$2;\n/g; #" foreach my $i (keys %cmdnames) { # XXX This is a hack. Really, we should break $j up into individual # lines, and go through each one. - if ($j =~ /([^ \t\/]*[ \t\/][\@\-]{0,2}$i[ \t\n;][^\n]*\n?)/) { - if ($1 !~ /\n[A-Z]+_TARGET[?+]?=[^\n]+$i/ - && $1 !~ /\nIGNORE(.)?=[^\n]+$i/ - && $1 !~ /\nBROKEN(.)?=[^\n]+$i/ - && $1 !~ /\nRESTRICTED(.)?=[^\n]+$i/ - && $1 !~ /\nNO_PACKAGE(.)?=[^\n]+$i/ - && $1 !~ /\nNO_CDROM(.)?=[^\n]+$i/ - && $1 !~ /\nCOMMENT(.)?=[^\n]+$i/) { +# if ($j =~ /([^ \t\/]*[ \t\/][\@\-]{0,2}$i[ \t\n;][^\n]*\n?)/) { + while ($j =~ /^(.*$i.*)$/gm) { + my $curline = $1; + my $lineno = &linenumber($`); + if ($curline =~ /(^|\s+)[\@\-]{0,2}$i\b/ + && $curline !~ /^[A-Z]+_TARGET[?+]?=[^\n]+$i/m + && $curline !~ /^IGNORE(.)?=[^\n]+$i/m + && $curline !~ /^BROKEN(.)?=[^\n]+$i/m + && $curline !~ /^RESTRICTED(.)?=[^\n]+$i/m + && $curline !~ /^NO_PACKAGE(.)?=[^\n]+$i/m + && $curline !~ /^NO_CDROM(.)?=[^\n]+$i/m + && $curline !~ /^CATEGORIES(.)?=[^\n]+$i/m + && $curline !~ /^COMMENT(.)?=[^\n]+$i/m) { &perror("WARN: possible direct use of command \"$i\" ". - "found. use $cmdnames{$i} instead."); + "found at line $lineno. use $cmdnames{$i} instead."); } } } foreach my $i (keys %autocmdnames) { # XXX Same hack as above. - if ($j =~ /([^ \t\/]*[ \t\/][\@\-]{0,2}($i\d*)[ \t\n;][^\n]*\n?)/) { +# if ($j =~ /([^ \t\/]*[ \t\/][\@\-]{0,2}($i\d*)[ \t\n;][^\n]*\n?)/) { + while ($j =~ /^(.*($i\d*).*)$/gm) { my $lm = $1; my $sm = $2; - if ($lm !~ /\n[A-Z]+_TARGET[?+]?=[^\n]+($i\d*)/ - && $1 !~ /\nIGNORE(.)?=[^\n]+$i/ - && $1 !~ /\nBROKEN(.)?=[^\n]+$i/ - && $1 !~ /\nRESTRICTED(.)?=[^\n]+$i/ - && $1 !~ /\nNO_PACKAGE(.)?=[^\n]+$i/ - && $1 !~ /\nNO_CDROM(.)?=[^\n]+$i/ - && $lm !~ /\nCOMMENT(.)?=[^\n]+($i\d*)/) { + my $lineno = &linenumber($`); + if ($lm =~ /(^|\s+)[\@\-]{0,2}($i\d*)\b/ + && $lm !~ /^[A-Z]+_TARGET[?+]?=[^\n]+($i\d*)/m + && $lm !~ /^IGNORE(.)?=[^\n]+($i\d*)/m + && $lm !~ /^BROKEN(.)?=[^\n]+($i\d*)/m + && $lm !~ /^RESTRICTED(.)?=[^\n]+($i\d*)/m + && $lm !~ /^NO_PACKAGE(.)?=[^\n]+($i\d*)/m + && $lm !~ /^NO_CDROM(.)?=[^\n]+($i\d*)/m + && $lm !~ /^CATEGORIES(.)?=[^\n]+($i\d*)/m + && $lm !~ /^COMMENT(.)?=[^\n]+($i\d*)/m) { &perror("WARN: possible direct use of command \"$sm\" ". - "found. Use $autocmdnames{$i} instead and ". - "set according USE_*_VER= flag"); + "found at line $lineno. Use $autocmdnames{$i} ". + "instead and set according USE_*_VER= flag"); } } } @@ -1048,7 +1062,8 @@ ldconfig ln md5 mkdir mv patch perl rm rmdir ruby sed sh touch tr which xargs xm # if ($j =~ /\${MKDIR}\s+-p/) { &perror("WARN: possible use of \"\${MKDIR} -p\" ". - "found. \${MKDIR} includes \"-p\" by default."); + "found at line " . (&linenumber($`)) . ". \${MKDIR} includes ". + "\"-p\" by default."); } # @@ -1083,6 +1098,14 @@ ldconfig ln md5 mkdir mv patch perl rm rmdir ruby sed sh touch tr which xargs xm } # + # whole file: check for deprecated USE_MESA + # + if ($whole =~ /^USE_MESA[?:]?=/m) { + &perror("WARN: USE_MESA is deprecated at line " . (&linenumber($`)) . + ". use USE_GL instead."); + } + + # # slave port check # my $masterdir = $makevar{MASTERDIR}; @@ -1227,7 +1250,7 @@ DISTFILES DIST_SUBDIR EXTRACT_ONLY } if ($committer && $makevar{'.CURDIR'} =~ m'/([^/]+)/[^/]+/?$') { - if ($cat[0] ne $1) { + if ($cat[0] ne $1 && $makevar{PKGCATEGORY} ne $1 ) { &perror("FATAL: category \"$1\" must be listed first"); } } @@ -1919,6 +1942,15 @@ sub checkearlier { } } +sub linenumber { + my $text = shift; + my @lines; + + @lines = split /\n/, $text; + + return scalar(@lines); +} + sub abspathname { my($str, $file) = @_; my($s, $i, %cmdnames); diff --git a/ports-mgmt/portlint/src/portlintgrep.pl b/ports-mgmt/portlint/src/portlintgrep.pl new file mode 100644 index 000000000000..1bf267e0988d --- /dev/null +++ b/ports-mgmt/portlint/src/portlintgrep.pl @@ -0,0 +1,53 @@ +#!/usr/bin/perl +# +# Copyright (c) 2003 Oliver Eikemeier. All rights reserved. +# +# BSD licensed. +# + +# +# List all the ports with FATAL errors: +# +# portlintgrep ^FATAL: +# + +require 5.005; +use diagnostics; +use strict; +use Carp; + +my $make = $ENV{MAKE} ? $ENV{MAKE} : '/usr/bin/make'; +my $portlint = $ENV{PORTLINT} ? $ENV{PORTLINT} : '/usr/local/bin/portlint'; +my $portsdir = $ENV{PORTSDIR} ? $ENV{PORTSDIR} : '/usr/ports'; +my $portlint_args = $ENV{PORTLINT_ARGS} ? $ENV{PORTLINT_ARGS} : ''; + +die "Usage: portlintgrep <regex>\n" if $#ARGV != 0; +my $regex = qr/$ARGV[0]/; + +my %failedports; + +my @categories = split ' ', `cd $portsdir; $make -VSUBDIR`; +foreach my $category (@categories) { + my @ports = split ' ', `cd "$portsdir/$category"; $make -VSUBDIR`; + foreach my $port (@ports) { + my @result = + `cd "$portsdir/$category/$port"; $portlint $portlint_args`; + map chomp, @result; + my @filteredresult = grep /$regex/o, @result; + if (@filteredresult) { + my $maintainer = + `cd "$portsdir/$category/$port"; $make -VMAINTAINER`; + chomp $maintainer; + push @{$failedports{$maintainer}}, "$category/$port"; + print join("\n ", + "$category/$port <$maintainer>:", + @filteredresult), + "\n"; + } + } +} + +print "\nPorts sorted by maintainer:\n"; +foreach my $maintainer (sort { lc $a cmp lc $b } keys %failedports) { + print join("\n - ", $maintainer, @{$failedports{$maintainer}}), "\n"; +} |