From owner-svn-ports-all@FreeBSD.ORG Mon Mar 11 23:13:19 2013 Return-Path: Delivered-To: svn-ports-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 1E0EFCCE; Mon, 11 Mar 2013 23:13:19 +0000 (UTC) (envelope-from mandree@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 0175992C; Mon, 11 Mar 2013 23:13:19 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.6/8.14.6) with ESMTP id r2BNDIKh031925; Mon, 11 Mar 2013 23:13:18 GMT (envelope-from mandree@svn.freebsd.org) Received: (from mandree@localhost) by svn.freebsd.org (8.14.6/8.14.5/Submit) id r2BNDIAx031922; Mon, 11 Mar 2013 23:13:18 GMT (envelope-from mandree@svn.freebsd.org) Message-Id: <201303112313.r2BNDIAx031922@svn.freebsd.org> From: Matthias Andree Date: Mon, 11 Mar 2013 23:13:18 +0000 (UTC) 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 X-SVN-Group: ports-head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-ports-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the ports tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 11 Mar 2013 23:13:19 -0000 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 -# +# Created by: Matthias Andree # $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 + +.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(8), L(8), L - this script is under the GNU -General Public License v3 or any later version. +Copyright 2011, 2013 Matthias Andree . +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.