mirror of
https://git.freebsd.org/ports.git
synced 2025-07-16 16:59:17 -04:00
update to portlint 2.2.2:
- better rcsid checking - add DIST_SUBDIR to section 1 of the Makefile - add check for WWW: in pkg/DESCR when http:// exists - add new -t flag, which will require a tab after a variable defination instead of spaces - cleanup english grammar - add -M (make variable passing) flag - change into portdir instead of constantly using $portdir/file - get variables from make instead of parsing the Makefile - update usage() - fix some portname/version bugs - add EXTRACT_ONLY to section 1 - fix multi comment sections on top bug I think I'm going to start a rewrite of lots of portlint's code to *hopefully* make it easier to add new checks in the future. If you have any requests of things for me to put on portlint's TODO list, send me an email letting me know what they are.
This commit is contained in:
parent
3b26e0ea23
commit
de91bdd9c9
Notes:
svn2git
2021-03-31 03:12:20 +00:00
svn path=/head/; revision=28009
8 changed files with 294 additions and 150 deletions
|
@ -8,7 +8,7 @@
|
||||||
#
|
#
|
||||||
|
|
||||||
PORTNAME= portlint
|
PORTNAME= portlint
|
||||||
PORTVERSION= 2.2.1
|
PORTVERSION= 2.2.2
|
||||||
CATEGORIES= devel
|
CATEGORIES= devel
|
||||||
MASTER_SITES= # none
|
MASTER_SITES= # none
|
||||||
DISTFILES= # none
|
DISTFILES= # none
|
||||||
|
|
|
@ -1,8 +1,10 @@
|
||||||
portlint makes a small set of sanity checks for port directory.
|
portlint makes a small set of sanity checks for port directory.
|
||||||
|
|
||||||
usage: portlint [-avN] [port_directory]
|
usage: portlint [-abctvN] [-B#] [port_directory]
|
||||||
-a additional check for scripts/* and pkg/*
|
-a additional check for scripts/* and pkg/*
|
||||||
-b warn $(VARIABLE)
|
-b warn $(VARIABLE)
|
||||||
-c committer mode
|
-c committer mode
|
||||||
-v verbose mode
|
-v verbose mode
|
||||||
-N writing a new port
|
-t nit pick about use of spaces
|
||||||
|
-N writing a new port
|
||||||
|
-B# allow # contiguous blank lines (default: 1 line)
|
||||||
|
|
|
@ -119,6 +119,7 @@ port collection
|
||||||
on NetBSD/OpenBSD
|
on NetBSD/OpenBSD
|
||||||
.Pc
|
.Pc
|
||||||
.Sh AUTHORS
|
.Sh AUTHORS
|
||||||
|
.An Michael Haro Aq mharo@FreeBSD.org
|
||||||
.An Jun-ichiro Hagino Aq itojun@itojun.org
|
.An Jun-ichiro Hagino Aq itojun@itojun.org
|
||||||
and
|
and
|
||||||
.An Yoshishige Arai Aq ryo2@on.rim.or.jp .
|
.An Yoshishige Arai Aq ryo2@on.rim.or.jp .
|
||||||
|
|
|
@ -17,20 +17,21 @@
|
||||||
# OpenBSD and NetBSD will be accepted.
|
# OpenBSD and NetBSD will be accepted.
|
||||||
#
|
#
|
||||||
# $FreeBSD$
|
# $FreeBSD$
|
||||||
# $Id: portlint.pl,v 1.16 2000/04/16 22:39:57 mharo Exp $
|
# $Id: portlint.pl,v 1.28.2.1 2000/04/24 02:12:36 mharo Exp $
|
||||||
#
|
#
|
||||||
|
|
||||||
use vars qw/ $opt_a $opt_b $opt_c $opt_h $opt_v $opt_N $opt_B $opt_V /;
|
use vars qw/ $opt_a $opt_b $opt_c $opt_h $opt_t $opt_v $opt_M $opt_N $opt_B $opt_V /;
|
||||||
use Getopt::Std;
|
use Getopt::Std;
|
||||||
#use strict;
|
#use strict;
|
||||||
|
|
||||||
my ($err, $warn);
|
my ($err, $warn);
|
||||||
my ($extrafile, $parenwarn, $committer, $verbose, $newport);
|
my ($extrafile, $parenwarn, $committer, $verbose, $usetabs, $newport);
|
||||||
my $contblank;
|
my $contblank;
|
||||||
my $portdir;
|
my $portdir;
|
||||||
|
my $makeenv;
|
||||||
|
|
||||||
$err = $warn = 0;
|
$err = $warn = 0;
|
||||||
$extrafile = $parenwarn = $committer = $verbose = $newport = 0;
|
$extrafile = $parenwarn = $committer = $verbose = $usetabs = $newport = 0;
|
||||||
$contblank = 1;
|
$contblank = 1;
|
||||||
$portdir = '.';
|
$portdir = '.';
|
||||||
|
|
||||||
|
@ -46,7 +47,6 @@ my $l = &l;
|
||||||
my $r = &r;
|
my $r = &r;
|
||||||
my $s = &s;
|
my $s = &s;
|
||||||
|
|
||||||
|
|
||||||
# default setting - for FreeBSD
|
# default setting - for FreeBSD
|
||||||
my $portsdir = '/usr/ports';
|
my $portsdir = '/usr/ports';
|
||||||
my $rcsidstr = 'FreeBSD';
|
my $rcsidstr = 'FreeBSD';
|
||||||
|
@ -71,11 +71,13 @@ my $re_lang_pref = '(' . join('|', @lang_pref) . ')';
|
||||||
my ($prog) = ($0 =~ /([^\/]+)$/);
|
my ($prog) = ($0 =~ /([^\/]+)$/);
|
||||||
sub usage {
|
sub usage {
|
||||||
print STDERR <<EOF;
|
print STDERR <<EOF;
|
||||||
usage: $prog [-abcvN] [-B#] [port_directory]
|
usage: $prog [-abctvN] [-B#] [port_directory]
|
||||||
-a additional check for scripts/* and pkg/*
|
-a additional check for scripts/* and pkg/*
|
||||||
-b warn \$(VARIABLE)
|
-b warn \$(VARIABLE)
|
||||||
-c committer mode
|
-c committer mode
|
||||||
-v verbose mode
|
-v verbose mode
|
||||||
|
-t nit pick about use of spaces
|
||||||
|
-M set make variables (ex. PORTSDIR=/usr/ports.work)
|
||||||
-N writing a new port
|
-N writing a new port
|
||||||
-B# allow # contiguous blank lines (default: $contblank line)
|
-B# allow # contiguous blank lines (default: $contblank line)
|
||||||
EOF
|
EOF
|
||||||
|
@ -88,7 +90,7 @@ sub version {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
getopts('abchvNB:V');
|
getopts('abchtvBM:N:V');
|
||||||
|
|
||||||
&usage if $opt_h;
|
&usage if $opt_h;
|
||||||
&version if $opt_V;
|
&version if $opt_V;
|
||||||
|
@ -97,7 +99,9 @@ $parenwarn = 1 if $opt_b;
|
||||||
$committer = 1 if $opt_c;
|
$committer = 1 if $opt_c;
|
||||||
$verbose = 1 if $opt_v;
|
$verbose = 1 if $opt_v;
|
||||||
$newport = 1 if $opt_N;
|
$newport = 1 if $opt_N;
|
||||||
|
$usetabs = 1 if $opt_t;
|
||||||
$contblank = $opt_B if $opt_B;
|
$contblank = $opt_B if $opt_B;
|
||||||
|
$makeenv = $opt_M;
|
||||||
|
|
||||||
$portdir = $ARGV[0] ? $ARGV[0] : '.';
|
$portdir = $ARGV[0] ? $ARGV[0] : '.';
|
||||||
|
|
||||||
|
@ -139,6 +143,28 @@ if (! -d $portdir) {
|
||||||
exit 1;
|
exit 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
chdir "$portdir" || die "$portdir: $!";
|
||||||
|
|
||||||
|
# get make vars
|
||||||
|
my $cmd = "make $makeenv MASTER_SITE_BACKUP=''";
|
||||||
|
my @varlist = (split(/\s+/, <<EOF));
|
||||||
|
PORTNAME PORTVERSION PKGNAME PKGNAMEPREFIX PKGNAMESUFFIX
|
||||||
|
DISTNAME DISTFILES CATEGORIES MASTERDIR MAINTAINER MASTER_SITES
|
||||||
|
WRKDIR WRKSRC NO_WRKSUBDIR PATCHDIR SCRIPTDIR FILESDIR PKGDIR
|
||||||
|
COMMENT DESCR PLIST MD5_FILE .CURDIR
|
||||||
|
EOF
|
||||||
|
|
||||||
|
for (@varlist) {
|
||||||
|
$cmd .= " -V $_";
|
||||||
|
}
|
||||||
|
my %makevar;
|
||||||
|
my $i = 0;
|
||||||
|
for (split(/\n/, `$cmd`)) {
|
||||||
|
print "OK: makevar: $varlist[$i] = $_\n" if ($verbose);
|
||||||
|
$makevar{$varlist[$i]} = $_;
|
||||||
|
$i++;
|
||||||
|
}
|
||||||
|
|
||||||
#
|
#
|
||||||
# variables for global checks.
|
# variables for global checks.
|
||||||
#
|
#
|
||||||
|
@ -232,13 +258,12 @@ EOF
|
||||||
#
|
#
|
||||||
# check for files.
|
# check for files.
|
||||||
#
|
#
|
||||||
my @checker = ('pkg/COMMENT', 'pkg/DESCR', 'Makefile', 'files/md5');
|
my @checker = ($makevar{COMMENT}, $makevar{DESCR}, 'Makefile', $makevar{MD5_FILE});
|
||||||
my %checker = ('pkg/COMMENT', 'checkdescr', 'pkg/DESCR', 'checkdescr',
|
my %checker = ($makevar{COMMENT}, 'checkdescr', $makevar{DESCR}, 'checkdescr',
|
||||||
'Makefile', 'checkmakefile', 'files/md5', 'TRUE');
|
'Makefile', 'checkmakefile', $makevar{MD5_FILE}, 'TRUE');
|
||||||
if ($extrafile) {
|
if ($extrafile) {
|
||||||
foreach my $i ((<$portdir/scripts/*>, <$portdir/pkg/*>)) {
|
foreach my $i ((<scripts/*>, <pkg/*>)) {
|
||||||
next if (! -T $i);
|
next if (! -T $i);
|
||||||
$i =~ s/^$portdir\///;
|
|
||||||
next if (defined $checker{$i});
|
next if (defined $checker{$i});
|
||||||
if ($i =~ /pkg\/PLIST$/
|
if ($i =~ /pkg\/PLIST$/
|
||||||
|| ($multiplist && $i =~ /pkg\/PLIST/)) {
|
|| ($multiplist && $i =~ /pkg\/PLIST/)) {
|
||||||
|
@ -250,16 +275,15 @@ if ($extrafile) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
foreach my $i (<$portdir/patches/patch-??>) {
|
foreach my $i (<patches/patch-??>) {
|
||||||
next if (! -T $i);
|
next if (! -T $i);
|
||||||
$i =~ s/^$portdir\///;
|
|
||||||
next if (defined $checker{$i});
|
next if (defined $checker{$i});
|
||||||
push(@checker, $i);
|
push(@checker, $i);
|
||||||
$checker{$i} = 'checkpatch';
|
$checker{$i} = 'checkpatch';
|
||||||
}
|
}
|
||||||
foreach my $i (@checker) {
|
foreach my $i (@checker) {
|
||||||
print "OK: checking $i.\n";
|
print "OK: checking $i.\n";
|
||||||
if (! -f "$portdir/$i") {
|
if (! -f "$i") {
|
||||||
&perror("FATAL: no $i in \"$portdir\".");
|
&perror("FATAL: no $i in \"$portdir\".");
|
||||||
} else {
|
} else {
|
||||||
my $proc = $checker{$i};
|
my $proc = $checker{$i};
|
||||||
|
@ -271,16 +295,16 @@ foreach my $i (@checker) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ($committer) {
|
if ($committer) {
|
||||||
if (scalar(@_ = <$portdir/work/*>) || -d "$portdir/work") {
|
if (scalar(@_ = <work/*>) || -d "work") {
|
||||||
&perror("FATAL: be sure to cleanup $portdir/work ".
|
&perror("FATAL: be sure to cleanup $portdir/work ".
|
||||||
"before committing the port.");
|
"before committing the port.");
|
||||||
}
|
}
|
||||||
if (scalar(@_ = <$portdir/*/*~>) || scalar(@_ = <$portdir/*~>)) {
|
if (scalar(@_ = <*/*~>) || scalar(@_ = <*~>)) {
|
||||||
&perror("FATAL: for safety, be sure to cleanup ".
|
&perror("FATAL: for safety, be sure to cleanup ".
|
||||||
"editor backup files before committing the port.");
|
"editor backup files before committing the port.");
|
||||||
}
|
}
|
||||||
if (scalar(@_ = <$portdir/*/*.orig>) || scalar(@_ = <$portdir/*.orig>)
|
if (scalar(@_ = <*/*.orig>) || scalar(@_ = </*.orig>)
|
||||||
|| scalar(@_ = <$portdir/*/*.rej>) || scalar(@_ = <$portdir/*.rej>)) {
|
|| scalar(@_ = <*/*.rej>) || scalar(@_ = <*.rej>)) {
|
||||||
&perror("FATAL: for safety, be sure to cleanup ".
|
&perror("FATAL: for safety, be sure to cleanup ".
|
||||||
"patch backup files before committing the port.");
|
"patch backup files before committing the port.");
|
||||||
}
|
}
|
||||||
|
@ -297,14 +321,14 @@ exit $err;
|
||||||
#
|
#
|
||||||
sub checkdescr {
|
sub checkdescr {
|
||||||
my($file) = @_;
|
my($file) = @_;
|
||||||
my(%maxchars) = ('pkg/COMMENT', 70, 'pkg/DESCR', 80);
|
my(%maxchars) = ($makevar{COMMENT}, 70, $makevar{DESCR}, 80);
|
||||||
my(%maxlines) = ('pkg/COMMENT', 1, 'pkg/DESCR', 24);
|
my(%maxlines) = ($makevar{COMMENT}, 1, $makevar{DESCR}, 24);
|
||||||
my(%errmsg) = ('pkg/COMMENT', "must be one-liner.",
|
my(%errmsg) = ($makevar{COMMENT}, "must be one-liner.",
|
||||||
'pkg/DESCR', "exceeds $maxlines{'pkg/DESCR'} ".
|
$makevar{DESCR}, "exceeds $maxlines{$makevar{DESCR}} ".
|
||||||
"lines, make it shorter if possible.");
|
"lines, make it shorter if possible.");
|
||||||
my($longlines, $linecnt, $tmp) = (0, 0, "");
|
my($longlines, $linecnt, $tmp) = (0, 0, "");
|
||||||
|
|
||||||
open(IN, "< $portdir/$file") || return 0;
|
open(IN, "< $file") || return 0;
|
||||||
while (<IN>) {
|
while (<IN>) {
|
||||||
$linecnt++;
|
$linecnt++;
|
||||||
$longlines++ if ($maxchars{$file} < length(chomp($_)));
|
$longlines++ if ($maxchars{$file} < length(chomp($_)));
|
||||||
|
@ -325,8 +349,22 @@ sub checkdescr {
|
||||||
"other local characters. $file should be ".
|
"other local characters. $file should be ".
|
||||||
"plain ascii file.");
|
"plain ascii file.");
|
||||||
}
|
}
|
||||||
|
if ($file =~ m/DESCR/ && $tmp =~ m,http://,) {
|
||||||
|
my $has_url = 0;
|
||||||
|
my $has_www = 0;
|
||||||
|
foreach my $line (grep($_ =~ "http://", split(/\n+/, $tmp))) {
|
||||||
|
$has_url = 1;
|
||||||
|
if ($line =~ m,WWW:[ \t]+http://,) {
|
||||||
|
$has_www = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($has_url && ! $has_www) {
|
||||||
|
&perror("FATAL: $file: contains a URL but no WWW:");
|
||||||
|
}
|
||||||
|
}
|
||||||
if ($file =~ m/COMMENT/) {
|
if ($file =~ m/COMMENT/) {
|
||||||
if (($tmp !~ /^[0-9A-Z].*$/) || ($tmp =~ m/\.$/)) {
|
if (($tmp !~ /^["0-9A-Z]/) || ($tmp =~ m/\.$/)) {
|
||||||
&perror("WARN: pkg/COMMENT should begin with a capital, and end without a period");
|
&perror("WARN: pkg/COMMENT should begin with a capital, and end without a period");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -348,7 +386,7 @@ sub checkplist {
|
||||||
my(@unexec_info) = ();
|
my(@unexec_info) = ();
|
||||||
my(@infofile) = ();
|
my(@infofile) = ();
|
||||||
|
|
||||||
open(IN, "< $portdir/$file") || return 0;
|
open(IN, "< $file") || return 0;
|
||||||
while (<IN>) {
|
while (<IN>) {
|
||||||
if ($_ =~ /[ \t]+\n?$/) {
|
if ($_ =~ /[ \t]+\n?$/) {
|
||||||
&perror("WARN: $file $.: whitespace before end ".
|
&perror("WARN: $file $.: whitespace before end ".
|
||||||
|
@ -515,7 +553,7 @@ sub checkpathname {
|
||||||
my($file) = @_;
|
my($file) = @_;
|
||||||
my($whole);
|
my($whole);
|
||||||
|
|
||||||
open(IN, "< $portdir/$file") || return 0;
|
open(IN, "< $file") || return 0;
|
||||||
$whole = '';
|
$whole = '';
|
||||||
while (<IN>) {
|
while (<IN>) {
|
||||||
$whole .= $_;
|
$whole .= $_;
|
||||||
|
@ -528,7 +566,7 @@ sub checklastline {
|
||||||
my($file) = @_;
|
my($file) = @_;
|
||||||
my($whole);
|
my($whole);
|
||||||
|
|
||||||
open(IN, "< $portdir/$file") || return 0;
|
open(IN, "< $file") || return 0;
|
||||||
$whole = '';
|
$whole = '';
|
||||||
while (<IN>) {
|
while (<IN>) {
|
||||||
$whole .= $_;
|
$whole .= $_;
|
||||||
|
@ -549,13 +587,13 @@ sub checkpatch {
|
||||||
my($file) = @_;
|
my($file) = @_;
|
||||||
my($whole);
|
my($whole);
|
||||||
|
|
||||||
if (-z "$portdir/$file") {
|
if (-z "$file") {
|
||||||
&perror("FATAL: $file has no content. should be removed ".
|
&perror("FATAL: $file has no content. should be removed ".
|
||||||
"from repository.");
|
"from repository.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
open(IN, "< $portdir/$file") || return 0;
|
open(IN, "< $file") || return 0;
|
||||||
$whole = '';
|
$whole = '';
|
||||||
while (<IN>) {
|
while (<IN>) {
|
||||||
$whole .= $_;
|
$whole .= $_;
|
||||||
|
@ -581,10 +619,12 @@ sub checkmakefile {
|
||||||
my $bogusdistfiles = 0;
|
my $bogusdistfiles = 0;
|
||||||
my @varnames = ();
|
my @varnames = ();
|
||||||
my($portname, $portversion, $distfiles, $distname, $extractsufx) = ('', '', '', '', '');
|
my($portname, $portversion, $distfiles, $distname, $extractsufx) = ('', '', '', '', '');
|
||||||
|
my $masterport = 0;
|
||||||
|
my $slaveport = 0;
|
||||||
my($realwrksrc, $wrksrc, $nowrksubdir) = ('', '', '');
|
my($realwrksrc, $wrksrc, $nowrksubdir) = ('', '', '');
|
||||||
my(@mman, @pman);
|
my(@mman, @pman);
|
||||||
|
|
||||||
open(IN, "< $portdir/$file") || return 0;
|
open(IN, "< $file") || return 0;
|
||||||
$rawwhole = '';
|
$rawwhole = '';
|
||||||
$tmp = 0;
|
$tmp = 0;
|
||||||
while (<IN>) {
|
while (<IN>) {
|
||||||
|
@ -596,6 +636,17 @@ sub checkmakefile {
|
||||||
&perror("WARN: $file $.: use tab (not space) to make ".
|
&perror("WARN: $file $.: use tab (not space) to make ".
|
||||||
"indentation");
|
"indentation");
|
||||||
}
|
}
|
||||||
|
if ($usetabs) {
|
||||||
|
if (m/^[A-Za-z0-9_-]+.?= /) {
|
||||||
|
if (m/[?+]=/) {
|
||||||
|
&perror("WARN: $file $.: use a tab (not space) after a ".
|
||||||
|
"variable name");
|
||||||
|
} else {
|
||||||
|
&perror("FATAL: $file $.: use a tab (not space) after a ".
|
||||||
|
"variable name");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
#
|
#
|
||||||
# I'm still not very convinced, for using this kind of magical word.
|
# I'm still not very convinced, for using this kind of magical word.
|
||||||
# 1. This kind of items are not important for Makefile;
|
# 1. This kind of items are not important for Makefile;
|
||||||
|
@ -673,7 +724,6 @@ sub checkmakefile {
|
||||||
"PORTVERSION, PKGNAMEPREFIX and PKGNAMESUFFIX.");
|
"PORTVERSION, PKGNAMEPREFIX and PKGNAMESUFFIX.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# whole file: IS_INTERACTIVE/NOPORTDOCS
|
# whole file: IS_INTERACTIVE/NOPORTDOCS
|
||||||
#
|
#
|
||||||
|
@ -752,6 +802,18 @@ EOF
|
||||||
#
|
#
|
||||||
&abspathname($whole, $file);
|
&abspathname($whole, $file);
|
||||||
|
|
||||||
|
#
|
||||||
|
# slave port check
|
||||||
|
#
|
||||||
|
my $masterdir = $makevar{MASTERDIR};
|
||||||
|
if ($masterdir ne '' && $masterdir ne $makevar{'.CURDIR'}) {
|
||||||
|
$slaveport = 1;
|
||||||
|
print "OK: checking master port in $masterdir.\n" if ($verbose);
|
||||||
|
if (! -e "$masterdir/Makefile") {
|
||||||
|
&perror("WARN: unable to locate master port in $masterdir");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#
|
#
|
||||||
# break the makefile into sections.
|
# break the makefile into sections.
|
||||||
#
|
#
|
||||||
|
@ -795,14 +857,12 @@ EOF
|
||||||
print "OK: \"$j\" seen in $file.\n" if ($verbose);
|
print "OK: \"$j\" seen in $file.\n" if ($verbose);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
foreach my $i (@linestocheck) {
|
if ($tmp =~ m/Version [rR]equired/) {
|
||||||
if ($i =~ m/Version [rR]equired/) {
|
&perror("WARN: Version required is no longer needed in the comment section of $file.");
|
||||||
&perror("FATAL: Version required is no longer needed in the comment section of $file.");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
my $tmp2 = "";
|
my $tmp2 = "";
|
||||||
for (split(/\n/, $tmp)) {
|
for (split(/\n/, $tmp)) {
|
||||||
$tmp2 = $_ if (m/$rcsidstr/);
|
$tmp2 .= $_ if (m/\$$rcsidstr/);
|
||||||
}
|
}
|
||||||
if ($tmp2 !~ /#(\s+)\$$rcsidstr([^\$]*)\$$/) {
|
if ($tmp2 !~ /#(\s+)\$$rcsidstr([^\$]*)\$$/) {
|
||||||
|
|
||||||
|
@ -847,38 +907,38 @@ EOF
|
||||||
# check the order of items.
|
# check the order of items.
|
||||||
&checkorder('PORTNAME', $tmp, split(/\s+/, <<EOF));
|
&checkorder('PORTNAME', $tmp, split(/\s+/, <<EOF));
|
||||||
PORTNAME PORTVERSION CATEGORIES MASTER_SITES MASTER_SITE_SUBDIR
|
PORTNAME PORTVERSION CATEGORIES MASTER_SITES MASTER_SITE_SUBDIR
|
||||||
PKGNAMEPREFIX PKGNAMESUFFIX DISTNAME EXTRACT_SUFX DISTFILES EXTRACT_ONLY
|
PKGNAMEPREFIX PKGNAMESUFFIX DISTNAME EXTRACT_SUFX DISTFILES DIST_SUBDIR
|
||||||
|
EXTRACT_ONLY
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
# check the items that has to be there.
|
# check the items that has to be there.
|
||||||
$tmp = "\n" . $tmp;
|
$tmp = "\n" . $tmp;
|
||||||
print "OK: checking PORTNAME/PORTVERSION.\n" if ($verbose);
|
print "OK: checking PORTNAME/PORTVERSION.\n" if ($verbose);
|
||||||
if ($tmp !~ /\nPORTNAME(.)?=/) {
|
if ($tmp !~ /\nPORTNAME(.)?=/) {
|
||||||
&perror("FATAL: PORTNAME has to be there.");
|
&perror("FATAL: PORTNAME has to be there.") unless ($slaveport && $makevar{PORTNAME} ne '');
|
||||||
}
|
}
|
||||||
if ($1 ne '') {
|
if ($1 ne '') {
|
||||||
&perror("WARN: PORTNAME has be set by \"=\", ".
|
&perror("WARN: PORTNAME has to be set by \"=\", ".
|
||||||
"not by \"$1=\".");
|
"not by \"$1=\".") unless ($masterport);
|
||||||
}
|
}
|
||||||
if ($tmp !~ /\nPORTVERSION(.)?=/) {
|
if ($tmp !~ /\nPORTVERSION(.)?=/) {
|
||||||
&perror("FATAL: PORTVERSION has to be there.");
|
&perror("FATAL: PORTVERSION has to be there.") unless ($slaveport && $makevar{PORTVERSION} ne '');
|
||||||
}
|
}
|
||||||
if ($1 ne '') {
|
if ($1 ne '') {
|
||||||
&perror("WARN: PORTVERSION has be set by \"=\", ".
|
&perror("WARN: PORTVERSION has to be set by \"=\", ".
|
||||||
"not by \"$1=\".");
|
"not by \"$1=\".") unless ($masterport);
|
||||||
}
|
}
|
||||||
print "OK: checking CATEGORIES.\n" if ($verbose);
|
print "OK: checking CATEGORIES.\n" if ($verbose);
|
||||||
#MICHAEL: do we want to use [^\n] here?
|
if ($tmp !~ /\nCATEGORIES(.)?=[ \t]*/) {
|
||||||
if ($tmp !~ /\nCATEGORIES(.)?=[ \t]*([^\n]*)/) {
|
&perror("FATAL: CATEGORIES has to be there.") unless ($slaveport && $makevar{CATEGORIES} ne '');
|
||||||
&perror("FATAL: CATEGORIES has to be there.");
|
|
||||||
}
|
}
|
||||||
@cat = split(/\s+/, $2);
|
|
||||||
$i = $1;
|
$i = $1;
|
||||||
if ($i ne '' && $i =~ /[^?+]/) {
|
if ($i ne '' && $i =~ /[^?+]/) {
|
||||||
&perror("WARN: CATEGORIES should be set by \"=\", \"?=\", or \"+=\", ".
|
&perror("WARN: CATEGORIES should be set by \"=\", \"?=\", or \"+=\", ".
|
||||||
"not by \"$i=\".");
|
"not by \"$i=\".") unless ($masterport);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@cat = split(/\s+/, $makevar{CATEGORIES});
|
||||||
if (@cat == 0) {
|
if (@cat == 0) {
|
||||||
&perror("FATAL: CATEGORIES left blank. set it to \"misc\"".
|
&perror("FATAL: CATEGORIES left blank. set it to \"misc\"".
|
||||||
" if nothing seems apropriate.");
|
" if nothing seems apropriate.");
|
||||||
|
@ -924,26 +984,14 @@ EOF
|
||||||
}
|
}
|
||||||
|
|
||||||
# check the URL
|
# check the URL
|
||||||
if ($tmp =~ /\nMASTER_SITES[+?]?=[ \t]*([^\n]*)\n/
|
if (($tmp =~ /\nMASTER_SITES[+?]?=[ \t]*([^\n]*)\n/
|
||||||
&& $1 !~ /^[ \t]*$/) {
|
&& $1 !~ /^[ \t]*$/) || ($makevar{MASTER_SITES} ne '')) {
|
||||||
print "OK: seen MASTER_SITES, sanity checking URLs.\n"
|
print "OK: seen MASTER_SITES, sanity checking URLs.\n"
|
||||||
if ($verbose);
|
if ($verbose);
|
||||||
my @sites = split(/\s+/, $1);
|
my @sites = split(/\s+/, $1);
|
||||||
foreach my $i (@sites) {
|
foreach my $i (@sites) {
|
||||||
if ($i =~ m#^\w+://#) {
|
if ($i =~ m#^\w+://#) {
|
||||||
if ($i !~ m#/$#) {
|
&urlcheck($i);
|
||||||
&perror("FATAL: URL \"$i\" should ".
|
|
||||||
"end with \"/\".");
|
|
||||||
}
|
|
||||||
if ($i =~ m#://[^/]*:/#) {
|
|
||||||
&perror("FATAL: URL \"$i\" contains ".
|
|
||||||
"extra \":\".");
|
|
||||||
}
|
|
||||||
if ($osname == 'FreeBSD' && $i =~ m#(www.freebsd.org)/~.+/#i) {
|
|
||||||
&perror("WARN: URL \"$i\", ".
|
|
||||||
"$1 should be ".
|
|
||||||
"people.FreeBSD.org");
|
|
||||||
}
|
|
||||||
unless (&is_predefined($i)) {
|
unless (&is_predefined($i)) {
|
||||||
print "OK: URL \"$i\" ok.\n"
|
print "OK: URL \"$i\" ok.\n"
|
||||||
if ($verbose);
|
if ($verbose);
|
||||||
|
@ -959,8 +1007,10 @@ EOF
|
||||||
|
|
||||||
# check DISTFILES and related items.
|
# check DISTFILES and related items.
|
||||||
$distfiles = $1 if ($tmp =~ /\nDISTFILES[+?]?=[ \t]*([^\n]+)\n/);
|
$distfiles = $1 if ($tmp =~ /\nDISTFILES[+?]?=[ \t]*([^\n]+)\n/);
|
||||||
$portname = $1 if ($tmp =~ /\nPORTNAME[+?]?=[ \t]*([^\n]+)\n/);
|
#$portname = $1 if ($tmp =~ /\nPORTNAME[+?]?=[ \t]*([^\n]+)\n/);
|
||||||
$portversion = $1 if ($tmp =~ /\nPORTVERSION[+?]?=[ \t]*([^\n]+)\n/);
|
#$portversion = $1 if ($tmp =~ /\nPORTVERSION[+?]?=[ \t]*([^\n]+)\n/);
|
||||||
|
$portname = $makevar{PORTNAME};
|
||||||
|
$portversion = $makevar{PORTVERSION};
|
||||||
$distname = $1 if ($tmp =~ /\nDISTNAME[+?]?=[ \t]*([^\n]+)\n/);
|
$distname = $1 if ($tmp =~ /\nDISTNAME[+?]?=[ \t]*([^\n]+)\n/);
|
||||||
$extractsufx = $1 if ($tmp =~ /\nEXTRACT_SUFX[+?]?=[ \t]*([^\n]+)\n/);
|
$extractsufx = $1 if ($tmp =~ /\nEXTRACT_SUFX[+?]?=[ \t]*([^\n]+)\n/);
|
||||||
|
|
||||||
|
@ -1051,7 +1101,7 @@ EOF
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($committer) {
|
if ($committer) {
|
||||||
if (opendir(DIR, $portdir)) {
|
if (opendir(DIR, ".")) {
|
||||||
my @tgz = grep(/\.tgz$/, readdir(DIR));
|
my @tgz = grep(/\.tgz$/, readdir(DIR));
|
||||||
closedir(DIR);
|
closedir(DIR);
|
||||||
|
|
||||||
|
@ -1119,7 +1169,7 @@ EOF
|
||||||
if ($tmp =~ /\nMAINTAINER\??=[^\n]+/) {
|
if ($tmp =~ /\nMAINTAINER\??=[^\n]+/) {
|
||||||
$tmp =~ s/\nMAINTAINER\??=[^\n]+//;
|
$tmp =~ s/\nMAINTAINER\??=[^\n]+//;
|
||||||
} elsif ($whole !~ /\nMAINTAINER[?]?=/) {
|
} elsif ($whole !~ /\nMAINTAINER[?]?=/) {
|
||||||
&perror("FATAL: no MAINTAINER listed in $file.");
|
&perror("FATAL: no MAINTAINER listed in $file.") unless ($slaveport && $makevar{MAINTAINER} ne '');
|
||||||
}
|
}
|
||||||
$tmp =~ s/\n\n+/\n/g;
|
$tmp =~ s/\n\n+/\n/g;
|
||||||
|
|
||||||
|
@ -1577,4 +1627,23 @@ sub is_predefined {
|
||||||
undef;
|
undef;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub urlcheck {
|
||||||
|
my ($url) = @_;
|
||||||
|
if ($url !~ m#^\w+://#) {
|
||||||
|
&perror("WARN: \"$url\" doesn't appear to be a URL to me.");
|
||||||
|
}
|
||||||
|
if ($url !~ m#/$#) {
|
||||||
|
&perror("FATAL: URL \"$url\" should ".
|
||||||
|
"end with \"/\".");
|
||||||
|
}
|
||||||
|
if ($url =~ m#://[^/]*:/#) {
|
||||||
|
&perror("FATAL: URL \"$url\" contains ".
|
||||||
|
"extra \":\".");
|
||||||
|
}
|
||||||
|
if ($osname == 'FreeBSD' && $url =~ m#(www.freebsd.org)/~.+/#i) {
|
||||||
|
&perror("WARN: URL \"$url\", ".
|
||||||
|
"$1 should be ".
|
||||||
|
"people.FreeBSD.org");
|
||||||
|
}
|
||||||
|
}
|
||||||
sub TRUE {1;}
|
sub TRUE {1;}
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
#
|
#
|
||||||
|
|
||||||
PORTNAME= portlint
|
PORTNAME= portlint
|
||||||
PORTVERSION= 2.2.1
|
PORTVERSION= 2.2.2
|
||||||
CATEGORIES= devel
|
CATEGORIES= devel
|
||||||
MASTER_SITES= # none
|
MASTER_SITES= # none
|
||||||
DISTFILES= # none
|
DISTFILES= # none
|
||||||
|
|
|
@ -1,8 +1,10 @@
|
||||||
portlint makes a small set of sanity checks for port directory.
|
portlint makes a small set of sanity checks for port directory.
|
||||||
|
|
||||||
usage: portlint [-avN] [port_directory]
|
usage: portlint [-abctvN] [-B#] [port_directory]
|
||||||
-a additional check for scripts/* and pkg/*
|
-a additional check for scripts/* and pkg/*
|
||||||
-b warn $(VARIABLE)
|
-b warn $(VARIABLE)
|
||||||
-c committer mode
|
-c committer mode
|
||||||
-v verbose mode
|
-v verbose mode
|
||||||
-N writing a new port
|
-t nit pick about use of spaces
|
||||||
|
-N writing a new port
|
||||||
|
-B# allow # contiguous blank lines (default: 1 line)
|
||||||
|
|
|
@ -119,6 +119,7 @@ port collection
|
||||||
on NetBSD/OpenBSD
|
on NetBSD/OpenBSD
|
||||||
.Pc
|
.Pc
|
||||||
.Sh AUTHORS
|
.Sh AUTHORS
|
||||||
|
.An Michael Haro Aq mharo@FreeBSD.org
|
||||||
.An Jun-ichiro Hagino Aq itojun@itojun.org
|
.An Jun-ichiro Hagino Aq itojun@itojun.org
|
||||||
and
|
and
|
||||||
.An Yoshishige Arai Aq ryo2@on.rim.or.jp .
|
.An Yoshishige Arai Aq ryo2@on.rim.or.jp .
|
||||||
|
|
|
@ -17,20 +17,21 @@
|
||||||
# OpenBSD and NetBSD will be accepted.
|
# OpenBSD and NetBSD will be accepted.
|
||||||
#
|
#
|
||||||
# $FreeBSD$
|
# $FreeBSD$
|
||||||
# $Id: portlint.pl,v 1.16 2000/04/16 22:39:57 mharo Exp $
|
# $Id: portlint.pl,v 1.28.2.1 2000/04/24 02:12:36 mharo Exp $
|
||||||
#
|
#
|
||||||
|
|
||||||
use vars qw/ $opt_a $opt_b $opt_c $opt_h $opt_v $opt_N $opt_B $opt_V /;
|
use vars qw/ $opt_a $opt_b $opt_c $opt_h $opt_t $opt_v $opt_M $opt_N $opt_B $opt_V /;
|
||||||
use Getopt::Std;
|
use Getopt::Std;
|
||||||
#use strict;
|
#use strict;
|
||||||
|
|
||||||
my ($err, $warn);
|
my ($err, $warn);
|
||||||
my ($extrafile, $parenwarn, $committer, $verbose, $newport);
|
my ($extrafile, $parenwarn, $committer, $verbose, $usetabs, $newport);
|
||||||
my $contblank;
|
my $contblank;
|
||||||
my $portdir;
|
my $portdir;
|
||||||
|
my $makeenv;
|
||||||
|
|
||||||
$err = $warn = 0;
|
$err = $warn = 0;
|
||||||
$extrafile = $parenwarn = $committer = $verbose = $newport = 0;
|
$extrafile = $parenwarn = $committer = $verbose = $usetabs = $newport = 0;
|
||||||
$contblank = 1;
|
$contblank = 1;
|
||||||
$portdir = '.';
|
$portdir = '.';
|
||||||
|
|
||||||
|
@ -46,7 +47,6 @@ my $l = &l;
|
||||||
my $r = &r;
|
my $r = &r;
|
||||||
my $s = &s;
|
my $s = &s;
|
||||||
|
|
||||||
|
|
||||||
# default setting - for FreeBSD
|
# default setting - for FreeBSD
|
||||||
my $portsdir = '/usr/ports';
|
my $portsdir = '/usr/ports';
|
||||||
my $rcsidstr = 'FreeBSD';
|
my $rcsidstr = 'FreeBSD';
|
||||||
|
@ -71,11 +71,13 @@ my $re_lang_pref = '(' . join('|', @lang_pref) . ')';
|
||||||
my ($prog) = ($0 =~ /([^\/]+)$/);
|
my ($prog) = ($0 =~ /([^\/]+)$/);
|
||||||
sub usage {
|
sub usage {
|
||||||
print STDERR <<EOF;
|
print STDERR <<EOF;
|
||||||
usage: $prog [-abcvN] [-B#] [port_directory]
|
usage: $prog [-abctvN] [-B#] [port_directory]
|
||||||
-a additional check for scripts/* and pkg/*
|
-a additional check for scripts/* and pkg/*
|
||||||
-b warn \$(VARIABLE)
|
-b warn \$(VARIABLE)
|
||||||
-c committer mode
|
-c committer mode
|
||||||
-v verbose mode
|
-v verbose mode
|
||||||
|
-t nit pick about use of spaces
|
||||||
|
-M set make variables (ex. PORTSDIR=/usr/ports.work)
|
||||||
-N writing a new port
|
-N writing a new port
|
||||||
-B# allow # contiguous blank lines (default: $contblank line)
|
-B# allow # contiguous blank lines (default: $contblank line)
|
||||||
EOF
|
EOF
|
||||||
|
@ -88,7 +90,7 @@ sub version {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
getopts('abchvNB:V');
|
getopts('abchtvBM:N:V');
|
||||||
|
|
||||||
&usage if $opt_h;
|
&usage if $opt_h;
|
||||||
&version if $opt_V;
|
&version if $opt_V;
|
||||||
|
@ -97,7 +99,9 @@ $parenwarn = 1 if $opt_b;
|
||||||
$committer = 1 if $opt_c;
|
$committer = 1 if $opt_c;
|
||||||
$verbose = 1 if $opt_v;
|
$verbose = 1 if $opt_v;
|
||||||
$newport = 1 if $opt_N;
|
$newport = 1 if $opt_N;
|
||||||
|
$usetabs = 1 if $opt_t;
|
||||||
$contblank = $opt_B if $opt_B;
|
$contblank = $opt_B if $opt_B;
|
||||||
|
$makeenv = $opt_M;
|
||||||
|
|
||||||
$portdir = $ARGV[0] ? $ARGV[0] : '.';
|
$portdir = $ARGV[0] ? $ARGV[0] : '.';
|
||||||
|
|
||||||
|
@ -139,6 +143,28 @@ if (! -d $portdir) {
|
||||||
exit 1;
|
exit 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
chdir "$portdir" || die "$portdir: $!";
|
||||||
|
|
||||||
|
# get make vars
|
||||||
|
my $cmd = "make $makeenv MASTER_SITE_BACKUP=''";
|
||||||
|
my @varlist = (split(/\s+/, <<EOF));
|
||||||
|
PORTNAME PORTVERSION PKGNAME PKGNAMEPREFIX PKGNAMESUFFIX
|
||||||
|
DISTNAME DISTFILES CATEGORIES MASTERDIR MAINTAINER MASTER_SITES
|
||||||
|
WRKDIR WRKSRC NO_WRKSUBDIR PATCHDIR SCRIPTDIR FILESDIR PKGDIR
|
||||||
|
COMMENT DESCR PLIST MD5_FILE .CURDIR
|
||||||
|
EOF
|
||||||
|
|
||||||
|
for (@varlist) {
|
||||||
|
$cmd .= " -V $_";
|
||||||
|
}
|
||||||
|
my %makevar;
|
||||||
|
my $i = 0;
|
||||||
|
for (split(/\n/, `$cmd`)) {
|
||||||
|
print "OK: makevar: $varlist[$i] = $_\n" if ($verbose);
|
||||||
|
$makevar{$varlist[$i]} = $_;
|
||||||
|
$i++;
|
||||||
|
}
|
||||||
|
|
||||||
#
|
#
|
||||||
# variables for global checks.
|
# variables for global checks.
|
||||||
#
|
#
|
||||||
|
@ -232,13 +258,12 @@ EOF
|
||||||
#
|
#
|
||||||
# check for files.
|
# check for files.
|
||||||
#
|
#
|
||||||
my @checker = ('pkg/COMMENT', 'pkg/DESCR', 'Makefile', 'files/md5');
|
my @checker = ($makevar{COMMENT}, $makevar{DESCR}, 'Makefile', $makevar{MD5_FILE});
|
||||||
my %checker = ('pkg/COMMENT', 'checkdescr', 'pkg/DESCR', 'checkdescr',
|
my %checker = ($makevar{COMMENT}, 'checkdescr', $makevar{DESCR}, 'checkdescr',
|
||||||
'Makefile', 'checkmakefile', 'files/md5', 'TRUE');
|
'Makefile', 'checkmakefile', $makevar{MD5_FILE}, 'TRUE');
|
||||||
if ($extrafile) {
|
if ($extrafile) {
|
||||||
foreach my $i ((<$portdir/scripts/*>, <$portdir/pkg/*>)) {
|
foreach my $i ((<scripts/*>, <pkg/*>)) {
|
||||||
next if (! -T $i);
|
next if (! -T $i);
|
||||||
$i =~ s/^$portdir\///;
|
|
||||||
next if (defined $checker{$i});
|
next if (defined $checker{$i});
|
||||||
if ($i =~ /pkg\/PLIST$/
|
if ($i =~ /pkg\/PLIST$/
|
||||||
|| ($multiplist && $i =~ /pkg\/PLIST/)) {
|
|| ($multiplist && $i =~ /pkg\/PLIST/)) {
|
||||||
|
@ -250,16 +275,15 @@ if ($extrafile) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
foreach my $i (<$portdir/patches/patch-??>) {
|
foreach my $i (<patches/patch-??>) {
|
||||||
next if (! -T $i);
|
next if (! -T $i);
|
||||||
$i =~ s/^$portdir\///;
|
|
||||||
next if (defined $checker{$i});
|
next if (defined $checker{$i});
|
||||||
push(@checker, $i);
|
push(@checker, $i);
|
||||||
$checker{$i} = 'checkpatch';
|
$checker{$i} = 'checkpatch';
|
||||||
}
|
}
|
||||||
foreach my $i (@checker) {
|
foreach my $i (@checker) {
|
||||||
print "OK: checking $i.\n";
|
print "OK: checking $i.\n";
|
||||||
if (! -f "$portdir/$i") {
|
if (! -f "$i") {
|
||||||
&perror("FATAL: no $i in \"$portdir\".");
|
&perror("FATAL: no $i in \"$portdir\".");
|
||||||
} else {
|
} else {
|
||||||
my $proc = $checker{$i};
|
my $proc = $checker{$i};
|
||||||
|
@ -271,16 +295,16 @@ foreach my $i (@checker) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ($committer) {
|
if ($committer) {
|
||||||
if (scalar(@_ = <$portdir/work/*>) || -d "$portdir/work") {
|
if (scalar(@_ = <work/*>) || -d "work") {
|
||||||
&perror("FATAL: be sure to cleanup $portdir/work ".
|
&perror("FATAL: be sure to cleanup $portdir/work ".
|
||||||
"before committing the port.");
|
"before committing the port.");
|
||||||
}
|
}
|
||||||
if (scalar(@_ = <$portdir/*/*~>) || scalar(@_ = <$portdir/*~>)) {
|
if (scalar(@_ = <*/*~>) || scalar(@_ = <*~>)) {
|
||||||
&perror("FATAL: for safety, be sure to cleanup ".
|
&perror("FATAL: for safety, be sure to cleanup ".
|
||||||
"editor backup files before committing the port.");
|
"editor backup files before committing the port.");
|
||||||
}
|
}
|
||||||
if (scalar(@_ = <$portdir/*/*.orig>) || scalar(@_ = <$portdir/*.orig>)
|
if (scalar(@_ = <*/*.orig>) || scalar(@_ = </*.orig>)
|
||||||
|| scalar(@_ = <$portdir/*/*.rej>) || scalar(@_ = <$portdir/*.rej>)) {
|
|| scalar(@_ = <*/*.rej>) || scalar(@_ = <*.rej>)) {
|
||||||
&perror("FATAL: for safety, be sure to cleanup ".
|
&perror("FATAL: for safety, be sure to cleanup ".
|
||||||
"patch backup files before committing the port.");
|
"patch backup files before committing the port.");
|
||||||
}
|
}
|
||||||
|
@ -297,14 +321,14 @@ exit $err;
|
||||||
#
|
#
|
||||||
sub checkdescr {
|
sub checkdescr {
|
||||||
my($file) = @_;
|
my($file) = @_;
|
||||||
my(%maxchars) = ('pkg/COMMENT', 70, 'pkg/DESCR', 80);
|
my(%maxchars) = ($makevar{COMMENT}, 70, $makevar{DESCR}, 80);
|
||||||
my(%maxlines) = ('pkg/COMMENT', 1, 'pkg/DESCR', 24);
|
my(%maxlines) = ($makevar{COMMENT}, 1, $makevar{DESCR}, 24);
|
||||||
my(%errmsg) = ('pkg/COMMENT', "must be one-liner.",
|
my(%errmsg) = ($makevar{COMMENT}, "must be one-liner.",
|
||||||
'pkg/DESCR', "exceeds $maxlines{'pkg/DESCR'} ".
|
$makevar{DESCR}, "exceeds $maxlines{$makevar{DESCR}} ".
|
||||||
"lines, make it shorter if possible.");
|
"lines, make it shorter if possible.");
|
||||||
my($longlines, $linecnt, $tmp) = (0, 0, "");
|
my($longlines, $linecnt, $tmp) = (0, 0, "");
|
||||||
|
|
||||||
open(IN, "< $portdir/$file") || return 0;
|
open(IN, "< $file") || return 0;
|
||||||
while (<IN>) {
|
while (<IN>) {
|
||||||
$linecnt++;
|
$linecnt++;
|
||||||
$longlines++ if ($maxchars{$file} < length(chomp($_)));
|
$longlines++ if ($maxchars{$file} < length(chomp($_)));
|
||||||
|
@ -325,8 +349,22 @@ sub checkdescr {
|
||||||
"other local characters. $file should be ".
|
"other local characters. $file should be ".
|
||||||
"plain ascii file.");
|
"plain ascii file.");
|
||||||
}
|
}
|
||||||
|
if ($file =~ m/DESCR/ && $tmp =~ m,http://,) {
|
||||||
|
my $has_url = 0;
|
||||||
|
my $has_www = 0;
|
||||||
|
foreach my $line (grep($_ =~ "http://", split(/\n+/, $tmp))) {
|
||||||
|
$has_url = 1;
|
||||||
|
if ($line =~ m,WWW:[ \t]+http://,) {
|
||||||
|
$has_www = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($has_url && ! $has_www) {
|
||||||
|
&perror("FATAL: $file: contains a URL but no WWW:");
|
||||||
|
}
|
||||||
|
}
|
||||||
if ($file =~ m/COMMENT/) {
|
if ($file =~ m/COMMENT/) {
|
||||||
if (($tmp !~ /^[0-9A-Z].*$/) || ($tmp =~ m/\.$/)) {
|
if (($tmp !~ /^["0-9A-Z]/) || ($tmp =~ m/\.$/)) {
|
||||||
&perror("WARN: pkg/COMMENT should begin with a capital, and end without a period");
|
&perror("WARN: pkg/COMMENT should begin with a capital, and end without a period");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -348,7 +386,7 @@ sub checkplist {
|
||||||
my(@unexec_info) = ();
|
my(@unexec_info) = ();
|
||||||
my(@infofile) = ();
|
my(@infofile) = ();
|
||||||
|
|
||||||
open(IN, "< $portdir/$file") || return 0;
|
open(IN, "< $file") || return 0;
|
||||||
while (<IN>) {
|
while (<IN>) {
|
||||||
if ($_ =~ /[ \t]+\n?$/) {
|
if ($_ =~ /[ \t]+\n?$/) {
|
||||||
&perror("WARN: $file $.: whitespace before end ".
|
&perror("WARN: $file $.: whitespace before end ".
|
||||||
|
@ -515,7 +553,7 @@ sub checkpathname {
|
||||||
my($file) = @_;
|
my($file) = @_;
|
||||||
my($whole);
|
my($whole);
|
||||||
|
|
||||||
open(IN, "< $portdir/$file") || return 0;
|
open(IN, "< $file") || return 0;
|
||||||
$whole = '';
|
$whole = '';
|
||||||
while (<IN>) {
|
while (<IN>) {
|
||||||
$whole .= $_;
|
$whole .= $_;
|
||||||
|
@ -528,7 +566,7 @@ sub checklastline {
|
||||||
my($file) = @_;
|
my($file) = @_;
|
||||||
my($whole);
|
my($whole);
|
||||||
|
|
||||||
open(IN, "< $portdir/$file") || return 0;
|
open(IN, "< $file") || return 0;
|
||||||
$whole = '';
|
$whole = '';
|
||||||
while (<IN>) {
|
while (<IN>) {
|
||||||
$whole .= $_;
|
$whole .= $_;
|
||||||
|
@ -549,13 +587,13 @@ sub checkpatch {
|
||||||
my($file) = @_;
|
my($file) = @_;
|
||||||
my($whole);
|
my($whole);
|
||||||
|
|
||||||
if (-z "$portdir/$file") {
|
if (-z "$file") {
|
||||||
&perror("FATAL: $file has no content. should be removed ".
|
&perror("FATAL: $file has no content. should be removed ".
|
||||||
"from repository.");
|
"from repository.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
open(IN, "< $portdir/$file") || return 0;
|
open(IN, "< $file") || return 0;
|
||||||
$whole = '';
|
$whole = '';
|
||||||
while (<IN>) {
|
while (<IN>) {
|
||||||
$whole .= $_;
|
$whole .= $_;
|
||||||
|
@ -581,10 +619,12 @@ sub checkmakefile {
|
||||||
my $bogusdistfiles = 0;
|
my $bogusdistfiles = 0;
|
||||||
my @varnames = ();
|
my @varnames = ();
|
||||||
my($portname, $portversion, $distfiles, $distname, $extractsufx) = ('', '', '', '', '');
|
my($portname, $portversion, $distfiles, $distname, $extractsufx) = ('', '', '', '', '');
|
||||||
|
my $masterport = 0;
|
||||||
|
my $slaveport = 0;
|
||||||
my($realwrksrc, $wrksrc, $nowrksubdir) = ('', '', '');
|
my($realwrksrc, $wrksrc, $nowrksubdir) = ('', '', '');
|
||||||
my(@mman, @pman);
|
my(@mman, @pman);
|
||||||
|
|
||||||
open(IN, "< $portdir/$file") || return 0;
|
open(IN, "< $file") || return 0;
|
||||||
$rawwhole = '';
|
$rawwhole = '';
|
||||||
$tmp = 0;
|
$tmp = 0;
|
||||||
while (<IN>) {
|
while (<IN>) {
|
||||||
|
@ -596,6 +636,17 @@ sub checkmakefile {
|
||||||
&perror("WARN: $file $.: use tab (not space) to make ".
|
&perror("WARN: $file $.: use tab (not space) to make ".
|
||||||
"indentation");
|
"indentation");
|
||||||
}
|
}
|
||||||
|
if ($usetabs) {
|
||||||
|
if (m/^[A-Za-z0-9_-]+.?= /) {
|
||||||
|
if (m/[?+]=/) {
|
||||||
|
&perror("WARN: $file $.: use a tab (not space) after a ".
|
||||||
|
"variable name");
|
||||||
|
} else {
|
||||||
|
&perror("FATAL: $file $.: use a tab (not space) after a ".
|
||||||
|
"variable name");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
#
|
#
|
||||||
# I'm still not very convinced, for using this kind of magical word.
|
# I'm still not very convinced, for using this kind of magical word.
|
||||||
# 1. This kind of items are not important for Makefile;
|
# 1. This kind of items are not important for Makefile;
|
||||||
|
@ -673,7 +724,6 @@ sub checkmakefile {
|
||||||
"PORTVERSION, PKGNAMEPREFIX and PKGNAMESUFFIX.");
|
"PORTVERSION, PKGNAMEPREFIX and PKGNAMESUFFIX.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# whole file: IS_INTERACTIVE/NOPORTDOCS
|
# whole file: IS_INTERACTIVE/NOPORTDOCS
|
||||||
#
|
#
|
||||||
|
@ -752,6 +802,18 @@ EOF
|
||||||
#
|
#
|
||||||
&abspathname($whole, $file);
|
&abspathname($whole, $file);
|
||||||
|
|
||||||
|
#
|
||||||
|
# slave port check
|
||||||
|
#
|
||||||
|
my $masterdir = $makevar{MASTERDIR};
|
||||||
|
if ($masterdir ne '' && $masterdir ne $makevar{'.CURDIR'}) {
|
||||||
|
$slaveport = 1;
|
||||||
|
print "OK: checking master port in $masterdir.\n" if ($verbose);
|
||||||
|
if (! -e "$masterdir/Makefile") {
|
||||||
|
&perror("WARN: unable to locate master port in $masterdir");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#
|
#
|
||||||
# break the makefile into sections.
|
# break the makefile into sections.
|
||||||
#
|
#
|
||||||
|
@ -795,14 +857,12 @@ EOF
|
||||||
print "OK: \"$j\" seen in $file.\n" if ($verbose);
|
print "OK: \"$j\" seen in $file.\n" if ($verbose);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
foreach my $i (@linestocheck) {
|
if ($tmp =~ m/Version [rR]equired/) {
|
||||||
if ($i =~ m/Version [rR]equired/) {
|
&perror("WARN: Version required is no longer needed in the comment section of $file.");
|
||||||
&perror("FATAL: Version required is no longer needed in the comment section of $file.");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
my $tmp2 = "";
|
my $tmp2 = "";
|
||||||
for (split(/\n/, $tmp)) {
|
for (split(/\n/, $tmp)) {
|
||||||
$tmp2 = $_ if (m/$rcsidstr/);
|
$tmp2 .= $_ if (m/\$$rcsidstr/);
|
||||||
}
|
}
|
||||||
if ($tmp2 !~ /#(\s+)\$$rcsidstr([^\$]*)\$$/) {
|
if ($tmp2 !~ /#(\s+)\$$rcsidstr([^\$]*)\$$/) {
|
||||||
|
|
||||||
|
@ -847,38 +907,38 @@ EOF
|
||||||
# check the order of items.
|
# check the order of items.
|
||||||
&checkorder('PORTNAME', $tmp, split(/\s+/, <<EOF));
|
&checkorder('PORTNAME', $tmp, split(/\s+/, <<EOF));
|
||||||
PORTNAME PORTVERSION CATEGORIES MASTER_SITES MASTER_SITE_SUBDIR
|
PORTNAME PORTVERSION CATEGORIES MASTER_SITES MASTER_SITE_SUBDIR
|
||||||
PKGNAMEPREFIX PKGNAMESUFFIX DISTNAME EXTRACT_SUFX DISTFILES EXTRACT_ONLY
|
PKGNAMEPREFIX PKGNAMESUFFIX DISTNAME EXTRACT_SUFX DISTFILES DIST_SUBDIR
|
||||||
|
EXTRACT_ONLY
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
# check the items that has to be there.
|
# check the items that has to be there.
|
||||||
$tmp = "\n" . $tmp;
|
$tmp = "\n" . $tmp;
|
||||||
print "OK: checking PORTNAME/PORTVERSION.\n" if ($verbose);
|
print "OK: checking PORTNAME/PORTVERSION.\n" if ($verbose);
|
||||||
if ($tmp !~ /\nPORTNAME(.)?=/) {
|
if ($tmp !~ /\nPORTNAME(.)?=/) {
|
||||||
&perror("FATAL: PORTNAME has to be there.");
|
&perror("FATAL: PORTNAME has to be there.") unless ($slaveport && $makevar{PORTNAME} ne '');
|
||||||
}
|
}
|
||||||
if ($1 ne '') {
|
if ($1 ne '') {
|
||||||
&perror("WARN: PORTNAME has be set by \"=\", ".
|
&perror("WARN: PORTNAME has to be set by \"=\", ".
|
||||||
"not by \"$1=\".");
|
"not by \"$1=\".") unless ($masterport);
|
||||||
}
|
}
|
||||||
if ($tmp !~ /\nPORTVERSION(.)?=/) {
|
if ($tmp !~ /\nPORTVERSION(.)?=/) {
|
||||||
&perror("FATAL: PORTVERSION has to be there.");
|
&perror("FATAL: PORTVERSION has to be there.") unless ($slaveport && $makevar{PORTVERSION} ne '');
|
||||||
}
|
}
|
||||||
if ($1 ne '') {
|
if ($1 ne '') {
|
||||||
&perror("WARN: PORTVERSION has be set by \"=\", ".
|
&perror("WARN: PORTVERSION has to be set by \"=\", ".
|
||||||
"not by \"$1=\".");
|
"not by \"$1=\".") unless ($masterport);
|
||||||
}
|
}
|
||||||
print "OK: checking CATEGORIES.\n" if ($verbose);
|
print "OK: checking CATEGORIES.\n" if ($verbose);
|
||||||
#MICHAEL: do we want to use [^\n] here?
|
if ($tmp !~ /\nCATEGORIES(.)?=[ \t]*/) {
|
||||||
if ($tmp !~ /\nCATEGORIES(.)?=[ \t]*([^\n]*)/) {
|
&perror("FATAL: CATEGORIES has to be there.") unless ($slaveport && $makevar{CATEGORIES} ne '');
|
||||||
&perror("FATAL: CATEGORIES has to be there.");
|
|
||||||
}
|
}
|
||||||
@cat = split(/\s+/, $2);
|
|
||||||
$i = $1;
|
$i = $1;
|
||||||
if ($i ne '' && $i =~ /[^?+]/) {
|
if ($i ne '' && $i =~ /[^?+]/) {
|
||||||
&perror("WARN: CATEGORIES should be set by \"=\", \"?=\", or \"+=\", ".
|
&perror("WARN: CATEGORIES should be set by \"=\", \"?=\", or \"+=\", ".
|
||||||
"not by \"$i=\".");
|
"not by \"$i=\".") unless ($masterport);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@cat = split(/\s+/, $makevar{CATEGORIES});
|
||||||
if (@cat == 0) {
|
if (@cat == 0) {
|
||||||
&perror("FATAL: CATEGORIES left blank. set it to \"misc\"".
|
&perror("FATAL: CATEGORIES left blank. set it to \"misc\"".
|
||||||
" if nothing seems apropriate.");
|
" if nothing seems apropriate.");
|
||||||
|
@ -924,26 +984,14 @@ EOF
|
||||||
}
|
}
|
||||||
|
|
||||||
# check the URL
|
# check the URL
|
||||||
if ($tmp =~ /\nMASTER_SITES[+?]?=[ \t]*([^\n]*)\n/
|
if (($tmp =~ /\nMASTER_SITES[+?]?=[ \t]*([^\n]*)\n/
|
||||||
&& $1 !~ /^[ \t]*$/) {
|
&& $1 !~ /^[ \t]*$/) || ($makevar{MASTER_SITES} ne '')) {
|
||||||
print "OK: seen MASTER_SITES, sanity checking URLs.\n"
|
print "OK: seen MASTER_SITES, sanity checking URLs.\n"
|
||||||
if ($verbose);
|
if ($verbose);
|
||||||
my @sites = split(/\s+/, $1);
|
my @sites = split(/\s+/, $1);
|
||||||
foreach my $i (@sites) {
|
foreach my $i (@sites) {
|
||||||
if ($i =~ m#^\w+://#) {
|
if ($i =~ m#^\w+://#) {
|
||||||
if ($i !~ m#/$#) {
|
&urlcheck($i);
|
||||||
&perror("FATAL: URL \"$i\" should ".
|
|
||||||
"end with \"/\".");
|
|
||||||
}
|
|
||||||
if ($i =~ m#://[^/]*:/#) {
|
|
||||||
&perror("FATAL: URL \"$i\" contains ".
|
|
||||||
"extra \":\".");
|
|
||||||
}
|
|
||||||
if ($osname == 'FreeBSD' && $i =~ m#(www.freebsd.org)/~.+/#i) {
|
|
||||||
&perror("WARN: URL \"$i\", ".
|
|
||||||
"$1 should be ".
|
|
||||||
"people.FreeBSD.org");
|
|
||||||
}
|
|
||||||
unless (&is_predefined($i)) {
|
unless (&is_predefined($i)) {
|
||||||
print "OK: URL \"$i\" ok.\n"
|
print "OK: URL \"$i\" ok.\n"
|
||||||
if ($verbose);
|
if ($verbose);
|
||||||
|
@ -959,8 +1007,10 @@ EOF
|
||||||
|
|
||||||
# check DISTFILES and related items.
|
# check DISTFILES and related items.
|
||||||
$distfiles = $1 if ($tmp =~ /\nDISTFILES[+?]?=[ \t]*([^\n]+)\n/);
|
$distfiles = $1 if ($tmp =~ /\nDISTFILES[+?]?=[ \t]*([^\n]+)\n/);
|
||||||
$portname = $1 if ($tmp =~ /\nPORTNAME[+?]?=[ \t]*([^\n]+)\n/);
|
#$portname = $1 if ($tmp =~ /\nPORTNAME[+?]?=[ \t]*([^\n]+)\n/);
|
||||||
$portversion = $1 if ($tmp =~ /\nPORTVERSION[+?]?=[ \t]*([^\n]+)\n/);
|
#$portversion = $1 if ($tmp =~ /\nPORTVERSION[+?]?=[ \t]*([^\n]+)\n/);
|
||||||
|
$portname = $makevar{PORTNAME};
|
||||||
|
$portversion = $makevar{PORTVERSION};
|
||||||
$distname = $1 if ($tmp =~ /\nDISTNAME[+?]?=[ \t]*([^\n]+)\n/);
|
$distname = $1 if ($tmp =~ /\nDISTNAME[+?]?=[ \t]*([^\n]+)\n/);
|
||||||
$extractsufx = $1 if ($tmp =~ /\nEXTRACT_SUFX[+?]?=[ \t]*([^\n]+)\n/);
|
$extractsufx = $1 if ($tmp =~ /\nEXTRACT_SUFX[+?]?=[ \t]*([^\n]+)\n/);
|
||||||
|
|
||||||
|
@ -1051,7 +1101,7 @@ EOF
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($committer) {
|
if ($committer) {
|
||||||
if (opendir(DIR, $portdir)) {
|
if (opendir(DIR, ".")) {
|
||||||
my @tgz = grep(/\.tgz$/, readdir(DIR));
|
my @tgz = grep(/\.tgz$/, readdir(DIR));
|
||||||
closedir(DIR);
|
closedir(DIR);
|
||||||
|
|
||||||
|
@ -1119,7 +1169,7 @@ EOF
|
||||||
if ($tmp =~ /\nMAINTAINER\??=[^\n]+/) {
|
if ($tmp =~ /\nMAINTAINER\??=[^\n]+/) {
|
||||||
$tmp =~ s/\nMAINTAINER\??=[^\n]+//;
|
$tmp =~ s/\nMAINTAINER\??=[^\n]+//;
|
||||||
} elsif ($whole !~ /\nMAINTAINER[?]?=/) {
|
} elsif ($whole !~ /\nMAINTAINER[?]?=/) {
|
||||||
&perror("FATAL: no MAINTAINER listed in $file.");
|
&perror("FATAL: no MAINTAINER listed in $file.") unless ($slaveport && $makevar{MAINTAINER} ne '');
|
||||||
}
|
}
|
||||||
$tmp =~ s/\n\n+/\n/g;
|
$tmp =~ s/\n\n+/\n/g;
|
||||||
|
|
||||||
|
@ -1577,4 +1627,23 @@ sub is_predefined {
|
||||||
undef;
|
undef;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub urlcheck {
|
||||||
|
my ($url) = @_;
|
||||||
|
if ($url !~ m#^\w+://#) {
|
||||||
|
&perror("WARN: \"$url\" doesn't appear to be a URL to me.");
|
||||||
|
}
|
||||||
|
if ($url !~ m#/$#) {
|
||||||
|
&perror("FATAL: URL \"$url\" should ".
|
||||||
|
"end with \"/\".");
|
||||||
|
}
|
||||||
|
if ($url =~ m#://[^/]*:/#) {
|
||||||
|
&perror("FATAL: URL \"$url\" contains ".
|
||||||
|
"extra \":\".");
|
||||||
|
}
|
||||||
|
if ($osname == 'FreeBSD' && $url =~ m#(www.freebsd.org)/~.+/#i) {
|
||||||
|
&perror("WARN: URL \"$url\", ".
|
||||||
|
"$1 should be ".
|
||||||
|
"people.FreeBSD.org");
|
||||||
|
}
|
||||||
|
}
|
||||||
sub TRUE {1;}
|
sub TRUE {1;}
|
||||||
|
|
Loading…
Add table
Reference in a new issue