3

On Alpine Linux, given the results of an apk search, how do I determine the package name to give to apk add?

For example, suppose I forgot the how to spell "lighttpd", or I forgot exactly what the package name was. I might do an apk search "lightt*" which yields the following on my machine (a Docker image):

lighttpd-mod_auth-1.4.45-r1
acf-lighttpd-0.6.0-r2
lighttpd-mod_webdav-1.4.45-r1
lighttpd-1.4.45-r1
lighttpd-doc-1.4.45-r1
lighttpd-dbg-1.4.45-r1

Given the above, how do I figure out that I need to type apk add lighttpd? I naively typed in apk add lighttpd-1.4.45-r1 and it gave an error:

ERROR: unsatisfiable constraints:
  lighttpd-1.4.45-r1 (missing):
    required by: world[lighttpd-1.4.45-r1]

I'm used to things like apt-cache search on Debian, where each line of the search results includes exactly the package name to type into apt-get install.

0

2 Answers 2

1

You can tell apk search to not include version numbers by passing it -q/--quiet:

$ apk -q search "lightt*"
lighttpd-mod_auth
acf-lighttpd
lighttpd-mod_webdav
lighttpd
lighttpd-doc
lighttpd-dbg

If you want to find out what version a package provides, it gets a bit more awkward:

apk info lighttpd | head -n1 | sed 's/^lighttpd-\(.*\) description:/\1/g'

Here's a simple function to get the version for a package:

apkver() {
    apk info "$1" | head -n1 | sed "s/^$1-\(.*\) description:/\1/g"
}
-1

This issue is most likely because apk repos aren't updated.

It works fine for me.

monitor:~# apk search lighttpd
lighttpd-mod_auth-1.4.45-r1
acf-lighttpd-0.6.0-r2
lighttpd-mod_webdav-1.4.45-r1
lighttpd-1.4.45-r1
lighttpd-doc-1.4.45-r1
lighttpd-dbg-1.4.45-r1
monitor:~# apk add lighttpd
(1/10) Installing libev (4.24-r0)
(2/10) Installing libintl (0.19.8.1-r1)
(3/10) Installing libmount (2.28.2-r2)
(4/10) Installing glib (2.52.1-r0)
(5/10) Installing gamin (0.1.10-r10)
(6/10) Installing db (5.3.28-r0)
(7/10) Installing libsasl (2.1.26-r10)
....

So try first with apk update.

2
  • What I meant was, from the string "lighttpd-1.4.45-r1", how do I know that I need to type in "lighttpd" as the package name? How do I know which trailing numbers and dashes are required and which are not?
    – peterpi
    Jun 1, 2017 at 15:55
  • You don't need version number, unless you install specific version. Just tested.
    – fugitive
    Jun 1, 2017 at 15:59

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .