summaryrefslogtreecommitdiff
path: root/pkgtools
diff options
context:
space:
mode:
authorabs <abs>2000-09-22 22:41:07 +0000
committerabs <abs>2000-09-22 22:41:07 +0000
commit77539d05ca7b01c9373609e4494dbaaafb1aab11 (patch)
treee4ce299ac84004ce4b5cc6f1779e5c2468ac2c90 /pkgtools
parent9ecb553f4df15cc56592feb91a77baaed59a815b (diff)
downloadpkgsrc-77539d05ca7b01c9373609e4494dbaaafb1aab11.tar.gz
Update pkglint to 2.24:
lintpkgsrc tried to break DEPENDS up into a packagename and version section, so if the version did not match it could lookup the matching packages and suggest valid versions. Unfortunately this excessive helpfulness meant globs that cover both sides such as 'perl-{5.0*,5.6.0nb2,base-5.[6-9]*}' gave it a certain degree of indigestion. It also didn't handle the '.if ${BINNAME} != common' correctly in www/ns-plugger-common/Makefile. I believe now that any outstanding -i or -d warnings are genuine...
Diffstat (limited to 'pkgtools')
-rw-r--r--pkgtools/pkglint/Makefile4
-rwxr-xr-xpkgtools/pkglint/files/lintpkgsrc.pl193
2 files changed, 113 insertions, 84 deletions
diff --git a/pkgtools/pkglint/Makefile b/pkgtools/pkglint/Makefile
index 1a468e044e5..06b68f3d804 100644
--- a/pkgtools/pkglint/Makefile
+++ b/pkgtools/pkglint/Makefile
@@ -1,7 +1,7 @@
-# $NetBSD: Makefile,v 1.61 2000/09/21 10:28:44 abs Exp $
+# $NetBSD: Makefile,v 1.62 2000/09/22 22:41:07 abs Exp $
#
-DISTNAME= pkglint-2.23
+DISTNAME= pkglint-2.24
CATEGORIES= pkgtools devel
MASTER_SITES= # empty
DISTFILES= # empty
diff --git a/pkgtools/pkglint/files/lintpkgsrc.pl b/pkgtools/pkglint/files/lintpkgsrc.pl
index 0f6a8648ffc..90ac46d77f1 100755
--- a/pkgtools/pkglint/files/lintpkgsrc.pl
+++ b/pkgtools/pkglint/files/lintpkgsrc.pl
@@ -1,6 +1,6 @@
#!/usr/bin/env perl
-# $NetBSD: lintpkgsrc.pl,v 1.32 2000/09/21 10:28:44 abs Exp $
+# $NetBSD: lintpkgsrc.pl,v 1.33 2000/09/22 22:41:08 abs Exp $
# Written by David Brownlee <abs@netbsd.org>.
#
@@ -38,19 +38,24 @@ $| = 1;
%default_makefile_vars = &get_default_makefile_vars;
-if ($opt{'D'})
+if ($opt{'D'} && @ARGV)
{
my($file);
foreach $file (@ARGV)
{
if ( -d $file)
{ $file .= "/Makefile"; }
+ if (! -f $file)
+ { &fail("No such file: $file"); }
my($pkgname, $vars);
($pkgname, $vars) = &parse_makefile_pkgsrc($file);
print "$file -> $pkgname\n";
foreach ( sort keys %{$vars} )
{ print "\t$_ = $vars->{$_}\n"; }
+ if ($opt{'d'})
+ { &pkgsrc_check_depends(); }
}
+ exit;
}
# main
@@ -110,7 +115,12 @@ if ($opt{'D'})
}
if ($opt{'d'})
- { &scan_pkgsrc_makefiles($pkgsrcdir, 1); }
+ {
+ if (!%pkg)
+ { &scan_pkgsrc_makefiles($pkgsrcdir); }
+ &pkgsrc_check_depends;
+ }
+
if ($opt{'i'} || $opt{'u'})
{
my(@pkgs, @bad, $pkg);
@@ -334,7 +344,6 @@ sub glob2regex
my(@chars, $in_alt);
my($regex);
- $regex = '^';
@chars = split(//, $glob);
while (defined($_ = shift @chars))
{
@@ -350,23 +359,21 @@ sub glob2regex
{ $regex .= '('; $in_alt = 1; }
elsif ($_ eq '}' )
{
- if (!$in_alt)
- { print "Warning - mismatched glob '$glob' -> '$regex'\n"; }
- else
- { $regex .= ')'; $in_alt = 0; }
+ if (!$in_alt) # Error
+ { return undef; }
+ $regex .= ')';
+ $in_alt = 0;
}
elsif ($_ eq ',' && $in_alt)
{ $regex .= '|'; }
else
{ $regex .= $_; }
}
- if ($in_alt)
- {
- print "Warning - mismatched glob '$glob' -> '$regex'\n";
- $regex .= ')';
- }
- $regex .= '$';
- $regex;
+ if ($in_alt) # Error
+ { return undef; }
+ if ($regex eq $glob)
+ { return(''); }
+ '^'.$regex.'$';
}
# Perform some (reasonable) subset of 'pkg_info -e' / glob(3)
@@ -376,67 +383,73 @@ sub glob2regex
sub package_globmatch
{
my($pkgmatch) = @_;
- my($matchpkgname, $matchver);
+ my($matchpkgname, $matchver, $regex);
+
+ if ( $pkgmatch =~ /^([^*?[]+)(<|>|<=|>=)(\d.+)/ )
+ { # (package)(cmp)(dewey)
+ my($test);
- # if ($pkgmatch =~ /^([^*?[]+)(<|>|<=|>=|-)([\d*?{].*)/)
- # {
- # }
- if ( $pkgmatch =~ /^([^[]+)-([\d*?{[].*)/ )
+ ($matchpkgname, $test, $matchver) = ($1, $2, $3);
+
+ if ($matchver !~ /^[\d.]+(nb\d+|)$/ )
+ { $matchver = "invalid-dewey($test$matchver)"; }
+ else
+ {
+ my($ver);
+ if (defined $pkg{$matchpkgname})
+ {
+ foreach $ver (%{$pkg{$matchpkgname}})
+ {
+ if (deweycmp($ver, $test, $matchver))
+ { $matchver = undef; last }
+ }
+ if ($matchver)
+ { $matchver = "$test$matchver"; }
+ }
+ }
+ }
+ elsif ( $pkgmatch =~ /^([^[]+)-([\d*?{[].*)$/ )
{ # (package)-(globver)
- my($pkgname, @pkgnames);
+ my($pkgname, $ver, @pkgnames);
+
($matchpkgname, $matchver) = ($1, $2);
if (defined $pkg{$matchpkgname})
{ push(@pkgnames, $matchpkgname); }
- else
+ elsif ($regex = glob2regex($matchpkgname))
{
- # Uh, check all package names against this regex. hmmmm.
- my($pkgregex) = glob2regex($matchpkgname);
- my($pkgname);
foreach $pkgname (sort keys %pkg)
- {
- if ($pkgname =~ /$pkgregex/)
- { push(@pkgnames, $pkgname); }
- }
+ { ($pkgname =~ /$regex/) && push(@pkgnames, $pkgname); }
}
foreach $pkgname (@pkgnames)
{
if (defined $pkg{$pkgname}{$matchver})
{ return($matchver); }
- # Try to convert $globver into regex version $regexver
- my($regexver);
- $regexver = glob2regex($matchver);
+ # Try to convert $globver into regex version
- my($ver);
- foreach $ver (%{$pkg{$pkgname}})
+ if ( $regex = glob2regex($matchver))
{
- if( $ver =~ /$regexver/ )
- { $matchver = undef; last }
+ foreach $ver (keys %{$pkg{$pkgname}})
+ {
+ if( $ver =~ /$regex/ )
+ { $matchver = undef; last }
+ }
}
$matchver || last;
}
- }
- elsif ( $pkgmatch =~ /^([^*?[]+)(<|>|<=|>=)(\d.+)/ )
- { # (package)(cmp)(dewey)
- my($test);
-
- ($matchpkgname, $test, $matchver) = ($1, $2, $3);
-
- if ($matchver !~ /^[\d.]+(nb\d+|)$/ )
- { $matchver = "invalid-dewey($test$matchver)"; }
- else
+ # last ditch attempt to handle the whole DEPENDS as a glob
+ if ($matchver && ($regex = glob2regex($pkgmatch))) # (large-glob)
{
- my($ver);
- if (defined $pkg{$matchpkgname})
+ my($pkgname, $ver);
+ foreach $pkgname (sort keys %pkg)
{
- foreach $ver (%{$pkg{$matchpkgname}})
+ foreach $ver (keys %{$pkg{$pkgname}})
{
- if (deweycmp($ver, $test, $matchver))
+ if( "$pkgname-$ver" =~ /$regex/ )
{ $matchver = undef; last }
}
- if ($matchver)
- { $matchver = "$test$matchver"; }
+ $matchver || last;
}
}
}
@@ -467,9 +480,28 @@ sub parse_makefile_pkgsrc
{ print "\rBogus: $pkgname (from $file)\n"; }
elsif ($pkgname =~ /(.*)-(\d.*)/)
{
+ my($cat, $pkgdir);
+
if (defined $vars->{'NO_BIN_ON_FTP'} ||
defined $vars->{'RESTRICTED'})
{ $pkg{$1}{$2}{'restricted'} = 1; }
+ if ($file =~ m:([^/]+)/([^/]+)/Makefile$:)
+ {
+ $cat = $1;
+ $pkgdir = $2;
+ }
+ else
+ { $cat = $pkgdir = 'unknown'; }
+ if ($pkgname !~ /(.*)-(\d.*)/)
+ {
+ print "Cannot extract $pkgname version ($cat/$pkgdir)\n";
+ next;
+ }
+ else
+ {
+ $pkg{$1}{$2}{'dir'} = "$cat/$pkgdir";
+ $pkg{$1}{$2}{'depends'} = $vars->{'DEPENDS'};
+ }
}
return($pkgname, $vars);
}
@@ -634,11 +666,12 @@ sub parse_makefile_vars
{ next; }
my($how, $from, $to, $global) = ($1, $2, $3, $4);
- debug("substitute: $subvar, $how, $from, $to, $global\n");
+ debug("substituteglob: $subvar, $how, $from, $to, $global\n");
if ($how eq 'S') # Limited substitution - keep ^ and $
- { $from =~ s/[?.{}\]\[*+]/\$1/g; }
+ { $from =~ s/([?.{}\]\[*+])/\\$1/g; }
$to =~ s/\\(\d)/\$$1/g; # Change \1 etc to $1
+ debug("substituteperl: $subvar, $how, $from, $to\n");
eval "\$result =~ s/$from/$to/$global";
}
$vars{$key} = $left . $result . $right;
@@ -679,10 +712,13 @@ sub parse_eval_make_false
$_ = (defined($${vars}{$1}) ?1 :0);
$test =~ s/defined\(\S+\)/$_/;
}
- while ( $test =~ /([^\s()]+)\s+==\s+([^\s()]+)/ )
+ while ( $test =~ /([^\s()]+)\s+(!=|==)\s+([^\s()]+)/ )
{
- $_ = ($1 eq $2) ?1 :0;
- $test =~ s/\S+\s+==\s+\S+/$_/;
+ if ($2 eq '==')
+ { $_ = ($1 eq $3) ?1 :0; }
+ else
+ { $_ = ($1 ne $3) ?1 :0; }
+ $test =~ s/\S+\s+(!=|==)\s+\S+/$_/;
}
if ($test !~ /[^\d()\s&|]/ )
{ $false = (eval $test) ?0 :1; }
@@ -752,16 +788,6 @@ sub scan_pkgsrc_makefiles
my($vars);
($pkgname, $vars) =
&parse_makefile_pkgsrc("$pkgsrcdir/$cat/$pkgdir/Makefile");
- if ($pkgname)
- {
- if ($pkgname !~ /(.*)-(\d.*)/)
- {
- print "Cannot extract $pkgname version ($cat/$pkgdir)\n";
- next;
- }
- $pkg{$1}{$2}{'dir'} = "$cat/$pkgdir";
- $pkg{$1}{$2}{'depends'} = $vars->{'DEPENDS'};
- }
}
if (!$opt{'L'})
{ &verbose('.'); }
@@ -774,26 +800,29 @@ sub scan_pkgsrc_makefiles
$len = @categories - length($_);
&verbose("\b"x@categories, $_, ' 'x$len, "\b"x$len, "\n");
}
+ }
- if ($check_depends)
+# Cross reference all depends
+#
+sub pkgsrc_check_depends
+ {
+ my($pkgname);
+ foreach $pkgname (sort keys %pkg)
{
- foreach $pkgname (sort keys %pkg)
+ my($ver);
+ foreach $ver (keys %{$pkg{$pkgname}})
{
- my($ver);
- foreach $ver (keys %{$pkg{$pkgname}})
+ my($err, $msg);
+ defined $pkg{$pkgname}{$ver}{'depends'} || next;
+ foreach (split("\n", $pkg{$pkgname}{$ver}{'depends'}))
{
- my($err, $msg);
- defined $pkg{$pkgname}{$ver}{'depends'} || next;
- foreach (split("\n", $pkg{$pkgname}{$ver}{'depends'}))
+ s/:.*// || next;
+ if (($msg = &invalid_version($_)) )
{
- s/:.*// || next;
- if (($msg = &invalid_version($_)) )
- {
- if (!defined($err))
- { print "$pkgname-$ver DEPENDS errors:\n"; }
- $err = 1;
- print "\t$msg";
- }
+ if (!defined($err))
+ { print "$pkgname-$ver DEPENDS errors:\n"; }
+ $err = 1;
+ print "\t$msg";
}
}
}