Date: Mon, 11 Mar 2013 23:13:18 +0000 (UTC) From: Matthias Andree <mandree@FreeBSD.org> To: ports-committers@freebsd.org, svn-ports-all@freebsd.org, svn-ports-head@freebsd.org Subject: svn commit: r313945 - in head/ports-mgmt/pkgs_which: . files Message-ID: <201303112313.r2BNDIAx031922@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: mandree Date: Mon Mar 11 23:13:18 2013 New Revision: 313945 URL: http://svnweb.freebsd.org/changeset/ports/313945 Log: - 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 Modified: head/ports-mgmt/pkgs_which/Makefile (contents, props changed) head/ports-mgmt/pkgs_which/files/pkgs_which (contents, props changed) head/ports-mgmt/pkgs_which/pkg-descr (contents, props changed) Modified: head/ports-mgmt/pkgs_which/Makefile ============================================================================== --- head/ports-mgmt/pkgs_which/Makefile Mon Mar 11 22:49:21 2013 (r313944) +++ head/ports-mgmt/pkgs_which/Makefile Mon Mar 11 23:13:18 2013 (r313945) @@ -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 Modified: head/ports-mgmt/pkgs_which/files/pkgs_which ============================================================================== --- head/ports-mgmt/pkgs_which/files/pkgs_which Mon Mar 11 22:49:21 2013 (r313944) +++ head/ports-mgmt/pkgs_which/files/pkgs_which Mon Mar 11 23:13:18 2013 (r313945) @@ -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<port =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 Modified: head/ports-mgmt/pkgs_which/pkg-descr ============================================================================== --- head/ports-mgmt/pkgs_which/pkg-descr Mon Mar 11 22:49:21 2013 (r313944) +++ head/ports-mgmt/pkgs_which/pkg-descr Mon Mar 11 23:13:18 2013 (r313945) @@ -3,3 +3,6 @@ files and/or directories, which ports/pa 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.
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201303112313.r2BNDIAx031922>