PKGDB(1)

NAME
pkgdb, pkg_which - tools to manage and look up the packages database

SYNOPSIS
pkgdb [-hfFquv] [-o pkgname] [-s /old/new/]
pkg_which [-hq] [-c pkgname] [file] ...

DESCRIPTION
The pkgdb command is a tool to create or update packages database which is commonly used among the tool suite. It keeps a hash that maps an installed file to a pacakge name, a hash that maps a package to an origin, and a list of installed packages.

pkg_which looks up the packages database to tell which package each specified file came from. If you do not have permission to update the database although it is outdated, it delegates tasks to pkg_info(1).

Actually, pkgdb and pkg_which share an entity and are totally equivalent.

The pkgdb command also works as an interactive tool for fixing the package registry database when -F is specified. It helps you resolve stale dependencies, unlink cyclic dependencies, complete stale or missing origins and remove duplicates. You have to run this periodically so portupgrade(1) and other pkg_* tools can work effectively and unfailingly.

OPTIONS
The following command line arguments are supported:

file
    Inquire which package file came from. If the file is not present, pkg_which calls which(1) to search PATH for the file.

-h
--help
    Show help and exit.

-c PKGNAME
--collate PKGNAME
    Show files installed by the given packge that have been overwritten by other packages.

-f
--force
    Force; Specified with -u, update database regardless of timestamps. Specified with -F, fix "held" packages too.

-F
--fix
    Interactively fix the package registry database.

-o PKGNAME
--origin PKGNAME
    Look up the origin of the given package in the package database.

-q
--noconfig
    Do not read the configuration file - $PREFIX/etc/pkgtools.conf.

-s /OLD/NEW/
--substitute /OLD/NEW/
    Substitute all the dependencies recorded as OLD with NEW and exit.

-u
--update
    Update or create the packages database file pkgdb.db in $PKG_DBDIR, which is /var/db/pkg by default.

    Note: the ports database files are automatically updated if it is not up-to-date when looked up, so manual updating is not mandatory.

-v
--verbose
    Turn on verbose output.

EXAMPLES

•   Get a list of files under /usr/local and /usr/X11R6 that do not belong to any package:

        find /usr/local /usr/X11R6 -type f | xargs pkg_which -v | fgrep '?'

    As you see, you can omit version numbers. If multiple versions are installed, each of them is upgraded unless they share a port origin. (For example you may probably have foo-1.02 and

ENVIRONMENT
PKG_DBDIR
    Alternative location for the installed package database. Default is “/var/db/pkg”.

PORTSDIR
    Alternative location for the ports tree. Default is “/usr/ports”.

PORTS_INDEX
    Alternative location for the ports INDEX file. Default is “$PORTSDIR/INDEX”.

PORTS_DBDIR
    Alternative location for the ports database files. Default is “$PORTSDIR”. The database files in the directory are automatically created or updated as necessary. See portsdb(1) for details.

PKGTOOLS_CONF
    Configuration file for the pkgtools suite. Default is “$PREFIX/etc/pkgtools.conf”.

FILES
/var/db/pkg
    Default location of the package database.

$PREFIX/etc/pkgtools.conf
    Default location of the pkgtools configuration file.

SEE ALSO
portsclean(1), portsdb(1), portupgrade(1), pkgtools.conf(5), ports(7)

HISTORY
The idea of pkgdb.db was taken from NetBSD.

AUTHORS
Akinori MUSHA <knu@iDaemons.org>

BUGS

Sometimes a database may get corrupt and the pkgtools commands start to abort due to segmentation fault. In such cases, run “pkgdb -fu” to rebuild the database, and the problems will go away.