summaryrefslogtreecommitdiff
path: root/pkgtools
diff options
context:
space:
mode:
authorhubertf <hubertf@pkgsrc.org>2004-06-26 18:53:17 +0000
committerhubertf <hubertf@pkgsrc.org>2004-06-26 18:53:17 +0000
commit3e7babfcb5ee364aa90182881af2603245b6dc59 (patch)
tree98b463c2da4cc42353d62a460c224aa537625bb4 /pkgtools
parent7ebcf68a791ecd0aba34d80c143fa3e478d5b9de (diff)
downloadpkgsrc-3e7babfcb5ee364aa90182881af2603245b6dc59.tar.gz
Update to pkglint 3.79
== functional changes == - prints the various "OK: ..." messages only when called with "-v". - prints a summary after pkgsrc category checks - fixed a bug for commented category entries (in line 1718) - removed the option "-q". It has become unnecessary == refactoring == - more consistent naming scheme for variables and functions - replaced some "local" with "my" when possible - clustered the variables that are processed by the ${SED} commands - provided function prototypes for argument checking - replaced the old perror by log_{error,warning,info}. - Avoided the (implicit or explicit) use of $_ in many places Patch contributed by Roland Illig via private mail.
Diffstat (limited to 'pkgtools')
-rw-r--r--pkgtools/pkglint/Makefile4
-rw-r--r--pkgtools/pkglint/files/pkglint.pl1018
2 files changed, 531 insertions, 491 deletions
diff --git a/pkgtools/pkglint/Makefile b/pkgtools/pkglint/Makefile
index 13ccee911da..1a90842fe61 100644
--- a/pkgtools/pkglint/Makefile
+++ b/pkgtools/pkglint/Makefile
@@ -1,7 +1,7 @@
-# $NetBSD: Makefile,v 1.191 2004/06/25 19:03:26 hubertf Exp $
+# $NetBSD: Makefile,v 1.192 2004/06/26 18:53:17 hubertf Exp $
#
-DISTNAME= pkglint-3.78
+DISTNAME= pkglint-3.79
CATEGORIES= pkgtools devel
MASTER_SITES= # empty
DISTFILES= # empty
diff --git a/pkgtools/pkglint/files/pkglint.pl b/pkgtools/pkglint/files/pkglint.pl
index 6d0fa731dd3..932ad4f2022 100644
--- a/pkgtools/pkglint/files/pkglint.pl
+++ b/pkgtools/pkglint/files/pkglint.pl
@@ -11,12 +11,12 @@
# Freely redistributable. Absolutely no warranty.
#
# From Id: portlint.pl,v 1.64 1998/02/28 02:34:05 itojun Exp
-# $NetBSD: pkglint.pl,v 1.107 2004/06/25 19:03:26 hubertf Exp $
+# $NetBSD: pkglint.pl,v 1.108 2004/06/26 18:53:17 hubertf Exp $
#
# This version contains lots of changes necessary for NetBSD packages
# done by Hubert Feyrer <hubertf@netbsd.org>,
-# Thorsten Frueauf <frueauf@netbsd.org>, Thomas Klausner <wiz@netbsd.org>
-# and others.
+# Thorsten Frueauf <frueauf@netbsd.org>, Thomas Klausner <wiz@netbsd.org>,
+# Roland Illig <roland.illig@gmx.de> and others.
#
use Getopt::Std;
@@ -24,73 +24,110 @@ use File::Basename;
use FileHandle;
use Cwd;
-$err = $warn = 0;
-$extrafile = $parenwarn = $committer = 1; # -abc
-$verbose = $newpkg = 0; # -vN
-$showmakefile = 0; # -I
-$contblank = 1;
-$portdir = '.';
-%definesfound = ();
-
-# default settings for NetBSD
-$portsdir = '@PORTSDIR@';
-$rcsidstr = 'NetBSD';
-$localbase = '@PREFIX@';
-
-%opts = ();
-getopts('hINB:qvV', \%opts);
-
-if ($opts{"h"}) {
- ($prog) = ($0 =~ /([^\/]+)$/);
+# Start of configuration area
+my $conf_rcsidstr = 'NetBSD';
+my $conf_portsdir = '@PORTSDIR@';
+my $conf_localbase = '@PREFIX@';
+my $conf_distver = '@DISTVER@';
+my $conf_make = '@MAKE@';
+# End of configuration area
+
+# Command line options
+my $opt_extrafile = 1; #
+my $opt_parenwarn = 1; #
+my $opt_committer = 1; #
+my $opt_verbose = 0; #
+my $opt_newpackage = 0; #
+my $opt_dumpmakefile = 0; #
+my $opt_contblank = 1; # number of allowed contigoous blank lines
+my $opt_packagedir = "."; #
+
+# Global variables that should be eliminated by the next refactoring.
+my %definesfound = ();
+my $errors = 0; # number of errors
+my $warnings = 0; # number of warnings
+
+# == Output of messages to the user ==
+# The log_* routines take the parameters ($file, $lineno, $msg).
+# $file is the file where the message originated or NO_FILE.
+# $lineno is the line number if applicable or NO_LINE_NUMBER.
+# $msg is the text of the message.
+sub NO_FILE();
+sub NO_LINE_NUMBER();
+sub log_error($$$);
+sub log_warning($$$);
+sub log_info($$$);
+sub print_summary_and_exit();
+
+sub checkfile_DESCR($);
+sub checkfile_distinfo($);
+sub checkfile_Makefile($);
+sub checkfile_MESSAGE($);
+sub checkfile_patches_patch($);
+sub checkfile_PLIST($);
+
+sub print_summary_and_exit();
+sub checkperms($);
+sub checkpathname($);
+sub checklastline($);
+sub readmakefile($);
+sub checkextra($$);
+sub checkorder($$@);
+sub checkearlier($@);
+sub abspathname($$);
+sub is_predefined($);
+sub category_check();
+
+sub parse_command_line() {
+ my %opts = ();
+ getopts('hINB:qvV', \%opts);
+ if ($opts{"h"}) {
+ my $prog = basename($0);
print STDERR <<EOF;
usage: $prog [-qvIN] [-B#] [package_directory]
- -q quiet
-v verbose mode
- -V version (@DISTVER@)
+ -V version ($conf_distver)
-I show Makefile (with all included files)
-N writing a new package
- -B# allow # contiguous blank lines (default: $contblank line)
+ -B# allow # contiguous blank lines (default: $opt_contblank line)
EOF
exit 0;
-};
-$quiet = 1 if $opts{"q"};
-$verbose = 1 if $opts{"v"};
-$newpkg = 1 if $opts{"N"};
-$showmakefile = 1 if $opts{"I"};
-$contblank = $opts{"B"} if $opts{"B"};
-
-$portdir = shift || ".";
-
-if ($opts{"V"}) {
- print "@DISTVER@\n";
- exit;
+ }
+ if ($opts{"v"}) { $opt_verbose = 1; }
+ if ($opts{"N"}) { $opt_newpackage = 1; }
+ if ($opts{"I"}) { $opt_dumpmakefile = 1; }
+ if ($opts{"B"}) { $opt_contblank = $opts{"B"}; }
+ if (scalar(@ARGV)) { $opt_packagedir = shift(@ARGV); }
+ if ($opts{"V"}) {
+ print "$conf_distver\n";
+ exit;
+ }
}
+parse_command_line();
-if ($verbose) {
- print "OK: config: portsdir: \"$portsdir\" ".
- "rcsidstr: \"$rcsidstr\" ".
- "localbase: $localbase\n";
-}
+log_info(NO_FILE, NO_LINE_NUMBER, "config: portsdir: \"$conf_portsdir\" ".
+ "rcsidstr: \"$conf_rcsidstr\" ".
+ "localbase: $conf_localbase");
#
# just for safety.
#
-if (! -d $portdir) {
- print STDERR "FATAL: invalid directory $portdir specified.\n";
+if (! -d $opt_packagedir) {
+ print STDERR "FATAL: invalid directory $opt_packagedir specified.\n";
exit 1;
}
-if (-e <$portdir/../Packages.txt>) {
- print "OK: checking category Makefile.\n" if ($verbose);
- &category_check;
- exit 0;
+if (-e <$opt_packagedir/../Packages.txt>) {
+ log_info(NO_FILE, NO_LINE_NUMBER, "checking category Makefile.");
+ category_check();
+ print_summary_and_exit();
}
-if (-e <$portdir/../../Packages.txt>) {
- if ($portdir eq ".") {
+if (-e <$opt_packagedir/../../Packages.txt>) {
+ if ($opt_packagedir eq ".") {
$category = basename(dirname(cwd()));
} else {
- $category = basename(dirname($portdir));
+ $category = basename(dirname($opt_packagedir));
}
}
@@ -136,11 +173,11 @@ EOF
}
# we need to handle the Makefile first to get some variables
-print "OK: checking Makefile.\n" unless $quiet;
-if (! -f "$portdir/Makefile") {
- &perror("FATAL: no Makefile in \"$portdir\".");
+log_info(NO_FILE, NO_LINE_NUMBER, "checking Makefile.");
+if (! -f "$opt_packagedir/Makefile") {
+ log_error(NO_FILE, NO_LINE_NUMBER, "no Makefile in \"$opt_packagedir\".");
} else {
- checkmakefile("Makefile") || &perror("Cannot open the file $i\n");
+ checkfile_Makefile("Makefile") || log_error(NO_FILE, NO_LINE_NUMBER, "Cannot open the file $i\n");
}
@@ -148,474 +185,457 @@ if (! -f "$portdir/Makefile") {
# check for files.
#
@checker = ("$pkgdir/DESCR");
-%checker = ("$pkgdir/DESCR", 'checkdescr');
+%checker = ("$pkgdir/DESCR", \&checkfile_DESCR);
-if ($extrafile) {
- foreach $i ((<$portdir/$filesdir/*>, <$portdir/$pkgdir/*>)) {
+if ($opt_extrafile) {
+ foreach $i ((<$opt_packagedir/$filesdir/*>, <$opt_packagedir/$pkgdir/*>)) {
next if (! -T $i);
next if ($i =~ /distinfo$/);
next if ($i =~ /Makefile$/);
- $i =~ s/^\Q$portdir\E\///;
+ $i =~ s/^\Q$opt_packagedir\E\///;
next if (defined $checker{$i});
if ($i =~ /MESSAGE/) {
unshift(@checker, $i);
- $checker{$i} = 'checkmessage';
+ $checker{$i} = \&checkfile_MESSAGE;
} elsif ($i =~ /PLIST/) {
unshift(@checker, $i);
- $checker{$i} = 'checkplist';
+ $checker{$i} = \&checkfile_PLIST;
} else {
push(@checker, $i);
- $checker{$i} = 'checkpathname';
+ $checker{$i} = \&checkpathname;
}
}
}
-foreach $i (<$portdir/$patchdir/patch-*>) {
+foreach $i (<$opt_packagedir/$patchdir/patch-*>) {
next if (! -T $i);
- $i =~ s/^\Q$portdir\E\///;
+ $i =~ s/^\Q$opt_packagedir\E\///;
next if (defined $checker{$i});
push(@checker, $i);
- $checker{$i} = 'checkpatch';
+ $checker{$i} = \&checkfile_patches_patch;
}
-if (-e <$portdir/$distinfo>) {
+if (-e <$opt_packagedir/$distinfo>) {
$i = "$distinfo";
next if (defined $checker{$i});
push(@checker, $i);
- $checker{$i} = 'checkdistinfo';
+ $checker{$i} = \&checkfile_distinfo;
}
{
# Make sure there's a distinfo if there are patches
$patches=0;
patch:
- foreach $i (<$portdir/$patchdir/patch-*>) {
+ foreach $i (<$opt_packagedir/$patchdir/patch-*>) {
if ( -T "$i" ) {
$patches=1;
last patch;
}
}
- if ($patches && ! -f "$portdir/$distinfo" ) {
- &perror("WARN: no $portdir/$distinfo file. Please run '@MAKE@ makepatchsum'.");
+ if ($patches && ! -f "$opt_packagedir/$distinfo" ) {
+ log_warning(NO_FILE, NO_LINE_NUMBER, "no $opt_packagedir/$distinfo file. Please run '$conf_make makepatchsum'.");
}
}
foreach $i (@checker) {
- print "OK: checking $i.\n" unless $quiet;
- if (! -f "$portdir/$i") {
- &perror("FATAL: no $i in \"$portdir\".");
+ log_info(NO_FILE, NO_LINE_NUMBER, "checking $i.");
+ if (! -f "$opt_packagedir/$i") {
+ log_error(NO_FILE, NO_LINE_NUMBER, "no $i in \"$opt_packagedir\".");
} else {
- $proc = $checker{$i};
- &$proc($i) || &perror("WARN: Cannot open the file $i\n");
+ $checker{$i}->($i) || log_warning(NO_FILE, NO_LINE_NUMBER, "Cannot open the file $i\n");
if ($i !~ /patches\/patch/) {
&checklastline($i) ||
- &perror("WARN: Cannot open the file $i\n");
+ log_warning(NO_FILE, NO_LINE_NUMBER, "Cannot open the file $i\n");
}
}
}
-if (-e <$portdir/$distinfo> ) {
+if (-e <$opt_packagedir/$distinfo> ) {
if ( $seen_NO_CHECKSUM ) {
- &perror("WARN: NO_CHECKSUM set, but $portdir/$distinfo exists. Please remove it.");
+ log_warning(NO_FILE, NO_LINE_NUMBER, "NO_CHECKSUM set, but $opt_packagedir/$distinfo exists. Please remove it.");
}
} else {
if ( ! $seen_NO_CHECKSUM ) {
- &perror("WARN: no $portdir/$distinfo file. Please run '@MAKE@ makesum'.");
+ log_warning(NO_FILE, NO_LINE_NUMBER, "no $opt_packagedir/$distinfo file. Please run '$conf_make makesum'.");
}
}
-if (-e <$portdir/$filesdir/md5> ) {
- &perror("FATAL: $filesdir/md5 is deprecated -- run '@MAKE@ mdi' to generate distinfo.");
+if (-e <$opt_packagedir/$filesdir/md5> ) {
+ log_error(NO_FILE, NO_LINE_NUMBER, "$filesdir/md5 is deprecated -- run '$conf_make mdi' to generate distinfo.");
}
-if (-e <$portdir/$filesdir/patch-sum> ) {
- &perror("FATAL: $filesdir/patch-sum is deprecated -- run '@MAKE@ mps' to generate distinfo.");
+if (-e <$opt_packagedir/$filesdir/patch-sum> ) {
+ log_error(NO_FILE, NO_LINE_NUMBER, "$filesdir/patch-sum is deprecated -- run '$conf_make mps' to generate distinfo.");
}
if (-e <$pkgdir/COMMENT> ) {
- &perror("FATAL: $pkgdir/COMMENT is deprecated -- please use a COMMENT variable instead.");
+ log_error(NO_FILE, NO_LINE_NUMBER, "$pkgdir/COMMENT is deprecated -- please use a COMMENT variable instead.");
}
-if (-d "$portdir/pkg" ) {
- &perror("FATAL: $portdir/pkg and its contents are deprecated!\n".
- "\tPlease 'mv $portdir/pkg/* $portdir' and 'rmdir $portdir/pkg'.");
+if (-d "$opt_packagedir/pkg" ) {
+ log_error(NO_FILE, NO_LINE_NUMBER, "$opt_packagedir/pkg and its contents are deprecated!\n".
+ "\tPlease 'mv $opt_packagedir/pkg/* $opt_packagedir' and 'rmdir $opt_packagedir/pkg'.");
}
-if (-d "$portdir/scripts" ) {
- &perror("WARN: $portdir/scripts and its contents are deprecated! Please call the script(s)\n".
+if (-d "$opt_packagedir/scripts" ) {
+ log_warning(NO_FILE, NO_LINE_NUMBER, "$opt_packagedir/scripts and its contents are deprecated! Please call the script(s)\n".
"\texplicitly from the corresponding target(s) in the pkg's Makefile.");
}
-if (! -f "$portdir/$pkgdir/PLIST"
- and ! -f "$portdir/$pkgdir/PLIST-mi"
+if (! -f "$opt_packagedir/$pkgdir/PLIST"
+ and ! -f "$opt_packagedir/$pkgdir/PLIST-mi"
and ! $seen_PLIST_SRC
and ! $seen_NO_PKG_REGISTER ) {
- &perror("WARN: no PLIST or PLIST-mi, and PLIST_SRC and NO_PKG_REGISTER unset.\n Are you sure PLIST handling is ok?");
+ log_warning(NO_FILE, NO_LINE_NUMBER, "no PLIST or PLIST-mi, and PLIST_SRC and NO_PKG_REGISTER unset.\n Are you sure PLIST handling is ok?");
}
-if ($committer) {
- if (scalar(@_ = <$portdir/work*/*>) || -d "$portdir/work*") {
- &perror("WARN: be sure to cleanup $portdir/work* ".
+if ($opt_committer) {
+ if (scalar(@_ = <$opt_packagedir/work*/*>) || -d "$opt_packagedir/work*") {
+ log_warning(NO_FILE, NO_LINE_NUMBER, "be sure to cleanup $opt_packagedir/work* ".
"before committing the package.");
}
- if (scalar(@_ = <$portdir/*/*~>) || scalar(@_ = <$portdir/*~>)) {
- &perror("WARN: for safety, be sure to cleanup ".
+ if (scalar(@_ = <$opt_packagedir/*/*~>) || scalar(@_ = <$opt_packagedir/*~>)) {
+ log_warning(NO_FILE, NO_LINE_NUMBER, "for safety, be sure to cleanup ".
"emacs backup files before committing the package.");
}
- if (scalar(@_ = <$portdir/*/*.orig>) || scalar(@_ = <$portdir/*.orig>)
- || scalar(@_ = <$portdir/*/*.rej>) || scalar(@_ = <$portdir/*.rej>)) {
- &perror("WARN: for safety, be sure to cleanup ".
+ if (scalar(@_ = <$opt_packagedir/*/*.orig>) || scalar(@_ = <$opt_packagedir/*.orig>)
+ || scalar(@_ = <$opt_packagedir/*/*.rej>) || scalar(@_ = <$opt_packagedir/*.rej>)) {
+ log_warning(NO_FILE, NO_LINE_NUMBER, "for safety, be sure to cleanup ".
"patch backup files before committing the package.");
}
}
-if ($err || $warn) {
- print "$err fatal errors and $warn warnings found.\n"
-} else {
- print "looks fine.\n";
-}
-exit $err;
+print_summary_and_exit();
-#
-# DESCR
-#
-sub checkdescr {
+sub checkfile_DESCR($) {
local($file) = @_;
local(%maxchars) = ('DESCR', 80);
local(%maxlines) = ('DESCR', 24);
local(%errmsg) = ('DESCR', "exceeds $maxlines{'DESCR'} ".
"lines, make it shorter if possible");
local($longlines, $linecnt, $tmp) = (0, 0, "");
+ my ($line);
- &checkperms("$portdir/$file");
+ &checkperms("$opt_packagedir/$file");
$shortname = basename($file);
- open(IN, "< $portdir/$file") || return 0;
+ open(IN, "< $opt_packagedir/$file") || return 0;
- while (<IN>) {
+ while (defined($line = <IN>)) {
$linecnt++;
- $longlines++ if ($maxchars{$shortname} < length($_));
- $tmp .= $_;
+ $longlines++ if ($maxchars{$shortname} < length($line));
+ $tmp .= $line;
}
+ close(IN);
+
if ($linecnt > $maxlines{$shortname}) {
- &perror("WARN: $file $errmsg{$shortname} ".
+ log_warning(NO_FILE, NO_LINE_NUMBER, "$file $errmsg{$shortname} ".
"(currently $linecnt lines).");
} else {
- print "OK: $file has $linecnt lines.\n" if ($verbose);
+ log_info(NO_FILE, NO_LINE_NUMBER, "$file has $linecnt lines.");
}
if ($longlines > 0) {
- &perror("WARN: $file includes lines that exceed ".
+ log_warning(NO_FILE, NO_LINE_NUMBER, "$file includes lines that exceed ".
"$maxchars{$shortname} characters.");
}
if ($tmp =~ /[\033\200-\377]/) {
- &perror("WARN: $file includes iso-8859-1, or ".
+ log_warning(NO_FILE, NO_LINE_NUMBER, "$file includes iso-8859-1, or ".
"other local characters. $file should be ".
"plain ascii file.");
}
- close(IN);
+ return 1;
}
-#
-# distinfo
-#
-sub checkdistinfo {
+sub checkfile_distinfo($) {
local($file) = @_; # distinfo
local(%indistinfofile);
+ my $line;
- &checkperms("$portdir/$file");
+ checkperms("$opt_packagedir/$file");
- open(SUM,"<$portdir/$file") || return 0;
- $_ = <SUM>;
- if (! /^\$NetBSD(:.*|)\$$/) {
- &perror("FATAL: missing RCS Id in distinfo file: $_");
+ open(SUM,"<$opt_packagedir/$file") || return 0;
+ $line = <SUM>;
+ if ($line !~ /^\$NetBSD(:.*|)\$$/) {
+ log_error(NO_FILE, NO_LINE_NUMBER, "missing RCS Id in distinfo file: $_");
}
- while(<SUM>) {
- next if !/^(MD5|SHA1|RMD160) \(([^)]+)\) = (.*)$/;
+ while(defined($line = <SUM>)) {
+ next unless $line =~ /^(MD5|SHA1|RMD160) \(([^)]+)\) = (.*)$/;
$alg=$1;
$patch=$2;
$sum=$3;
# bitch about *~
if ($patch =~ /~$/) {
- &perror("WARN: possible backup file '$patch' in $portdir/$file?");
+ log_warning(NO_FILE, NO_LINE_NUMBER, "possible backup file '$patch' in $opt_packagedir/$file?");
}
- if (-T "$portdir/$patchdir/$patch") {
- $calcsum=`sed -e '/\$NetBSD.*/d' $portdir/$patchdir/$patch | digest $alg`;
+ if (-T "$opt_packagedir/$patchdir/$patch") {
+ $calcsum=`sed -e '/\$NetBSD.*/d' $opt_packagedir/$patchdir/$patch | digest $alg`;
chomp($calcsum);
if ( "$sum" ne "$calcsum" ) {
- &perror("FATAL: checksum of $patch differs between $portdir/$file and\n"
- ." $portdir/$patchdir/$patch. Rerun '@MAKE@ makepatchsum'.");
+ log_error(NO_FILE, NO_LINE_NUMBER, "checksum of $patch differs between $opt_packagedir/$file and\n"
+ ." $opt_packagedir/$patchdir/$patch. Rerun '$conf_make makepatchsum'.");
}
} elsif ($patch =~ /^patch-[a-z0-9]+$/) {
- &perror("FATAL: patchfile '$patch' is in $file\n"
- ." but not in $portdir/$patchdir/$patch. Rerun '@MAKE@ makepatchsum'.");
+ log_error(NO_FILE, NO_LINE_NUMBER, "patchfile '$patch' is in $file\n"
+ ." but not in $opt_packagedir/$patchdir/$patch. Rerun '$conf_make makepatchsum'.");
}
$indistinfofile{$patch} = 1;
}
close(SUM);
- foreach $patch ( <$portdir/$patchdir/patch-*> ) {
+ foreach $patch ( <$opt_packagedir/$patchdir/patch-*> ) {
$patch =~ /\/([^\/]+)$/;
if (! $indistinfofile{$1}) {
- &perror("FATAL: patchsum of '$1' is in $portdir/$patchdir/$1 but not in\n"
- ." $file. Rerun '@MAKE@ makepatchsum'.");
+ log_error(NO_FILE, NO_LINE_NUMBER, "patchsum of '$1' is in $opt_packagedir/$patchdir/$1 but not in\n"
+ ." $file. Rerun '$conf_make makepatchsum'.");
}
}
return 1;
}
-#
-# MESSAGE
-#
-sub checkmessage {
+sub checkfile_MESSAGE($) {
local($file) = @_;
local($longlines, $lastline, $tmp) = (0, "", "");
+ my ($line);
- &checkperms("$portdir/$file");
+ &checkperms("$opt_packagedir/$file");
$shortname = basename($file);
- open(IN, "< $portdir/$file") || return 0;
+ open(IN, "< $opt_packagedir/$file") || return 0;
- $_ = <IN>;
- if (! /^={75}$/) {
- &perror("WARN: $file should begin with a 75-character ".
+ $line = <IN>;
+ if ($line !~ /^={75}$/) {
+ log_warning(NO_FILE, NO_LINE_NUMBER, "$file should begin with a 75-character ".
"double-dashed line.");
}
- $_ = <IN>;
- if (! /^\$NetBSD(:.*|)\$$/) {
- &perror("FATAL: missing RCS Id in MESSAGE file: $file");
+ $line = <IN>;
+ if ($line !~ /^\$NetBSD(:.*|)\$$/) {
+ log_error(NO_FILE, NO_LINE_NUMBER, "missing RCS Id in MESSAGE file: $file");
}
- while (<IN>) {
- $longlines++ if (80 < length($_));
- $lastline = $_;
- $tmp .= $_;
+ while (defined($line = <IN>)) {
+ $longlines++ if (80 < length($line));
+ $lastline = $line;
+ $tmp .= $line;
}
if ($lastline !~ /^={75}$/) {
- &perror("WARN: $file should end with a 75-character ".
+ log_warning(NO_FILE, NO_LINE_NUMBER, "$file should end with a 75-character ".
"double-dashed line.");
}
if ($longlines > 0) {
- &perror("WARN: $file includes lines that exceed ".
+ log_warning(NO_FILE, NO_LINE_NUMBER, "$file includes lines that exceed ".
"80 characters.");
}
if ($tmp =~ /[\033\200-\377]/) {
- &perror("WARN: $file includes iso-8859-1, or ".
+ log_warning(NO_FILE, NO_LINE_NUMBER, "$file includes iso-8859-1, or ".
"other local characters. $file should be ".
"plain ascii file.");
}
close(IN);
+ return 1;
}
-#
-# PLIST
-#
-sub checkplist {
+sub checkfile_PLIST($) {
local($file) = @_;
- local($curdir) = ($localbase);
+ local($curdir) = ($conf_localbase);
local($installinfoseen) = 0;
local($rcsidseen) = 0;
local($docseen) = 0;
local($etcseen) = 0;
+ my ($line);
- &checkperms("$portdir/$file");
+ &checkperms("$opt_packagedir/$file");
- open(IN, "< $portdir/$file") || return 0;
- while (<IN>) {
- if ($_ =~ /[ \t]+\n?$/) {
- &perror("WARN: $file $.: whitespace before end ".
+ open(IN, "< $opt_packagedir/$file") || return 0;
+ while (defined($line = <IN>)) {
+ if ($line =~ /[ \t]+\n?$/) {
+ log_warning(NO_FILE, NO_LINE_NUMBER, "$file $.: whitespace before end ".
"of line.");
}
# make it easier to handle.
- $_ =~ s/\s+$//;
-
- $_ =~ s/\n$//;
+ $line =~ s/\s+$//;
+ $line =~ s/\n$//;
- if ($_ =~ /<\$ARCH>/) {
- &perror("WARN: $file $.: use of <\$ARCH> ".
+ if ($line =~ /<\$ARCH>/) {
+ log_warning(NO_FILE, NO_LINE_NUMBER, "$file $.: use of <\$ARCH> ".
"deprecated, use \${MACHINE_ARCH instead}.");
}
- if ($_ =~ /^\@/) {
- if ($_ =~ /^\@(cwd|cd)[ \t]+(\S+)/) {
+ if ($line =~ /^\@/) {
+ if ($line =~ /^\@(cwd|cd)[ \t]+(\S+)/) {
$curdir = $2;
- } elsif ($_ =~ /^\@unexec[ \t]+rmdir/) {
- &perror("WARN: use \"\@dirrm\" ".
+ } elsif ($line =~ /^\@unexec[ \t]+rmdir/) {
+ log_warning(NO_FILE, NO_LINE_NUMBER, "use \"\@dirrm\" ".
"instead of \"\@unexec rmdir\".");
- } elsif ($_ =~ /^\@(un)?exec[ \t]+(.*\/)?(install-info|\$\{INSTALL_INFO\})/) {
+ } elsif ($line =~ /^\@(un)?exec[ \t]+(.*\/)?(install-info|\$\{INSTALL_INFO\})/) {
$installinfoseen = $.
- } elsif ($_ =~ /^\@(exec|unexec)/) {
- if (/ldconfig/
- && !/\/usr\/bin\/true/) {
- &perror("FATAL: $file $.: ldconfig ".
+ } elsif ($line =~ /^\@(exec|unexec)/) {
+ if ($line =~ /ldconfig/ && $line !~ /\/usr\/bin\/true/) {
+ log_error(NO_FILE, NO_LINE_NUMBER, "$file $.: ldconfig ".
"must be used with ".
"\"||/usr/bin/true\".");
}
- } elsif ($_ =~ /^\@(comment)/) {
- $rcsidseen++ if (/\$$rcsidstr[:\$]/);
- } elsif ($_ =~ /^\@(dirrm|option)/) {
+ } elsif ($line =~ /^\@(comment)/) {
+ $rcsidseen++ if ($line =~ /\$$conf_rcsidstr[:\$]/);
+ } elsif ($line =~ /^\@(dirrm|option)/) {
; # no check made
- } elsif ($_ =~ /^\@(mode|owner|group)/) {
- &perror("WARN: \"\@mode/owner/group\" are ".
+ } elsif ($line =~ /^\@(mode|owner|group)/) {
+ log_warning(NO_FILE, NO_LINE_NUMBER, "\"\@mode/owner/group\" are ".
"deprecated, please use chmod/".
"chown/chgrp in the pkg Makefile ".
"and let tar do the rest.");
} else {
- &perror("WARN: $file $.: ".
- "unknown PLIST directive \"$_\"");
+ log_warning(NO_FILE, NO_LINE_NUMBER, "$file $.: ".
+ "unknown PLIST directive \"$line\"");
}
next;
}
- if ($_ =~ /^\//) {
- &perror("FATAL: $file $.: use of full pathname ".
+ if ($line =~ /^\//) {
+ log_error(NO_FILE, NO_LINE_NUMBER, "$file $.: use of full pathname ".
"disallowed.");
}
- if ($_ =~ /^doc/ and !$docseen) {
- &perror("FATAL: documentation must be installed under ".
+ if ($line =~ /^doc/ and !$docseen) {
+ log_error(NO_FILE, NO_LINE_NUMBER, "documentation must be installed under ".
"share/doc, not doc.");
$docseen = 1;
}
- if ($_ =~ /^etc/ && $_ !~ /^etc\/rc.d/ and !$etcseen) {
- &perror("FATAL: configuration files must not be ".
+ if ($line =~ /^etc/ && $line !~ /^etc\/rc.d/ and !$etcseen) {
+ log_error(NO_FILE, NO_LINE_NUMBER, "configuration files must not be ".
"registered in the PLIST (don't you use the ".
"PKG_SYSCONFDIR framework?)");
$etcseen = 1;
}
- if ($_ =~ /etc\/rc\.d/ and !$etcrcdseen) {
- &perror("FATAL: RCD_SCRIPTS must not be ".
+ if ($line =~ /etc\/rc\.d/ and !$etcrcdseen) {
+ log_error(NO_FILE, NO_LINE_NUMBER, "RCD_SCRIPTS must not be ".
"registered in the PLIST (don't you use the ".
"RCD_SCRIPTS framework?)");
$etcrcdseen = 1;
}
- if ($_ =~ /^info\/dir$/) {
- &perror("FATAL: \"info/dir\" should not be listed in ".
+ if ($line =~ /^info\/dir$/) {
+ log_error(NO_FILE, NO_LINE_NUMBER, "\"info/dir\" should not be listed in ".
"$file. use install-info to add/remove ".
"an entry.");
}
- if ($_ =~ /^lib\/locale/) {
- &perror("FATAL: \"lib/locale\" should not be listed ".
+ if ($line =~ /^lib\/locale/) {
+ log_error(NO_FILE, NO_LINE_NUMBER, "\"lib/locale\" should not be listed ".
"in $file. Use \${PKGLOCALEDIR}/locale and ".
"set USE_PKGLOCALEDIR instead.");
}
- if ($_ =~ /^share\/locale/) {
- &perror("WARN: use of \"share/locale\" in $file is ".
+ if ($line =~ /^share\/locale/) {
+ log_warning(NO_FILE, NO_LINE_NUMBER, "use of \"share/locale\" in $file is ".
"deprecated. Use \${PKGLOCALEDIR}/locale and ".
"set USE_PKGLOCALEDIR instead.");
}
- if ($_ =~ /\${PKGLOCALEDIR}/ && $seen_USE_BUILDLINK2 && ! $seen_USE_PKGLOCALEDIR) {
- &perror("WARN: PLIST contains \${PKGLOCALEDIR}, ".
+ if ($line =~ /\${PKGLOCALEDIR}/ && $seen_USE_BUILDLINK2 && ! $seen_USE_PKGLOCALEDIR) {
+ log_warning(NO_FILE, NO_LINE_NUMBER, "PLIST contains \${PKGLOCALEDIR}, ".
"but USE_PKGLOCALEDIR was not found.");
}
- if ($curdir !~ m#^$localbase#
+ if ($curdir !~ m#^$conf_localbase#
&& $curdir !~ m#^/usr/X11R6#) {
- &perror("WARN: $file $.: installing to ".
+ log_warning(NO_FILE, NO_LINE_NUMBER, "$file $.: installing to ".
"directory $curdir discouraged. ".
"could you please avoid it?");
}
- if ("$curdir/$_" =~ m#^$localbase/share/doc#) {
- print "OK: seen installation to share/doc in $file. ".
- "($curdir/$_)\n" if ($verbose);
+ if ("$curdir/$line" =~ m#^$conf_localbase/share/doc#) {
+ log_info(NO_FILE, NO_LINE_NUMBER, "seen installation to share/doc in $file. ".
+ "($curdir/$line)");
$sharedocused++;
}
}
if (!$rcsidseen) {
- &perror("FATAL: RCS tag \"\$$rcsidstr\$\" must be present ".
+ log_error(NO_FILE, NO_LINE_NUMBER, "RCS tag \"\$$conf_rcsidstr\$\" must be present ".
"in $file as \@comment.")
}
if ($installinfoseen) {
- &perror("FATAL: \"\@exec install-info ...\" or \"\@unexec ".
+ log_error(NO_FILE, NO_LINE_NUMBER, "\"\@exec install-info ...\" or \"\@unexec ".
"install-info ...\" is deprecated.");
}
close(IN);
return 1;
}
-sub checkperms {
+sub checkperms($) {
local($file) = @_;
if (-f $file && -x $file) {
- &perror("WARN: \"$file\" is executable.");
+ log_warning(NO_FILE, NO_LINE_NUMBER, "\"$file\" is executable.");
}
+ return 1;
}
#
# misc files
#
-sub checkpathname {
+sub checkpathname($) {
local($file) = @_;
local($whole);
- &checkperms("$portdir/$file");
+ checkperms("$opt_packagedir/$file");
if ($file =~ /$filesdir\//) {
return 1;
}
- open(IN, "< $portdir/$file") || return 0;
- $whole = '';
- while (<IN>) {
- $whole .= $_;
- }
- &abspathname($whole, $file);
+ open(IN, "< $opt_packagedir/$file") || return 0;
+ { local $/; $whole = <IN>; }
close(IN);
+ abspathname($whole, $file);
+ return 1;
}
-sub checklastline {
+sub checklastline($) {
local($file) = @_;
local($whole);
- open(IN, "< $portdir/$file") || return 0;
- $whole = '';
- while (<IN>) {
- $whole .= $_;
- }
+ open(IN, "< $opt_packagedir/$file") || return 0;
+ { local $/; $whole = <IN>; }
+ close(IN);
if ($whole eq "") {
- &perror("FATAL: $file is empty.");
+ log_error(NO_FILE, NO_LINE_NUMBER, "$file is empty.");
}
else
{
if ($whole !~ /\n$/) {
- &perror("FATAL: the last line of $file has to be ".
+ log_error(NO_FILE, NO_LINE_NUMBER, "the last line of $file has to be ".
"terminated by \\n.");
}
if ($whole =~ /\n([ \t]*\n)+$/) {
- &perror("WARN: $file seems to have unnecessary ".
+ log_warning(NO_FILE, NO_LINE_NUMBER, "$file seems to have unnecessary ".
"blank lines at the bottom.");
}
}
-
- close(IN);
+ return 1;
}
-sub checkpatch {
+sub checkfile_patches_patch($) {
my ($file) = @_;
- my ($rcsidseen, $whole, @lines);
+ my ($rcsidseen, $whole, @lines, $line);
$rcsidseen = 0;
if ($file =~ /.*~$/) {
- &perror("WARN: is $file a backup file? If so, please remove it \n"
- ." and rerun '@MAKE@ makepatchsum'");
+ log_warning(NO_FILE, NO_LINE_NUMBER, "is $file a backup file? If so, please remove it \n"
+ ." and rerun '$conf_make makepatchsum'");
}
- &checkperms("$portdir/$file");
+ &checkperms("$opt_packagedir/$file");
- open(IN, "< $portdir/$file") || return 0;
+ open(IN, "< $opt_packagedir/$file") || return 0;
$whole = '';
- while (<IN>) {
- $rcsidseen++ if /\$$rcsidstr[:\$]/;
- $whole .= $_;
- push(@lines, $_);
+ while (defined($line = <IN>)) {
+ $rcsidseen++ if ($line =~ /\$$conf_rcsidstr[:\$]/);
+ $whole .= $line;
+ push(@lines, $line);
}
- if ($committer && $whole =~ /.\$(Author|Date|Header|Id|Locker|Log|Name|RCSfile|Revision|Source|State|NetBSD)(:.*\$|\$)/) { # XXX
+ if ($opt_committer && $whole =~ /.\$(Author|Date|Header|Id|Locker|Log|Name|RCSfile|Revision|Source|State|NetBSD)(:.*\$|\$)/) { # XXX
# RCS ID in very first line is ok, to identify version
# of patch (-> only warn if there's something before the
# actual $RCS_ID$, not on BOF - '.' won't match there)
- &perror("WARN: $file includes possible RCS tag \"\$$1\$\". ".
+ log_warning(NO_FILE, NO_LINE_NUMBER, "$file includes possible RCS tag \"\$$1\$\". ".
"use binary mode (-ko) on commit/import.");
}
if (!$rcsidseen) {
- &perror("FATAL: RCS tag \"\$$rcsidstr\$\" must be present ".
+ log_error(NO_FILE, NO_LINE_NUMBER, "RCS tag \"\$$conf_rcsidstr\$\" must be present ".
"in patch $file.")
}
close(IN);
@@ -638,14 +658,14 @@ sub checkpatch {
$files_in_patch++;
$patch_state = "";
} else {
- &perror("WARN: $i:$.: unknown patch format (might be an internal error)");
+ log_warning(NO_FILE, NO_LINE_NUMBER, "$i:$.: unknown patch format (might be an internal error)");
}
} elsif ($patch_state eq "-") {
if ($line_type eq "+") {
$files_in_patch++;
$patch_state = "";
} else {
- &perror("WARN: $i:$.: unknown patch format (might be an internal error)");
+ log_warning(NO_FILE, NO_LINE_NUMBER, "$i:$.: unknown patch format (might be an internal error)");
}
} elsif ($patch_state eq "") {
$patch_state = $line_type;
@@ -653,46 +673,46 @@ sub checkpatch {
#printf("%s:%d: state=(%s), line=(%s)\n", $i, $., $patch_state, $line_type);
}
if ($files_in_patch > 1) {
- &perror("WARN: patch `$i' contains patches for more than one file, namely $files_in_patch");
+ log_warning(NO_FILE, NO_LINE_NUMBER, "patch `$i' contains patches for more than one file, namely $files_in_patch");
} elsif ($files_in_patch == 0) {
- &perror("WARN: patch `$i' contains no patch");
+ log_warning(NO_FILE, NO_LINE_NUMBER, "patch `$i' contains no patch");
}
return 1;
}
-sub readmakefile {
+sub readmakefile($) {
local ($file) = @_;
local $contents = "";
local $includefile;
local $dirname;
local $savedln;
local $level;
- local $_;
my $handle = new FileHandle;
+ my $line;
$savedln = $.;
$. = 0;
open($handle, "< $file") || return 0;
- print("OK: reading Makefile '$file'\n") if ($verbose);
- while (<$handle>) {
- if ($_ =~ /[ \t]+\n?$/ && !/^#/) {
- &perror("WARN: $file $.: whitespace before ".
+ log_info($file, NO_LINE_NUMBER, "called readmakefile");
+ while (defined($line = <$handle>)) {
+ if ($line =~ /[ \t]+\n?$/ && $line !~ /^#/) {
+ log_warning(NO_FILE, NO_LINE_NUMBER, "$file $.: whitespace before ".
"end of line.");
}
- if ($_ =~ /^ /) { # 8 spaces here!
- &perror("WARN: $file $.: use tab (not spaces) to".
+ if ($line =~ /^\040{8}/) {
+ log_warning(NO_FILE, NO_LINE_NUMBER, "$file $.: use tab (not spaces) to".
" make indentation.");
}
- if ($_ =~ /^\.\s*if\s+!defined\s*\((\w+)\)/) {
+ if ($line =~ /^\.\s*if\s+!defined\s*\((\w+)\)/) {
if ($definesfound{$1}) {
$level = 1;
- print("OK: omitting contents of !defined($1)\n") if ($verbose);
+ log_info($file, $., "omitting contents of !defined($1)\n");
$contents .= "# omitted inclusion for !defined($1) here\n";
- while (<$handle>) {
- if ($_ =~ /^\.\s*if\s+/) {
+ while (defined($line = <$handle>)) {
+ if ($line =~ /^\.\s*if\s+/) {
$level++;
}
- elsif ($_ =~ /^\.\s*endif\s+/) {
+ elsif ($line =~ /^\.\s*endif\s+/) {
$level--;
}
if ($level eq 0) {
@@ -700,42 +720,42 @@ sub readmakefile {
}
}
if ($level > 0) {
- &perror("WARN: missing .endif.");
+ log_warning(NO_FILE, NO_LINE_NUMBER, "missing .endif.");
}
next;
}
else {
- print("OK: defining $1\n") if $verbose;
+ log_info($file, $., "defining $1");
$definesfound{$1} = 1;
}
}
# try to get any included file
- if ($_ =~ /^.include\s+([^\n]+)\n/) {
+ if ($line =~ /^.include\s+([^\n]+)\n/) {
$includefile = $1;
if ($includefile =~ /\"([^\"]+)\"/) {
$includefile = $1;
}
if ($includefile =~ /\/mk\/texinfo\.mk/) {
- &perror("FATAL: do not include $includefile");
+ log_error(NO_FILE, NO_LINE_NUMBER, "do not include $includefile");
}
if ($includefile =~ /\/mk\/bsd/) {
# we don't want to include the whole
# bsd.pkg.mk or bsd.prefs.mk files
- $contents .= $_;
+ $contents .= $line;
} else {
$dirname = dirname($file);
if (-e "$dirname/$includefile") {
- print("OK: including $dirname/$includefile\n") unless $quiet;
+ log_info($file, $., "including $dirname/$includefile");
$contents .= readmakefile("$dirname/$includefile");
}
else {
- &perror("FATAL: can't read $dirname/$includefile");
+ log_error(NO_FILE, NO_LINE_NUMBER, "can't read $dirname/$includefile");
}
}
} else {
# we don't want the include Makefile.common lines
# to be pkglinted
- $contents .= $_;
+ $contents .= $line;
}
}
close($handle);
@@ -744,10 +764,7 @@ sub readmakefile {
return $contents;
}
-#
-# Makefile
-#
-sub checkmakefile {
+sub checkfile_Makefile($) {
local($file) = @_;
local($rawwhole, $whole, $idx, @sections);
local($tmp, $tmp2);
@@ -759,38 +776,37 @@ sub checkmakefile {
local($realwrksrc, $wrksrc, $nowrksubdir) = ('', '', '');
local($includefile);
- &checkperms("$portdir/$file");
+ &checkperms("$opt_packagedir/$file");
$tmp = 0;
- $rawwhole = readmakefile("$portdir/$file");
+ $rawwhole = readmakefile("$opt_packagedir/$file");
if ($rawwhole eq '') {
- &perror("FATAL: can't read $portdir/$file");
+ log_error(NO_FILE, NO_LINE_NUMBER, "can't read $opt_packagedir/$file");
return 0;
}
else {
print("OK: whole Makefile (with all included files):\n".
- "$rawwhole\n") if ($showmakefile);
+ "$rawwhole\n") if ($opt_dumpmakefile);
}
#
# whole file: blank lines.
#
$whole = "\n" . $rawwhole;
- print "OK: checking contiguous blank lines in $file.\n"
- if ($verbose);
- $i = "\n" x ($contblank + 2);
+ log_info(NO_FILE, NO_LINE_NUMBER, "checking contiguous blank lines in $file.");
+ $i = "\n" x ($opt_contblank + 2);
if ($whole =~ /$i/) {
- &perror("FATAL: contiguous blank lines (> $contblank lines) found ".
+ log_error(NO_FILE, NO_LINE_NUMBER, "contiguous blank lines (> $opt_contblank lines) found ".
"in $file at line " . int(@_ = split(/\n/, $`)) . ".");
}
#
# whole file: $(VARIABLE)
#
- if ($parenwarn) {
- print "OK: checking for \$(VARIABLE).\n" if ($verbose);
+ if ($opt_parenwarn) {
+ log_info(NO_FILE, NO_LINE_NUMBER, "checking for \$(VARIABLE).");
if ($whole =~ /\$\([\w\d]+\)/) {
- &perror("WARN: use \${VARIABLE}, instead of ".
+ log_warning(NO_FILE, NO_LINE_NUMBER, "use \${VARIABLE}, instead of ".
"\$(VARIABLE).");
}
}
@@ -799,8 +815,8 @@ sub checkmakefile {
# whole file: get FILESDIR, PATCHDIR, PKGDIR, SCRIPTDIR,
# PATCH_SUM_FILE and DIGEST_FILE
#
- print "OK: checking for PATCHDIR, SCRIPTDIR, FILESDIR, PKGDIR,".
- " DIGEST_FILE.\n" if ($verbose);
+ log_info(NO_FILE, NO_LINE_NUMBER, "checking for PATCHDIR, SCRIPTDIR, FILESDIR, PKGDIR,".
+ " DIGEST_FILE.");
$filesdir = "files";
$filesdir = $1 if ($whole =~ /\nFILESDIR[+?]?=[ \t]*([^\n]+)\n/);
@@ -814,7 +830,7 @@ sub checkmakefile {
$patchdir =~ s/\${PKGSRCDIR}/..\/../;
$pkgdir = "pkg";
- if (! -d "$portdir/$pkgdir") {
+ if (! -d "$opt_packagedir/$pkgdir") {
$pkgdir = ".";
}
$pkgdir = $1 if ($whole =~ /\nPKGDIR[+?]?=[ \t]*([^\n]+)\n/);
@@ -832,125 +848,125 @@ sub checkmakefile {
$distinfo =~ s/\$\{.CURDIR\}/./;
$distinfo =~ s/\${PKGSRCDIR}/..\/../;
- print("OK: PATCHDIR: $patchdir, SCRIPTDIR: $scriptdir, ".
+ log_info(NO_FILE, NO_LINE_NUMBER, "PATCHDIR: $patchdir, SCRIPTDIR: $scriptdir, ".
"FILESDIR: $filesdir, PKGDIR: $pkgdir, ".
- "DISTINFO: $distinfo\n") if ($verbose);
+ "DISTINFO: $distinfo\n");
#
# whole file: INTERACTIVE_STAGE
#
$whole =~ s/\n#[^\n]*/\n/g;
$whole =~ s/\n\n+/\n/g;
- print "OK: checking INTERACTIVE_STAGE.\n" if ($verbose);
+ log_info(NO_FILE, NO_LINE_NUMBER, "checking INTERACTIVE_STAGE.");
if ($whole =~ /\nINTERACTIVE_STAGE/) {
if ($whole !~ /defined\((BATCH|FOR_CDROM)\)/) {
- &perror("WARN: use of INTERACTIVE_STAGE discouraged. ".
+ log_warning(NO_FILE, NO_LINE_NUMBER, "use of INTERACTIVE_STAGE discouraged. ".
"provide batch mode by using BATCH and/or ".
"FOR_CDROM.");
}
}
- print "OK: checking IS_INTERACTIVE.\n" if ($verbose);
+ log_info(NO_FILE, NO_LINE_NUMBER, "checking IS_INTERACTIVE.");
if ($whole =~ /\nIS_INTERACTIVE/) {
- &perror("FATAL: IS_INTERACTIVE is deprecated, ".
+ log_error(NO_FILE, NO_LINE_NUMBER, "IS_INTERACTIVE is deprecated, ".
"use INTERACTIVE_STAGE instead.");
}
- print "OK: checking for PLIST_SRC.\n" if ($verbose);
+ log_info(NO_FILE, NO_LINE_NUMBER, "checking for PLIST_SRC.");
if ($whole =~ /\nPLIST_SRC/) {
$seen_PLIST_SRC=1;
}
- print "OK: checking for NO_PKG_REGISTER.\n" if ($verbose);
+ log_info(NO_FILE, NO_LINE_NUMBER, "checking for NO_PKG_REGISTER.");
if ($whole =~ /\nNO_PKG_REGISTER/) {
$seen_NO_PKG_REGISTER=1;
}
- print "OK: checking for NO_CHECKSUM.\n" if ($verbose);
+ log_info(NO_FILE, NO_LINE_NUMBER, "checking for NO_CHECKSUM.");
if ($whole =~ /\nNO_CHECKSUM/) {
$seen_NO_CHECKSUM=1;
}
- print "OK: checking USE_PERL usage.\n" if ($verbose);
+ log_info(NO_FILE, NO_LINE_NUMBER, "checking USE_PERL usage.");
if ($whole =~ /\nUSE_PERL[^5]/) {
- &perror("WARN: USE_PERL found -- you probably mean USE_PERL5.");
+ log_warning(NO_FILE, NO_LINE_NUMBER, "USE_PERL found -- you probably mean USE_PERL5.");
}
- print "OK: checking USE_PKGLIBTOOL.\n" if ($verbose);
+ log_info(NO_FILE, NO_LINE_NUMBER, "checking USE_PKGLIBTOOL.");
if ($whole =~ /\nUSE_PKGLIBTOOL/) {
- &perror("FATAL: USE_PKGLIBTOOL is deprecated, ".
+ log_error(NO_FILE, NO_LINE_NUMBER, "USE_PKGLIBTOOL is deprecated, ".
"use USE_LIBTOOL instead.");
}
- print "OK: checking for USE_BUILDLINK2.\n" if ($verbose);
+ log_info(NO_FILE, NO_LINE_NUMBER, "checking for USE_BUILDLINK2.");
if ($whole =~ /\nUSE_BUILDLINK2/) {
$seen_USE_BUILDLINK2=1;
}
- print "OK: checking for USE_PKGLOCALEDIR.\n" if ($verbose);
+ log_info(NO_FILE, NO_LINE_NUMBER, "checking for USE_PKGLOCALEDIR.");
if ($whole =~ /\nUSE_PKGLOCALEDIR/) {
$seen_USE_PKGLOCALEDIR=1;
}
- print "OK: checking USE_SSL.\n" if ($verbose);
+ log_info(NO_FILE, NO_LINE_NUMBER, "checking USE_SSL.");
if ($whole =~ /\nUSE_SSL/) {
- &perror("FATAL: USE_SSL is deprecated, ".
+ log_error(NO_FILE, NO_LINE_NUMBER, "USE_SSL is deprecated, ".
"use the openssl buildlink2.mk instead.");
}
- print "OK: checking NO_WRKSUBDIR.\n" if ($verbose);
+ log_info(NO_FILE, NO_LINE_NUMBER, "checking NO_WRKSUBDIR.");
if ($whole =~ /\nNO_WRKSUBDIR/) {
- &perror("FATAL: NO_WRKSUBDIR is deprecated, ".
+ log_error(NO_FILE, NO_LINE_NUMBER, "NO_WRKSUBDIR is deprecated, ".
"use WRKSRC=\$\{WRKDIR\} instead.");
}
- print "OK: checking MD5_FILE, DIGEST_FILE and PATCH_SUM_FILE.\n" if ($verbose);
+ log_info(NO_FILE, NO_LINE_NUMBER, "checking MD5_FILE, DIGEST_FILE and PATCH_SUM_FILE.");
if ($whole =~ /\n(MD5_FILE)/ or $whole =~ /\n(DIGEST_FILE)/ or
$whole =~ /\n(PATCH_SUM_FILE)/) {
- &perror("FATAL: $1 is deprecated, ".
+ log_error(NO_FILE, NO_LINE_NUMBER, "$1 is deprecated, ".
"use DISTINFO_FILE instead.");
}
- print "OK: checking MIRROR_DISTFILE.\n" if ($verbose);
+ log_info(NO_FILE, NO_LINE_NUMBER, "checking MIRROR_DISTFILE.");
if ($whole =~ /\nMIRROR_DISTFILE/) {
- &perror("WARN: use of MIRROR_DISTFILE deprecated, ".
+ log_warning(NO_FILE, NO_LINE_NUMBER, "use of MIRROR_DISTFILE deprecated, ".
"use NO_BIN_ON_FTP and/or NO_SRC_ON_FTP instead.");
}
- print "OK: checking NO_CDROM.\n" if ($verbose);
+ log_info(NO_FILE, NO_LINE_NUMBER, "checking NO_CDROM.");
if ($whole =~ /\nNO_CDROM/) {
- &perror("WARN: use of NO_CDROM discouraged, ".
+ log_warning(NO_FILE, NO_LINE_NUMBER, "use of NO_CDROM discouraged, ".
"use NO_BIN_ON_CDROM and/or NO_SRC_ON_CDROM instead.");
}
- print "OK: checking NO_PACKAGE.\n" if ($verbose);
+ log_info(NO_FILE, NO_LINE_NUMBER, "checking NO_PACKAGE.");
if ($whole =~ /\nNO_PACKAGE/) {
- &perror("WARN: use of NO_PACKAGE to enforce license ".
+ log_warning(NO_FILE, NO_LINE_NUMBER, "use of NO_PACKAGE to enforce license ".
"restrictions is deprecated.");
}
- print "OK: checking NO_PATCH.\n" if ($verbose);
+ log_info(NO_FILE, NO_LINE_NUMBER, "checking NO_PATCH.");
if ($whole =~ /\nNO_PATCH/) {
- &perror("WARN: use of NO_PATCH deprecated.");
+ log_warning(NO_FILE, NO_LINE_NUMBER, "use of NO_PATCH deprecated.");
}
- print "OK: checking IGNORE.\n" if ($verbose);
+ log_info(NO_FILE, NO_LINE_NUMBER, "checking IGNORE.");
if ($whole =~ /\nIGNORE/) {
- &perror("FATAL: use of IGNORE deprecated, ".
+ log_error(NO_FILE, NO_LINE_NUMBER, "use of IGNORE deprecated, ".
"use PKG_FAIL_REASON or PKG_SKIP_REASON instead.");
}
- print "OK: checking USE_GMAKE.\n" if ($verbose);
+ log_info(NO_FILE, NO_LINE_NUMBER, "checking USE_GMAKE.");
if ($whole =~ /\nUSE_GMAKE/) {
- &perror("FATAL: use of USE_GMAKE deprecated, ".
+ log_error(NO_FILE, NO_LINE_NUMBER, "use of USE_GMAKE deprecated, ".
"use USE_GNU_TOOLS+=make instead.");
}
- print "OK: checking for MKDIR.\n" if ($verbose);
+ log_info(NO_FILE, NO_LINE_NUMBER, "checking for MKDIR.");
if ($whole =~ m|\${MKDIR}.*(\${PREFIX}[/0-9a-zA-Z\${}]*)|) {
- &perror("WARN: \${MKDIR} $1: consider using INSTALL_*_DIR");
+ log_warning(NO_FILE, NO_LINE_NUMBER, "\${MKDIR} $1: consider using INSTALL_*_DIR");
}
- print "OK: checking for unneeded INSTALL -d.\n" if ($verbose);
+ log_info(NO_FILE, NO_LINE_NUMBER, "checking for unneeded INSTALL -d.");
if ($whole =~ m|\${INSTALL}(.*)\n|) {
$args = $1;
if ($args =~ /-d/) {
if ($args !~ /-[ogm]/) {
- &perror("WARN: \${INSTALL}$args: " .
+ log_warning(NO_FILE, NO_LINE_NUMBER, "\${INSTALL}$args: " .
"consider using INSTALL_*_DIR");
}
}
}
- print "OK: checking for unneeded failure check on directory creation.\n" if ($verbose);
+ log_info(NO_FILE, NO_LINE_NUMBER, "checking for unneeded failure check on directory creation.");
if ($whole =~ /\n\t-(.*(MKDIR|INSTALL.*-d|INSTALL_.*_DIR).*)/g) {
- &perror("WARN: $1: no need to use '-' before command");
+ log_warning(NO_FILE, NO_LINE_NUMBER, "$1: no need to use '-' before command");
}
#
# whole file: direct use of command names
#
- print "OK: checking direct use of command names.\n" if ($verbose);
+ log_info(NO_FILE, NO_LINE_NUMBER, "checking direct use of command names.");
foreach $i (split(/\s+/, <<EOF)) {
awk basename cat chmod chown chgrp cmp cp cut digest dirname echo egrep false
file find gmake grep gtar gzcat id ident install ldconfig ln md5 mkdir mtree mv
@@ -974,7 +990,7 @@ EOF
$j =~ s/\nCOMMENT[\t ]*=[\t ]*[^\n]*\n/\nCOMMENT=#replaced\n/;
foreach $i (keys %cmdnames) {
if ($j =~ /[ \t\/@]$i[ \t\n;]/) {
- &perror("WARN: possible direct use of command \"$i\" ".
+ log_warning(NO_FILE, NO_LINE_NUMBER, "possible direct use of command \"$i\" ".
"found. Use $cmdnames{$i} instead.");
}
}
@@ -984,21 +1000,21 @@ EOF
#
if ($j =~ /(ldconfig|\$[{(]LDCONFIG[)}])/
&& $j !~ /(\/usr\/bin\/true|\$[{(]TRUE[)}])/) {
- &perror("FATAL: ldconfig must be used with \"||\${TRUE}\".");
+ log_error(NO_FILE, NO_LINE_NUMBER, "ldconfig must be used with \"||\${TRUE}\".");
}
#
# whole file: ${MKDIR} -p
#
if ($j =~ /\${MKDIR}\s+-p/) {
- &perror("WARN: possible use of \"\${MKDIR} -p\" ".
+ log_warning(NO_FILE, NO_LINE_NUMBER, "possible use of \"\${MKDIR} -p\" ".
"found. \${MKDIR} includes \"-p\" by default.");
}
#
# whole file: continuation line in DEPENDS
#
if ($whole =~ /\n(BUILD_|)DEPENDS[^\n]*\\\n/) {
- &perror("WARN: Please don't use continuation lines in".
+ log_warning(NO_FILE, NO_LINE_NUMBER, "Please don't use continuation lines in".
" (BUILD_)DEPENDS, use (BUILD_)DEPENDS+= instead.");
}
@@ -1006,11 +1022,11 @@ EOF
#
if ($whole =~ /\/wip\//
&& $category ne "wip") {
- &perror("FATAL: possible pkgsrc-wip pathname detected.");
+ log_error(NO_FILE, NO_LINE_NUMBER, "possible pkgsrc-wip pathname detected.");
}
if ($whole =~ /etc\/rc\.d/) {
- &perror("WARN: Use RCD_SCRIPTS mechanism to install rc.d ".
+ log_warning(NO_FILE, NO_LINE_NUMBER, "Use RCD_SCRIPTS mechanism to install rc.d ".
"scripts automatically to \${RCD_SCRIPTS_EXAMPLEDIR}.");
}
@@ -1033,23 +1049,23 @@ EOF
#
# section 1: comment lines.
#
- print "OK: checking comment section of $file.\n" if ($verbose);
+ log_info(NO_FILE, NO_LINE_NUMBER, "checking comment section of $file.");
$tmp = $sections[$idx++];
- if ($tmp !~ /#(\s+)\$$rcsidstr([^\$]*)\$/) {
- &perror("FATAL: no \$$rcsidstr\$ line in $file comment ".
+ if ($tmp !~ /#(\s+)\$$conf_rcsidstr([^\$]*)\$/) {
+ log_error(NO_FILE, NO_LINE_NUMBER, "no \$$conf_rcsidstr\$ line in $file comment ".
"section.");
} else {
- print "OK: \$$rcsidstr\$ seen in $file.\n" if ($verbose);
+ log_info(NO_FILE, NO_LINE_NUMBER, "\$$conf_rcsidstr\$ seen in $file.");
if ($1 ne ' ') {
- &perror("WARN: please use single whitespace ".
- "right before \$$rcsidstr\$ tag.");
+ log_warning(NO_FILE, NO_LINE_NUMBER, "please use single whitespace ".
+ "right before \$$conf_rcsidstr\$ tag.");
}
if ($2 ne '') {
- if ($verbose || $newpkg) { # XXX
- &perror("WARN: ".
- ($newpkg ? 'for new package, '
+ if ($opt_verbose || $opt_newpackage) { # XXX
+ log_warning(NO_FILE, NO_LINE_NUMBER, "".
+ ($opt_newpackage ? 'for new package, '
: 'is it a new package? if so, ').
- "make \$$rcsidstr\$ tag in comment ".
+ "make \$$conf_rcsidstr\$ tag in comment ".
"section empty, to make CVS happy.");
}
}
@@ -1070,8 +1086,7 @@ EOF
#
# section 2: DISTNAME/PKGNAME/...
#
- print "OK: checking first section of $file. (DISTNAME/...)\n"
- if ($verbose);
+ log_info(NO_FILE, NO_LINE_NUMBER, "checking first section of $file. (DISTNAME/...)");
$tmp = $sections[$idx++];
# check the order of items.
@@ -1088,10 +1103,10 @@ EOF
$tmp = "\n" . $tmp;
foreach $i ('DISTNAME', 'CATEGORIES') {
if ($tmp !~ /\n$i=/) {
- &perror("FATAL: $i has to be there.");
+ log_error(NO_FILE, NO_LINE_NUMBER, "$i has to be there.");
}
if ($tmp =~ /\n$i(\?=)/) {
- &perror("FATAL: $i has to be set by \"=\", ".
+ log_error(NO_FILE, NO_LINE_NUMBER, "$i has to be set by \"=\", ".
"not by \"$1\".");
}
}
@@ -1099,40 +1114,37 @@ EOF
# check for pkgsrc-wip remnants in CATEGORIES
if ($tmp =~ /\nCATEGORIES=[ \t]*.*wip.*\n/
&& $category ne "wip") {
- &perror("FATAL: don't forget to remove \"wip\" from CATEGORIES.");
+ log_error(NO_FILE, NO_LINE_NUMBER, "don't forget to remove \"wip\" from CATEGORIES.");
}
# check the URL
if ($tmp =~ /\nMASTER_SITES[+?]?=[ \t]*([^\n]*)\n/
&& $1 !~ /^[ \t]*$/) {
- print "OK: seen MASTER_SITES, sanity checking URLs.\n"
- if ($verbose);
+ log_info(NO_FILE, NO_LINE_NUMBER, "seen MASTER_SITES, sanity checking URLs.");
@sites = split(/\s+/, $1);
foreach $i (@sites) {
if ($i =~ m#^\w+://#) {
if ($i !~ m#/$#) {
- &perror("FATAL: URL \"$i\" should ".
+ log_error(NO_FILE, NO_LINE_NUMBER, "URL \"$i\" should ".
"end with \"/\".");
}
if ($i =~ m#://[^/]*:/#) {
- &perror("FATAL: URL \"$i\" contains ".
+ log_error(NO_FILE, NO_LINE_NUMBER, "URL \"$i\" contains ".
"extra \":\".");
}
unless (&is_predefined($i)) {
- print "OK: URL \"$i\" ok.\n"
- if ($verbose);
+ log_info(NO_FILE, NO_LINE_NUMBER, "URL \"$i\" ok.");
}
} else {
- print "OK: non-URL \"$i\" ok.\n"
- if ($verbose);
+ log_info(NO_FILE, NO_LINE_NUMBER, "non-URL \"$i\" ok.\n");
}
if ($tmp =~ /\nDYNAMIC_MASTER_SITES[+?]?=/) {
- &perror("WARN: MASTER_SITES and DYNAMIC_MASTER_SITES ".
+ log_warning(NO_FILE, NO_LINE_NUMBER, "MASTER_SITES and DYNAMIC_MASTER_SITES ".
"found. Is this ok?");
}
}
} elsif ($tmp !~ /\nDYNAMIC_MASTER_SITES[+?]?=/) {
- &perror("WARN: no MASTER_SITES or DYNAMIC_MASTER_SITES found. ".
+ log_warning(NO_FILE, NO_LINE_NUMBER, "no MASTER_SITES or DYNAMIC_MASTER_SITES found. ".
"Is this ok?");
}
@@ -1145,29 +1157,28 @@ EOF
# check bogus EXTRACT_SUFX.
if ($extractsufx ne '') {
- print "OK: seen EXTRACT_SUFX, checking value.\n" if ($verbose);
+ log_info(NO_FILE, NO_LINE_NUMBER, "seen EXTRACT_SUFX, checking value.");
if ($distfiles ne '' && ($extractsufx eq '.tar.gz')) {
- &perror("WARN: no need to define EXTRACT_SUFX if ".
+ log_warning(NO_FILE, NO_LINE_NUMBER, "no need to define EXTRACT_SUFX if ".
"DISTFILES is defined.");
}
if ($extractsufx eq '.tar.gz') {
- &perror("WARN: EXTRACT_SUFX is \".tar.gz.\" ".
+ log_warning(NO_FILE, NO_LINE_NUMBER, "EXTRACT_SUFX is \".tar.gz.\" ".
"by default. you don't need to specify it.");
}
} else {
- print "OK: no EXTRACT_SUFX seen, using default value.\n"
- if ($verbose);
+ log_info(NO_FILE, NO_LINE_NUMBER, "no EXTRACT_SUFX seen, using default value.");
$extractsufx = '.tar.gz';
}
- print "OK: sanity checking PKGNAME.\n" if ($verbose);
+ log_info(NO_FILE, NO_LINE_NUMBER, "sanity checking PKGNAME.");
if ($pkgname ne '' && $pkgname eq $distname) {
- &perror("WARN: PKGNAME is \${DISTNAME} by default, ".
+ log_warning(NO_FILE, NO_LINE_NUMBER, "PKGNAME is \${DISTNAME} by default, ".
"you don't need to define PKGNAME.");
}
if ($svrpkgname ne '') {
if (length($svrpkgname) > 5) {
- &perror("FATAL: SVR4_PKGNAME should not be longer ".
+ log_error(NO_FILE, NO_LINE_NUMBER, "SVR4_PKGNAME should not be longer ".
"than 5 characters.");
}
}
@@ -1177,7 +1188,7 @@ EOF
$j = $`;
$k = $1;
if ($j =~ /[0-9]$/) {
- &perror("WARN: is \"$j\" sane as package name ".
+ log_warning(NO_FILE, NO_LINE_NUMBER, "is \"$j\" sane as package name ".
"WITHOUT version number? ".
"if not, avoid \"-\" in version number ".
"part of ".
@@ -1190,30 +1201,30 @@ EOF
}
if ($k =~ /^pl[0-9]*$/
|| $k =~ /^[0-9]*[A-Za-z]*[0-9]*(\.[0-9]*[A-Za-z]*[0-9]*)*$/) {
- print "OK: trailing part of PKGNAME\"-$k\" ".
- "looks fine.\n" if ($verbose);
+ log_info(NO_FILE, NO_LINE_NUMBER, "trailing part of PKGNAME\"-$k\" ".
+ "looks fine.");
} else {
- &perror("FATAL: version number part of PKGNAME".
+ log_error(NO_FILE, NO_LINE_NUMBER, "version number part of PKGNAME".
(($pkgname eq '')
? ', which is derived from DISTNAME, '
: ' ').
"looks illegal. You should modify \"-$k\"");
}
} else {
- &perror("FATAL: PKGNAME".
+ log_error(NO_FILE, NO_LINE_NUMBER, "PKGNAME".
(($pkgname eq '')
? ', which is derived from DISTNAME, '
: ' ').
"must come with version number, like \"foobaa-1.0\".");
if ($i =~ /_pl[0-9]*$/
|| $i =~ /_[0-9]*[A-Za-z]?[0-9]*(\.[0-9]*[A-Za-z]?[0-9]*)*$/) {
- &perror("FATAL: you seem to be using underline ".
+ log_error(NO_FILE, NO_LINE_NUMBER, "you seem to be using underline ".
"before version number in PKGNAME. ".
"it has to be hyphen.");
}
}
if ($distname =~ /(nb\d*)/) {
- &perror("WARN: is '$1' really ok on DISTNAME, ".
+ log_warning(NO_FILE, NO_LINE_NUMBER, "is '$1' really ok on DISTNAME, ".
"or is it intended for PKGNAME?");
}
@@ -1226,20 +1237,19 @@ EOF
# EXTRACT_SUFX= .tgz
if ($distfiles =~ /^\S+$/) {
$bogusdistfiles++;
- print "OK: seen DISTFILES with single item, checking value.\n"
- if ($verbose);
- &perror("WARN: use of DISTFILES with single file ".
+ log_info(NO_FILE, NO_LINE_NUMBER, "seen DISTFILES with single item, checking value.");
+ log_warning(NO_FILE, NO_LINE_NUMBER, "use of DISTFILES with single file ".
"discouraged. distribution filename should be set by ".
"DISTNAME and EXTRACT_SUFX.");
if ($distfiles eq $distname . $extractsufx) {
- &perror("WARN: definition of DISTFILES not necessary. ".
+ log_warning(NO_FILE, NO_LINE_NUMBER, "definition of DISTFILES not necessary. ".
"DISTFILES is \${DISTNAME}/\${EXTRACT_SUFX} ".
"by default.");
}
# make an advice only in certain cases.
if ($pkgname ne '' && $distfiles =~ /^$pkgname([-\.].+)$/) {
- &perror("WARN: how about \"DISTNAME=$pkgname\"".
+ log_warning(NO_FILE, NO_LINE_NUMBER, "how about \"DISTNAME=$pkgname\"".
(($1 eq '.tar.gz')
? ""
: " and \"EXTRACT_SUFX=$1\"").
@@ -1249,8 +1259,8 @@ EOF
# additional checks for committer.
$i = ($pkgname eq '') ? $distname : $pkgname;
- if ($committer && -f "$portdir/$i.tgz") {
- &perror("WARN: be sure to remove $portdir/$i.tgz ".
+ if ($opt_committer && -f "$opt_packagedir/$i.tgz") {
+ log_warning(NO_FILE, NO_LINE_NUMBER, "be sure to remove $opt_packagedir/$i.tgz ".
"before committing the package.");
}
@@ -1262,8 +1272,7 @@ EOF
#
# section 3: PATCH_SITES/PATCHFILES(optional)
#
- print "OK: checking second section of $file, (PATCH*: optional).\n"
- if ($verbose);
+ log_info(NO_FILE, NO_LINE_NUMBER, "checking second section of $file, (PATCH*: optional).");
$tmp = $sections[$idx];
if ($tmp =~ /(PATCH_SITES|PATCH_SITE_SUBDIR|PATCHFILES|PATCH_DIST_STRIP)/) {
@@ -1272,23 +1281,23 @@ EOF
$tmp = "\n$tmp";
if ($tmp =~ /\n(PATCH_SITES)=/) {
- print "OK: seen PATCH_SITES.\n" if ($verbose);
+ log_info(NO_FILE, NO_LINE_NUMBER, "seen PATCH_SITES.");
$tmp =~ s/$1[^\n]+\n//;
}
if ($tmp =~ /\n(PATCH_SITE_SUBDIR)=/) {
- print "OK: seen PATCH_SITE_SUBDIR.\n" if ($verbose);
+ log_info(NO_FILE, NO_LINE_NUMBER, "seen PATCH_SITE_SUBDIR.");
$tmp =~ s/$1[^\n]+\n//;
}
if ($tmp =~ /\n(PATCHFILES)=/) {
- print "OK: seen PATCHFILES.\n" if ($verbose);
+ log_info(NO_FILE, NO_LINE_NUMBER, "seen PATCHFILES.");
$tmp =~ s/$1[^\n]+\n//;
}
if ($tmp =~ /\n(PATCH_DIST_ARGS)=/) {
- print "OK: seen PATCH_DIST_ARGS.\n" if ($verbose);
+ log_info(NO_FILE, NO_LINE_NUMBER, "seen PATCH_DIST_ARGS.");
$tmp =~ s/$1[^\n]+\n//;
}
if ($tmp =~ /\n(PATCH_DIST_STRIP)=/) {
- print "OK: seen PATCH_DIST_STRIP.\n" if ($verbose);
+ log_info(NO_FILE, NO_LINE_NUMBER, "seen PATCH_DIST_STRIP.");
$tmp =~ s/$1[^\n]+\n//;
}
@@ -1304,8 +1313,7 @@ EOF
#
# section 4: MAINTAINER
#
- print "OK: checking third section of $file (MAINTAINER).\n"
- if ($verbose);
+ log_info(NO_FILE, NO_LINE_NUMBER, "checking third section of $file (MAINTAINER).");
$tmp = $sections[$idx++];
# check the order of items.
@@ -1318,12 +1326,12 @@ EOF
# warnings for missing or incorrect HOMEPAGE
$tmp = "\n" . $tmp;
if ($tmp !~ /\nHOMEPAGE[+?]?=[ \t]*([^\n]*)\n/ || $1 =~ /^[ \t]*$/) {
- &perror("WARN: please add HOMEPAGE if the package has one.");
+ log_warning(NO_FILE, NO_LINE_NUMBER, "please add HOMEPAGE if the package has one.");
} else {
$i = $1;
if ($i =~ m#^\w+://#) {
if ($i !~ m#^\w+://[^\n/]+/#) {
- &perror("WARN: URL \"$i\" does not ".
+ log_warning(NO_FILE, NO_LINE_NUMBER, "URL \"$i\" does not ".
"end with \"/\".");
}
}
@@ -1331,31 +1339,31 @@ EOF
# warnings for missing COMMENT
if ($tmp !~ /\nCOMMENT=\s*(.*)$/) {
- &perror("FATAL: please add a short COMMENT describing the package.");
+ log_error(NO_FILE, NO_LINE_NUMBER, "please add a short COMMENT describing the package.");
}
# and its properties:
$tmp2 = $1;
if ($tmp2 =~ /\.$/i) {
- &perror("WARN: COMMENT should not end with a '.' (period).");
+ log_warning(NO_FILE, NO_LINE_NUMBER, "COMMENT should not end with a '.' (period).");
}
if ($tmp2 =~ /^(a|an) /i) {
- &perror("WARN: COMMENT should not begin with '$1 '.");
+ log_warning(NO_FILE, NO_LINE_NUMBER, "COMMENT should not begin with '$1 '.");
}
if ($tmp2 =~ /^[a-z]/) {
- &perror("WARN: COMMENT should start with a capital letter.");
+ log_warning(NO_FILE, NO_LINE_NUMBER, "COMMENT should start with a capital letter.");
}
if (length($tmp2) > 70) {
- &perror("WARN: COMMENT should not be longer than 70 characters.");
+ log_warning(NO_FILE, NO_LINE_NUMBER, "COMMENT should not be longer than 70 characters.");
}
&checkearlier($tmp, @varnames);
$tmp = "\n" . $tmp;
if ($tmp =~ /\nMAINTAINER=[^@]+\@netbsd.org/) {
- &perror("WARN: \@netbsd.org should be \@NetBSD.org in MAINTAINER.");
+ log_warning(NO_FILE, NO_LINE_NUMBER, "\@netbsd.org should be \@NetBSD.org in MAINTAINER.");
} elsif ($tmp =~ /\nMAINTAINER=[^\n]+/) {
$tmp =~ s/\nMAINTAINER=[^\n]+//;
} else {
- &perror("FATAL: no MAINTAINER listed in $file.");
+ log_error(NO_FILE, NO_LINE_NUMBER, "no MAINTAINER listed in $file.");
# Why is this fatal? There's a default in bsd.pkg.mk - HF
}
$tmp =~ s/\n\n+/\n/g;
@@ -1367,54 +1375,52 @@ EOF
#
# section 5: *_DEPENDS (may not be there)
#
- print "OK: checking fourth section of $file(*_DEPENDS).\n"
- if ($verbose);
+ log_info(NO_FILE, NO_LINE_NUMBER, "checking fourth section of $file(*_DEPENDS).");
$tmp = $sections[$idx];
@linestocheck = split(/\s+/, <<EOF);
BUILD_USES_MSGFMT BUILD_DEPENDS DEPENDS
EOF
if ($tmp =~ /(DEPENDS_TARGET|FETCH_DEPENDS|LIB_DEPENDS|RUN_DEPENDS).*=/) {
- &perror("WARN: $1 is deprecated, please use DEPENDS.");
+ log_warning(NO_FILE, NO_LINE_NUMBER, "$1 is deprecated, please use DEPENDS.");
}
if ($tmp =~ /(LIB_|BUILD_|RUN_|FETCH_)?DEPENDS/ or
$tmp =~ /BUILD_USES_MSGFMT/) {
&checkearlier($tmp, @varnames);
if (!defined $ENV{'PORTSDIR'}) {
- $ENV{'PORTSDIR'} = $portsdir;
+ $ENV{'PORTSDIR'} = $conf_portsdir;
}
foreach $i (grep(/^[A-Z_]*DEPENDS[?+]?=/, split(/\n/, $tmp))) {
$i =~ s/^([A-Z_]*DEPENDS)[?+]?=[ \t]*//;
$j = $1;
- print "OK: checking packages listed in $j.\n"
- if ($verbose);
+ log_info(NO_FILE, NO_LINE_NUMBER, "checking packages listed in $j.");
foreach $k (split(/\s+/, $i)) {
$l = (split(':', $k))[0];
# check BUILD_USES_MSGFMT
if ($l =~ /^(msgfmt|gettext)$/) {
- &perror("WARN: dependency to $1 ".
+ log_warning(NO_FILE, NO_LINE_NUMBER, "dependency to $1 ".
"listed in $j. Consider using".
" BUILD_USES_MSGFMT.");
}
# check USE_PERL5
if ($l =~ /^perl(\.\d+)?$/) {
- &perror("WARN: dependency to perl ".
+ log_warning(NO_FILE, NO_LINE_NUMBER, "dependency to perl ".
"listed in $j. Consider using".
" USE_PERL5.");
}
# check USE_GMAKE
if ($l =~ /^(gmake|\${GMAKE})$/) {
- &perror("WARN: dependency to $1 ".
+ log_warning(NO_FILE, NO_LINE_NUMBER, "dependency to $1 ".
"listed in $j. Consider using".
" USE_GMAKE.");
}
# check direct dependencies on -dirs packages
if ($l =~ /^([-a-zA-Z0-9]+)-dirs[-><=]+(.*)/) {
- &perror("WARN: dependency to $1-dirs ".
+ log_warning(NO_FILE, NO_LINE_NUMBER, "dependency to $1-dirs ".
"listed in $j. Consider using".
" USE_DIRS+=$1-$2.");
}
@@ -1422,13 +1428,12 @@ EOF
# check pkg dir existence
$k = (split(':', $k))[1];
$k =~ s/\${PKGSRCDIR}/$ENV{'PKGSRCDIR'}/;
- if (! -d "$portdir/$k") {
- &perror("WARN: no package directory $k ".
+ if (! -d "$opt_packagedir/$k") {
+ log_warning(NO_FILE, NO_LINE_NUMBER, "no package directory $k ".
"found, even though it is ".
"listed in $j.");
} else {
- print "OK: package directory $k found.\n"
- if ($verbose);
+ log_info(NO_FILE, NO_LINE_NUMBER, "package directory $k found.");
}
}
}
@@ -1447,7 +1452,7 @@ EOF
#
# Makefile 6: check the rest of file
#
- print "OK: checking the rest of the $file.\n" if ($verbose);
+ log_info(NO_FILE, NO_LINE_NUMBER, "checking the rest of the $file.");
$tmp = join("\n\n", @sections[$idx .. scalar(@sections)-1]);
$tmp = "\n" . $tmp; # to make the begin-of-line check easier
@@ -1467,7 +1472,7 @@ EOF
# EXTRACT_SUFX=.tgz
# WRKSRC= ${WRKDIR}/package
#
- print "OK: checking WRKSRC.\n" if ($verbose);
+ log_info(NO_FILE, NO_LINE_NUMBER, "checking WRKSRC.");
$wrksrc = $nowrksubdir = '';
$wrksrc = $1 if ($tmp =~ /\nWRKSRC[+?]?=[ \t]*([^\n]*)\n/);
$nowrksubdir = $1 if ($tmp =~ /\nNO_WRKSUBDIR[+?]?=[ \t]*([^\n]*)\n/);
@@ -1477,13 +1482,12 @@ EOF
} else {
$realwrksrc = $wrksrc ? $wrksrc : '${WRKDIR}';
}
- print "OK: WRKSRC seems to be $realwrksrc.\n" if ($verbose);
+ log_info(NO_FILE, NO_LINE_NUMBER, "WRKSRC seems to be $realwrksrc.");
if ($nowrksubdir eq '') {
- print "OK: no NO_WRKSUBDIR, checking value of WRKSRC.\n"
- if ($verbose);
+ log_info(NO_FILE, NO_LINE_NUMBER, "no NO_WRKSUBDIR, checking value of WRKSRC.");
if ($wrksrc eq 'work' || $wrksrc =~ /^$[\{\(]WRKDIR[\}\)]/) {
- &perror("WARN: WRKSRC is set to meaningless value ".
+ log_warning(NO_FILE, NO_LINE_NUMBER, "WRKSRC is set to meaningless value ".
"\"$1\".".
($nowrksubdir eq ''
? " use \"NO_WRKSUBDIR=yes\" instead."
@@ -1491,19 +1495,18 @@ EOF
}
if ($bogusdistfiles) {
if ($distname ne '' && $wrksrc eq '') {
- &perror("WARN: do not use DISTFILES and DISTNAME ".
+ log_warning(NO_FILE, NO_LINE_NUMBER, "do not use DISTFILES and DISTNAME ".
"to control WRKSRC. how about ".
"\"WRKSRC=\${WRKDIR}/$distname\"?");
} else {
- &perror("WARN: DISTFILES/DISTNAME affects WRKSRC. ".
+ log_warning(NO_FILE, NO_LINE_NUMBER, "DISTFILES/DISTNAME affects WRKSRC. ".
"Use caution when changing them.");
}
}
} else {
- print "OK: seen NO_WRKSUBDIR, checking value of WRKSRC.\n"
- if ($verbose);
+ log_info(NO_FILE, NO_LINE_NUMBER, "seen NO_WRKSUBDIR, checking value of WRKSRC.");
if ($wrksrc eq 'work' || $wrksrc =~ /^$[\{\(]WRKDIR[\}\)]/) {
- &perror("WARN: definition of WRKSRC not necessary. ".
+ log_warning(NO_FILE, NO_LINE_NUMBER, "definition of WRKSRC not necessary. ".
"WRKSRC is \${WRKDIR} by default.");
}
}
@@ -1513,7 +1516,7 @@ EOF
$j = $1;
foreach $k (split(/\s+/, $i)) {
if ($k !~/^".*"$/ && $k =~ /\${/ && $k !~/:Q}/) {
- &perror("WARN: definition of $k in $j. ".
+ log_warning(NO_FILE, NO_LINE_NUMBER, "definition of $k in $j. ".
"should use :Q or be quoted.");
}
}
@@ -1521,31 +1524,21 @@ EOF
# check USE_X11 and USE_IMAKE
if ($tmp =~ /\nUSE_IMAKE[?+]?=/ && $tmp =~ /\nUSE_X11[?+]?=/) {
- &perror("WARN: since you already have USE_IMAKE, ".
+ log_warning(NO_FILE, NO_LINE_NUMBER, "since you already have USE_IMAKE, ".
"you don't need USE_X11.");
}
# check direct use of important make targets.
if ($tmp =~ /\n(fetch|extract|patch|configure|build|install):/) {
- &perror("FATAL: direct redefinition of make target \"$1\" ".
+ log_error(NO_FILE, NO_LINE_NUMBER, "direct redefinition of make target \"$1\" ".
"discouraged. redefine \"do-$1\" instead.");
}
1;
}
-sub perror {
- local(@msg) = @_;
- if ($msg[0] =~ /^FATAL/) {
- $err++;
- } else {
- $warn++;
- }
- print join("\n", @msg) . "\n";
-}
-
-sub checkextra {
- local($str, $section) = @_;
+sub checkextra($$) {
+ my ($str, $section) = @_;
$str = "\n" . $str if ($str !~ /^\n/);
$str =~ s/\n#[^\n]*/\n/g;
@@ -1555,70 +1548,68 @@ sub checkextra {
return if ($str eq '');
if ($str =~ /^([\w\d]+)/) {
- &perror("WARN: extra item placed in the ".
+ log_warning(NO_FILE, NO_LINE_NUMBER, "extra item placed in the ".
"$section section, ".
"for example, \"$1\".");
} else {
- &perror("WARN: extra item placed in the ".
+ log_warning(NO_FILE, NO_LINE_NUMBER, "extra item placed in the ".
"$section section.");
}
}
-sub checkorder {
- local($section, $str, @order) = @_;
- local(@items, $i, $j, $k, $invalidorder);
+sub checkorder($$@) {
+ my ($section, $str, @order) = @_;
- print "OK: checking the order of $section section.\n" if ($verbose);
+ log_info(NO_FILE, NO_LINE_NUMBER, "checking the order of $section section.");
- @items = ();
- foreach $i (split("\n", $tmp)) {
+ my @items = ();
+ foreach my $i (split("\n", $tmp)) {
$i =~ s/[+?]?=.*$//;
push(@items, $i);
}
@items = reverse(@items);
- $j = -1;
- $invalidorder = 0;
+ my $j = -1;
+ my $invalidorder = 0;
while (scalar(@items)) {
- $i = pop(@items);
- $k = 0;
+ my $i = pop(@items);
+ my $k = 0;
while ($k < scalar(@order) && $order[$k] ne $i) {
$k++;
}
if ($order[$k] eq $i) {
if ($k < $j) {
- &perror("FATAL: $i appears out-of-order.");
+ log_error(NO_FILE, NO_LINE_NUMBER, "$i appears out-of-order.");
$invalidorder++;
} else {
- print "OK: seen $i, in order.\n" if ($verbose);
+ log_info(NO_FILE, NO_LINE_NUMBER, "seen $i, in order.");
}
$j = $k;
} else {
- &perror("FATAL: extra item \"$i\" placed in".
+ log_error(NO_FILE, NO_LINE_NUMBER, "extra item \"$i\" placed in".
" the $section section.");
}
}
if ($invalidorder) {
- &perror("FATAL: order must be " . join('/', @order) . '.');
+ log_error(NO_FILE, NO_LINE_NUMBER, "order must be " . join('/', @order) . '.');
} else {
- print "OK: $section section is ordered properly.\n"
- if ($verbose);
+ log_info(NO_FILE, NO_LINE_NUMBER, "$section section is ordered properly.");
}
}
-sub checkearlier {
+sub checkearlier($@) {
local($str, @varnames) = @_;
local($i);
- print "OK: checking items that have to appear earlier.\n" if ($verbose);
+ log_info(NO_FILE, NO_LINE_NUMBER, "checking items that have to appear earlier.");
foreach $i (@varnames) {
if ($str =~ /\n$i[?+]?=/) {
- &perror("WARN: \"$i\" has to appear earlier in $file.");
+ log_warning(NO_FILE, NO_LINE_NUMBER, "\"$i\" has to appear earlier in $file.");
}
}
}
-sub abspathname {
+sub abspathname($$) {
local($str, $file) = @_;
local($s, $i, %cmdnames);
local($pre);
@@ -1626,8 +1617,7 @@ sub abspathname {
# ignore parameter string to echo command
$str =~ s/[ \t][\@-]?(echo|\$[\{\(]ECHO[\}\)]|\$[\{\(]ECHO_MSG[\}\)])[ \t]+("(\\'|\\"|[^"])*"|'(\\'|\\"|[^"])*')[ \t]*[;\n]//;
- print "OK: checking direct use of full pathnames in $file.\n"
- if ($verbose);
+ log_info(NO_FILE, NO_LINE_NUMBER, "checking direct use of full pathnames in $file.");
foreach $s (split(/\n+/, $str)) {
$i = '';
if ($s =~ /(^|[ \t\@'"-])(\/[\w\d])/) {
@@ -1644,27 +1634,27 @@ sub abspathname {
$i =~ s/\s.*$//;
$i =~ s/['"].*$//;
$i = substr($i, 0, 20) . '...' if (20 < length($i));
- &perror("WARN: possible use of absolute pathname ".
+ log_warning(NO_FILE, NO_LINE_NUMBER, "possible use of absolute pathname ".
"\"$i\", in $file.");
}
}
- print "OK: checking direct use of pathnames, phase 1.\n" if ($verbose);
+ log_info(NO_FILE, NO_LINE_NUMBER, "checking direct use of pathnames, phase 1.");
%cmdnames = split(/\n|\t+/, <<EOF);
/usr/opt \${PORTSDIR} instead
-$portsdir \${PORTSDIR} instead
-$localbase \${PREFIX} or \${LOCALBASE}, as appropriate
+$conf_portsdir \${PORTSDIR} instead
+$conf_localbase \${PREFIX} or \${LOCALBASE}, as appropriate
/usr/X11 \${PREFIX} or \${X11BASE}, as appropriate
/usr/X11R6 \${PREFIX} or \${X11BASE}, as appropriate
EOF
foreach $i (keys %cmdnames) {
if ($str =~ /$i/) {
- &perror("WARN: possible direct use of \"$&\" ".
+ log_warning(NO_FILE, NO_LINE_NUMBER, "possible direct use of \"$&\" ".
"found in $file. if so, use $cmdnames{$i}.");
}
}
- print "OK: checking direct use of pathnames, phase 2.\n" if ($verbose);
+ log_info(NO_FILE, NO_LINE_NUMBER, "checking direct use of pathnames, phase 2.");
%cmdnames = split(/\n|\t+/, <<EOF);
distfiles \${DISTDIR} instead
pkg \${PKGDIR} instead
@@ -1675,13 +1665,13 @@ work \${WRKDIR} instead
EOF
foreach $i (keys %cmdnames) {
if ($str =~ /(\.\/|\$[\{\(]\.CURDIR[\}\)]\/|[ \t])(\b$i)\//) {
- &perror("WARN: possible direct use of \"$i\" ".
+ log_warning(NO_FILE, NO_LINE_NUMBER, "possible direct use of \"$i\" ".
"found in $file. if so, use $cmdnames{$i}.");
}
}
}
-sub is_predefined {
+sub is_predefined($) {
local($url) = @_;
local($site);
local($subdir);
@@ -1689,14 +1679,14 @@ sub is_predefined {
$url =~ /$site/;
$subdir = $';
$subdir =~ s/\/$//;
- &perror("WARN: how about using ".
+ log_warning(NO_FILE, NO_LINE_NUMBER, "how about using ".
"\${MASTER_SITE_$predefined{$site}:=$subdir/} instead of \"$url\?");
- return &TRUE;
+ return 1;
}
- undef;
+ return 0;
}
-sub category_check {
+sub category_check() {
local($file) = "Makefile";
local($first) = 1;
local($lastsub) = "";
@@ -1705,13 +1695,13 @@ sub category_check {
local(@dirlist);
local($i);
- $contents = readmakefile("$portdir/$file") or
- &perror("FATAL: can't read $portdir/$file") and return 0;
- if ($contents !~ /#(\s+)\$$rcsidstr([^\$]*)\$/) {
- &perror("FATAL: no \$$rcsidstr\$ line in $file");
+ $contents = readmakefile("$opt_packagedir/$file") or
+ log_error(NO_FILE, NO_LINE_NUMBER, "can't read $opt_packagedir/$file") and return 0;
+ if ($contents !~ /#(\s+)\$$conf_rcsidstr([^\$]*)\$/) {
+ log_error(NO_FILE, NO_LINE_NUMBER, "no \$$conf_rcsidstr\$ line in $file");
}
if ($contents !~ /COMMENT=\s+\w/) {
- &perror("FATAL: no COMMENT line in $file");
+ log_error(NO_FILE, NO_LINE_NUMBER, "no COMMENT line in $file");
}
# get list of dirs to compare against
@@ -1725,14 +1715,14 @@ sub category_check {
$hash{CVS} = 0;
# remove comments
foreach $n (split "\n", $contents) {
- if ($n =~ /^(#)?SUBDIR(\+*)=\s*(\S+)(\s*#.*|\s*)$/) {
+ if ($n =~ /^(#?)SUBDIR(\+*)=\s*(\S+)(\s*#.*|\s*)$/) {
$sub = $3;
if ($first == 0) {
if ($2 ne "+") {
- &perror("FATAL: use SUBDIR+=, not SUBDIR$2=");
+ log_error(NO_FILE, NO_LINE_NUMBER, "use SUBDIR+=, not SUBDIR$2=");
}
if ($lastsub ge $sub) {
- &perror("FATAL: $sub should come before $lastsub");
+ log_error(NO_FILE, NO_LINE_NUMBER, "$sub should come before $lastsub");
}
}
else {
@@ -1746,19 +1736,69 @@ sub category_check {
$hash{$sub} = -1;
}
if ($1 eq "#" and not $4 =~ /#\s*\w+/) {
- &perror("WARN: $3 commented out without giving a reason");
+ log_warning(NO_FILE, NO_LINE_NUMBER, "$3 commented out without giving a reason");
}
}
}
foreach $i (sort(keys(%hash))) {
if ($hash{$i} gt 0) {
- &perror("FATAL: directory $i not in Makefile");
+ log_error(NO_FILE, NO_LINE_NUMBER, "directory $i not in Makefile");
}
elsif ($hash{$i} lt 0) {
- &perror("FATAL: non-existing directory $i listed in Makefile");
+ log_error(NO_FILE, NO_LINE_NUMBER, "non-existing directory $i listed in Makefile");
}
}
}
-sub TRUE {1;}
+#
+# Output of various log messages
+#
+
+
+sub log_message($$$$)
+{
+ my ($file, $lineno, $type, $message) = @_;
+ if ($file eq NO_FILE) {
+ printf("%s: %s\n", $type, $message);
+ } elsif ($lineno == NO_LINE_NUMBER) {
+ printf("%s: %s: %s\n", $type, $file, $message);
+ } else {
+ printf("%s: %s:%d: %s\n", $type, $file, $lineno, $message);
+ }
+}
+
+sub NO_FILE() { return ""; }
+sub NO_LINE_NUMBER() { return 0; }
+
+sub log_error($$$)
+{
+ my ($file, $lineno, $msg) = @_;
+ log_message($file, $lineno, "FATAL", $msg);
+ $errors++;
+}
+
+sub log_warning($$$)
+{
+ my ($file, $lineno, $msg) = @_;
+ log_message($file, $lineno, "WARN", $msg);
+ $warnings++;
+}
+
+sub log_info($$$)
+{
+ my ($file, $lineno, $msg) = @_;
+ if ($opt_verbose) {
+ log_message($file, $lineno, "OK", $msg);
+ }
+}
+
+sub print_summary_and_exit()
+{
+ if ($errors != 0 || $warnings != 0) {
+ print("$errors errors and $warnings warnings found.\n");
+ } else {
+ print "looks fine.\n";
+ }
+ exit($errors != 0);
+}