1
0
mirror of synced 2026-01-13 15:17:30 +00:00

Move findBinary to Xen::Tools::Common

This commit is contained in:
Axel Beckert 2012-11-27 23:42:21 +01:00
parent 6b64dcc122
commit 4c3e4abff7
3 changed files with 36 additions and 33 deletions

View File

@ -218,3 +218,5 @@ Axel's Break-Backwards-Compatibility Wishlist
* Uncouple generating auto start symlinks from `--boot`.
Maybe add some `--autostart` or such.
* Maybe replace findBinary with File::Which

View File

@ -4006,38 +4006,6 @@ sub generatePassword {
}
=begin doc
Find the location of the specified binary on the curent user's PATH.
Return undef if the named binary isn't found.
=end doc
=cut
sub findBinary
{
my ($bin) = (@_);
# strip any path which might be present.
$bin = $2 if ( $bin =~ /(.*)[\/\\](.*)/ );
foreach my $entry ( split( /:/, $ENV{ 'PATH' } ) )
{
# guess of location.
my $guess = $entry . "/" . $bin;
# return it if it exists and is executable
return $guess if ( -e $guess && -x $guess );
}
return undef;
}
=begin doc
Unmount any mount-points which are below the given path.

View File

@ -21,7 +21,8 @@ use vars qw(@EXPORT_OK @EXPORT);
use English;
@EXPORT = qw(readConfigurationFile xenRunning runCommand setupAdminUsers
findXenToolstack logprint_with_config logonly_with_config fail_with_config);
findXenToolstack findBinary
logprint_with_config logonly_with_config fail_with_config);
=head1 FUNCTIONS
@ -137,6 +138,38 @@ sub xenRunning ($$)
return ($running);
}
=head2 findBinary
=begin doc
Find the location of the specified binary on the curent user's PATH.
Return undef if the named binary isn't found.
=end doc
=cut
sub findBinary
{
my ($bin) = (@_);
# strip any path which might be present.
$bin = $2 if ( $bin =~ /(.*)[\/\\](.*)/ );
foreach my $entry ( split( /:/, $ENV{ 'PATH' } ) )
{
# guess of location.
my $guess = $entry . "/" . $bin;
# return it if it exists and is executable
return $guess if ( -e $guess && -x $guess );
}
return undef;
}
=head2 findXenToolstack
=begin doc