From 2c2c89592cc515d7485732b89daa3c9e763c7c4c Mon Sep 17 00:00:00 2001 From: Heikki Levanto Date: Fri, 18 Mar 2011 15:04:19 +0100 Subject: [PATCH] Cross-ref table by package name --- aptcheck/aptcheck.pl | 42 ++++++++++++++++++++++++++++++++++-------- 1 file changed, 34 insertions(+), 8 deletions(-) diff --git a/aptcheck/aptcheck.pl b/aptcheck/aptcheck.pl index 317341d..71e00fe 100755 --- a/aptcheck/aptcheck.pl +++ b/aptcheck/aptcheck.pl @@ -67,21 +67,19 @@ for $hline ( split("\n",$hostlist) ) { $pkgs++; my $key = $pkg; if ( $src =~ /Security/ ) { - $det .= "$pkg (s) "; - $key = "$pkg"; + $det .= "$pkg (s) "; $sechosts{$H}=1; $secpkgs{$pkg}=1; $secs++; $sectot++; } elsif ( $src =~ /Indexdata/ ) { $det .= "$pkg (id) "; - $key = "$pkg"; $ownhosts{$H}=1; $ownpkgs{$pkg}=1; $own++; $owntot++; } else { - $det .= "$pkg"; + $det .= "$pkg "; $normhosts{$H}=1; $normpkgs{$pkg}=1; $normtot++; @@ -89,9 +87,9 @@ for $hline ( split("\n",$hostlist) ) { if ( !$summary{$key} ) { $summary{$key} = ""; } + $summary{$key} .= "$H "; $new = strdiff($cur,$new); $cur = strdiff($new,$cur); - $summary{$key} .= "$H "; $det .= " "; $det .= "$cur "; $det .= "$new "; @@ -126,7 +124,7 @@ print F "\n"; print F "

Apt package status

\n"; -# Summary table - NEW: one row for per host group +# Summary table: one row for per host group print F "

\n"; print F "\n"; print F "" ; @@ -140,7 +138,12 @@ if ( $sectot ) { for $HH ( sort(keys(%sechosts)) ) { print F "$HH "; } - print F ""; + print F ""; + print F ""; print F "\n"; } if ( $owntot ) { @@ -150,7 +153,13 @@ if ( $owntot ) { for $HH ( sort(keys(%ownhosts)) ) { print F "$HH "; } - print F ""; + print F ""; + print F ""; + #print F ""; print F "\n"; } if ( $normtot ) { @@ -185,6 +194,23 @@ print F "
 " . join(" ",sort(keys(%secpkgs))) . " "; + for $PP ( sort(keys(%secpkgs)) ) { + print F "$PP "; + } + print F "
" . join(" ",sort(keys(%ownpkgs))) . " "; + for $PP ( sort(keys(%ownpkgs)) ) { + print F "$PP "; + } + print F "" . join(" ",sort(keys(%ownpkgs))) . " 
\n"; # The host table print F $table; +# Package table +print F "

Packages\n"; +print F "\n"; +for $P ( sort(keys(%summary)) ) { + my $PN = $P; + $PN = "$P (s)" if ($secpkgs{$P}); + $PN = "$P (id)" if ($ownpkgs{$P}); + print F "\n"; + print F "\n"; + +} +print F "
$PN"; + for $HH ( split(' ',$summary{$P} )) { + print F "$HH "; + } + print F "
\n"; + print F "

Produced " . `date`. " on " . `hostname` . " by " . `whoami` . "
\n"; -- 1.7.10.4