The future: opkg vs apk

With @slh's posting of @aparcar's status report on the APK project (How can I tell opkg to prioritize a repo when a package if found in multiple repos? - #6 by slh), it seems like a good time to start talking about the user side of APK.

I installed Alpine on one of my laptops a month ago, so I could get the true "native" feel for APK. I've compiled a preliminary cheatsheet, that I'm thinking we can turn into the basis for a wiki page to ease the transition. Here's the start, anyone with questions or comments, come on in!

opkg vs apk

APK docs on Alpine
Arch apk man page
Arch apk-list man page

Interesting note under "Update the Package list". I have not been able to make -U work, it seems to be ignored, but --update-cache works fine.

Just as with opkg most commands allow an optional package name pattern (denoted [P] in commands below). Again, like opkg, the patterns are file globs, e.g., *dns* matches every package with dns somewhere in its name.

Command Description
apk -h show commands and summaries
apk subcmd -h help specific to "subcmd"
apk update force update of local indexes, same as opkg

Add and remove

apk opkg Description
apk update opkg update refresh the package feeds
apk add pkg opkg install pkg install "pkg"
apk del pkg opkg remove pkg uninstall "pkg"

Adding is substantially the same with both package managers. One difference is that apk wants you to provide valid signatures for all packages, while opkg ignores this on local ones, so if you're installing a non-standard (self-built) package, use the --allow-untrusted option:

$ apk add ./owut_2024.07.01~189b2721-r1.apk
ERROR: ./owut_2024.07.01~189b2721-r1.apk: UNTRUSTED signature

$ apk add --allow-untrusted ./owut_2024.07.01~189b2721-r1.apk
OK: 2313 MiB in 569 packages

Using our note above about --update-cache, we can now replace the traditional chained opkg commands with a single apk one.

$ opkg update && opkg install dnsmasq-full


$ apk --update-cache add dnsmasq-full

List commands

To reiterate, P is a file glob in the following.

(editor's note: wrapping of the commands in the table is not optimal)

apk opkg Description
apk list opkg list show everything available
apk list P opkg list P show matches for "P", or if you prefer regex then pipe through grep
apk list --installed [P] opkg list-installed show all installed or those matching "P"
apk list --upgradeable [P] opkg list-upgradable show upgradeable packages
apk list --providers [P] opkg -A whatprovides P show all packages that provide "P"

Interesting variants

  • apk list --installed --orphaned - shows any dependencies that have been orphaned, i.e., unused packages that may be safely deleted

Comparative examples of listings:

$ opkg -A whatprovides dnsmasq  # Show all candidates
What provides dnsmasq
$ apk list --providers dnsmasq
<dnsmasq> dnsmasq-2.90-r3 x86_64 {dnsmasq} (GPL-2.0-or-later)
<dnsmasq> dnsmasq-dnssec-2.90-r3 x86_64 {dnsmasq} (GPL-2.0-or-later)
<dnsmasq> dnsmasq-dnssec-dbus-2.90-r3 x86_64 {dnsmasq} (GPL-2.0-or-later)
<dnsmasq> dnsmasq-dnssec-nftset-2.90-r3 x86_64 {dnsmasq} (GPL-2.0-or-later)

Show installed provider for dnsmasq:

$ opkg whatprovides dnsmasq  # Show the installed provider
What provides dnsmasq
$ apk list --installed --providers dnsmasq
<dnsmasq> dnsmasq-2.90-r3 x86_64 {dnsmasq} (GPL-2.0-or-later)

Package Info

apk opkg Description
apk info P opkg info P show summary information
apk info --all P no equivalent show extensive information
apk info --contents P opkg files P show files contained in the package