GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
PKGS_WHICH(1) User Contributed Perl Documentation PKGS_WHICH(1)

pkgs_which - Quickly find packages where trees of files got installed

pkgs_which [-oqvsd] {dir|file} [...]

pkgs_which {-h|-?|--help}

pkgs_which --man

    --origins, -o      print package origins instead of names
    --quiet, -q        only print actual package names
    --verbose, -v      also print unmatched files
    --sort, -s         sort package and file lists
    --[no-]cacheall    read and cache all package file lists first
    --[no-]find        descend directories on the command line [default]

    --debug, -d        emit additional debug information on stderr

    --help, -h, -?     print a brief help message and quit
    --man              show the full full documentation and quit

Long options can be abbreviated to the shortest unambiguous string. Short options can be bundled (Example: pkgs_which -qo ...).

pkgs_which is a tool to efficiently look up which FreeBSD ports or packages installed the files on its command line, or the files in the directories on the command line.

pkgs_which

  • accepts files on the command line, which are looked up directly,
  • accepts directories on the command line, which are recursively scanned for regular files, which are then looked up,
  • accepts an arbitrary mix of files and directories on the command line,
  • prints each port or package only once,
  • prints port/package names by default, but can print origins instead (--origins option).
  • supports a "quiet" mode that emits output suitable for scripting and shell command expansion (see EXAMPLES below)
  • is optimized for efficient bulk lookups of data without assistance of an on-disk database.

It is most useful for quickly obtaining a list of site-packages that need to be reinstalled after upgrading a script language interpreter to a new version that uses new directories for its site-packages, for instance, after a Python 2.6 => 2.7 or Perl 5.10 => 5.12 upgrade, and is a good companion to portmaster(8).

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)

pkg_info(8), portmaster(8), portupgrade(8), pkg_which(8)

0.4.1 2014-02-11 - 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.

0.4.0 2013-11-28 - support pkgNG. Known issue is that pkg which returns bogus exit codes, spamming your screen. pkgs_which works nonetheless. https://github.com/freebsd/pkg/issues/657

    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".

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.

  - added the --no-find option

0.1.0 2011-03-12 - pkgs_which made its first appearance in the FreeBSD ports tree

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.
2022-04-02 perl v5.32.1

Search for    or go to Top of page |  Section 1 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.