diff --git a/pisi/actionsapi/get.py b/pisi/actionsapi/get.py index 00b87164..11185c50 100644 --- a/pisi/actionsapi/get.py +++ b/pisi/actionsapi/get.py @@ -14,8 +14,12 @@ # Standart Python Modules import os.path +# PISI Modules +from pisi.ui import ui + # ActionsAPI Modules from variables import glb +from shelltools import exists_binary env = glb.env dirs = glb.dirs @@ -86,8 +90,17 @@ def defaultprefixDIR(): # Binutils Variables -def getBinutilsInfo(needed): - return '%s-%s' % (HOST(), needed) +def getBinutilsInfo(util): + cross_build_name = '%s-%s' % (HOST(), util) + if not exists_binary(cross_build_name): + if not exists_binary(util): + ui.error('Error: util %s cannot be found' % util) + else: + ui.debug('Warning: %s does not exist, using plain name %s' + % (cross_build_name, util)) + return util + else: + return cross_build_name def AR(): return getBinutilsInfo('ar') diff --git a/pisi/actionsapi/shelltools.py b/pisi/actionsapi/shelltools.py index 3b5db41d..9424ad4e 100644 --- a/pisi/actionsapi/shelltools.py +++ b/pisi/actionsapi/shelltools.py @@ -82,6 +82,7 @@ def export(key, value): os.environ[key] = value def system(command): + ui.debug('executing ' + command) p = os.popen(command) while 1: line = p.readline() @@ -90,3 +91,12 @@ def system(command): ui.debug(line) return p.close() + +def exists_binary(bin): + # determine if path has binary + from os.path import exists, join + path = os.environ['PATH'].split(':') + for directory in path: + if exists( join(directory, bin) ): + return True + return False diff --git a/pisi/cli/pisicli.py b/pisi/cli/pisicli.py index 4858f619..5ca1ed6c 100644 --- a/pisi/cli/pisicli.py +++ b/pisi/cli/pisicli.py @@ -45,6 +45,9 @@ class PisiCLI(object): #if len(parser.rargs)==0: # self.die() cmd = args[0] + cli = pisi.ui.CLI(options.debug) + pisi.ui.ui = cli + except IndexError: self.die() except ParserError: diff --git a/pisi/ui.py b/pisi/ui.py index a288fbd8..43d3e3bf 100644 --- a/pisi/ui.py +++ b/pisi/ui.py @@ -22,15 +22,25 @@ def register(_impl): # default UI implementation class CLI: - def __init__(self, debuggy = True): - self.showDebug = debuggy + def __init__(self, debuggy = False, verbose = False): + self.show_debug = debuggy + self.show_verbose = verbose - def info(self, msg): - sys.stdout.write(colorize(msg, 'blue')) + def set_verbose(self, flag): + self.show_verbose = flag + + def set_debug(self, flag): + self.show_debug = flag + + def info(self, msg, verbose = False): + if verbose and self.show_verbose: + sys.stdout.write(colorize(msg, 'blue')) + elif not verbose: + sys.stdout.write(colorize(msg, 'blue')) sys.stdout.flush() def debug(self, msg): - if self.showDebug: + if self.show_debug: sys.stdout.write(msg) sys.stdout.flush() diff --git a/tests/alpha-light.sh b/tests/alpha-light.sh index 659a1857..1e788657 100755 --- a/tests/alpha-light.sh +++ b/tests/alpha-light.sh @@ -2,7 +2,7 @@ pwd PATH=$PATH:. -set -x +set -x -e pisi-cli build tests/zip/pspec.xml tests/unzip/pspec.xml pisi-cli index . pisi-cli add-repo repo1 pisi-index.xml