diff options
author | atatat <atatat@pkgsrc.org> | 2003-01-24 15:00:41 +0000 |
---|---|---|
committer | atatat <atatat@pkgsrc.org> | 2003-01-24 15:00:41 +0000 |
commit | 70dc0105da17a8ef2c43cec61ede60ad3bc74d67 (patch) | |
tree | a08e7771599e4ded93b896a36747497875097f25 /pkgtools | |
parent | 6b251046c866f10b642da2a1a84450293bbe40fd (diff) | |
download | pkgsrc-70dc0105da17a8ef2c43cec61ede60ad3bc74d67.tar.gz |
Add -E and -I to lintpkgsrc for the "exporting" and "importing" of a
"database" that lintpkgsrc can use in lieu of scanning all the pkgsrc
Makefiles.
This has several nice effects, chiefly:
(1) Using any of -B, -O, -R, -S, -V, -d, -g, -i, -p, or -u, are now
*much* faster since reading the "database" takes at most 3 seconds on
my laptop, whereas reading all the Makefiles takes at least 3 minutes.
(2) One can now check for out-of-date packages on machines which do
not have an expanded pkgsrc tree simply by copying the "database"
over. Note that the database will inherently have some dependencies
on the environment of machine where it is generated (eg, mk.conf
settings, architecture type, etc).
Reviewed by the wiz.
Diffstat (limited to 'pkgtools')
-rw-r--r-- | pkgtools/pkglint/Makefile | 4 | ||||
-rw-r--r-- | pkgtools/pkglint/files/lintpkgsrc.1 | 31 | ||||
-rwxr-xr-x | pkgtools/pkglint/files/lintpkgsrc.pl | 78 |
3 files changed, 105 insertions, 8 deletions
diff --git a/pkgtools/pkglint/Makefile b/pkgtools/pkglint/Makefile index f4050b489d4..dfe0ba69e68 100644 --- a/pkgtools/pkglint/Makefile +++ b/pkgtools/pkglint/Makefile @@ -1,7 +1,7 @@ -# $NetBSD: Makefile,v 1.148 2003/01/15 23:41:31 rh Exp $ +# $NetBSD: Makefile,v 1.149 2003/01/24 15:00:41 atatat Exp $ # -DISTNAME= pkglint-3.43 +DISTNAME= pkglint-3.44 CATEGORIES= pkgtools devel MASTER_SITES= # empty DISTFILES= # empty diff --git a/pkgtools/pkglint/files/lintpkgsrc.1 b/pkgtools/pkglint/files/lintpkgsrc.1 index 1c8e146edfe..0ea56f924c6 100644 --- a/pkgtools/pkglint/files/lintpkgsrc.1 +++ b/pkgtools/pkglint/files/lintpkgsrc.1 @@ -1,4 +1,4 @@ -.\" $NetBSD: lintpkgsrc.1,v 1.22 2003/01/02 22:58:41 schmonz Exp $ +.\" $NetBSD: lintpkgsrc.1,v 1.23 2003/01/24 15:00:41 atatat Exp $ .\" .\" Copyright (c) 1999 by David Brownlee (abs@netbsd.org) .\" Absolutely no warranty. @@ -11,6 +11,8 @@ .Sh SYNOPSIS .Nm .Op Fl BDLORSVdhilmopru +.Op Fl E Ar file +.Op Fl I Ar file .Op Fl K Ar PACKAGES .Op Fl M Ar DISTDIR .Op Fl P Ar PKGSRCDIR @@ -29,6 +31,33 @@ Note that it does NOT implement complete Makefile parser. List packages marked as BROKEN. .It Fl D Ar paths Parse Makefiles and output contents (useful for debugging). +.It Fl E Ar file +Exports the internal database generated from the pkgsrc Makefiles to a +file for faster loading at a later time. +Note that some of the stored data is, in all likelihood, dependent on +the architecture and operating system of the machine where it is +generated. +However, the database does make the task of, eg, checking for out of +date packages on a set of similarly configured machines (in the +absence of extra copies of the pkgsrc tree) both quick and possible. +.It Fl I Ar file +Imports the data to construct the internal database for checking the +installed versions of packages, among other things, against the +current version found in pkgsrc. +This database provides most or all of the data required for running +.Nm +with any combination of +.Fl B , +.Fl O , +.Fl R , +.Fl S , +.Fl V , +.Fl d , +.Fl g , +.Fl i , +.Fl p , +or +.Fl u . .It Fl K Ar PACKAGES Override binary packages base directory, normally set from .Pa /etc/mk.conf diff --git a/pkgtools/pkglint/files/lintpkgsrc.pl b/pkgtools/pkglint/files/lintpkgsrc.pl index 67a5cf3f6ae..4e906dbd405 100755 --- a/pkgtools/pkglint/files/lintpkgsrc.pl +++ b/pkgtools/pkglint/files/lintpkgsrc.pl @@ -1,6 +1,6 @@ #!@PREFIX@/bin/perl -# $NetBSD: lintpkgsrc.pl,v 1.74 2003/01/02 22:58:42 schmonz Exp $ +# $NetBSD: lintpkgsrc.pl,v 1.75 2003/01/24 15:00:41 atatat Exp $ # Written by David Brownlee <abs@netbsd.org>. # @@ -31,12 +31,13 @@ my( $pkglist, # list of Pkg packages $ENV{PATH} .= ':/usr/sbin'; -if (! getopts('BDK:LM:OP:RSVdg:hilmopru', \%opt) || $opt{h} || +if (! getopts('BDE:I:K:LM:OP:RSVdg:hilmopru', \%opt) || $opt{h} || ! ( defined($opt{d}) || defined($opt{g}) || defined($opt{i}) || defined($opt{l}) || defined($opt{m}) || defined($opt{o}) || defined($opt{p}) || defined($opt{r}) || defined($opt{u}) || defined($opt{B}) || defined($opt{D}) || defined($opt{R}) || - defined($opt{O}) || defined($opt{S}) || defined($opt{V}) )) + defined($opt{O}) || defined($opt{S}) || defined($opt{V}) || + defined($opt{E}))) { usage_and_exit(); } $| = 1; @@ -242,6 +243,11 @@ if ($opt{D} && @ARGV) } if ($opt{l}) { pkglint_all_pkgsrc($pkgsrcdir, $pkglint_flags); } + if ($opt{E}) + { + scan_pkgsrc_makefiles($pkgsrcdir); + store_pkgsrc_makefiles($opt{E}); + } } exit; @@ -1075,6 +1081,11 @@ sub scan_pkgsrc_makefiles if ($pkglist) # Already done { return; } + if ($opt{I}) + { + load_pkgsrc_makefiles($opt{I}); + return; + } $pkglist = new PkgList; @categories = list_pkgsrc_categories($pkgsrcdir); verbose("Scanning pkgsrc Makefiles: "); @@ -1242,6 +1253,26 @@ sub scan_pkgsrc_distfiles_vs_distinfo (sort keys %bad_distfiles); } +sub load_pkgsrc_makefiles + { + open(STORE, "<$_[0]") || die("Cannot read pkgsrc store from $_[0]: $!\n"); + my ($pkgver, $pkgcnt, $pkgnum); + $pkglist = new PkgList; + while (<STORE>) + { eval $_; } + close(STORE); + } + +sub store_pkgsrc_makefiles + { + open(STORE, ">$_[0]") || die("Cannot save pkgsrc store to $_[0]: $!\n"); + my $was = select(STORE); + $pkglist->store; + print("verbose(\"...done\\n\");\n"); + select($was); + close(STORE); + } + # Remember to update manual page when modifying option list # sub usage_and_exit @@ -1261,6 +1292,8 @@ Prebuilt package options: Makefile options: -V : List known vulnerabilities Misc: + -E file : Export the internal pkgsrc database to file + -I file : Import the internal pkgsrc database to file (for use with -i) -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) @@ -1342,6 +1375,14 @@ sub pkgs return; } +sub store + { + my $self = shift; + my @pkgs = keys %{$self->{_pkgs}}; + print("\$pkgcnt = ", scalar(@pkgs), ";\n"); + map($self->{_pkgs}{$_}->store, keys %{$self->{_pkgs}}); + } + # Pkgs is all versions of a given package (eg: apache-1.x and apache-2.x) # package Pkgs; @@ -1391,6 +1432,15 @@ sub latestver ($self->pkgver())[0]; } +sub store + { + my $self = shift; + print("\$pkgnum++;\n"); + print("verbose(\"\\rReading pkgsrc database: ", + "\$pkgnum / \$pkgcnt pkgs\");\n"); + map($self->{_pkgver}{$_}->store, keys %{$self->{_pkgver}}); + } + # PkgVer is a unique package+version # package PkgVer; @@ -1400,8 +1450,8 @@ sub new my $class = shift; my $self = {}; bless $self, $class; - $self->{_pkg} = $1; - $self->{_ver} = $2; + $self->{_pkg} = $_[0]; + $self->{_ver} = $_[1]; return $self; } @@ -1430,3 +1480,21 @@ sub ver my $self = shift; $self->{_ver}; } + +sub vars + { + my $self = shift; + grep(!/^_(pkg|ver)$/, keys %{$self}); + } + +sub store + { + my $self = shift; + my $data; + print("\$pkgver = \$pkglist->add(\"$self->{_pkg}\", \"$self->{_ver}\");\n"); + foreach ($self->vars) + { + ($data = $self->{$_}) =~ s/([\\\$\@\%\"])/\\$1/g; + print("\$pkgver->var(\"$_\", \"$data\");\n"); + } + } |