From ParabolaWiki
Jump to: navigation, search

From GitHub:

pkgfile searches the .files metadata created by repo-add(8) to retrieve file information about packages. By default, the provided target is considered to be a filename and pkgfile will return the package(s) which contain this file. The repos which pkgfile searches is determined by those enabled in /etc/pacman.conf.
Note: Simpler is pkgfile is a tool that tells you which package owns a specified file or which files a given package provides.

You can install pkgfile from the official repositories.

1 Usage

# pkgfile [operation] [options] target

1.1 Options and operations

Option or operation Description
-l, --list The target is considered to be a package name rather than a filename, and the contents of the named package are returned. This allows for repo/package style syntax (such as "core/pacman") to limit the breadth of the search, but only when --list is used without the --glob or --regex options.
-s, --search Search for packages containing the provided target. This is the default mode of operation.
-u, --update Update the stored metadata files. It is recommended to create a daily cron job with this command to ensure accurate results. By default, only repos which are found to be newer on the mirror will be downloaded. Pass this option twice to force all repos to be downloaded.
-b, --binaries Return only files which are contained within a bin or sbin directory.
-d, --directories Match directories in search results.
-g, --glob Enable shell-style glob pattern matching. See glob(7).
-i, --ignorecase Disable case sensitivity in matching.
-r, --regex Enable regular expression matching. See pcre(3).
-R REPO, --repo=REPO Search only the specific repo.
-0, --null Delimit output with null bytes rather than newline characters.
-q, --quiet Output less. This applies to the --list operation.
-v, --verbose Output more. This applies to the --search operation.
-w, --raw Avoid justification of 2 column output.
-z, --compress[=COMPRESSION] Repack downloaded repos with the optionally supplied compression method, which may be one of none, gzip, bzip2, lzop, lz4, lzma, or xz. If this flag is passed without a compression method, this defaults to gzip. If this flag is not passed at all, no compression will be applied. Applying any form of compression will decrease performance, but may be desirable for disk space concerns.
General options
-C FILE, --config=FILE Use a config file other than the default of /etc/pacman.conf.
-D DIRECTORY, --cachedir=DIRECTORY Use a cache path other than the compile-time default.
-h, --help Print help and exit.
-V, --version Print the version and exit.

1.1.1 Examples

Example to search for a package that contains a file named "makepkg":

$ pkgfile makepkg

So your searched file is in the pacman package from the [core] repository.

Another example to list all files provided by the archlinux-keyring package from the [core] repository:

$ pkgfile --list core/archlinux-keyring
core/archlinux-keyring usr/
core/archlinux-keyring usr/share/
core/archlinux-keyring usr/share/pacman/
core/archlinux-keyring usr/share/pacman/keyrings/
core/archlinux-keyring usr/share/pacman/keyrings/archlinux-revoked
core/archlinux-keyring usr/share/pacman/keyrings/archlinux-trusted
core/archlinux-keyring usr/share/pacman/keyrings/archlinux.gpg

1.2 "Command not found" hook

pkgfile includes a "command not found" hook that will automatically search the official repositories, if you enter an unrecognized command.

To enable it in all children shells, you need to source the hook from one of your shell initialization files.

source /usr/share/doc/pkgfile/command-not-found.bash
  • Example for Zsh:
source /usr/share/doc/pkgfile/command-not-found.zsh

2 See also

3 Acknowledgement

This wiki article is based on ArchWiki. We may have removed non-FSDG bits from it.

Some information taken from GitHub.