~frank-cizmich/percona-toolkit/percona-toolkit

« back to all changes in this revision

Viewing changes to lib/VersionCheck.pm

  • Committer: Daniel Nichter
  • Date: 2014-02-20 03:00:02 UTC
  • Revision ID: daniel@percona.com-20140220030002-gsj22qr101mb2fbp
Remove version check bin type.  Update all tools.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# This program is copyright 2012-2013 Percona Ireland Ltd.
 
1
# This program is copyright 2012-2014 Percona Ireland Ltd.
2
2
# Feedback and improvements are welcome.
3
3
#
4
4
# THIS PROGRAM IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED
479
479
   perl_version        => \&get_perl_version,
480
480
   perl_module_version => \&get_perl_module_version,
481
481
   mysql_variable      => \&get_mysql_variable,
482
 
   bin_version         => \&get_bin_version,
483
482
);
484
483
 
485
484
sub valid_item {
669
668
   return \%version_for;
670
669
}
671
670
 
672
 
sub get_bin_version {
673
 
   my (%args) = @_;
674
 
   my $item = $args{item};
675
 
   my $cmd  = $item->{item};
676
 
   return unless $cmd;
677
 
 
678
 
   my $sanitized_command = File::Basename::basename($cmd);
679
 
   PTDEBUG && _d('cmd:', $cmd, 'sanitized:', $sanitized_command);
680
 
   return if $sanitized_command !~ /\A[a-zA-Z0-9_-]+\z/;
681
 
 
682
 
   my $output = `$sanitized_command --version 2>&1`;
683
 
   PTDEBUG && _d('output:', $output);
684
 
 
685
 
   my ($version) = $output =~ /v?([0-9]+\.[0-9]+(?:\.[\w-]+)?)/;
686
 
 
687
 
   PTDEBUG && _d('Version for', $sanitized_command, '=', $version);
688
 
   return $version;
689
 
}
690
 
 
691
671
sub _d {
692
672
   my ($package, undef, $line) = caller 0;
693
673
   @_ = map { (my $temp = $_) =~ s/\n/\n# /g; $temp; }