From 030ab202c8314251314a5812c7ff1ebd21c8d938 Mon Sep 17 00:00:00 2001 From: Simon Schampijer Date: Thu, 23 Aug 2012 14:15:02 +0200 Subject: [PATCH] Bundlebuilder: don't fail to package if git is not installed, OLPC #11341 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When git is installed, it will return non-zero if it gets asked to list the files in a non-git-repository. The subprocess.Popen instantiation is successful in this case and the returncode attribute will contain the error code from git. The current code handles this fine and does fall back to our own source file listing facility. If git isn't installed, however, trying to instantiate subprocess.Popen will fail with OSError. We need to catch this and fall back to our own source file listing facility like we do for the non-repository case. Signed-off-by: Simon Schampijer Reviewed-by: Gonzalo Odiard Acked-by: Manuel QuiƱones --- src/sugar3/activity/bundlebuilder.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/sugar3/activity/bundlebuilder.py b/src/sugar3/activity/bundlebuilder.py index bcc7aa9b..0e4af59b 100644 --- a/src/sugar3/activity/bundlebuilder.py +++ b/src/sugar3/activity/bundlebuilder.py @@ -157,11 +157,21 @@ class Packager(object): os.mkdir(self.config.dist_dir) def get_files_in_git(self): - git_ls = subprocess.Popen(['git', 'ls-files'], stdout=subprocess.PIPE, - cwd=self.config.source_dir) + try: + git_ls = subprocess.Popen(['git', 'ls-files'], + stdout=subprocess.PIPE, + cwd=self.config.source_dir) + except OSError: + logging.warn('Packager: git is not installed, ' \ + 'fall back to filtered list') + return list_files(self.config.source_dir, + IGNORE_DIRS, IGNORE_FILES) + stdout, _ = git_ls.communicate() if git_ls.returncode: # Fall back to filtered list + logging.warn('Packager: this is not a git repository, ' \ + 'fall back to filtered list') return list_files(self.config.source_dir, IGNORE_DIRS, IGNORE_FILES)