pkgsrc-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[pkgsrc/trunk]: pkgsrc Update pkglint 3.84



details:   https://anonhg.NetBSD.org/pkgsrc/rev/2aee96b2463e
branches:  trunk
changeset: 477402:2aee96b2463e
user:      abs <abs%pkgsrc.org@localhost>
date:      Thu Jul 01 20:14:58 2004 +0000

description:
Update pkglint 3.84
    Parse Make .{if,endif,else,elif,include} directives which
    contain a space between the . and the directive. Fix an include
    path issue which this threw up. Now 'lintpkgsrc -d' correctly
    extracts the PKGNAMEs for the gcc3 packages.
    It still doesn't understand 'dewey' versions with alpha chars, or
    some of the more interesting makefile constructs, but it looks closer
    to reality.

diffstat:

 doc/CHANGES                          |   4 +-
 pkgtools/pkglint/Makefile            |   4 +-
 pkgtools/pkglint/files/lintpkgsrc.pl |  99 ++++++++++++++++++++----------------
 3 files changed, 60 insertions(+), 47 deletions(-)

diffs (231 lines):

diff -r e6f2608f14dd -r 2aee96b2463e doc/CHANGES
--- a/doc/CHANGES       Thu Jul 01 19:05:56 2004 +0000
+++ b/doc/CHANGES       Thu Jul 01 20:14:58 2004 +0000
@@ -1,4 +1,4 @@
-$NetBSD: CHANGES,v 1.6416 2004/07/01 17:15:33 adrianp Exp $
+$NetBSD: CHANGES,v 1.6417 2004/07/01 20:15:28 abs Exp $
 
 Changes to the packages collection and infrastructure in 2004:
 
@@ -3204,3 +3204,5 @@
        Updated wmi to 8nb1 [seb 2004-07-01]
        Updated liferea to 0.5.1 [minskim 2004-07-01]
        Updated snort to 2.1.3 [adrianp 2004-07-01]
+       Update pkglint to 3.84 [abs 2004-07-01]
+
diff -r e6f2608f14dd -r 2aee96b2463e pkgtools/pkglint/Makefile
--- a/pkgtools/pkglint/Makefile Thu Jul 01 19:05:56 2004 +0000
+++ b/pkgtools/pkglint/Makefile Thu Jul 01 20:14:58 2004 +0000
@@ -1,7 +1,7 @@
-# $NetBSD: Makefile,v 1.196 2004/06/30 18:49:36 hubertf Exp $
+# $NetBSD: Makefile,v 1.197 2004/07/01 20:14:58 abs Exp $
 #
 
-DISTNAME=      pkglint-3.83
+DISTNAME=      pkglint-3.84
 CATEGORIES=    pkgtools devel
 MASTER_SITES=  # empty
 DISTFILES=     # empty
diff -r e6f2608f14dd -r 2aee96b2463e pkgtools/pkglint/files/lintpkgsrc.pl
--- a/pkgtools/pkglint/files/lintpkgsrc.pl      Thu Jul 01 19:05:56 2004 +0000
+++ b/pkgtools/pkglint/files/lintpkgsrc.pl      Thu Jul 01 20:14:58 2004 +0000
@@ -1,6 +1,6 @@
 #!@PERL@
 
-# $NetBSD: lintpkgsrc.pl,v 1.91 2004/06/28 09:55:44 abs Exp $
+# $NetBSD: lintpkgsrc.pl,v 1.92 2004/07/01 20:14:58 abs Exp $
 
 # Written by David Brownlee <abs%netbsd.org@localhost>.
 #
@@ -61,8 +61,8 @@
        print "$file -> $pkgname\n";
        foreach my $varname (sort keys %{$vars})
            { print "\t$varname = $vars->{$varname}\n"; }
-       if ($opt{d})
-           { pkgsrc_check_depends(); }
+#      if ($opt{d})
+#          { pkgsrc_check_depends(); }
        }
     exit;
     }
@@ -764,6 +764,7 @@
            if ($pkglist)
                {
                my($pkgver) = $pkglist->add($1, $2);
+               debug("add $1 $2\n");
 
                foreach my $var (qw(DEPENDS RESTRICTED OSVERSION_SPECIFIC BROKEN))
                    { $pkgver->var($var, $vars->{$var}); }
@@ -789,8 +790,9 @@
 sub parse_makefile_vars
     {
     my($file, $cwd) = @_;
-    my($CURDIR, $NEWCURDIR, $pkgname, %vars, $plus, $value, @data,
-       %incfiles,
+    my($pkgname, %vars, $plus, $value, @data,
+       %incfiles,      # Cache of previously included fils
+       %incdirs,       # Directories in which to check for includes
        @if_false); # 0:true 1:false 2:nested-false&nomore-elsif
 
     if (! open(FILE, $file))
@@ -811,7 +813,7 @@
        { $vars{'.CURDIR'} = $1; }
     else
        { $vars{'.CURDIR'} = getcwd; }
-    $CURDIR = $vars{'.CURDIR'};
+    $incdirs{$vars{'.CURDIR'}} = 1;
     if ($opt{L})
        { print "$file\n"; }
 
@@ -826,7 +828,7 @@
 
        # Conditionals
        #
-       if (m#^\.if(|def|ndef)\s+(.*)#)
+       if (m#^\.\s*if(|def|ndef)\s+(.*)#)
            {
            my($type, $false);
 
@@ -842,82 +844,91 @@
                    { $false = ! $false ; }
                push(@if_false, $false ?1 :0);
                }
-           debug("$file: .if$type (@if_false)\n");
+           debug("$file: .if$type (! @if_false)\n");
            next;
            }
-       if (m#^\.elif\s+(.*)# && @if_false)
+       if (m#^\.\s*elif\s+(.*)# && @if_false)
            {
            if ($if_false[$#if_false] == 0)
                { $if_false[$#if_false] = 2; }
            elsif ($if_false[$#if_false] == 1 &&
                    ! parse_eval_make_false($1, \%vars) )
                { $if_false[$#if_false] = 0; }
-           debug("$file: .elif (@if_false)\n");
+           debug("$file: .elif (! @if_false)\n");
            next;
            }
-       if (m#^\.else\b# && @if_false)
+       if (m#^\.\s*else\b# && @if_false)
            {
            $if_false[$#if_false] = $if_false[$#if_false] == 1?0:1;
-           debug("$file: .else (@if_false)\n");
+           debug("$file: .else (! @if_false)\n");
            next;
            }
-       if (m#^\.endif\b#)
+       if (m#^\.\s*endif\b#)
            {
            pop(@if_false);
-           debug("$file: .endif (@if_false)\n");
+           debug("$file: .endif (! @if_false)\n");
            next;
            }
 
         $if_false[$#if_false] && next;
 
-       # for getting the path for .includes right
-       if (m#__CURDIR__=#)
-           {
-           s/__CURDIR__=//;
-           $CURDIR = $_;
-           next;
-           }
        # Included files (just unshift onto @data)
        #
-       if (m#^\.include\s+"([^"]+)"#)
+       if (m#^\.\s*include\s+"([^"]+)"#)
            {
-           $_ = $1;
-           debug("$file: .include \"$_\"\n");
-           if (m#/mk/bsd# || (!$opt{d} && m#/(buildlink[^/]*\.mk)#))
-               { debug("$file: .include skipped\n"); }
+           my($incfile) = parse_expand_vars($1, \%vars);
+           # At this point just skip any includes which we were not able to
+           # fully expand
+           if ($incfile =~ m#/mk/bsd# || $incfile =~ /$magic_undefined/ ||
+                   (!$opt{d} && $incfile =~ m#/(buildlink[^/]*\.mk)#))
+               { debug("$file: .include \"$incfile\" skipped\n"); }
            else
                {
-               my($incfile) = $_;
+               debug("$file: .include \"$incfile\"\n");
 
                # Expand any simple vars in $incfile
                #
-               $incfile = parse_expand_vars($incfile, \%vars);
 
                if (substr($incfile, 0, 1) ne '/')
-                   { $incfile = "$CURDIR/$incfile"; }
+                   {
+                   foreach my $dir (keys %incdirs)
+                       {
+                       if (-f "$dir/$incfile")
+                           { $incfile = "$dir/$incfile"; last; }
+                       }
+                   }
 
                # perl 5.6.1 realpath() cannot handle files, only directories
                # If the last component is a symlink this will give a false
                # negative, but that is not a problem as the duplicate check
                # is for performance
                 $incfile =~ m#^(.+)(/[^/]+)$#;
-               $incfile = realpath($1).$2;
 
-               if (!$incfiles{$incfile})
+               if (! -f $incfile)
+                   {
+                   verbose("Cannot locate '$incfile' (from $file): $_\n");
+                   }
+               else
                    {
-                   if ($opt{L})
-                       { print "inc $incfile\n"; }
-                   $incfiles{$incfile} = 1;
-                   $NEWCURDIR = $incfile;
-                   $NEWCURDIR =~ s#/[^/]*$##;
-                   if (!open(FILE, $incfile))
-                       { verbose("Cannot open '$incfile' (from $file): $!\n");}
-                   else
+                   $incfile = realpath($1).$2;
+
+                   if (!$incfiles{$incfile})
                        {
-                       unshift(@data, "__CURDIR__=$CURDIR");
-                       unshift(@data, map {chomp; $_} <FILE>);
-                       unshift(@data, "__CURDIR__=$NEWCURDIR");
-                       close(FILE);
+                       if ($opt{L})
+                           { print "inc $incfile\n"; }
+                       $incfiles{$incfile} = 1;
+                       if (!open(FILE, $incfile))
+                           { verbose("Cannot open '$incfile' (from $file): $_ $!\n");}
+                       else
+                           {
+                           my $NEWCURDIR = $incfile;
+                           $NEWCURDIR =~ s#/[^/]*$##;
+                           $incdirs{$NEWCURDIR} = 1;
+                           unshift(@data, ".CURDIR=$vars{'.CURDIR'}");
+                           unshift(@data, map {chomp; $_} <FILE>);
+                           unshift(@data, ".CURDIR=$NEWCURDIR");
+                           close(FILE);
+                           }
                        }
                    }
                }
@@ -930,13 +941,13 @@
            $key = $1;
            $plus = $2;
            $value = $3;
-           debug("assignment: $key$plus=[$value]\n");
            if ($plus eq ':')
                { $vars{$key} = parse_expand_vars($value, \%vars); }
            elsif ($plus eq '+' && defined $vars{$key} )
                { $vars{$key} .= " $value"; }
            elsif ($plus ne '?' || !defined $vars{$key} )
                { $vars{$key} = $value; }
+           debug("assignment: $key$plus=[$value] ($vars{$key})\n");
 
            # Give python a little hand (XXX - do we wanna consider actually
            # implementing make .for loops, etc?



Home | Main Index | Thread Index | Old Index