`apk add` failing on private branch builds

:waving_hand: I’m attempting to install some new packages on a router currently running a private build based off main, and am failing like so:

root@logan:~# apk add tcpdump
ERROR: wget: exited with error 8
WARNING: updating and opening https://downloads.openwrt.org/snapshots/targets/qualcommax/ipq807x/kmods/6.12.79-1-5f1eadfddeee7f76a5561ecbbb77a09d/packages.adb: unexpected end of file
ERROR: unable to select packages:
  kmod-qca-nss-dp (no such package):
    required by: world[kmod-qca-nss-dp]
  libblobmsg-json20260213 (no such package):
    required by: world[libblobmsg-json20260213]
  libjson-script20260213 (no such package):
    required by: world[libjson-script20260213]
  libubox20260213 (no such package):
    required by: world[libubox20260213]
  base-files-1~a226686:
    breaks: world[base-files=1700~8a18e84a88]
  kernel-6.12.79~5f1eadfddeee7f76a5561ecbbb77a09d-r1:
    breaks: world[kernel=6.12.74~7cbe14d1bf010c4cf58d6deeee1a9b71-r1]

This build should not have a kmod-qca-nss-dp package, as this is on the EDMA migration branch which does away with that in favor of edma / ppe drivers. However, this must be a more generic question, since I can see other cases where installing packages on SNAPSHOTbuilds will fail to get the kmods (due to them being aged out and updated for the latest build, for example).

So, is there a way to tell apk to ignore the current state, or the missing dependency and just try and get the dang tcpdump package? And what’s the deal with the missing libblobmsg-json libjson-script and libubox? Artifacts of broken main state? Something else?

Thanks in advance!

NOTE: I’ve tried --force (didn’t help), --force-missing-repositories (didn’t help), and am very afraid to try --force-broken-world (update: I’m dumb and figured I’d try it anyway… it looks like it’s going to cause a lot of breakage and in the end it still didn’t work, because it uninstalled a whole lot of crap including /etc/resolv.conf therefore causing further name resolution to break).

UPDATE: Somehow, my /etc/apk/world was included in the sysupgrade backup, so this makes a lot more sense now. How that happened, I'm not sure, but ..

Also, --force-broken-world really did a number on the AP as I predicted, so don't be dumb like me and try to use that to fix random package issues. Couldn't log in to Luci, couldn't SSH in (wouldn't take either password or SSH key), … fortunately, I have another router of the same model so MTTR was under 5 mins (flash updated build, restore backup, reconnect in place of old router).. recovering the busted one might be a bigger task since even the backup partition seems busted.

The kernel and all kmods are built with a unique signature which prevents mix and match, so you can't just grab a kmod from snapshot or 25.12.0 and install it on 25.12.1 or whatever.

The easiest way to do this is to build the full image with the packages you want, avoiding post-install apk add altogether. Just get into make menuconfig and set all the desired packages to y.

3 Likes
2 Likes

Yeah I knew this about the kernel but I was trying to install tcpdump, so other than the “missing by design" kmods it shouldn't need any kmod dependencies.

Thanks for that article @frollic .. I knew some of that but definitely not at that level.

Still, tcpdump shouldn't have needed any kmods :confused:

Will need to see how to do this using GitHub Actions builder.

Yeah, exactly:

$ apk query --format yaml --fields all tcpdump
# 1 items
- package: tcpdump-4.99.6-r1
  name: tcpdump
  version: 4.99.6-r1
  description: Network monitoring and data acquisition tool
  arch: x86_64
  license: BSD-3-Clause
  origin: feeds/base/network/utils/tcpdump
  maintainer: Felix Fietkau <nbd@nbd.name>
  url: http://www.tcpdump.org/
  installed-size: 890772
  file-size: 355734
  depends: # 2 items
    - libc
    - libpcap1
  provides: # 1 items
    - tcpdump-any
  repositories:
    - lib/apk/db/installed
  reverse-depends:
  reverse-install-if:
  contents:
    - lib/apk/packages/tcpdump.list
    - usr/bin/tcpdump
  scripts: # 2 items
    - pre-deinstall
    - post-upgrade
  status:
    - installed

You know, it could be that apk world is mangled, otherwise why would it want to be changing the kernel? What does it say if you just run apk fix?

apk is different that other package managers in this regard, and doesn't have an install command because of this. When you do add it actually does two things: edits the world file to contain whatever you added, then runs fix to make the installation match the world (which might in reality delete, upgrade, downgrade and install packages). Likewise for del: first change world, then fix (again possiblly deleting, upgrading, downgrading or installing).

So, if the constraints on kernel=... don't match the installation, you'd see exactly what you report in the opening post.

If you have the time, I'd recommend this article to everyone:

1 Like

I think this is the root of the issue – the world file got included in sysupgrade (oops, wrong command up top) backup, so then the state matched the wrong kernel/build. I didn’t know about apk fix but I will try it next time. My attempt to use --force-broken-world definitely killed the router.

Thanks for all the suggestions here, though! I learned a lot!

PS: @efahl was there a sysupgrade bug that somehow included /etc/apk/world in the backups? I seem to recall something like that early in 25.x release cycle.

Yes, https://github.com/openwrt/openwrt/pull/17847 which is languishing. It might help move it along if you comment there...

1 Like

Done! Thanks for the link!

1 Like

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.