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

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

becomes

$ apk --update-cache add dnsmasq-full

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 --orphaned - shows any dependencies that have been orphaned, i.e., unused packages that may be safely deleted
  • apk list --installed --manifest - produces a simple list of “package-name version” pairs that are easily parsed with awk or sed

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 {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
    dnsmasq-full
$ apk list --installed --providers dnsmasq
<dnsmasq> dnsmasq-2.90-r3 x86_64 {dnsmasq} (GPL-2.0-or-later)
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/11/28 01:49
  • by efahlgren