| @@ -1,16 +1,16 @@ | | | @@ -1,16 +1,16 @@ |
1 | #! @PERL@ | | 1 | #! @PERL@ |
2 | | | 2 | |
3 | # $NetBSD: lintpkgsrc.pl,v 1.1 2012/07/13 21:12:07 abs Exp $ | | 3 | # $NetBSD: lintpkgsrc.pl,v 1.2 2012/09/09 15:47:35 mspo Exp $ |
4 | | | 4 | |
5 | # Written by David Brownlee <abs@netbsd.org>. | | 5 | # Written by David Brownlee <abs@netbsd.org>. |
6 | # | | 6 | # |
7 | # Caveats: | | 7 | # Caveats: |
8 | # The 'Makefile parsing' algorithm used to obtain package versions and | | 8 | # The 'Makefile parsing' algorithm used to obtain package versions and |
9 | # DEPENDS information is geared towards speed rather than perfection, | | 9 | # DEPENDS information is geared towards speed rather than perfection, |
10 | # though it has gotten somewhat better over time, it only parses the | | 10 | # though it has gotten somewhat better over time, it only parses the |
11 | # simpler Makefile conditionals. | | 11 | # simpler Makefile conditionals. |
12 | # | | 12 | # |
13 | # TODO: Handle fun DEPENDS like avifile-devel with | | 13 | # TODO: Handle fun DEPENDS like avifile-devel with |
14 | # {qt2-designer>=2.2.4,qt2-designer-kde>=2.3.1nb1} | | 14 | # {qt2-designer>=2.2.4,qt2-designer-kde>=2.3.1nb1} |
15 | | | 15 | |
16 | $^W = 1; | | 16 | $^W = 1; |
| @@ -591,26 +591,28 @@ sub invalid_version($) { | | | @@ -591,26 +591,28 @@ sub invalid_version($) { |
591 | } | | 591 | } |
592 | else { | | 592 | else { |
593 | | | 593 | |
594 | # If we find one match, don't bitch about others | | 594 | # If we find one match, don't bitch about others |
595 | $ok = 1; | | 595 | $ok = 1; |
596 | } | | 596 | } |
597 | } | | 597 | } |
598 | $ok && ( $fail = undef ); | | 598 | $ok && ( $fail = undef ); |
599 | $fail; | | 599 | $fail; |
600 | } | | 600 | } |
601 | | | 601 | |
602 | # List (recursive) non directory contents of specified directory | | 602 | # List (recursive) non directory contents of specified directory |
603 | # | | 603 | # |
| | | 604 | #TODO this entire sub should be replaced with direct calls to |
| | | 605 | # File::Find |
604 | sub listdir($$) { | | 606 | sub listdir($$) { |
605 | my ( $base, $dir ) = @_; | | 607 | my ( $base, $dir ) = @_; |
606 | my ($thisdir); | | 608 | my ($thisdir); |
607 | my ( @list, @thislist ); | | 609 | my ( @list, @thislist ); |
608 | | | 610 | |
609 | $thisdir = $base; | | 611 | $thisdir = $base; |
610 | if ( defined($dir) ) { | | 612 | if ( defined($dir) ) { |
611 | $thisdir .= "/$dir"; | | 613 | $thisdir .= "/$dir"; |
612 | $dir .= '/'; | | 614 | $dir .= '/'; |
613 | } | | 615 | } |
614 | else { | | 616 | else { |
615 | $dir = ''; | | 617 | $dir = ''; |
616 | } | | 618 | } |
| @@ -1496,39 +1498,58 @@ sub scan_pkgsrc_distfiles_vs_distinfo($$ | | | @@ -1496,39 +1498,58 @@ sub scan_pkgsrc_distfiles_vs_distinfo($$ |
1496 | close(DISTINFO); | | 1498 | close(DISTINFO); |
1497 | } | | 1499 | } |
1498 | } | | 1500 | } |
1499 | verbose('.'); | | 1501 | verbose('.'); |
1500 | } | | 1502 | } |
1501 | verbose(" ($numpkg packages)\n"); | | 1503 | verbose(" ($numpkg packages)\n"); |
1502 | | | 1504 | |
1503 | # Do not mark the vulnerabilities file as unknown | | 1505 | # Do not mark the vulnerabilities file as unknown |
1504 | $distfiles{'pkg-vulnerabilities'} = { | | 1506 | $distfiles{'pkg-vulnerabilities'} = { |
1505 | path => 'pkg-vulnerabilities', | | 1507 | path => 'pkg-vulnerabilities', |
1506 | sum => 'IGNORE' | | 1508 | sum => 'IGNORE' |
1507 | }; | | 1509 | }; |
1508 | | | 1510 | |
1509 | foreach my $file ( listdir( "$pkgdistdir", undef ) ) { | | 1511 | # bad for memory |
1510 | my ($dist); | | 1512 | # foreach my $file ( listdir( "$pkgdistdir", undef ) ) { |
1511 | | | 1513 | # my ($dist); |
1512 | if ( !defined( $dist = $distfiles{$file} ) ) { | | 1514 | # |
1513 | $bad_distfiles{$file} = 1; | | 1515 | # if ( !defined( $dist = $distfiles{$file} ) ) { |
1514 | | | 1516 | # $bad_distfiles{$file} = 1; |
1515 | } | | 1517 | # |
1516 | else { | | 1518 | # } |
1517 | if ( $dist->{sum} ne 'IGNORE' ) { | | 1519 | # else { |
1518 | push( @{ $sumfiles{ $dist->{sumtype} } }, $file ); | | 1520 | # if ( $dist->{sum} ne 'IGNORE' ) { |
| | | 1521 | # push( @{ $sumfiles{ $dist->{sumtype} } }, $file ); |
| | | 1522 | # } |
| | | 1523 | # } |
| | | 1524 | # } |
| | | 1525 | # check each file in $pkgdistdir |
| | | 1526 | find ( { wanted => sub { |
| | | 1527 | my ($dist); |
| | | 1528 | if ( -f $File::Find::name ) |
| | | 1529 | { |
| | | 1530 | my $distn = $File::Find::name; |
| | | 1531 | $distn =~ s/$pkgdistdir\/?//g; |
| | | 1532 | if ( !defined ($dist = $distfiles{$distn} ) ) { |
| | | 1533 | $bad_distfiles{$distn} = 1; |
| | | 1534 | } |
| | | 1535 | else { |
| | | 1536 | if ( $dist->{sum} ne 'IGNORE' ) { |
| | | 1537 | push( @{ $sumfiles{ $dist->{sumtype} } }, $distn ); |
| | | 1538 | } |
| | | 1539 | } |
1519 | } | | 1540 | } |
1520 | } | | 1541 | } }, |
1521 | } | | 1542 | ($pkgdistdir) ); |
1522 | | | 1543 | |
1523 | if ( $check_unref && %bad_distfiles ) { | | 1544 | if ( $check_unref && %bad_distfiles ) { |
1524 | verbose( scalar( keys %bad_distfiles ), | | 1545 | verbose( scalar( keys %bad_distfiles ), |
1525 | " unreferenced file(s) in '$pkgdistdir':\n" ); | | 1546 | " unreferenced file(s) in '$pkgdistdir':\n" ); |
1526 | print join( "\n", sort keys %bad_distfiles ), "\n"; | | 1547 | print join( "\n", sort keys %bad_distfiles ), "\n"; |
1527 | } | | 1548 | } |
1528 | | | 1549 | |
1529 | if ($check_distinfo) { | | 1550 | if ($check_distinfo) { |
1530 | if (@distwarn) { | | 1551 | if (@distwarn) { |
1531 | verbose(@distwarn); | | 1552 | verbose(@distwarn); |
1532 | } | | 1553 | } |
1533 | | | 1554 | |
1534 | verbose("checksum mismatches\n"); | | 1555 | verbose("checksum mismatches\n"); |