dsa-check-packages: Ignore :$arch in package names of dpkg -l output
authorPeter Palfrader <peter@palfrader.org>
Tue, 3 Apr 2012 23:05:53 +0000 (01:05 +0200)
committerPeter Palfrader <peter@palfrader.org>
Tue, 3 Apr 2012 23:05:53 +0000 (01:05 +0200)
Ignore :$arch in package names of dpkg -l output at least for the
"primary" arch.  Does not really handle multi-arch packages, but it
makes things work again for now.

dsa-nagios-checks/checks/dsa-check-packages
dsa-nagios-checks/debian/changelog

index 9a28c5a..107b94b 100755 (executable)
@@ -61,7 +61,13 @@ sub record($) {
 sub get_packages {
        $ENV{'COLUMNS'} = 1000;
        $ENV{'LC_ALL'} = 'C';
-       open(F, "dpkg -l|") or die ("Cannot run dpkg: $!\n");
+       open(F, "dpkg --print-architecture|") or die ("Cannot run dpkg --print-architecture: $!\n");
+       my $arch = <F>;
+       chomp($arch);
+       close(F);
+
+
+       open(F, "dpkg -l|") or die ("Cannot run dpkg -l: $!\n");
        my @lines = <F>;
        close(F);
        chomp(@lines);
@@ -72,6 +78,7 @@ sub get_packages {
        my %pkgs;
        for my $line (@lines) {
                my ($state, $pkg, $version, undef) = split(/  */, $line);
+               $pkg =~ s/\Q:$arch\E$//;
                $pkgs{$state}{$pkg} = { 'installed' => $version }
        }
 
index 114e052..0b215ff 100644 (file)
@@ -12,12 +12,15 @@ dsa-nagios-checks (9X) Xnstable; urgency=low
   * rename checks/dsa-check-backuppg.conf.sample ->
     etc/dsa-check-backuppg.conf.sample.
   * dsa-check-running-kernel: Fix finding meta package for 3.x kernels.
+  * dsa-check-packages: Ignore :$arch in package names of dpkg -l output,
+    at least for the "primary" arch.  Does not really handle multi-arch
+    packages, but it makes things work again for now.
 
   [ Stephen Gran ]
   * dsa-check-udldap-freshness: check new last_update.trace if it
     exists instead of /var/lib/misc/thishost/passwd.{db,tdb}.
 
- -- Peter Palfrader <weasel@debian.org>  Sun, 18 Mar 2012 20:34:29 +0100
+ -- Peter Palfrader <weasel@debian.org>  Wed, 04 Apr 2012 01:05:01 +0200
 
 dsa-nagios-checks (92.1) unstable; urgency=low