diff options
author | abs <abs> | 2000-09-20 06:39:27 +0000 |
---|---|---|
committer | abs <abs> | 2000-09-20 06:39:27 +0000 |
commit | 4a0e2e10fcb70b9fb289b2d3ea150209031558bd (patch) | |
tree | f79428e3d6ced3d6ed69a47a0dd8028cc6ce4ac6 /pkgtools | |
parent | 21d98dcff5beaabce7712ab5bd39ae01d4ae90b0 (diff) | |
download | pkgsrc-4a0e2e10fcb70b9fb289b2d3ea150209031558bd.tar.gz |
lintpkgsrc:
Rework substitution handling to correctly deal with
${DISTNAME:S/-/-gnome-/:S/$/nb1/} and friends. I remember being
in something of a hurry when that code was fist written. Slight
cleanup to not completely blow up on DEPENDS such as
perl-{5.0*,5.6.0nb2,base-5.[6-9]*}, though we still do not
handle globbing that includes packagename and version.
Update to 2.22
Diffstat (limited to 'pkgtools')
-rw-r--r-- | pkgtools/pkglint/Makefile | 4 | ||||
-rwxr-xr-x | pkgtools/pkglint/files/lintpkgsrc.pl | 62 |
2 files changed, 47 insertions, 19 deletions
diff --git a/pkgtools/pkglint/Makefile b/pkgtools/pkglint/Makefile index 5983ecc5671..0deb3e98121 100644 --- a/pkgtools/pkglint/Makefile +++ b/pkgtools/pkglint/Makefile @@ -1,7 +1,7 @@ -# $NetBSD: Makefile,v 1.59 2000/09/11 10:39:04 abs Exp $ +# $NetBSD: Makefile,v 1.60 2000/09/20 06:39:27 abs Exp $ # -DISTNAME= pkglint-2.21 +DISTNAME= pkglint-2.22 CATEGORIES= pkgtools devel MASTER_SITES= # empty DISTFILES= # empty diff --git a/pkgtools/pkglint/files/lintpkgsrc.pl b/pkgtools/pkglint/files/lintpkgsrc.pl index 8ee84c948b1..d70a9224abc 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.30 2000/09/11 10:39:05 abs Exp $ +# $NetBSD: lintpkgsrc.pl,v 1.31 2000/09/20 06:39:28 abs Exp $ # Written by David Brownlee <abs@netbsd.org>. # @@ -349,12 +349,22 @@ sub glob2regex elsif ($_ eq '{' ) { $regex .= '('; $in_alt = 1; } elsif ($_ eq '}' ) - { $regex .= ')'; $in_alt = 0; } + { + if (!$in_alt) + { print "Warning - mismatched glob '$glob' -> '$regex'\n"; } + else + { $regex .= ')'; $in_alt = 0; } + } elsif ($_ eq ',' && $in_alt) { $regex .= '|'; } else { $regex .= $_; } } + if ($in_alt) + { + print "Warning - mismatched glob '$glob' -> '$regex'\n"; + $regex .= ')'; + } $regex .= '$'; $regex; } @@ -455,9 +465,7 @@ sub parse_makefile_pkgsrc { if ( $pkgname =~ /\$/ ) { print "\rBogus: $pkgname (from $file)\n"; } - elsif ($pkgname !~ /(.*)-(\d.*)/) - { print "Cannot extract $pkgname version ($file)\n"; } - else + elsif ($pkgname =~ /(.*)-(\d.*)/) { if (defined $vars->{'NO_BIN_ON_FTP'} || defined $vars->{'RESTRICTED'}) @@ -594,7 +602,7 @@ sub parse_makefile_vars for ($loop = 1 ; $loop ;) { $loop = 0; - foreach $key ( keys %vars ) + foreach $key (keys %vars) { if ( index($vars{$key}, '$') == -1 ) { next; } @@ -604,23 +612,43 @@ sub parse_makefile_vars $vars{$key} = $_; $loop = 1; } - elsif ($vars{$key} =~ m#\${(\w+):([CS])/([^/]+)/([^/]*)/(g?)}#) + elsif ($vars{$key} =~ m#\${(\w+):([CS]/[^{}/]+/[^{}/]*/g?(|:[^{}]+))}#) { - my($var, $how, $from, $to, $global) = ($1, $2, $3, $4, $5); + my($left, $subvar, $right) = ($`, $1, $'); + my(@patterns) = split(':', $2); + my($result); - # If $vars{$var} contains a $ skip it on this pass. - # Hopefully it will get subtituted and we can catch it + $result = $vars{$subvar}; + $result ||= ''; + + # If $vars{$subvar} contains a $ skip it on this pass. + # Hopefully it will get substituted and we can catch it # next time around. - if (defined($vars{$var}) && index($vars{$var}, '$') == -1 ) + if (index($result, '${') != -1) + { next; } + + debug("substitutelist: $key ($result) $subvar (@patterns)\n"); + foreach (@patterns) { + if (! m#([CS])/([^/]+)/([^/]*)/(g?)#) + { next; } + + my($how, $from, $to, $global) = ($1, $2, $3, $4); + debug("substitute: $subvar, $how, $from, $to, $global\n"); + if ($how eq 'S') - { $from =~ s/\./\\./g; } # Change . etc to \\. - $to =~ s/\\(\d)/\$$1/g; # Change \1 etc to $1 - $_ = $vars{$var}; - eval "s/$from/$to/$global"; - if ($vars{$key} =~ s#\${$var:[CS]/[^/]+/[^/]*/$global}#$_#) - { $loop = 1; } + { + if (($_ = index($result, $from)) != -1) + { substr($result, $_, length($from), $to); } + } + else + { + $to =~ s/\\(\d)/\$$1/g; # Change \1 etc to $1 + eval "\$result =~ s/$from/$to/$global"; + } } + $vars{$key} = $left . $result . $right; + $loop = 1; } } } |