From cdd95b53176e584a1e1e51117007bc208cb5d259 Mon Sep 17 00:00:00 2001 From: Daniel Narvaez Date: Tue, 27 Nov 2012 18:46:24 +0000 Subject: Display error messages when the source dir is invalid --- diff --git a/devbot/build.py b/devbot/build.py index 38cd816..29c886d 100644 --- a/devbot/build.py +++ b/devbot/build.py @@ -37,9 +37,11 @@ def build(): skipped = [] for module in modules[:]: - old_commit_id = state.get_built_commit_id(module) new_commit_id = module.get_commit_id() + if new_commit_id is None: + break + old_commit_id = state.get_built_commit_id(module) if old_commit_id == new_commit_id: modules.pop(0) skipped.append(module.name) @@ -54,7 +56,8 @@ def build(): state.remove_built_commit_id(module) for module in modules: - _build_module(module) + if not _build_module(module): + break def clean(): _rmtree(config.install_dir) @@ -125,32 +128,41 @@ def _build_activity(module): def _build_module(module): print "\n=== Building %s ===\n" % module.name - module_source_dir = module.get_source_dir() + source_dir = module.get_source_dir() + + if not os.path.exists(source_dir): + print "Source directory does not exist. Please pull the sources " \ + "before building." + return False if module.out_of_source: - module_build_dir = module.get_build_dir() + build_dir = module.get_build_dir() - if not os.path.exists(module_build_dir): - os.mkdir(module_build_dir) + if not os.path.exists(build_dir): + os.mkdir(build_dir) - os.chdir(module_build_dir) + os.chdir(build_dir) else: - os.chdir(module_source_dir) + os.chdir(source_dir) try: - if os.path.exists(os.path.join(module_source_dir, "setup.py")): + if os.path.exists(os.path.join(source_dir, "setup.py")): _build_activity(module) - elif os.path.exists(os.path.join(module_source_dir, "autogen.sh")): + elif os.path.exists(os.path.join(source_dir, "autogen.sh")): _build_autotools(module) - elif os.path.exists(os.path.join(module_source_dir, "Makefile")): + elif os.path.exists(os.path.join(source_dir, "Makefile")): _build_make(module) else: - raise RuntimeError("Unknown build system") + print "The source directory has unexpected content, please " \ + "delete it and pull\nthe source again." + return False except subprocess.CalledProcessError: - sys.exit(1) + return False state.touch_built_commit_id(module) + return True + def _rmtree(dir): print "Deleting %s" % dir shutil.rmtree(dir, ignore_errors=True) diff --git a/devbot/config.py b/devbot/config.py index 2b748e6..d5e1a74 100644 --- a/devbot/config.py +++ b/devbot/config.py @@ -47,6 +47,9 @@ class Module: return os.path.join(get_build_dir(), self.name) def get_commit_id(self): + if not os.path.exists(self.get_source_dir()): + return None + return utils.get_commit_id(self.get_source_dir()) def _ensure_dir(dir): -- cgit v0.9.1