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 at laptop.org> Reviewed-by: Gonzalo Odiard <gonzalo@laptop.org> Acked-by: Manuel Quiñones <manuq@laptop.org>
This commit is contained in:
parent
1e6cba8474
commit
030ab202c8
@ -157,11 +157,21 @@ class Packager(object):
|
|||||||
os.mkdir(self.config.dist_dir)
|
os.mkdir(self.config.dist_dir)
|
||||||
|
|
||||||
def get_files_in_git(self):
|
def get_files_in_git(self):
|
||||||
git_ls = subprocess.Popen(['git', 'ls-files'], stdout=subprocess.PIPE,
|
try:
|
||||||
|
git_ls = subprocess.Popen(['git', 'ls-files'],
|
||||||
|
stdout=subprocess.PIPE,
|
||||||
cwd=self.config.source_dir)
|
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()
|
stdout, _ = git_ls.communicate()
|
||||||
if git_ls.returncode:
|
if git_ls.returncode:
|
||||||
# Fall back to filtered list
|
# 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,
|
return list_files(self.config.source_dir,
|
||||||
IGNORE_DIRS, IGNORE_FILES)
|
IGNORE_DIRS, IGNORE_FILES)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user