From 5f3ef8e3b02cfeae505ee6479212f73a0f5b5b0e Mon Sep 17 00:00:00 2001 From: rillig Date: Thu, 2 Mar 2006 10:37:43 +0000 Subject: - At startup, pkglint checks against the package version in pkgtools/pkglint. If a newer version is available, it outputs a note. If the pkgtools/pkglint version is older than the currently running one, it outputs an error, since it is not a good idea to check and old tree with a new pkglint. Suggested by Alistair. --- pkgtools/pkglint/files/pkglint.pl | 77 ++++++++++++++++++++++++++------------- 1 file changed, 52 insertions(+), 25 deletions(-) (limited to 'pkgtools') diff --git a/pkgtools/pkglint/files/pkglint.pl b/pkgtools/pkglint/files/pkglint.pl index fd4fa68dd2c..1fc7f19e6a4 100644 --- a/pkgtools/pkglint/files/pkglint.pl +++ b/pkgtools/pkglint/files/pkglint.pl @@ -1,5 +1,5 @@ #! @PERL@ -# $NetBSD: pkglint.pl,v 1.539 2006/03/01 22:19:13 rillig Exp $ +# $NetBSD: pkglint.pl,v 1.540 2006/03/02 10:37:43 rillig Exp $ # # pkglint - static analyzer and checker for pkgsrc packages @@ -2065,6 +2065,36 @@ sub type_should_be_quoted($) { return !($type =~ qr"^(?:List(?:$|[^!]).*|ShellCommand|SedCommands)$"); } +my $check_pkglint_version_done = false; +sub check_pkglint_version() { + + return if $check_pkglint_version_done; + $check_pkglint_version_done = true; + + my $lines = load_lines("${current_dir}/${pkgsrcdir}/pkgtools/pkglint/Makefile", true); + return unless $lines; + + my $pkglint_version = undef; + foreach my $line (@{$lines}) { + if ($line->text =~ regex_varassign) { + my ($varname, undef, $value, undef) = ($1, $2, $3, $4); + + if ($varname eq "DISTNAME" || $varname eq "PKGNAME") { + if ($value =~ regex_pkgname) { + $pkglint_version = $2; + } + } + } + } + return unless defined($pkglint_version); + + if (dewey_cmp($pkglint_version, ">", conf_distver)) { + log_note(NO_FILE, NO_LINE_NUMBER, "A newer version of pkglint is available."); + } elsif (dewey_cmp($pkglint_version, "<", conf_distver)) { + log_error(NO_FILE, NO_LINE_NUMBER, "The pkglint version is newer than the tree to check."); + } +} + # # Loading package-specific data from files. # @@ -5027,36 +5057,33 @@ sub checkitem($) { $is_wip = !$opt_import && ($abs_current_dir =~ qr"/wip(?:/|$)"); $is_internal = ($abs_current_dir =~ qr"/mk(?:/|$)"); - if (-f "${current_dir}/../../../mk/bsd.pkg.mk") { - $pkgsrcdir = "../../.."; - if ($is_dir) { - log_error($item, NO_LINE_NUMBER, "Don't know how to check this directory."); + $pkgsrcdir = undef; + foreach my $d (".", "..", "../..", "../../..") { + if (-f "${current_dir}/${d}/mk/bsd.pkg.mk") { + $pkgsrcdir = $d; } - - } elsif (-f "${current_dir}/../../mk/bsd.pkg.mk") { - $pkgsrcdir = "../.."; - if ($is_dir) { - checkdir_package(); - } - - } elsif (-f "${current_dir}/../mk/bsd.pkg.mk") { - $pkgsrcdir = ".."; - if ($is_dir) { - checkdir_category(); - } - - } elsif (-f "${current_dir}/mk/bsd.pkg.mk") { - $pkgsrcdir = "."; - if ($is_dir) { - checkdir_root(); - } - } else { - log_error($item, NO_LINE_NUMBER, "Don't know how to check this " . (($is_dir) ? "directory" : "file") . "."); + } + if (!defined($pkgsrcdir)) { + log_error($current_dir, NO_LINE_NUMBER, "This is not inside a pkgsrc tree."); return; } + check_pkglint_version(); # (needs $pkgsrcdir) + if ($is_reg) { checkfile($item); + + } elsif ($pkgsrcdir eq "../..") { + checkdir_package(); + + } elsif ($pkgsrcdir eq "..") { + checkdir_category(); + + } elsif ($pkgsrcdir eq ".") { + checkdir_root(); + + } else { + log_error($item, NO_LINE_NUMBER, "Don't know how to check this directory."); } } -- cgit v1.2.3