diff options
| author | Hans Ulrich Niedermann <hun@n-dimensional.de> | 2008-02-13 02:12:04 +0100 |
|---|---|---|
| committer | Hans Ulrich Niedermann <hun@n-dimensional.de> | 2008-02-13 02:12:04 +0100 |
| commit | cb4d16327c252206056efe7ab22eb7763354e33e (patch) | |
| tree | d5050bdd5805f39385d08ee41a6de43bffac92a4 | |
| parent | 2f79a8d3ea74cae0d7a4389be39fb82c6dc232cf (diff) | |
Abort commands on errors
| -rw-r--r-- | nbb/nbb_lib.in | 36 |
1 files changed, 30 insertions, 6 deletions
diff --git a/nbb/nbb_lib.in b/nbb/nbb_lib.in index c132754..136b103 100644 --- a/nbb/nbb_lib.in +++ b/nbb/nbb_lib.in @@ -36,13 +36,30 @@ def prog_stdout(call_list): return stdout.strip() +class ProgramRunError(Exception): + def __init__(self, call_list, retcode, cwd=None): + self.call_list = call_list + self.retcode = retcode + if cwd: + self.cwd = cwd + else: + self.cwd = os.getcwd() + def __str__(self): + return ("Error running program (%s, retcode=%d, cwd=%s)" + % (repr(self.call_list), + self.retcode, + repr(self.cwd))) + + def prog_run(call_list): print "RUN:", call_list print " in", os.getcwd() return None p = subprocess.Popen(call_list) stdout, stderr = p.communicate(input=None) - return None # FIXME: Exit code + if p.returncode != 0: + raise ProgramRunError(call_list, p.returncode, os.getcwd()) + return p.returncode class AbstractConfig(object): @@ -123,6 +140,7 @@ class AutomakeSourceTree(BSSourceTree): def init(self): """'autoreconf'""" prog_run(["autoreconf", "-v", "-i", "-s", self.srcdir]) + def configure(self): """'configure --prefix'""" builddir = self.config.builddir() @@ -131,10 +149,12 @@ class AutomakeSourceTree(BSSourceTree): prog_run(["%s/configure" % self.srcdir, "--prefix=%s" % self.config.installdir() ]) + def build(self): """'make'""" os.chdir(self.config.builddir()) prog_run(["make", ]) + def install(self): """'make install'""" os.chdir(self.config.builddir()) @@ -284,13 +304,17 @@ class NBB(object): absdir = os.path.abspath(srcdir) self.vcs_sourcetree = VCSourceTree.detect(absdir) print str(self.vcs_sourcetree) + #print "sourcetree:", dir(self.sourcetree) self.bs_sourcetree = BSSourceTree.detect(self.vcs_sourcetree) print str(self.bs_sourcetree) - self.bs_sourcetree.init() - self.bs_sourcetree.configure() - self.bs_sourcetree.build() - self.bs_sourcetree.install() - #print "sourcetree:", dir(self.sourcetree) + try: + self.bs_sourcetree.init() + self.bs_sourcetree.configure() + self.bs_sourcetree.build() + self.bs_sourcetree.install() + except ProgramRunError, e: + print "Fatal:", e + print "Program aborted." def main(argv): |
