diff options
author | Simon Schampijer <simon@schampijer.de> | 2012-08-23 12:19:37 (GMT) |
---|---|---|
committer | Simon Schampijer <simon@laptop.org> | 2012-08-23 12:25:46 (GMT) |
commit | d1f68419e79376381fc2c3b111466714f044dfc0 (patch) | |
tree | f80d5b505952b807d035fe006774ab6fb1333610 /src | |
parent | 2341c412ccff5e65dbd4fd7c0b397817f21bb672 (diff) |
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 <simon@laptop.org>
Reviewed-by: Gonzalo Odiard <gonzalo@laptop.org>
Diffstat (limited to 'src')
-rw-r--r-- | src/sugar/activity/bundlebuilder.py | 14 |
1 files changed, 12 insertions, 2 deletions
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) |