1
0
mirror of https://github.com/ARM-software/devlib.git synced 2024-10-06 10:50:51 +01:00

Target: Modified get_installed search order

Changed get_installed to search self.executables_directory first.
This means that user provided binaries will be used over system ones.

Also added the option to not search system folders for a binary.
This commit is contained in:
Sebastian Goscik 2016-02-15 15:09:27 +00:00
parent 33603c6648
commit 84151f953a

View File

@ -421,16 +421,19 @@ class Target(object):
def uninstall(self, name): def uninstall(self, name):
raise NotImplementedError() raise NotImplementedError()
def get_installed(self, name): def get_installed(self, name, search_system_binaries=True):
for path in self.getenv('PATH').split(self.path.pathsep): # Check user installed binaries first
try:
if name in self.list_directory(path):
return self.path.join(path, name)
except TargetError:
pass # directory does not exist or no executable premssions
if self.file_exists(self.executables_directory): if self.file_exists(self.executables_directory):
if name in self.list_directory(self.executables_directory): if name in self.list_directory(self.executables_directory):
return self.path.join(self.executables_directory, name) return self.path.join(self.executables_directory, name)
# Fall back to binaries in PATH
if search_system_binaries:
for path in self.getenv('PATH').split(self.path.pathsep):
try:
if name in self.list_directory(path):
return self.path.join(path, name)
except TargetError:
pass # directory does not exist or no executable premssions
which = get_installed which = get_installed