Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for pacman -F/pkgfile #130

Open
jody-frankowski opened this issue Apr 10, 2020 · 4 comments
Open

Add support for pacman -F/pkgfile #130

jody-frankowski opened this issue Apr 10, 2020 · 4 comments

Comments

@jody-frankowski
Copy link

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.
@icy
Copy link
Owner

icy commented Apr 24, 2020

@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

@krasnh
Copy link

krasnh commented Sep 20, 2022

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

@jody-frankowski
Copy link
Author

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

@T-3B
Copy link

T-3B commented May 15, 2024

Any news on this ?
I'm really interested in this feature: would be useful inside the BASH command_not_found_handle() function, to automatically search for the package(s) providing the executable that wasn't found.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants