diff options
author | Marc Espie <espie@cvs.openbsd.org> | 2013-01-18 21:19:37 +0000 |
---|---|---|
committer | Marc Espie <espie@cvs.openbsd.org> | 2013-01-18 21:19:37 +0000 |
commit | b1b79aa89ca7e36188709980fc740cbed3f4d03b (patch) | |
tree | 0145f52545c9704252c09b9f6828ce1ac84024fb | |
parent | ebb8bdca7bfe8c5dab93e8dbb999767d2987674f (diff) |
much faster -E: try a sneak peek at the 'raw' contents file.
if it doesn't contain the last part of the filename, then we don't even
need to parse the plist...
idea prompted by a chance remark from Vadim.
-rw-r--r-- | usr.sbin/pkg_add/OpenBSD/PkgInfo.pm | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/usr.sbin/pkg_add/OpenBSD/PkgInfo.pm b/usr.sbin/pkg_add/OpenBSD/PkgInfo.pm index d5aa1982f72..8a5db9c7367 100644 --- a/usr.sbin/pkg_add/OpenBSD/PkgInfo.pm +++ b/usr.sbin/pkg_add/OpenBSD/PkgInfo.pm @@ -1,6 +1,6 @@ #! /usr/bin/perl # ex:ts=8 sw=4: -# $OpenBSD: PkgInfo.pm,v 1.26 2013/01/18 13:22:54 espie Exp $ +# $OpenBSD: PkgInfo.pm,v 1.27 2013/01/18 21:19:36 espie Exp $ # # Copyright (c) 2003-2010 Marc Espie <espie@openbsd.org> # @@ -264,12 +264,34 @@ sub filter_files my ($self, $state, $search, @args) = @_; require OpenBSD::PackingList; + my @k = (); + for my $file (keys %$search) { + my $k = $file; + if ($file =~ m|^.*/(.*?)$|) { + $k = $1; + } + push(@k, quotemeta($k)); + } + my $re = join('|', @k); + my @result = (); for my $arg (@args) { $self->find_pkg($state, $arg, sub { my ($pkgname, $handle) = @_; + if (-f $handle->info.CONTENTS) { + my $maybe = 0; + open(my $fh, '<', $handle->info.CONTENTS); + while (<$fh>) { + if (m/$re/) { + $maybe = 1; + last; + } + } + close($fh); + return if !$maybe; + } my $plist = $handle->plist(\&OpenBSD::PackingList::FilesOnly); $plist->hunt_file($search, $pkgname, \@result); |