opkg to apk cheat sheet

This is a cheat sheet which aims to help with a seamless transition from the previous opkg package manager to the new apk.

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
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

Interesting variants

apk's --update-cache option allows you to perform an update at the same time you do the add, so you can now replace the traditional chained opkg commands with a single apk one.

$ opkg update && opkg install dnsmasq-full

becomes

$ apk --update-cache add dnsmasq-full

The --simulate option allows you to do a dry run of a command, to see its effect before you actually execute it.

$ apk del --simulate nmap
(1/1) Purging nmap (7.95-r1)
OK: 47 MiB in 288 packages

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

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 --manifest - produces a simple list of “package-name version” pairs that are easily parsed with awk or sed
  • apk list --orphaned - shows any dependencies that may have been orphaned, i.e., packages that have no declared top-level dependents. This may indicate that they are left over from an error in removing another package, but it may show packages that are required, but simply have incorrect dependencies. If you wish to remove an orphaned package, first make absolutely sure that it is not required for your system to function correctly.

Comparative examples of listings:

$ opkg -A whatprovides dnsmasq  # Show all candidates
What provides dnsmasq
    dnsmasq-dhcpv6
    dnsmasq
    dnsmasq-full
$ apk list --providers dnsmasq
<dnsmasq> dnsmasq-2.90-r3 x86_64 {feeds/base/package/network/services/dnsmasq} (GPL-2.0)
<dnsmasq> dnsmasq-dhcpv6-2.90-r3 x86_64 {feeds/base/package/network/services/dnsmasq} (GPL-2.0)
<dnsmasq> dnsmasq-full-2.90-r3 x86_64 {feeds/base/package/network/services/dnsmasq} (GPL-2.0) [installed]

Show installed provider for `dnsmasq`:

$ opkg whatprovides dnsmasq  # Show the installed provider
What provides dnsmasq
    dnsmasq-full
$ apk list --installed --providers dnsmasq
<dnsmasq> dnsmasq-full-2.90-r3 x86_64 {feeds/base/package/network/services/dnsmasq} (GPL-2.0) [installed]
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
apk opkg Description
apk extract --allow-untrusted P tar -xvf P extract contents of the package
This website uses cookies. By using the website, you agree with storing cookies on your computer. Also you acknowledge that you have read and understand our Privacy Policy. If you do not agree leave the website.More information about cookies
  • Last modified: 2024/12/11 00:40
  • by efahlgren