From: Heikki Levanto Date: Tue, 30 Oct 2012 12:30:38 +0000 (+0100) Subject: Old changes... X-Git-Url: http://jsfdemo.indexdata.com/cgi-bin?a=commitdiff_plain;h=90e817a4e409512818d48db9abbaa55f11b3abf6;p=git-tools-moved-to-github.git Old changes... --- diff --git a/aptcheck/aptcheck.pl b/aptcheck/aptcheck.pl index 3866de9..2dac01a 100755 --- a/aptcheck/aptcheck.pl +++ b/aptcheck/aptcheck.pl @@ -19,6 +19,8 @@ # 11-Mar-2011 Heikki: Started this # 22-Mar-2011 Heikki: Adding manually maintained packages # 15-Aug-2011 Heikki: Adding a total in the headline, for nagiosgrapher +# 21-May-2012 Heikki: Added a date since when a package has been pending +# 31-May-2012 Heikki: Pointing to the new wiki # # TODO: Assumes that we release our restricted packages for all versions # and architectures at the same time. Gets only the highest version from @@ -32,7 +34,8 @@ use strict; my $debug= $ARGV[0] || 0; # 0=none, 1=some, 2=more, 3=much my $year =`date +%Y`; -my $wikilink = 'http://twiki.indexdata.dk/cgi-bin/twiki/view/ID/'; +#my $wikilink = 'http://twiki.indexdata.dk/cgi-bin/twiki/view/ID/'; +my $wikilink = 'https://twiki.indexdata.com/twiki/bin/view/ID/'; my $restrictedpackages = "ssh -q kebab cat /home/ftp/pub/debian/dists/*/restricted/*/Packages"; #### Host comments @@ -76,7 +79,7 @@ for my $pline ( split("\n",$restplines) ) { print "found $pname, first version $pver\n" if $debug>1; } else { my $bver = $restrpkgs{$pname}; - `dpkg --compare-versions "$bver" lt "$pver" `; + `dpkg --compare-versions "$bver" lt "$pver" 2>/dev/null `; if ( ! $? ) { print "found $pname, better version $pver (better than $bver)\n" if $debug>1; @@ -112,6 +115,7 @@ my $owntot = 0; my $mantot = 0; my $normtot = 0; my %updlinks; +my %debversions; # Pending modification dates my %olddates; # Read in from the file @@ -146,11 +150,12 @@ for my $hline ( split("\n",$hostlist) ) { next if ($H =~ /^servicegroups/ ); print "Checking $H\n" if $debug; $allhosts{$H}=1; + my $cmd0 = "cat /etc/debian_version"; my $cmd1 = "apt-cache -q policy " . join(" ",sort(keys(%restrpkgs))); my $cmd2 = "apt-get upgrade -s -o 'Debug::NoLocking=true' "; # Note, do not append -qq, we want some output even when nothing to do - print "ssh -q $H \"$cmd1 ; $cmd2 \" 2>/dev/null" if ($debug>1); - my $apt = `ssh -q $H "$cmd1 ; $cmd2 " 2>/dev/null`; + print "ssh -q $H \"$cmd0; $cmd1 ; $cmd2 \" 2>/dev/null \n" if ($debug>1); + my $apt = `ssh -q $H "$cmd0; $cmd1 ; $cmd2 " 2>/dev/null`; if ( !$apt ) { $table .= " \n"; $table .= "$H (skipped)\n"; @@ -166,7 +171,18 @@ for my $hline ( split("\n",$hostlist) ) { my $restrname = ""; my $restrinst = ""; my $restrcand = ""; + my $debver = 0; for my $p ( split("\n",$apt) ) { + if ( !$debver ) { # first line + $debver = 1; + $p =~ s/(5[0-9.]+)/$1 LENNY !!!/; + $p =~ s/(6[0-9.]+)/$1 squeeze/; + $p =~ s/(7[0-9.]+)/$1 wheezy/; + $p = " Debian $p"; + $debversions{$H} = $p; + print "Deb version for $H is $p\n" if ($debug>1); + next; + } # parse apt-cache output $restrname = $1 if $p =~ /^(\S+):$/; $restrinst = $1 if $p =~ /^\s+Installed:\s+(\S+)$/; @@ -177,7 +193,7 @@ for my $hline ( split("\n",$hostlist) ) { ( $restrinst ne $bver ) ) { # if different, it is a regular apt upgrade, and will be seen # later. AND we want to have a different version in our repo - `dpkg --compare-versions "$bver" lt "$restrinst" `; + `dpkg --compare-versions "$bver" lt "$restrinst" 2>/dev/null`; if ( $? ) { # It was not a downgrade # manual packages may be ahead of the repo! $mantot++; @@ -252,8 +268,8 @@ for my $hline ( split("\n",$hostlist) ) { $det .= "\n"; } - $table .= " \n"; - $table .= "$H  \n"; + $table .= " \n"; + $table .= "$H  \n"; if ( $pkgs ) { $table .= "$pkgs packages to upgrade. "; $table .= "$secs security. " if $secs; @@ -270,6 +286,7 @@ for my $hline ( split("\n",$hostlist) ) { $updlink =~ s/Opencontent-solrUpdates/OpenContentSolrUpdates/; $updlinks{$H} = $updlink; $table .= " Upd"; + $table .= " " . $debversions{$H}; $table .= "\n"; $table .= "$hostcomments{$H}\n" if ( $hostcomments{$H} ); @@ -282,7 +299,7 @@ $table .= "\n"; # Save the date file `mv -f $datefilename $dateoldfilename`; open F, ">$datefilename" or die "Could not open date file $datefilename for writing"; -for my $k (keys(%newdates) ) { +for my $k (sort(keys(%newdates)) ) { print F "$k " . $newdates{$k}. "\n"; print "date for '$k' '" . $newdates{$k}. "'\n" if $debug; }