summaryrefslogtreecommitdiff
path: root/buildtools
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2015-05-18 20:00:30 +0000
committerAndrew Bartlett <abartlet@samba.org>2015-05-19 19:28:19 +0200
commit5e0821201cc6b5ffc15b1b795ee85dabd3e9220c (patch)
tree15928c79ef6a5f6477dfab6c1517ea6cbf4acfdd /buildtools
parent5d672b9a530e79aff2a7791df82893bcd50d6233 (diff)
downloadsamba-5e0821201cc6b5ffc15b1b795ee85dabd3e9220c.tar.gz
Make waf fail if submodules are out of date.
Instead, suggest the user run 'git submodule update'. This should prevent users from accidentally building Samba against outdated or too new versions of the bundled third party libraries after switching branches. I've opted to make this an error rather than actually running 'git submodule update' directly, as the latter could cause unpredictable behaviour. If we find that manually updating submodules is too cumbersome, we can always change this. The normal mode of operation for developers should not involve any submodules at all, but system versions of these libraries. Signed-off-by: Jelmer Vernooij <jelmer@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Diffstat (limited to 'buildtools')
-rw-r--r--buildtools/wafsamba/samba_git.py34
1 files changed, 34 insertions, 0 deletions
diff --git a/buildtools/wafsamba/samba_git.py b/buildtools/wafsamba/samba_git.py
index a48ce129a98..d103aa8a60b 100644
--- a/buildtools/wafsamba/samba_git.py
+++ b/buildtools/wafsamba/samba_git.py
@@ -1,4 +1,5 @@
import os
+import subprocess
def find_git(env=None):
"""Find the git binary."""
@@ -12,3 +13,36 @@ def find_git(env=None):
return None
+
+def read_submodule_status(path, env=None):
+ """Check status of submodules.
+
+ :param path: Path to git directory
+ :param env: Optional waf environment
+ :return: Yields tuples with submodule relpath and status
+ (one of: 'out-of-date', 'not-checked-out', 'up-to-date')
+ :raise RuntimeError: raised when parsing of 'git submodule status' output
+ fails.
+ """
+ if not os.path.isfile(os.path.join(path, ".gitmodules")):
+ # No point in running git.
+ return
+ git = find_git(env)
+ if git is None:
+ return
+ p = subprocess.Popen([git, "submodule", "status"], stdout=subprocess.PIPE,
+ cwd=path)
+ (stdout, stderr) = p.communicate(None)
+ for l in stdout.splitlines():
+ l = l.rstrip()
+ status = l[0]
+ l = l[1:]
+ parts = l.split(" ")
+ if len(parts) > 2 and status in ("-", "+"):
+ yield (parts[1], "out-of-date")
+ elif len(parts) == 2 and status == "-":
+ yield (parts[1], "not-checked-out")
+ elif len(parts) > 2 and status == " ":
+ yield (parts[1], "up-to-date")
+ else:
+ raise RuntimeError("Unable to parse submodule status: %r, %r" % (status, parts))