pacapt icon indicating copy to clipboard operation
pacapt copied to clipboard

Add support for `pacman -F`/`pkgfile`

Open jody-frankowski opened this issue 5 years ago • 4 comments

A nice feature that's missing is the support for pacman -F/pkgfile https://wiki.archlinux.org/index.php/Pacman#Search_for_a_package_that_contains_a_specific_file https://wiki.archlinux.org/index.php/Pkgfile.

This kind of feature can be used to suggest package installation when executing a missing binary, like so (for zsh):

command_not_found_handler() {
    pkgs=($(pkgfile -b -- "$1"))
    if [[ -n "$pkgs" ]] ; then
        echo "Command not found but package found!" >&2
        echo "Installing ${pkgs[1]}\n" >&2

        sudo pacman -S ${pkgs[1]} >&2

        echo "\nExecuting $@" >&2

        "$@"
        return $?
    else
        echo "Command or package not found: $1" >&2
        return 127
    fi
}
$ wget
zsh: correct wget to _wget [nyae]? n
Command not found but package found!
Installing extra/wget

resolving dependencies...
looking for conflicting packages...

Packages (1) wget-1.20.3-2

Total Installed Size:  2.88 MiB

:: Proceed with installation? [Y/n]
[...]

Executing wget
wget: missing URL
Usage: wget [OPTION]... [URL]...

Try `wget --help' for more options.

jody-frankowski avatar Apr 10 '20 14:04 jody-frankowski

@jody-frankowski That feature is great for pacman, but I am not sure it's supported on other distribution. What distro/OS you're using with pacapt now? Thanks

icy avatar Apr 24 '20 15:04 icy

A nice feature that's missing is the support for pacman -F/pkgfile

+++++++++ :)

That feature is great for pacman, but I am not sure it's supported on other distribution.

dpkg -S file

Example:

dpkg -S zramctl
util-linux: /sbin/zramctl
util-linux: /usr/share/bash-completion/completions/zramctl
util-linux: /usr/share/man/man8/zramctl.8.gz

krasnh avatar Sep 20 '22 09:09 krasnh

Here is a (non-exhaustive) list of other distros implementations: https://ostechnix.com/find-package-provides-specific-file-linux/ (Forgot to answer. Sorry!)

jody-frankowski avatar Sep 20 '22 21:09 jody-frankowski