Skip to content

Commit

Permalink
Factor out submodule presence checking.
Browse files Browse the repository at this point in the history
Signed-off-by: Jelmer Vernooij <[email protected]>
Reviewed-by: Andrew Bartlett <[email protected]>

Autobuild-User(master): Andrew Bartlett <[email protected]>
Autobuild-Date(master): Tue May 19 22:17:48 CEST 2015 on sn-devel-104
  • Loading branch information
jelmer authored and abartlet committed May 19, 2015
1 parent 5e08212 commit 0dcf535
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
11 changes: 10 additions & 1 deletion buildtools/wafsamba/samba_git.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,15 @@ def find_git(env=None):
return None


def has_submodules(path):
"""Check whether a source directory is git-versioned and has submodules.
:param path: Path to Samba source directory
"""
return (os.path.isdir(os.path.join(path, ".git")) and
os.path.isfile(os.path.join(path, ".gitmodules")))


def read_submodule_status(path, env=None):
"""Check status of submodules.
Expand All @@ -24,7 +33,7 @@ def read_submodule_status(path, env=None):
:raise RuntimeError: raised when parsing of 'git submodule status' output
fails.
"""
if not os.path.isfile(os.path.join(path, ".gitmodules")):
if not has_submodules(path):
# No point in running git.
return
git = find_git(env)
Expand Down
4 changes: 2 additions & 2 deletions third_party/wscript
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/usr/bin/env python

import samba_git
import Utils
import os
import sys
Expand Down Expand Up @@ -27,8 +28,7 @@ def find_third_party_module(conf, module, package):
try:
__import__(module)
except ImportError:
if (os.path.isdir(os.path.join(conf.srcdir, ".git")) and
os.path.isfile(os.path.join(conf.srcdir, ".gitmodule"))):
if samba_git.has_submodules(conf.srcdir):
raise Utils.WafError("""\
Unable to find Python module '%s'. Please install the system package or check \
out the relevant submodule by running 'git submodule update --init'.
Expand Down

0 comments on commit 0dcf535

Please sign in to comment.