From: Jelmer Vernooij Date: Mon, 18 May 2015 20:19:23 +0000 (+0000) Subject: Factor out submodule presence checking. X-Git-Url: http://git.samba.org/?a=commitdiff_plain;h=0dcf5357959d2bc5cb984eb0276684b56477ed62;p=obnox%2Fsamba%2Fsamba-obnox.git Factor out submodule presence checking. Signed-off-by: Jelmer Vernooij Reviewed-by: Andrew Bartlett Autobuild-User(master): Andrew Bartlett Autobuild-Date(master): Tue May 19 22:17:48 CEST 2015 on sn-devel-104 --- diff --git a/buildtools/wafsamba/samba_git.py b/buildtools/wafsamba/samba_git.py index d103aa8a60b..c58a57983d5 100644 --- a/buildtools/wafsamba/samba_git.py +++ b/buildtools/wafsamba/samba_git.py @@ -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. @@ -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) diff --git a/third_party/wscript b/third_party/wscript index d41b90698ed..d5b9df7bb96 100644 --- a/third_party/wscript +++ b/third_party/wscript @@ -1,5 +1,6 @@ #!/usr/bin/env python +import samba_git import Utils import os import sys @@ -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'.