28

I would like to know, given a binary's name, which package I should install on Alpine Linux.

How can I do that?

Gilles 'SO- stop being evil'
  • 807,993
  • 194
  • 1,674
  • 2,175
Antoine
  • 1,021
  • 1
  • 12
  • 13

4 Answers4

27

You have three ways basically.

First: The package should be installed and you need to specify the full path :

apk info --who-owns /path/to/the/file

Second: Use the pkgs.alpinelinux.org website

Third: Use the api.alpinelinux.org API by filtering the json output. For this you need a json parser like jq:

apk add jq

then use the API with the instructions provided here

UPDATE on 2022-04-07

I've released a tiny utility that allows to search via CLI what can be found on pkgs.alpinelinux.org website: https://github.com/fcolista/apkfile

.: Francesco

Francesco Colista
  • 1,347
  • 10
  • 21
5

You're looking for the equivalent of Debian's apt-file for Alpine. Searching for that yields apk-file.

Basically apt-file but for alpine.

Gilles 'SO- stop being evil'
  • 807,993
  • 194
  • 1,674
  • 2,175
  • 2
    That's what I'm after. It appears that *apk-file* is not an alpine package, you can install it with `go get github.com/jessfraz/apk-file` (it happily runs on non alpine systems). The binary is likely static so can probably be copied into docker containers etc. – Att Righ Feb 15 '17 at 20:38
  • 3
    apt-file basically parses pkgs.alpinelinux.org website...so using a JSON decode as i wrote before would be better, since does not need bloated software to reach the same goal. – Francesco Colista Jul 03 '17 at 09:55
  • Indeed, you can see that with `-d` option. And it [doesn't strip whitespaces](https://github.com/genuinetools/apk-file/issues/7). And for some reason with `--arch` it [doesn't display all the results](https://github.com/genuinetools/apk-file/issues/6). – x-yuri Jun 02 '20 at 16:56
2

Example looking for file telnet:

enter image description here

2

given a binary's name, which package I should install on Alpine Linux.

The answer to the body of the question (not the same as the answer to the title of the question) is

apk search -xqa cmd:vim (where vim is the "binary's name"). In this case, there are two packages that provide that command.

earboxer
  • 171
  • 2
  • This should be the accepted answer for the question. Other solutions that propose to use apk-file or the alpine package website are also valid, but for the specific case of finding which package provides a specific command, this one is the most straight forward. – Gaëtan Lehmann Jan 06 '23 at 12:25