aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormandree <mandree@FreeBSD.org>2013-03-12 07:13:18 +0800
committermandree <mandree@FreeBSD.org>2013-03-12 07:13:18 +0800
commit0b92c57be1ce8ebd9dd9640e1395b5e89a16914f (patch)
tree834daa481f376eadc2e49daf36e59b678556a967
parent852ca99e81c7305a2a56f7aad099c295e257df07 (diff)
downloadfreebsd-ports-gnome-0b92c57be1ce8ebd9dd9640e1395b5e89a16914f.tar.gz
freebsd-ports-gnome-0b92c57be1ce8ebd9dd9640e1395b5e89a16914f.tar.zst
freebsd-ports-gnome-0b92c57be1ce8ebd9dd9640e1395b5e89a16914f.zip
- read pkg_info -L information in chunks of 100 packages at a time,
to avoid forking once per package, which was slow. - clean up ports header - NOPORTDOCS -> PORT_OPTIONS:MDOCS
-rw-r--r--ports-mgmt/pkgs_which/Makefile16
-rw-r--r--ports-mgmt/pkgs_which/files/pkgs_which34
-rw-r--r--ports-mgmt/pkgs_which/pkg-descr3
3 files changed, 35 insertions, 18 deletions
diff --git a/ports-mgmt/pkgs_which/Makefile b/ports-mgmt/pkgs_which/Makefile
index 9de9614800a1..c0b291badce6 100644
--- a/ports-mgmt/pkgs_which/Makefile
+++ b/ports-mgmt/pkgs_which/Makefile
@@ -1,14 +1,8 @@
-# New ports collection makefile for: pkgs_which
-# Date created: 12 March 2011
-# Whom: Matthias Andree <mandree@FreeBSD.org>
-#
+# Created by: Matthias Andree <mandree@FreeBSD.org>
# $FreeBSD$
-#
-# This port is self contained in the files directory.
-#
PORTNAME= pkgs_which
-PORTVERSION= 0.2.0
+PORTVERSION= 0.3.0
CATEGORIES= ports-mgmt perl5
MASTER_SITES= # none
DISTFILES= # none
@@ -22,14 +16,16 @@ NO_BUILD= yes
USE_PERL5= yes
PLIST_FILES= bin/${PORTNAME}
-.if !defined(NOPORTDOCS)
+.include <bsd.port.options.mk>
+
+.if ${PORT_OPTIONS:MDOCS}
MAN1= ${PORTNAME}.1
.endif
do-install:
${MKDIR} ${PREFIX}/bin
${INSTALL_SCRIPT} ${FILESDIR}/${PORTNAME} ${PREFIX}/bin
-.if !defined(NOPORTDOCS)
+.if ${PORT_OPTIONS:MDOCS}
${MKDIR} ${PREFIX}/man/man1
${LOCALBASE}/bin/pod2man ${FILESDIR}/${PORTNAME} >${PREFIX}/man/man1/${MAN1}
.endif
diff --git a/ports-mgmt/pkgs_which/files/pkgs_which b/ports-mgmt/pkgs_which/files/pkgs_which
index fbd7830665e5..20194965f890 100644
--- a/ports-mgmt/pkgs_which/files/pkgs_which
+++ b/ports-mgmt/pkgs_which/files/pkgs_which
@@ -116,7 +116,7 @@ my $PKG_INFO = '/usr/sbin/pkg_info';
# Which regexp to use for laundering tainted file
# and package names - note that this must not be let
# near a shell as it contains glob characters!
-my $UNTAINT = qr|^([()[\]{}\-+@\w.,/\$%!=~:^ *?]+)$|;
+my $UNTAINT = qr|^([()[\]{}\-+@\w.,/\$%!=~:^ *?]+)$|o;
# Default for cacheall.
my $cacheall = 1;
@@ -210,7 +210,7 @@ my $f;
# - pick random file from hash,
# - look up the package name (from hash or with pkg_info)
# - look up list of files in package
-# - purge all files from package
+# - purge all files recorded as belonging to package from the hash
while ($f = each %ufiles) {
# Find package for file $f and store in $p:
@@ -310,14 +310,27 @@ sub readcache() {
my @pkgs = map { $_ =~ $UNTAINT; $1; } safebacktick($PKG_INFO, '-EG', '-a');
my $n = scalar @pkgs;
debug "subreadcache: got $n packages.\n";
- foreach my $i (@pkgs) {
- my @fl = safebacktick($PKG_INFO, '-qGL', $i);
+ # Request file lists of so many packages at once, to save the
+ # overhead of forking and executing pkg_info and its initialization.
+ # This speeds up things by an order of magnitude or so.
+ my $chunksize = 100;
+ while (my @p = splice(@pkgs, 0, $chunksize)) {
+ my @fl = safebacktick($PKG_INFO, '-QGL', @p);
chomp @fl;
+ my $pkg;
map {
$_ =~ $UNTAINT;
- if ($1) {$f2p{$1} = $i;} else {warn "tainted file name in $i: $_"; }
+ while (s|^([^/:]+:)||o) {
+ $pkg = $1;
+ $pkg =~ s/:$//; # strip trailing colon
+ }
+ if ($_) { # file name
+ if ($pkg) { $f2p{$_} = $pkg; push @{$pfl{$pkg}}, $_;}
+ else { warn "pkg_info fault, missed package prefix before line $_."; }
+ } else {
+ warn "tainted file name in $pkg: $_";
+ }
} @fl;
- $pfl{$i} = [@fl];
}
debug "subreadcache: got ", scalar keys %f2p, " files.\n";
return (\%f2p, \%pfl);
@@ -360,6 +373,10 @@ L<pkg_info>(8), L<portmaster>(8), L<portupgrade>(8), L<pkg_which>(8)
=head1 HISTORY
+0.3.0 2013-03-11
+ - read pkg_info -L information in chunks of 100 packages at a time,
+ to avoid forking once per package, which was slow.
+
0.2.0 2011-07-25
- fixed a bug where skipping non-existent command line arguments
failed and resulted in an unterminated (endless) loop.
@@ -375,7 +392,8 @@ The current CVS Version tag is:
=head1 AUTHORS
-Matthias Andree <mandree@FreeBSD.org> - this script is under the GNU
-General Public License v3 or any later version.
+Copyright 2011, 2013 Matthias Andree <mandree@FreeBSD.org>.
+All rights reserved. This script is exclusively licensed under the GNU
+General Public License version 3, or any later version.
=cut
diff --git a/ports-mgmt/pkgs_which/pkg-descr b/ports-mgmt/pkgs_which/pkg-descr
index 9e65b6317102..608be49ef2cf 100644
--- a/ports-mgmt/pkgs_which/pkg-descr
+++ b/ports-mgmt/pkgs_which/pkg-descr
@@ -3,3 +3,6 @@ files and/or directories, which ports/packages have installed fiels
here. It does not require a database and is useful to determine which
ports need to be upgraded after, for instance, a script language
interpreter has been updated and needs the site-packages reinstalled.
+
+The port is self-contained in the ports tree.
+here are no external distribution sites or web pages.