pkgsrc-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[pkgsrc/trunk]: pkgsrc Updated pkglint to 4.38.
details: https://anonhg.NetBSD.org/pkgsrc/rev/ca9c217cf81e
branches: trunk
changeset: 502583:ca9c217cf81e
user: rillig <rillig%pkgsrc.org@localhost>
date: Mon Nov 07 00:45:01 2005 +0000
description:
Updated pkglint to 4.38.
- PKGNAME is checked for being a valid package name.
- PLIST files should not contain filenames that match */CVS/*.
- Completely rewrote the check for variable ordering. The new code
operates on a data structure that's easily understandable and
extendable (see the source for an example). It also generates greatly
improved diagnostics. As the old code had been enabled only when
checking with -Wvague or -Wall, it has been seldom used anyway.
diffstat:
doc/CHANGES | 3 +-
pkgtools/pkglint/Makefile | 4 +-
pkgtools/pkglint/files/makevars.map | 3 +-
pkgtools/pkglint/files/pkglint.pl | 320 +++++++++++++++++------------------
4 files changed, 158 insertions(+), 172 deletions(-)
diffs (truncated from 487 to 300 lines):
diff -r a3034e7a038d -r ca9c217cf81e doc/CHANGES
--- a/doc/CHANGES Mon Nov 07 00:19:14 2005 +0000
+++ b/doc/CHANGES Mon Nov 07 00:45:01 2005 +0000
@@ -1,4 +1,4 @@
-$NetBSD: CHANGES,v 1.11847 2005/11/07 00:02:10 joerg Exp $
+$NetBSD: CHANGES,v 1.11848 2005/11/07 00:45:35 rillig Exp $
Changes to the packages collection and infrastructure in 2005:
@@ -5097,3 +5097,4 @@
Updated www/lighttpd to 1.4.7 [joerg 2005-11-06]
Added net/netpipes version 4.2 [jlam 2005-11-06]
Updated audio/xmix to 2.1nb1 [joerg 2005-11-06]
+ Updated pkgtools/pkglint to 4.38 [rillig 2005-11-07]
diff -r a3034e7a038d -r ca9c217cf81e pkgtools/pkglint/Makefile
--- a/pkgtools/pkglint/Makefile Mon Nov 07 00:19:14 2005 +0000
+++ b/pkgtools/pkglint/Makefile Mon Nov 07 00:45:01 2005 +0000
@@ -1,7 +1,7 @@
-# $NetBSD: Makefile,v 1.285 2005/11/05 11:02:53 rillig Exp $
+# $NetBSD: Makefile,v 1.286 2005/11/07 00:45:01 rillig Exp $
#
-DISTNAME= pkglint-4.37.2
+DISTNAME= pkglint-4.38
CATEGORIES= pkgtools devel
MASTER_SITES= # empty
DISTFILES= # empty
diff -r a3034e7a038d -r ca9c217cf81e pkgtools/pkglint/files/makevars.map
--- a/pkgtools/pkglint/files/makevars.map Mon Nov 07 00:19:14 2005 +0000
+++ b/pkgtools/pkglint/files/makevars.map Mon Nov 07 00:45:01 2005 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: makevars.map,v 1.28 2005/11/06 15:54:06 rillig Exp $
+# $NetBSD: makevars.map,v 1.29 2005/11/07 00:45:01 rillig Exp $
#
# This file contains the guessed type of some variables, according to
@@ -117,6 +117,7 @@
PGSQL_VERSIONS_ACCEPTED List* of { 73 74 80 }
PGSQL_VERSION_DEFAULT Userdefined
PKGBASE Readonly
+PKGNAME PkgName
PKGNAME_NOREV Readonly
PKGREPOSITORY Userdefined
PKGREPOSITORY Userdefined
diff -r a3034e7a038d -r ca9c217cf81e pkgtools/pkglint/files/pkglint.pl
--- a/pkgtools/pkglint/files/pkglint.pl Mon Nov 07 00:19:14 2005 +0000
+++ b/pkgtools/pkglint/files/pkglint.pl Mon Nov 07 00:45:01 2005 +0000
@@ -11,7 +11,7 @@
# 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.336 2005/11/05 11:02:53 rillig Exp $
+# $NetBSD: pkglint.pl,v 1.337 2005/11/07 00:45:01 rillig Exp $
#
# This version contains lots of changes necessary for NetBSD packages
# done by:
@@ -620,11 +620,6 @@
# to be checked. Mostly relevant with
# --recursive.
-sub readmakefile($$$);
-sub checkextra($$);
-sub checkorder($$@);
-sub checkearlier($@);
-
sub help($$$) {
my ($out, $exitval, $show_all) = @_;
my ($prog) = (basename($0));
@@ -1159,6 +1154,10 @@
$line->log_warning("PLIST contains \${PKGLOCALEDIR}, but USE_PKGLOCALEDIR was not found.");
}
+ if ($text =~ qr"/CVS/") {
+ $line->log_warning("CVS files should not be in the PLIST.");
+ }
+
} else {
$line->log_error("Unknown line type.");
}
@@ -1285,6 +1284,7 @@
checklines_multiple_patches($lines);
}
+sub readmakefile($$$);
sub readmakefile($$$) {
my ($file, $all_lines, $seen_Makefile_include) = @_;
my $contents = "";
@@ -1572,6 +1572,11 @@
$line->log_warning("\"${value}\" is not a valid pathname mask.");
}
+ } elsif ($type eq "PkgName") {
+ if ($value eq $value_novar && $value !~ regex_pkgname) {
+ $line->log_warning("\"${value}\" is not a valid package name.");
+ }
+
} elsif ($type eq "PkgRevision") {
if ($value !~ qr"^\d+$") {
$line->log_warning("\"${value}\" is not a valid Integer.");
@@ -1913,6 +1918,145 @@
}
}
+sub checklines_package_Makefile_varorder($) {
+ my ($lines) = @_;
+
+# TODO: Add support for optional sections with non-optional variables.
+
+ use constant once => 0;
+ use constant optional => 1;
+ use constant many => 2;
+ my (@sections) = (
+ [ "initial comments", once,
+ [
+ ]
+ ],
+ [ "DISTNAME", once,
+ [
+ [ "DISTNAME", once ],
+ [ "PKGNAME", optional ],
+ [ "PKGREVISION", optional ],
+ [ "SVR4_PKGNAME", optional ],
+ [ "CATEGORIES", once ],
+ [ "MASTER_SITES", once ],
+ [ "DYNAMIC_MASTER_SITES", optional ],
+ [ "MASTER_SITE_SUBDIR", optional ],
+ [ "EXTRACT_SUFX", optional ],
+ [ "DISTFILES", optional ],
+# The following are questionable.
+# [ "NOT_FOR_PLATFORM", optional ],
+# [ "ONLY_FOR_PLATFORM", optional ],
+# [ "NO_BIN_ON_FTP", optional ],
+# [ "NO_SRC_ON_FTP", optional ],
+# [ "NO_BIN_ON_CDROM", optional ],
+# [ "NO_SRC_ON_CDROM", optional ],
+ ]
+ ],
+ [ "PATCH_SITES", optional,
+ [
+ [ "PATCH_SITES", optional ], # or once?
+ [ "PATCH_SITE_SUBDIR", optional ],
+ [ "PATCHFILES", optional ], # or once?
+ [ "PATCH_DIST_ARGS", optional ],
+ [ "PATCH_DIST_STRIP", optional ],
+ [ "PATCH_DIST_CAT", optional ],
+ ]
+ ],
+ [ "MAINTAINER", once,
+ [
+ [ "MAINTAINER", once ],
+ [ "HOMEPAGE", optional ],
+ [ "COMMENT", once ],
+ ]
+ ],
+ [ "DEPENDS", optional,
+ [
+ [ "BUILD_DEPENDS", many ],
+ [ "DEPENDS", many ],
+ ]
+ ]
+ );
+
+ if ($seen_Makefile_common) {
+ return;
+ }
+
+ my ($lineno, $sectindex, $varindex) = (0, -1, 0);
+ my ($next_section, $vars, $below, $below_what) = (true, undef, {}, undef);
+
+ # In each interation, one of the following becomes true:
+ # - new.lineno > old.lineno
+ # - new.sectindex > old.sectindex
+ # - new.sectindex == old.sectindex && new.varindex > old.varindex
+ # - next_section == true
+ while ($lineno <= $#{$lines}) {
+ my $line = $lines->[$lineno];
+ my $text = $line->text;
+
+ if ($next_section) {
+ $next_section = false;
+ $sectindex++;
+ last if ($sectindex > $#sections);
+ $vars = $sections[$sectindex]->[2];
+ $varindex = 0;
+ }
+
+ if ($text =~ qr"^#") {
+ $lineno++;
+
+ } elsif ($text =~ regex_varassign) {
+ my ($varname, $op, $value, $comment) = ($1, $2, $3, $4);
+
+ if (exists($below->{$varname})) {
+ if (defined($below->{$varname})) {
+ $line->log_warning("${varname} appears too late. Please put it below $below->{$varname}.");
+ } else {
+ $line->log_warning("${varname} appears too late. It should be the very first definition.");
+ }
+ $lineno++;
+ next;
+ }
+
+ while ($varindex <= $#{$vars} && $varname ne $vars->[$varindex]->[0] && $vars->[$varindex]->[1] != once) {
+ $below->{$vars->[$varindex]->[0]} = $below_what;
+ $varindex++;
+ }
+ if ($varindex > $#{$vars}) {
+ if ($sections[$sectindex]->[1] != optional) {
+ $line->log_warning("Empty line expected.");
+ }
+ $next_section = true;
+
+ } elsif ($varname ne $vars->[$varindex]->[0]) {
+ $line->log_warning(sprintf("Expected %s, but found %s.", $vars->[$varindex]->[0], $varname));
+ $lineno++;
+
+ } else {
+ if ($vars->[$varindex]->[1] != many) {
+ $below->{$vars->[$varindex]->[0]} = $below_what;
+ $varindex++;
+ }
+ $lineno++;
+ }
+ $below_what = $varname;
+
+ } else {
+ while ($varindex <= $#{$vars}) {
+ if ($vars->[$varindex]->[1] == once) {
+ $line->log_warning(sprintf("%s should be set here.", $vars->[$varindex]->[0]));
+ }
+ $below->{$vars->[$varindex]->[0]} = $below_what;
+ $varindex++;
+ }
+ $next_section = true;
+ if ($text eq "") {
+ $below_what = "the previous empty line";
+ $lineno++;
+ }
+ }
+ }
+}
+
# This subroutine contains "local" checks that can be made looking only
# at a single line at a time. The other checks are in
# checkfile_package_Makefile.
@@ -2093,7 +2237,7 @@
my ($fname, $rawwhole, $lines) = @_;
my ($distname, $category, $distfiles,
$extract_sufx, $wrksrc);
- my ($whole, $tmp, $idx, @sections, @varnames);
+ my ($whole, $tmp, $idx, @sections);
log_subinfo("checkfile_package_Makefile", $fname, NO_LINE_NUMBER, undef);
@@ -2207,24 +2351,6 @@
log_info($fname, NO_LINE_NUMBER, "Checking DISTNAME section.");
$tmp = $sections[$idx++];
- # check the order of items.
- &checkorder('DISTNAME', $tmp, qw(
- DISTNAME PKGNAME PKGREVISION SVR4_PKGNAME CATEGORIES
- MASTER_SITES DYNAMIC_MASTER_SITES MASTER_SITE_SUBDIR
- EXTRACT_SUFX DISTFILES ONLY_FOR_ARCHS NO_SRC_ON_FTP
- NO_BIN_ON_FTP));
-
- # check the items that have to be there.
- $tmp = "\n" . $tmp;
- foreach my $i ('DISTNAME', 'CATEGORIES') {
- if (!$seen_Makefile_common && $tmp !~ /\n$i=/) {
- $opt_warn_vague && log_error(NO_FILE, NO_LINE_NUMBER, "$i has to be there.");
- }
- if ($tmp =~ /\n$i(\?=)/) {
- $opt_warn_vague && log_error(NO_FILE, NO_LINE_NUMBER, "$i has to be set by \"=\", not by \"$1\".");
- }
- }
-
# check the URL
if ($tmp =~ /\nMASTER_SITES[+?]?=[ \t]*([^\n]*)\n/
&& $1 !~ /^[ \t]*$/) {
@@ -2279,10 +2405,6 @@
$pkgname = $distname;
}
- push(@varnames, qw(
- DISTNAME PKGNAME SVR4_PKGNAME CATEGORIES MASTER_SITES
- MASTER_SITE_SUBDIR EXTRACT_SUFX DISTFILES));
-
#
# section 3: PATCH_SITES/PATCHFILES(optional)
#
@@ -2290,47 +2412,15 @@
$tmp = $sections[$idx];
if ($tmp =~ /(PATCH_SITES|PATCH_SITE_SUBDIR|PATCHFILES|PATCH_DIST_STRIP|PATCH_DIST_CAT)/) {
- &checkearlier($tmp, @varnames);
-
- $tmp = "\n$tmp";
-
- if ($tmp =~ /\n(PATCH_SITES)=/) {
- log_info(NO_FILE, NO_LINE_NUMBER, "Seen PATCH_SITES.");
Home |
Main Index |
Thread Index |
Old Index