Bug in omd cleanup: it tries to purge dpkg-query

CMK version: 2.4.0p23.cre
OS version: Debian 13 (trixie)

So when updating CMK I noticed a few old versions, so as usual, I ran omd cleanup. To my surprise, it said:

# omd cleanup
2.4.0p17.cre         Uninstalling
Failed to uninstall package:
Reading package lists...
Building dependency tree...
Reading state information...
E: Unable to locate package dpkg-query

Huh, that error comes from apt. What is going on?

# omd -v cleanup
Executing: dpkg -S /opt/omd/versions/2.4.0p17.cre
2.4.0p17.cre         Uninstalling
Executing: apt-get -y purge dpkg-query
Failed to uninstall package:
Reading package lists...
Building dependency tree...
Reading state information...
E: Unable to locate package dpkg-query

It tries to run apt-get -y purge dpkg-query? That sounds like a bad idea. I’m glad dpkg-query is not a package!

So why does that happen? It runs a dpkg -S command, let’s try that…

# dpkg -S /opt/omd/versions/2.4.0p17.cre
dpkg-query: warning: files list file for package 'openssh-blacklist' missing; assuming package has no files currently installed
check-mk-raw-2.4.0p17: /opt/omd/versions/2.4.0p17.cre

Ah, that explains I guess. That warning surely doesn’t go to STDOUT but STDERR, let’s check that:

# dpkg -S /opt/omd/versions/2.4.0p17.cre 2>/dev/null
check-mk-raw-2.4.0p17: /opt/omd/versions/2.4.0p17.cre

So to fix this bug, omd cleanup should discard STDERR when parsing the output of dpkg -S.

(Yes, my dpkg apparently has an issue that needs fixing, but the fix mentioned should be made anyway IMO)

4 Likes

Hi @Jay2k1 !
Thanks for reporting.

It will be fixed with the release of the Werk #18897: omd cleanup: Don't try to purge dpkg-query :slight_smile:

1 Like