Update to pkglint-2.31

lintpkgsrc changes:
Add '-S' - List packages not in category 'SUBDIRS', rename experimental '-S'
to '-c'. Rework -h output to group by type. Fix poblem with handling certain
glob expressions for depends, clean up manpage.
This commit is contained in:
abs 2000-11-17 12:45:30 +00:00
parent 9ad61bf074
commit 8a657f9272
3 changed files with 121 additions and 62 deletions

View file

@ -1,7 +1,7 @@
# $NetBSD: Makefile,v 1.68 2000/11/14 17:11:42 abs Exp $ # $NetBSD: Makefile,v 1.69 2000/11/17 12:45:30 abs Exp $
# #
DISTNAME= pkglint-2.30 DISTNAME= pkglint-2.31
CATEGORIES= pkgtools devel CATEGORIES= pkgtools devel
MASTER_SITES= # empty MASTER_SITES= # empty
DISTFILES= # empty DISTFILES= # empty

View file

@ -1,4 +1,4 @@
.\" $NetBSD: lintpkgsrc.1,v 1.13 2000/11/14 17:11:43 abs Exp $ .\" $NetBSD: lintpkgsrc.1,v 1.14 2000/11/17 12:45:31 abs Exp $
.\" .\"
.\" Copyright (c) 1999 by David Brownlee (abs@netbsd.org) .\" Copyright (c) 1999 by David Brownlee (abs@netbsd.org)
.\" Absolutely no warranty. .\" Absolutely no warranty.
@ -10,12 +10,12 @@
.Nd a verifier for the pkgsrc tree .Nd a verifier for the pkgsrc tree
.Sh SYNOPSIS .Sh SYNOPSIS
.Nm .Nm
.Op Fl BLRdhilmor .Op Fl BDLRSVdhilmopru
.Op Fl D Ar paths
.Op Fl K Ar PACKAGES .Op Fl K Ar PACKAGES
.Op Fl M Ar distdir .Op Fl M Ar DISTDIR
.Op Fl P Ar PKGSRCDIR .Op Fl P Ar PKGSRCDIR
.Op Fl S Ar pkgsrcmap .Op Fl g Ar pkgsrcmap
.Op Pa makefile ...
.Sh DESCRIPTION .Sh DESCRIPTION
.Nm .Nm
tries to verify the entire contents of the pkgsrc tree. tries to verify the entire contents of the pkgsrc tree.
@ -34,10 +34,27 @@ Parse Makefiles and output contents (Useful for debugging).
Override binary packages base directory, normally set from Override binary packages base directory, normally set from
.Pa /etc/mk.conf .Pa /etc/mk.conf
or defaulted to PKGSRCDIR/packages. or defaulted to PKGSRCDIR/packages.
.Pp
Note: lintpkgsrc treats
.Em PACKAGES
slightly differently to the pkgsrc build system. -p, -R and -V check for
binary packages in any depth of PACKAGES subdirs - this allows packages for all
architectures/OS versions to be checked simultaneously with an
.Pa /etc/mk.conf
construct of the form:
.Bd -literal
\&.ifdef LINTPKGSRC
PACKAGES=${PKGSRCDIR}/packages
\&.else
PACKAGES=${PKGSRCDIR}/packages/${OS_VERSION}/${MACHINE_ARCH}
\&.endif
.Pp
Which would be an alternative to -K.
.Ed
.It Fl L .It Fl L
List the filenames of Makefiles as they are parsed (for debugging). List the filenames of Makefiles as they are parsed (for debugging).
.It Fl M Ar distdir .It Fl M Ar DISTDIR
Set directory for distfiles, otherwise PKGSRCDIR/distfiles is used. Set directory for distfiles, defaults to PKGSRCDIR/distfiles.
.It Fl P Ar PKGSRCDIR .It Fl P Ar PKGSRCDIR
Set base of pkgsrc tree, normally set from Set base of pkgsrc tree, normally set from
.Pa /etc/mk.conf .Pa /etc/mk.conf
@ -51,8 +68,10 @@ for whom the source Makefile lists
or or
.Em RESTRICTED . .Em RESTRICTED .
This is intended to help those making binary packages available for ftp. This is intended to help those making binary packages available for ftp.
.It Fl S Ar pkgsrcmap .It Fl S
Output map of 'pkgname pkgdir pkgver' List packages missing from category
.Em SUBDIR
lists.
.It Fl V .It Fl V
List any prebuilt packages in any subdirs of List any prebuilt packages in any subdirs of
.Em PACKAGES .Em PACKAGES
@ -62,6 +81,9 @@ PKGSRCDIR/distfiles/vulnerabilities .
Extract the 'DEPENDS' listing from each pkgsrc package Makefile, then Extract the 'DEPENDS' listing from each pkgsrc package Makefile, then
verify the version specified in each DEPEND correctly matches a current verify the version specified in each DEPEND correctly matches a current
pkgsrc package. pkgsrc package.
.It Fl g Ar pkgsrcmap
Generate pkgsrcmap file containing an entry for each package of
'pkgname pkgdir pkgver'.
.It Fl h .It Fl h
Basic help and usage. Basic help and usage.
.It Fl i .It Fl i
@ -83,6 +105,11 @@ Remove distfiles which are not referenced from any package's md5 file,
or have an incorrect checksum (usually due to an interrupted download), or have an incorrect checksum (usually due to an interrupted download),
and any old binary packages. To remove any given type, additionally and any old binary packages. To remove any given type, additionally
specify the -o, -m, or -p flags respectively. specify the -o, -m, or -p flags respectively.
.It Fl u
For each package current installed, run 'make fetch-list | sh' to ensure
all the distfiles needed for the latest version are present.
.Pp
Warning: The behaviour of this command may change in a later version.
.El .El
.Sh AUTHOR .Sh AUTHOR
David Brownlee <abs@netbsd.org> David Brownlee <abs@netbsd.org>
@ -106,7 +133,7 @@ or set conditionally in
based on the value of based on the value of
.Em LINTPKGSRC . .Em LINTPKGSRC .
.Sh BUGS .Sh BUGS
The 'Makefile parsing' algorithym used to obtain package versions The 'Makefile parsing' algorithm used to obtain package versions
and DEPENDS information is geared towards speed rather than and DEPENDS information is geared towards speed rather than
perfection, though it has got somewhat better over time, it only perfection, though it has got somewhat better over time, it only
parses the simplest Makefile conditionals. (a == b, no && etc). parses the simplest Makefile conditionals. (a == b, no && etc).

View file

@ -1,6 +1,6 @@
#!/usr/bin/env perl #!/usr/bin/env perl
# $NetBSD: lintpkgsrc.pl,v 1.39 2000/11/14 17:11:43 abs Exp $ # $NetBSD: lintpkgsrc.pl,v 1.40 2000/11/17 12:45:31 abs Exp $
# Written by David Brownlee <abs@netbsd.org>. # Written by David Brownlee <abs@netbsd.org>.
# #
@ -17,8 +17,7 @@ $^W = 1;
use strict; use strict;
use Getopt::Std; use Getopt::Std;
use File::Find; use File::Find;
my( $pkgdistdir, # Distfiles directory my( %pkg, # {$ver} ->{restricted} ->{dir} ->{BROKEN}
%pkg, # {$ver} ->{restricted} ->{dir} ->{BROKEN}
$default_vars, # Set for Makefiles, inc PACKAGES & PKGSRCDIR $default_vars, # Set for Makefiles, inc PACKAGES & PKGSRCDIR
%opt, # Command line options %opt, # Command line options
%vuln, # vulnerability data %vuln, # vulnerability data
@ -28,12 +27,12 @@ my( $pkgdistdir, # Distfiles directory
$ENV{PATH} .= ':/usr/sbin'; $ENV{PATH} .= ':/usr/sbin';
if (! &getopts('BS:VDK:LM:P:Rdhilmopru', \%opt) || $opt{'h'} || if (! &getopts('BDK:LM:P:RSVdg:hilmopru', \%opt) || $opt{'h'} ||
! ( defined($opt{'d'}) || defined($opt{'i'}) || defined($opt{'l'}) || ! ( defined($opt{'d'}) || defined($opt{'g'}) || defined($opt{'i'}) ||
defined($opt{'m'}) || defined($opt{'o'}) || defined($opt{'p'}) || defined($opt{'l'}) || defined($opt{'m'}) || defined($opt{'o'}) ||
defined($opt{'r'}) || defined($opt{'u'}) || defined($opt{'B'}) || defined($opt{'p'}) || defined($opt{'r'}) || defined($opt{'u'}) ||
defined($opt{'D'}) || defined($opt{'S'}) || defined($opt{'V'}) || defined($opt{'B'}) || defined($opt{'D'}) || defined($opt{'R'}) ||
defined($opt{'R'}) )) defined($opt{'S'}) || defined($opt{'V'}) ))
{ &usage_and_exit; } { &usage_and_exit; }
$| = 1; $| = 1;
@ -61,24 +60,19 @@ if ($opt{'D'} && @ARGV)
# main # main
{ {
my($pkglint_flags, $pkgsrcdir); my($pkglint_flags, $pkgsrcdir, $pkgdistdir);
$pkgsrcdir = $default_vars->{'PKGSRCDIR'}; $pkgsrcdir = $default_vars->{'PKGSRCDIR'};
$pkgdistdir = $default_vars->{'DISTDIR'};
$pkglint_flags = '-v'; $pkglint_flags = '-v';
if ($opt{'M'})
{ $pkgdistdir = $opt{'M'}; } # override distfile dir
else
{ $pkgdistdir = "$pkgsrcdir/distfiles"; } # default
if ($opt{'r'} && !$opt{'o'} && !$opt{'m'} && !$opt{'p'}) if ($opt{'r'} && !$opt{'o'} && !$opt{'m'} && !$opt{'p'})
{ $opt{'o'} = $opt{'m'} = $opt{'p'} = 1; } { $opt{'o'} = $opt{'m'} = $opt{'p'} = 1; }
if ($opt{'o'} || $opt{'m'}) if ($opt{'o'} || $opt{'m'})
{ {
my(@baddist); my(@baddist);
@baddist = &scan_pkgsrc_distfiles_vs_md5($pkgsrcdir, @baddist = &scan_pkgsrc_distfiles_vs_md5($pkgsrcdir, $pkgdistdir,
$opt{'o'}, $opt{'m'}); $opt{'o'}, $opt{'m'});
if ($opt{'r'}) if ($opt{'r'})
{ {
@ -135,10 +129,34 @@ if ($opt{'D'} && @ARGV)
} }
if ($opt{'S'}) if ($opt{'S'})
{
my($cat, %in_subdir, $pkgname, $ver);
foreach $cat (&list_pkgsrc_categories($pkgsrcdir))
{
my($vars) = parse_makefile_vars("$pkgsrcdir/$cat/Makefile");
if (! $vars->{'SUBDIR'})
{ print "Warning - no SUBDIR for $cat\n"; next; }
foreach (split(/\s+/, $vars->{'SUBDIR'}))
{ $in_subdir{"$cat/$_"} = 1; }
}
&scan_pkgsrc_makefiles($pkgsrcdir);
foreach $pkgname (sort keys %pkg)
{ # Print highest number first
foreach $ver (reverse sort keys %{$pkg{$pkgname}})
{
if (!defined $in_subdir{$pkg{$pkgname}{$ver}{'dir'}})
{ print "$pkg{$pkgname}{$ver}{'dir'}: Not in SUBDIR\n"; }
}
}
}
if ($opt{'g'})
{ {
my($pkgname, $ver, $tmpfile); my($pkgname, $ver, $tmpfile);
$tmpfile = "$opt{'S'}.tmp.$$"; $tmpfile = "$opt{'g'}.tmp.$$";
&scan_pkgsrc_makefiles($pkgsrcdir); &scan_pkgsrc_makefiles($pkgsrcdir);
if (!open(TABLE, ">$tmpfile")) if (!open(TABLE, ">$tmpfile"))
@ -150,9 +168,10 @@ if ($opt{'D'} && @ARGV)
} }
if (!close(TABLE)) if (!close(TABLE))
{ &fail("Error while writing '$tmpfile': $!"); } { &fail("Error while writing '$tmpfile': $!"); }
if (!rename($tmpfile, $opt{'S'})) if (!rename($tmpfile, $opt{'g'}))
{ &fail("Error in rename('$tmpfile','$opt{'S'}'): $!"); } { &fail("Error in rename('$tmpfile','$opt{'g'}'): $!"); }
} }
if ($opt{'d'}) if ($opt{'d'})
{ {
&scan_pkgsrc_makefiles($pkgsrcdir); &scan_pkgsrc_makefiles($pkgsrcdir);
@ -323,6 +342,10 @@ sub get_default_makefile_vars
if ($opt{'P'}) if ($opt{'P'})
{ $default_vars->{'PKGSRCDIR'} = $opt{'P'}; } { $default_vars->{'PKGSRCDIR'} = $opt{'P'}; }
if ($opt{'M'})
{ $default_vars->{'DISTDIR'} = $opt{'M'}; }
$default_vars->{'DISTDIR'} ||= $default_vars->{'PKGSRCDIR'}.'/distfiles';
if ($opt{'K'}) if ($opt{'K'})
{ $default_vars->{'PACKAGES'} = $opt{'K'}; } { $default_vars->{'PACKAGES'} = $opt{'K'}; }
$default_vars->{'PACKAGES'} ||= $default_vars->{'PKGSRCDIR'}.'/packages'; $default_vars->{'PACKAGES'} ||= $default_vars->{'PKGSRCDIR'}.'/packages';
@ -437,13 +460,13 @@ sub glob2regex
elsif ($_ eq '.' || $_ eq '|' ) elsif ($_ eq '.' || $_ eq '|' )
{ $regex .= quotemeta; } { $regex .= quotemeta; }
elsif ($_ eq '{' ) elsif ($_ eq '{' )
{ $regex .= '('; $in_alt = 1; } { $regex .= '('; ++$in_alt; }
elsif ($_ eq '}' ) elsif ($_ eq '}' )
{ {
if (!$in_alt) # Error if (!$in_alt) # Error
{ return undef; } { return undef; }
$regex .= ')'; $regex .= ')';
$in_alt = 0; --$in_alt;
} }
elsif ($_ eq ',' && $in_alt) elsif ($_ eq ',' && $in_alt)
{ $regex .= '|'; } { $regex .= '|'; }
@ -454,6 +477,8 @@ sub glob2regex
{ return undef; } { return undef; }
if ($regex eq $glob) if ($regex eq $glob)
{ return(''); } { return(''); }
if ($opt{'D'})
{ print "glob2regex: $glob -> $regex\n"; }
'^'.$regex.'$'; '^'.$regex.'$';
} }
@ -502,14 +527,17 @@ sub package_globmatch
foreach $pkgname (sort keys %pkg) foreach $pkgname (sort keys %pkg)
{ ($pkgname =~ /$regex/) && push(@pkgnames, $pkgname); } { ($pkgname =~ /$regex/) && push(@pkgnames, $pkgname); }
} }
# Try to convert $matchver into regex version
#
$regex = glob2regex($matchver);
foreach $pkgname (@pkgnames) foreach $pkgname (@pkgnames)
{ {
if (defined $pkg{$pkgname}{$matchver}) if (defined $pkg{$pkgname}{$matchver})
{ return($matchver); } { return($matchver); }
# Try to convert $globver into regex version if ($regex)
if ( $regex = glob2regex($matchver))
{ {
foreach $ver (keys %{$pkg{$pkgname}}) foreach $ver (keys %{$pkg{$pkgname}})
{ {
@ -519,7 +547,9 @@ sub package_globmatch
} }
$matchver || last; $matchver || last;
} }
# last ditch attempt to handle the whole DEPENDS as a glob # last ditch attempt to handle the whole DEPENDS as a glob
#
if ($matchver && ($regex = glob2regex($pkgmatch))) # (large-glob) if ($matchver && ($regex = glob2regex($pkgmatch))) # (large-glob)
{ {
my($pkgname, $ver); my($pkgname, $ver);
@ -697,7 +727,7 @@ sub parse_makefile_vars
next; next;
} }
if (/^ *(\w+)([+?]?)\s*=\s*(\S.*)/) if (/^ *(\w+)\s*([+?]?)=\s*(\S.*)/)
{ {
$key = $1; $key = $1;
$plus = $2; $plus = $2;
@ -918,7 +948,7 @@ sub pkgsrc_check_depends
# #
sub scan_pkgsrc_distfiles_vs_md5 sub scan_pkgsrc_distfiles_vs_md5
{ {
my($pkgsrcdir, $check_unref, $check_md5) = @_; my($pkgsrcdir, $pkgdistdir, $check_unref, $check_md5) = @_;
my($cat, @categories, $pkgdir); my($cat, @categories, $pkgdir);
my(%distfiles, %md5, @distwarn, $file, $numpkg); my(%distfiles, %md5, @distwarn, $file, $numpkg);
my(@distfiles, @bad_distfiles); my(@distfiles, @bad_distfiles);
@ -957,7 +987,7 @@ sub scan_pkgsrc_distfiles_vs_md5
} }
&verbose(" ($numpkg packages)\n"); &verbose(" ($numpkg packages)\n");
# Do not mark the vulnerabilitis file as unknown # Do not mark the vulnerabilities file as unknown
$distfiles{'vulnerabilities'} = 'vulnerabilities'; $distfiles{'vulnerabilities'} = 'vulnerabilities';
$md5{'vulnerabilities'} = 'IGNORE'; $md5{'vulnerabilities'} = 'IGNORE';
@ -1002,37 +1032,39 @@ sub scan_pkgsrc_distfiles_vs_md5
# #
sub usage_and_exit sub usage_and_exit
{ {
print "Usage: lintpkgsrc [opts] print "Usage: lintpkgsrc [opts] [makefiles]
opts: opts:
-h : This help. -h : This help. [see lintpkgsrc(1) for more information]
-d : Check 'DEPENDS' are up to date.
-i : Check installed package versions against pkgsrc.
-l : Pkglint every package in pkgsrc.
-R : List any NO_BIN_ON_FTP/RESTRICTED prebuilt packages (#).
-V : List any prebuilt packages with known vulnerabilities (#).
-m : List md5 mismatches for files in distfiles/.
-o : List old/obsolete distfiles (not referenced by any md5).
-p : List old/obsolete prebuilt packages (#).
-r : Remove 'bad' distfiles or packages (*).
-u : For each installed package ensure distfiles are fetched.
-B : List 'BROKEN' packages
-S file : Output map of 'pkgname pkgdir pkgver'
Installed package options: Distfile options:
-i : Check version against pkgsrc -m : List md5 mismatches
-u : Fetch distfiles (may change) -o : List obsolete (no md5)
Prebuilt package options: Makefile options:
-p : List old/obsolete -B : List packages marked as 'BROKEN'
-R : List NO_BIN_ON_FTP/RESTRICTED -d : Check 'DEPENDS' up to date
-V : List known vulnerabilities -S : List packages not in 'SUBDIRS'
Misc:
-g file : Generate 'pkgname pkgdir pkgver' map in file
-l : Pkglint all packages
-r : Remove bad files (Without -m -o -p or -V implies all, can use -R)
Modifiers:
-K path : Set PACKAGES basedir (default PKGSRCDIR/packages)
-M path : Set DISTDIR (default PKGSRCDIR/distfiles)
-P path : Set PKGSRCDIR (default /usr/pkgsrc)
-D : Debug makefile and glob parsing
-L : List each Makefile when scanned -L : List each Makefile when scanned
-P path : Set PKGSRCDIR
-K path : Set basedir for prebuild packages (default PKGSRCDIR/packages)
-M path : Set basedir for distfiles (default PKGSRCDIR/distfiles)
-D [paths] : Parse Makefiles and output contents (For debugging)
(*) Without any of -m, -o, -p, or -V implies all. Can use with -R.
See lintpkgsrc(1) for more information.
"; ";
exit; exit;
} }
sub verbose sub verbose
{
if (-t STDERR)
{ print STDERR @_; } { print STDERR @_; }
}
sub debug sub debug
{ {