1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-21 18:04:06 +03:00

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>
This commit is contained in:
Jelmer Vernooij 2015-05-18 20:00:30 +00:00 committed by Andrew Bartlett
parent 5d672b9a53
commit 5e0821201c
2 changed files with 44 additions and 1 deletions

View File

@ -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))

11
wscript
View File

@ -8,7 +8,7 @@ VERSION=None
import sys, os, tempfile
sys.path.insert(0, srcdir+"/buildtools/wafsamba")
import wafsamba, Options, samba_dist, Scripting, Utils, samba_version
import wafsamba, Options, samba_dist, samba_git, Scripting, Utils, samba_version
samba_dist.DIST_DIRS('.')
@ -225,6 +225,7 @@ def ctags(ctx):
if os.WEXITSTATUS(status):
raise Utils.WafError('ctags failed')
# putting this here enabled build in the list
# of commands in --help
def build(bld):
@ -320,6 +321,7 @@ def wildcard_cmd(cmd):
def main():
from samba_wildcard import wildcard_main
wildcard_main(wildcard_cmd)
Scripting.main = main
@ -327,3 +329,10 @@ def reconfigure(ctx):
'''reconfigure if config scripts have changed'''
import samba_utils
samba_utils.reconfigure(ctx)
if os.path.isdir(os.path.join(srcdir, ".git")):
# Check if there are submodules that are checked out but out of date.
for submodule, status in samba_git.read_submodule_status(srcdir):
if status == "out-of-date":
raise Utils.WafError("some submodules are out of date. Please run 'git submodule update'")