|o||accepts files on the command line, which are looked up directly,|
|o||accepts directories on the command line, which are recursively scanned for regular files, which are then looked up,|
|o||accepts an arbitrary mix of files and directories on the command line,|
|o||prints each port or package only once,|
|o||prints port/package names by default, but can print origins instead (--origins option).|
|o||supports a quiet mode that emits output suitable for scripting and shell command expansion (see EXAMPLES below)|
|o||is optimized for efficient bulk lookups of data without assistance of an on-disk database.|
pkgs_which uses pkg_info -L to accelerate the process. It first obtains a list of all files, looks at a random one, looks up the corresponding package and records its name, and then purges all files belonging to it before looking up the next file.
pkgs_which does not spawn subshells for pkg_info for security reasons, and makes sure to launder the pkg_info output.
The --cacheall option (default on) makes pkgs_which read all package file lists upon start. This takes a few seconds on a GHz-class computer but voids the need to run pkg_info -W often later on.
For looking up very few files, it is more efficient to use --no-cacheall.
pkgs_which performs a similar task to pkg_which(1) that is part of the ports-mgmt/portupgrade port, but unlike the latter, it does not require a database, and is optimized for bulk lookups of entire directory trees.
portmaster(8) is a tool written by Doug Barton to upgrade installed ports and their dependencies that does not require port/package databases.
Obtain the sorted list of all packages that installed at least one file under /usr/local/lib/python2.6/site-packages:
pkgs_which --sort /usr/local/lib/python2.6/site-packages
Upgrade all packages that installed at least one file under /usr/local/lib/python2.6/site-packages (this assumes a Bourne-shell such as sh, ash, ksh, bash):
portmaster -d $(pkgs_which -qo /usr/local/lib/python2.6/site-packages)
- do not require files given on command line are regular files,
but accept any non-directory (for instance, symlinks).
Workaround for previous versions: use --no-find if you intend to look up non-regular files.
- support pkgNG. Known issue is that pkg which returns bogus exit
codes, spamming your screen. pkgs_which works nonetheless.
Note that pkgNG always uses --nocache implictly for speed: https://github.com/freebsd/pkg/issues/658 Known issue: the pkgNG detection is a hack. It just looks for the executable and the database in default locations, but does not attempt to run "pkg -N".
- read pkg_info -L information in chunks of 100 packages at a time,
to avoid forking once per package, which was slow.
- fixed a bug where skipping non-existent command line arguments
failed and resulted in an unterminated (endless) loop.
- added the --no-find option
- pkgs_which made its first appearance in the FreeBSD ports tree
The current CVS Version tag is:
$FreeBSD: branches/2016Q1/ports-mgmt/pkgs_which/files/pkgs_which 343829 2014-02-11 22:50:26Z mandree $
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.
|perl v5.20.3||PKGS_WHICH (1)||2016-01-05|