| @@ -1,53 +1,59 @@ | | | @@ -1,53 +1,59 @@ |
1 | #!@PERL5@ | | 1 | #!@PERL5@ |
2 | | | 2 | |
3 | # $NetBSD: lintpkgsrc.pl,v 1.22 2022/04/27 22:24:16 rillig Exp $ | | 3 | # $NetBSD: lintpkgsrc.pl,v 1.23 2022/07/29 19:00:36 rillig 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; | | | |
17 | use locale; | | 16 | use locale; |
18 | use strict; | | 17 | use strict; |
| | | 18 | use warnings; |
19 | use Getopt::Std; | | 19 | use Getopt::Std; |
20 | use File::Find; | | 20 | use File::Find; |
21 | use File::Basename; | | 21 | use File::Basename; |
22 | use IPC::Open3; | | 22 | use IPC::Open3; |
23 | use Cwd 'realpath', 'getcwd'; | | 23 | use Cwd 'realpath', 'getcwd'; |
24 | | | 24 | |
25 | # Buildtime configuration | | 25 | # Buildtime configuration |
26 | my $conf_make = '@MAKE@'; | | 26 | my $conf_make = '@MAKE@'; |
27 | my $conf_pkgsrcdir = '@PKGSRCDIR@'; | | 27 | my $conf_pkgsrcdir = '@PKGSRCDIR@'; |
28 | my $conf_prefix = '@PREFIX@'; | | 28 | my $conf_prefix = '@PREFIX@'; |
29 | my $conf_sysconfdir = '@PKG_SYSCONFDIR@'; | | 29 | my $conf_sysconfdir = '@PKG_SYSCONFDIR@'; |
30 | | | 30 | |
31 | my ( | | 31 | my ( |
32 | $pkglist, # list of Pkg packages | | 32 | $pkglist, # list of Pkg packages |
33 | $pkg_installver, # installed version of pkg_install pseudo-pkg | | 33 | $pkg_installver, # installed version of pkg_install pseudo-pkg |
34 | $default_vars, # Set for Makefiles, inc PACKAGES & PKGSRCDIR | | 34 | $default_vars, # Set for Makefiles, inc PACKAGES & PKGSRCDIR |
35 | %opt, # Command line options | | 35 | %opt, # Command line options |
36 | @matched_prebuiltpackages, # List of obsolete prebuilt package paths | | 36 | @matched_prebuiltpackages, # List of obsolete prebuilt package paths |
37 | @prebuilt_pkgdirs, # Use to follow symlinks in prebuilt pkgdirs | | 37 | @prebuilt_pkgdirs, # Use to follow symlinks in prebuilt pkgdirs |
38 | %prebuilt_pkgdir_cache, # To avoid symlink loops in prebuilt_pkgdirs | | 38 | %prebuilt_pkgdir_cache, # To avoid symlink loops in prebuilt_pkgdirs |
39 | ); | | 39 | ); |
40 | | | 40 | |
| | | 41 | sub usage_and_exit(); |
| | | 42 | sub listdir($$); |
| | | 43 | sub get_default_makefile_vars(); |
| | | 44 | sub fail($); |
| | | 45 | sub parse_makefile_pkgsrc($); |
| | | 46 | |
41 | $ENV{PATH} .= | | 47 | $ENV{PATH} .= |
42 | ":/bin:/usr/bin:/sbin:/usr/sbin:${conf_prefix}/sbin:${conf_prefix}/bin"; | | 48 | ":/bin:/usr/bin:/sbin:/usr/sbin:${conf_prefix}/sbin:${conf_prefix}/bin"; |
43 | | | 49 | |
44 | if ( | | 50 | if ( |
45 | !getopts( 'BDE:I:K:LM:OP:RSVdg:himopruyz', \%opt ) | | 51 | !getopts( 'BDE:I:K:LM:OP:RSVdg:himopruyz', \%opt ) |
46 | || $opt{h} | | 52 | || $opt{h} |
47 | || !( | | 53 | || !( |
48 | defined $opt{d} | | 54 | defined $opt{d} |
49 | || defined $opt{g} | | 55 | || defined $opt{g} |
50 | || defined $opt{i} | | 56 | || defined $opt{i} |
51 | || defined $opt{m} | | 57 | || defined $opt{m} |
52 | || defined $opt{o} | | 58 | || defined $opt{o} |
53 | || defined $opt{p} | | 59 | || defined $opt{p} |
| @@ -161,27 +167,27 @@ sub main() { | | | @@ -161,27 +167,27 @@ sub main() { |
161 | $dn =~ s/^(\.\/)*//; | | 167 | $dn =~ s/^(\.\/)*//; |
162 | if (!defined $distfiles{$dn}) | | 168 | if (!defined $distfiles{$dn}) |
163 | { | | 169 | { |
164 | $distfiles{$dn}{name} = $dn; | | 170 | $distfiles{$dn}{name} = $dn; |
165 | push (@pkgdistfiles, $dn); | | 171 | push (@pkgdistfiles, $dn); |
166 | } | | 172 | } |
167 | } | | 173 | } |
168 | } | | 174 | } |
169 | close(DISTINFO); | | 175 | close(DISTINFO); |
170 | } | | 176 | } |
171 | } | | 177 | } |
172 | | | 178 | |
173 | # distfiles downloaded on the current system | | 179 | # distfiles downloaded on the current system |
174 | @tmpdistfiles = listdir("$pkgdistdir"); | | 180 | @tmpdistfiles = listdir("$pkgdistdir", undef); |
175 | foreach my $tmppkg (@tmpdistfiles) | | 181 | foreach my $tmppkg (@tmpdistfiles) |
176 | { | | 182 | { |
177 | if ($tmppkg ne "pkg-vulnerabilities") | | 183 | if ($tmppkg ne "pkg-vulnerabilities") |
178 | { push (@dldistfiles, $tmppkg); } | | 184 | { push (@dldistfiles, $tmppkg); } |
179 | } | | 185 | } |
180 | | | 186 | |
181 | # sort the two arrays to make searching a bit faster | | 187 | # sort the two arrays to make searching a bit faster |
182 | @dldistfiles = sort { $a cmp $b } @dldistfiles; | | 188 | @dldistfiles = sort { $a cmp $b } @dldistfiles; |
183 | @pkgdistfiles = sort { $a cmp $b } @pkgdistfiles; | | 189 | @pkgdistfiles = sort { $a cmp $b } @pkgdistfiles; |
184 | | | 190 | |
185 | if ($opt{y}) | | 191 | if ($opt{y}) |
186 | { | | 192 | { |
187 | # looking for files that are downloaded on the current system | | 193 | # looking for files that are downloaded on the current system |
| @@ -551,29 +557,29 @@ sub deweycmp_extract($$) { | | | @@ -551,29 +557,29 @@ sub deweycmp_extract($$) { |
551 | } | | 557 | } |
552 | while ( !$cmp && ( $i++ <= $len ) ) { | | 558 | while ( !$cmp && ( $i++ <= $len ) ) { |
553 | if ( !@matchlist ) { | | 559 | if ( !@matchlist ) { |
554 | push( @matchlist, 0 ); | | 560 | push( @matchlist, 0 ); |
555 | } | | 561 | } |
556 | if ( !@vallist ) { | | 562 | if ( !@vallist ) { |
557 | push( @vallist, 0 ); | | 563 | push( @vallist, 0 ); |
558 | } | | 564 | } |
559 | $cmp = ( shift @matchlist <=> shift @vallist ); | | 565 | $cmp = ( shift @matchlist <=> shift @vallist ); |
560 | } | | 566 | } |
561 | $cmp; | | 567 | $cmp; |
562 | } | | 568 | } |
563 | | | 569 | |
564 | sub fail(@) { | | 570 | sub fail($) { |
565 | | | 571 | |
566 | print STDERR @_, "\n"; | | 572 | print STDERR shift(), "\n"; |
567 | exit(3); | | 573 | exit(3); |
568 | } | | 574 | } |
569 | | | 575 | |
570 | sub get_default_makefile_vars() { | | 576 | sub get_default_makefile_vars() { |
571 | | | 577 | |
572 | chomp( $pkg_installver = `pkg_info -V 2>/dev/null || echo 20010302` ); | | 578 | chomp( $pkg_installver = `pkg_info -V 2>/dev/null || echo 20010302` ); |
573 | | | 579 | |
574 | chomp( $_ = `uname -srm` ); | | 580 | chomp( $_ = `uname -srm` ); |
575 | ( | | 581 | ( |
576 | $default_vars->{OPSYS}, | | 582 | $default_vars->{OPSYS}, |
577 | $default_vars->{OS_VERSION}, | | 583 | $default_vars->{OS_VERSION}, |
578 | $default_vars->{MACHINE} | | 584 | $default_vars->{MACHINE} |
579 | ) = (split); | | 585 | ) = (split); |