diff --git a/src/tito/builder.py b/src/tito/builder.py index b155062..2457c0d 100644 --- a/src/tito/builder.py +++ b/src/tito/builder.py @@ -23,6 +23,7 @@ from distutils.version import LooseVersion as loose_version from tempfile import mkdtemp from tito.common import * +from tito.exception import RunCommandException from tito.release import * from tito.exception import TitoException from tito.config_object import ConfigObject @@ -261,6 +262,11 @@ class Builder(ConfigObject): except (KeyboardInterrupt, SystemExit): print "" exit(1) + except RunCommandException, err: + msg = str(err) + if (re.search('Failed build dependencies', err.output)): + msg = "Please run 'yum-builddep %s' as root." % find_spec_file(self.relative_project_dir) + error_out('%s' % msg) except Exception, err: error_out('%s' % str(err)) print(output) diff --git a/src/tito/common.py b/src/tito/common.py index 3e0f729..f2b042c 100644 --- a/src/tito/common.py +++ b/src/tito/common.py @@ -20,6 +20,8 @@ import sys import commands import traceback +from tito.exception import RunCommandException + DEFAULT_BUILD_DIR = "/tmp/tito" DEFAULT_BUILDER = "default_builder" DEFAULT_TAGGER = "default_tagger" @@ -209,7 +211,6 @@ def extract_sha1(output): else: return "" - def run_command(command): debug(command) (status, output) = commands.getstatusoutput(command) @@ -218,7 +219,7 @@ def run_command(command): sys.stderr.write("Error running command: %s\n" % command) sys.stderr.write("Status code: %s\n" % status) sys.stderr.write("Command output: %s\n" % output) - raise Exception("Error running command") + raise RunCommandException("Error running command", command, status, output) return output diff --git a/src/tito/exception.py b/src/tito/exception.py index 21f442b..af3d133 100644 --- a/src/tito/exception.py +++ b/src/tito/exception.py @@ -28,3 +28,11 @@ class TitoException(Exception): def __str__(self): return "TitoException: %s" % self.message + +class RunCommandException(Exception): + """ Raised by run_command() """ + def __init__(self, msg, command, status, output): + Exception.__init__(self, msg) + self.command = command + self.status = status + self.output = output diff --git a/tito.spec b/tito.spec index 52133b2..94126fc 100644 --- a/tito.spec +++ b/tito.spec @@ -26,6 +26,7 @@ Requires: fedora-cert Requires: fedora-packager Requires: rpmdevtools Requires: rpm-python +Requires: yum-utils %description Tito is a tool for managing tarballs, rpms, and builds for projects using