37
37
local $Data::Dumper::Sortkeys = 1;
38
38
local $Data::Dumper::Quotekeys = 0;
40
use Digest::MD5 qw(md5_hex);
41
use Sys::Hostname qw(hostname);
40
use Digest::MD5 qw(md5_hex);
41
use Sys::Hostname qw(hostname);
42
42
use File::Basename qw();
45
use IPC::Cmd qw(can_run);
50
47
require Percona::Toolkit;
104
101
my $instances = $args{instances} || [];
105
102
my $instances_to_check;
108
if (exists $ENV{PERCONA_VERSION_CHECK} && !$ENV{PERCONA_VERSION_CHECK}) {
109
PTDEBUG && _d('--version-check disabled by PERCONA_VERSION_CHECK=0');
104
# This sub should only be called if $o->get('version-check') is true,
105
# and it is by default because the option is on by default in PT 2.2.
106
# However, we do not want dev and testing to v-c, so even though this
107
# sub is called, force should be false because $o->got('version-check')
108
# is false, then check for a .bzr dir which indicates dev or testing.
109
if ( !$args{force} ) {
110
if ( $FindBin::Bin && -d "$FindBin::Bin/../.bzr" ) {
111
PTDEBUG && _d("$FindBin::Bin/../.bzr disables --version-check");
113
if ( !$ENV{PERCONA_FORCE_VERSION_CHECK} ) {
114
# Check if we're running from a bzr repo, and that repo is ours.
115
if ( my $bzr = can_run('bzr') ) {
116
my $percona_repo = Percona::Toolkit::bzr_repo();
117
my $info = `$bzr info 2>/dev/null`;
118
if ( $info && $info =~ /\Q$percona_repo/ ) {
119
PTDEBUG && _d('--version-check disabled by running from a bzr checkout');
124
# Perhaps bzr isn't available, but we're still running from
125
# a bzr repo. Brian occasionally does this when running in
126
# his VMs, since it's usually easier than installing bzr.
127
# So check if $Cwd/.bzrignore or $FindBin::Bin/../.bzrignore
128
# exist, and if they do, check if it has this line:
129
# special/percona-toolkit/v-c-internal
130
for my $dir ( Cwd::cwd(), File::Spec->updir($FindBin::Bin) ) {
131
my $ignore = File::Spec->catfile($dir, '.bzrignore');
132
next unless -r $ignore;
133
open my $fh, '<', $ignore or next;
134
chomp(my $file_contents = do { local $/ = undef; <$fh> });
136
if ( $file_contents =~ m{special/percona-toolkit/v-c-internal} ) {
137
PTDEBUG && _d('--version-check disabled by running from a bzr checkout');
143
117
# Name and ID the instances. The name is for debugging,
144
118
# and the ID is what the code uses to prevent double-checking.
145
119
foreach my $instance ( @$instances ) {
197
171
# Always update the vc file, even if the version check fails.
199
# Update the check time for things we checked. I.e. if we
200
# didn't check it, do _not_ update its time.
202
instances => $instances_to_check,
203
vc_file => $args{vc_file}, # testing
204
now => $args{now}, # testing
208
PTDEBUG && _d('Error updating version check file:', $EVAL_ERROR);
172
if ( @$instances_to_check ) {
174
# Update the check time for things we checked. I.e. if we
175
# didn't check it, do _not_ update its time.
177
instances => $instances_to_check,
178
vc_file => $args{vc_file}, # testing
179
now => $args{now}, # testing
183
PTDEBUG && _d('Error updating version check file:', $EVAL_ERROR);
211
187
if ( $ENV{PTDEBUG_VERSION_CHECK} ) {