VersionCheck: Skip running if called from our bzr repo

This commit is contained in:
Brian Fraser
2013-02-21 04:41:57 -03:00
parent 8ecde260a7
commit 4534981913
4 changed files with 39 additions and 0 deletions

View File

@@ -7,3 +7,4 @@ release
snapshot snapshot
.DS_Store .DS_Store
build build
special/percona-toolkit/v-c-internal

View File

@@ -21,6 +21,8 @@
package Percona::Toolkit; package Percona::Toolkit;
our $VERSION = '2.1.8'; our $VERSION = '2.1.8';
sub bzr_repo { q{~percona-toolkit-dev} }
1; 1;
} }
# ########################################################################### # ###########################################################################

View File

@@ -42,6 +42,10 @@ use Sys::Hostname qw(hostname);
use File::Basename qw(); use File::Basename qw();
use File::Spec; use File::Spec;
use IPC::Cmd qw(can_run);
use FindBin qw();
use Cwd qw();
eval { eval {
require Percona::Toolkit; require Percona::Toolkit;
require HTTPMicro; require HTTPMicro;
@@ -106,6 +110,36 @@ sub version_check {
return; return;
} }
if ( !$ENV{PERCONA_FORCE_VERSION_CHECK} ) {
# Check if we're running from a bzr repo, and that repo is ours.
if ( my $bzr = can_run('bzr') ) {
my $percona_repo = Percona::Toolkit::bzr_repo();
my $info = `$bzr info 2>/dev/null`;
if ( $info && $info =~ /\Q$percona_repo/ ) {
PTDEBUG && _d('--version-check disabled by running from a bzr checkout');
return;
}
}
# Perhaps bzr isn't available, but we're still running from
# a bzr repo. Brian occasionally does this when running in
# his VMs, since it's usually easier than installing bzr.
# So check if $Cwd/.bzrignore or $FindBin::Bin/../.bzrignore
# exist, and if they do, check if it has this line:
# special/percona-toolkit/v-c-internal
for my $dir ( Cwd::cwd(), File::Spec->updir($FindBin::Bin) ) {
my $ignore = File::Spec->catfile($dir, '.bzrignore');
next unless -r $ignore;
open my $fh, '<', $ignore or next;
chomp(my $file_contents = do { local $/ = undef; <$fh> });
close $fh;
if ( $file_contents =~ m{special/percona-toolkit/v-c-internal} ) {
PTDEBUG && _d('--version-check disabled by running from a bzr checkout');
return;
}
}
}
# Name and ID the instances. The name is for debugging, # Name and ID the instances. The name is for debugging,
# and the ID is what the code uses to prevent double-checking. # and the ID is what the code uses to prevent double-checking.
foreach my $instance ( @$instances ) { foreach my $instance ( @$instances ) {

View File

@@ -25,6 +25,8 @@ my $sb = new Sandbox(basedir => '/tmp', DSNParser => $dp);
my $master_dbh = $sb->get_dbh_for('master'); my $master_dbh = $sb->get_dbh_for('master');
my $slave1_dbh = $sb->get_dbh_for('slave1'); my $slave1_dbh = $sb->get_dbh_for('slave1');
local $ENV{PERCONA_FORCE_VERSION_CHECK} = 1;
sub test_v { sub test_v {
my (%args) = @_; my (%args) = @_;