Difference between revisions of "Pkgfile"

From ArchWiki
Jump to: navigation, search
m ("Command not found" hook)
(Fish: rm "since version")
 
(34 intermediate revisions by 22 users not shown)
Line 2: Line 2:
 
[[Category:Package development]]
 
[[Category:Package development]]
 
[[Category:Package management]]
 
[[Category:Package management]]
'''pkgfile''' is a tool that tells you which package owns a specified file or which files a given package provides.
+
[[es:Pkgfile]]
 +
[[fa:Pkgfile]]
 +
[[ja:Pkgfile]]
 +
[[ko:Pkgfile]]
 +
[[ru:Pkgfile]]
 +
[[zh-CN:Pkgfile]]
 +
{{Related articles start}}
 +
{{Related|pacman}}
 +
{{Related articles end}}
 +
'''pkgfile''' is a tool for searching files from packages in the [[official repositories]].
  
You can [[Pacman|install]] {{pkg|pkgfile}} from the [[Official Repositories]], or {{AUR|pkgfile-git}} from the [[AUR]].
+
== Installation ==
  
Then update the file database, as root:
+
[[Install]] {{Pkg|pkgfile}} from the official repositories, or {{AUR|pkgfile-git}} from the [[AUR]].
  
# pkgfile --update
+
The ''pkgfile'' database can then be synced with:
  
==== Example: ====
+
# pkgfile -u
  
{{hc|$ pkgfile ''makepkg''    #Search for a package that contains a file named "makepkg".|
+
== Usage ==
core/pacman          #Your searched file is in the {{Pkg|pacman}} package from the [core] repository.}}
+
  
Another example:
+
To search for a package that owns the file {{ic|makepkg}}:
  
{{hc|$ pkgfile --list ''core/archlinux-keyring''    #List all files provided by the {{Pkg|archlinux-keyring}} package from the [core] repository.|
+
{{hc|$ pkgfile makepkg|
 +
core/pacman}}
 +
 
 +
To list all files provided by {{Pkg|archlinux-keyring}}:
 +
 
 +
{{hc|$ pkgfile -l archlinux-keyring|
 
core/archlinux-keyring usr/
 
core/archlinux-keyring usr/
 
core/archlinux-keyring usr/share/
 
core/archlinux-keyring usr/share/
Line 26: Line 39:
 
core/archlinux-keyring usr/share/pacman/keyrings/archlinux.gpg}}
 
core/archlinux-keyring usr/share/pacman/keyrings/archlinux.gpg}}
  
=== "Command not found" hook ===
+
Latter is comparable to {{ic|pacman -Ql}} (see [[pacman#Querying package databases]]), except it applies to remote packages.
  
pkgfile includes a "command not found" hook that will automatically search the official repositories, if you enter an unrecognized command.
+
== Command not found ==
 +
 
 +
{{Pkg|pkgfile}} includes a "command not found" hook for [[Bash]] and [[Zsh]] that will automatically search the official repositories, when entering an unrecognized command:
 +
 
 +
{{hc|$ abiword|
 +
abiword may be found in the following packages:
 +
  extra/abiword 2.8.6-7 usr/bin/abiword
 +
}}
  
 
To enable it in all children shells, you need to source the hook from one of your shell initialization files.
 
To enable it in all children shells, you need to source the hook from one of your shell initialization files.
  
* Example for [[Bash]]:
+
=== Bash ===
  
 
{{hc|~/.bashrc|
 
{{hc|~/.bashrc|
 
source /usr/share/doc/pkgfile/command-not-found.bash}}
 
source /usr/share/doc/pkgfile/command-not-found.bash}}
  
* Example for [[Zsh]]:
+
=== Zsh ===
  
 
{{hc|~/.zshrc|
 
{{hc|~/.zshrc|
 
source /usr/share/doc/pkgfile/command-not-found.zsh}}
 
source /usr/share/doc/pkgfile/command-not-found.zsh}}
  
==See also==
+
=== Fish ===
* [[Bash#The_"command_not_found"_hook]] - A section comparing {{Pkg|pkgfile}} and {{AUR|command-not-found}}
+
 
 +
[[Fish]] provides its own "command not found" hook for {{Pkg|pkgfile}}: [https://github.com/fish-shell/fish-shell/pull/1925  Add command-not-found handler for Arch Linux #1925]
 +
 
 +
== Automatic updates ==
 +
 
 +
'''pkgfile''' ships with a [[systemd]] service and [[systemd/Timers|timer]] for automatically synchronizing the pkgfile database. To activate automatic updates [[enable]] {{ic|pkgfile-update.timer}}.
 +
 
 +
By default, pkgfile will be updated daily. To change this schedule, [[systemd#Editing provided units|edit the unit file]].

Latest revision as of 20:07, 21 May 2016

Related articles

pkgfile is a tool for searching files from packages in the official repositories.

Installation

Install pkgfile from the official repositories, or pkgfile-gitAUR from the AUR.

The pkgfile database can then be synced with:

# pkgfile -u

Usage

To search for a package that owns the file makepkg:

$ pkgfile makepkg
core/pacman

To list all files provided by archlinux-keyring:

$ pkgfile -l 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

Latter is comparable to pacman -Ql (see pacman#Querying package databases), except it applies to remote packages.

Command not found

pkgfile includes a "command not found" hook for Bash and Zsh that will automatically search the official repositories, when entering an unrecognized command:

$ abiword
abiword may be found in the following packages:
  extra/abiword 2.8.6-7 usr/bin/abiword

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

Bash

~/.bashrc
source /usr/share/doc/pkgfile/command-not-found.bash

Zsh

~/.zshrc
source /usr/share/doc/pkgfile/command-not-found.zsh

Fish

Fish provides its own "command not found" hook for pkgfile: Add command-not-found handler for Arch Linux #1925

Automatic updates

pkgfile ships with a systemd service and timer for automatically synchronizing the pkgfile database. To activate automatic updates enable pkgfile-update.timer.

By default, pkgfile will be updated daily. To change this schedule, edit the unit file.