Skip to content
Snippets Groups Projects
Commit b5f4f8fd authored by Andreas Kusalananda Kähäri's avatar Andreas Kusalananda Kähäri
Browse files

Use "locate -l 1 $exe" to locate the executable when "which $exe" fails.

Do not re-set $executable{$key} = $key when we have worked so hard to
set it to something usable...
parent e3b3dd00
No related branches found
No related tags found
No related merge requests found
...@@ -228,32 +228,42 @@ if ( !defined($input_file) ) { ...@@ -228,32 +228,42 @@ if ( !defined($input_file) ) {
my %executables = ( 'myisamchk' => '/usr/local/ensembl/mysql/bin/myisamchk', my %executables = ( 'myisamchk' => '/usr/local/ensembl/mysql/bin/myisamchk',
'rsync' => '/usr/bin/rsync' ); 'rsync' => '/usr/bin/rsync' );
#Check executables # Make sure we can find all executables.
print( '-' x 35, ' EXECUTABLE CHECKS ', '-' x 35, "\n" ); print( '-' x 35, ' EXECUTABLE CHECKS ', '-' x 35, "\n" );
foreach my $key (keys %executables) { foreach my $key ( keys %executables ) {
my $exe = $executables{$key}; my $exe = $executables{$key};
my $output = `which $exe`; my $output = `which $exe`;
my $rc = $? >> 8; my $rc = $? >> 8;
if($rc != 0) {
my $possible_location = `which $key 2>&1`; if ( $rc != 0 ) {
my $loc_rc = $? >> 8; my $possible_location = `locate -l 1 $key 2>&1`; # Ugly but simple.
if($loc_rc == 0) { my $loc_rc = $? >> 8;
if ( $loc_rc == 0 ) {
chomp $possible_location; chomp $possible_location;
$executables{$key} = $possible_location; $executables{$key} = $possible_location;
printf("Can not find '%s'; using '%s'\n", $exe, $executables{$key}); printf( "Can not find '%s'; using '%s'\n",
$exe, $executables{$key} );
} }
else { else {
if($key eq 'myisamchk' && ! $opt_check) {
printf("Can not find '%s' but --nocheck was specified so skipping\n", $exe); if ( $key eq 'myisamchk' && !$opt_check ) {
print( "Can not find 'myisamchk' " .
"but --nocheck was specified so skipping\n" ),;
} }
else { else {
die(sprintf("Can not find '%s' and using 'locate %s' yields nothing Check your path", $exe, $key)); die(
sprintf(
"Can not find '%s' and neither 'which %s' nor 'locate %s' "
. "yields anything useful. Check your path",
$exe, $key, $key
) );
} }
} }
$executables{$key} = $key; } ## end if ( $rc != 0 )
} } ## end foreach my $key ( keys %executables)
}
my $run_hostname = ( gethostbyname( hostname() ) )[0]; my $run_hostname = ( gethostbyname( hostname() ) )[0];
my $working_dir = rel2abs( curdir() ); my $working_dir = rel2abs( curdir() );
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment