From d1f68419e79376381fc2c3b111466714f044dfc0 Mon Sep 17 00:00:00 2001 From: Simon Schampijer Date: Thu, 23 Aug 2012 12:19:37 +0000 Subject: Bundlebuilder: don't fail to package if git is not installed, OLPC #11341 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 --- diff --git a/src/sugar/activity/bundlebuilder.py b/src/sugar/activity/bundlebuilder.py index 65105ab..51e2372 100644 --- a/src/sugar/activity/bundlebuilder.py +++ b/src/sugar/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) -- cgit v0.9.1