Commit 29b51d14 authored by Jelmer Vernooij's avatar Jelmer Vernooij

Imported Upstream version 1.1.21

parent 6536dd06
This diff is collapsed.
pyldb_Dn_FromDn: PyObject *(struct ldb_dn *)
pyldb_Object_AsDn: bool (TALLOC_CTX *, PyObject *, struct ldb_context *, struct ldb_dn **)
......@@ -63,7 +63,7 @@ def test(dir):
except OSError: pass
def find_lib():
return os.path.abspath(os.path.dirname(os.path.dirname(__file__)))
return os.path.abspath(os.path.join(os.path.dirname(__file__), '../../third_party/waf'))
wafdir = find_lib()
w = join(wafdir, 'wafadmin')
......
#!/usr/bin/env python
#
# Sample run-on-target script
# This is a script that can be used as cross-execute parameter to samba
# configuration process, running the command on a remote target for which
# the cross-compiled configure test was compiled.
#
# To use:
# ./configure \
# --cross-compile \
# '--cross-execute=./buildtools/example/run_on_target.py --host=<host>'
#
# A more elaborate example:
# ./configure \
# --cross-compile \
# '--cross-execute=./buildtools/example/run_on_target.py --host=<host> --user=<user> "--ssh=ssh -i <some key file>" --destdir=/path/to/dir'
#
# Typically this is to be used also with --cross-answers, so that the
# cross answers file gets built and further builds can be made without
# the help of a remote target.
#
# The following assumptions are made:
# 1. rsync is available on build machine and target machine
# 2. A running ssh service on target machine with password-less shell login
# 3. A directory writable by the password-less login user
# 4. The tests on the target can run and provide reliable results
# from the login account's home directory. This is significant
# for example in locking tests which
# create files in the current directory. As a workaround to this
# assumption, the TESTDIR environment variable can be set on the target
# (using ssh command line or server config) and the tests shall
# chdir to that directory.
#
import sys
import os
import subprocess
from optparse import OptionParser
# those are defaults, but can be overidden using command line
SSH = 'ssh'
USER = None
HOST = 'localhost'
def xfer_files(ssh, srcdir, host, user, targ_destdir):
"""Transfer executable files to target
Use rsync to copy the directory containing program to run
INTO a destination directory on the target. An exact copy
of the source directory is created on the target machine,
possibly deleting files on the target machine which do not
exist on the source directory.
The idea is that the test may include files in addition to
the compiled binary, and all of those files reside alongside
the binary in a source directory.
For example, if the test to run is /foo/bar/test and the
destination directory on the target is /tbaz, then /tbaz/bar
on the target shall be an exact copy of /foo/bar on the source,
including deletion of files inside /tbaz/bar which do not exist
on the source.
"""
userhost = host
if user:
userhost = '%s@%s' % (user, host)
cmd = 'rsync --verbose -rl --ignore-times --delete -e "%s" %s %s:%s/' % \
(ssh, srcdir, userhost, targ_destdir)
p = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
(out, err) = p.communicate()
if p.returncode != 0:
raise Exception('failed syncing files\n stdout:\n%s\nstderr:%s\n'
% (out, err))
def exec_remote(ssh, host, user, destdir, targdir, prog, args):
"""Run a test on the target
Using password-less ssh, run the compiled binary on the target.
An assumption is that there's no need to cd into the target dir,
same as there's no need to do it on a native build.
"""
userhost = host
if user:
userhost = '%s@%s' % (user, host)
cmd = '%s %s %s/%s/%s' % (ssh, userhost, destdir, targdir, prog)
if args:
cmd = cmd + ' ' + ' '.join(args)
p = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
(out, err) = p.communicate()
return (p.returncode, out)
def main(argv):
usage = "usage: %prog [options] <prog> [args]"
parser = OptionParser(usage)
parser.add_option('--ssh', help="SSH client and additional flags",
default=SSH)
parser.add_option('--host', help="target host name or IP address",
default=HOST)
parser.add_option('--user', help="login user on target",
default=USER)
parser.add_option('--destdir', help="work directory on target",
default='~')
(options, args) = parser.parse_args(argv)
if len(args) < 1:
parser.error("please supply test program to run")
progpath = args[0]
# assume that a test that was not compiled fails (e.g. getconf)
if progpath[0] != '/':
return (1, "")
progdir = os.path.dirname(progpath)
prog = os.path.basename(progpath)
targ_progdir = os.path.basename(progdir)
xfer_files(
options.ssh,
progdir,
options.host,
options.user,
options.destdir)
(rc, out) = exec_remote(options.ssh,
options.host,
options.user,
options.destdir,
targ_progdir,
prog, args[1:])
return (rc, out)
if __name__ == '__main__':
(rc, out) = main(sys.argv[1:])
sys.stdout.write(out)
sys.exit(rc)
#!/bin/sh
# Update our copy of waf
TARGETDIR="`dirname $0`"
WORKDIR="`mktemp -d -t update-waf-XXXXXX`"
mkdir -p "$WORKDIR"
git clone https://code.google.com/p/waf.waf15/ "$WORKDIR"
rsync -C -avz --delete "$WORKDIR/wafadmin/" "$TARGETDIR/wafadmin/"
rm -rf "$WORKDIR"
......@@ -62,7 +62,7 @@ def s3_fix_kwargs(bld, kwargs):
s3reldir = os_path_relpath(s3dir, bld.curdir)
# the extra_includes list is relative to the source3 directory
extra_includes = [ '.', 'include', 'lib', '../lib/tdb_compat' ]
extra_includes = [ '.', 'include', 'lib' ]
# local heimdal paths only included when USING_SYSTEM_KRB5 is not set
if not bld.CONFIG_SET("USING_SYSTEM_KRB5"):
extra_includes += [ '../source4/heimdal/lib/com_err',
......
......@@ -229,7 +229,18 @@ def CHECK_DECLS(conf, vars, reverse=False, headers=None, always=False):
headers=headers,
msg='Checking for declaration of %s' % v,
always=always):
ret = False
if not CHECK_CODE(conf,
'''
return (int)%s;
''' % (v),
execute=False,
link=False,
msg='Checking for declaration of %s (as enum)' % v,
local_include=False,
headers=headers,
define=define,
always=always):
ret = False
return ret
......@@ -677,6 +688,8 @@ def SAMBA_CONFIG_H(conf, path=None):
testflags=True)
conf.ADD_CFLAGS('-Werror=return-type -Wreturn-type',
testflags=True)
conf.ADD_CFLAGS('-Werror=uninitialized -Wuninitialized',
testflags=True)
conf.ADD_CFLAGS('-Wformat=2 -Wno-format-y2k', testflags=True)
# This check is because for ldb_search(), a NULL format string
......@@ -703,6 +716,11 @@ int main(void) {
if Options.options.pedantic:
conf.ADD_CFLAGS('-W', testflags=True)
if Options.options.address_sanitizer:
conf.ADD_CFLAGS('-fno-omit-frame-pointer -O1 -fsanitize=address', testflags=True)
conf.ADD_LDFLAGS('-fsanitize=address', testflags=True)
conf.env['ADDRESS_SANITIZER'] = True
# Let people pass an additional ADDITIONAL_{CFLAGS,LDFLAGS}
# environment variables which are only used the for final build.
......@@ -839,3 +857,7 @@ def SAMBA_CHECK_UNDEFINED_SYMBOL_FLAGS(conf):
if not sys.platform.startswith("openbsd") and conf.env.undefined_ignore_ldflags == []:
if conf.CHECK_LDFLAGS(['-undefined', 'dynamic_lookup']):
conf.env.undefined_ignore_ldflags = ['-undefined', 'dynamic_lookup']
@conf
def CHECK_CFG(self, *k, **kw):
return self.check_cfg(*k, **kw)
......@@ -13,7 +13,7 @@ def SAMBA_AUTOPROTO(bld, header, source):
name = name,
source = source,
target = header,
on_results=True,
update_outputs=True,
ext_out='.c',
before ='cc',
rule = '${PERL} "${SCRIPT}/mkproto.pl" --srcdir=.. --builddir=. --public=/dev/null --private="${TGT}" ${SRC}'
......
......@@ -190,7 +190,7 @@ def CHECK_BUNDLED_SYSTEM(conf, libname, minversion='0.0.0',
pkg = libname
# try pkgconfig first
if (conf.check_cfg(package=pkg,
if (conf.CHECK_CFG(package=pkg,
args='"%s >= %s" --cflags --libs' % (pkg, minversion),
msg=msg, uselib_store=uselib_store) and
check_functions_headers_code()):
......
......@@ -565,7 +565,6 @@ def samba_config_c_parse_flags(line1, uselib, env):
# bugs in the real parse_flags() function.
#
if x == '-Wl,-rpath' or x == '-Wl,-R':
linkflags.remove(x)
x = lst1.pop(0)
if x.startswith('-Wl,'):
rpath = x[4:]
......
......@@ -2,11 +2,12 @@
import Utils, Logs, sys, os, Options, re
from Configure import conf
import shlex
real_Popen = None
ANSWER_UNKNOWN = (254, "")
ANSWER_FAIL = (255, "")
ANSWER_NO = (1, "")
ANSWER_OK = (0, "")
cross_answers_incomplete = False
......@@ -19,15 +20,27 @@ def add_answer(ca_file, msg, answer):
except:
Logs.error("Unable to open cross-answers file %s" % ca_file)
sys.exit(1)
(retcode, retstring) = answer
# if retstring is more than one line then we probably
# don't care about its actual content (the tests should
# yield one-line output in order to comply with the cross-answer
# format)
retstring = retstring.strip()
if len(retstring.split('\n')) > 1:
retstring = ''
answer = (retcode, retstring)
if answer == ANSWER_OK:
f.write('%s: OK\n' % msg)
elif answer == ANSWER_UNKNOWN:
f.write('%s: UNKNOWN\n' % msg)
elif answer == ANSWER_FAIL:
f.write('%s: FAIL\n' % msg)
elif answer == ANSWER_NO:
f.write('%s: NO\n' % msg)
else:
(retcode, retstring) = answer
f.write('%s: (%d, "%s")' % (msg, retcode, retstring))
if retcode == 0:
f.write('%s: "%s"\n' % (msg, retstring))
else:
f.write('%s: (%d, "%s")\n' % (msg, retcode, retstring))
f.close()
......@@ -36,14 +49,13 @@ def cross_answer(ca_file, msg):
try:
f = open(ca_file, 'r')
except:
add_answer(ca_file, msg, ANSWER_UNKNOWN)
return ANSWER_UNKNOWN
for line in f:
line = line.strip()
if line == '' or line[0] == '#':
continue
if line.find(':') != -1:
a = line.split(':')
a = line.split(':', 1)
thismsg = a[0].strip()
if thismsg != msg:
continue
......@@ -56,10 +68,12 @@ def cross_answer(ca_file, msg):
return ANSWER_UNKNOWN
elif ans == "FAIL" or ans == "NO":
f.close()
return ANSWER_FAIL
return ANSWER_NO
elif ans[0] == '"':
f.close()
return (0, ans.strip('"'))
elif ans[0] == "'":
f.close()
return (0, ans.strip("'"))
else:
m = re.match('\(\s*(-?\d+)\s*,\s*\"(.*)\"\s*\)', ans)
......@@ -69,7 +83,6 @@ def cross_answer(ca_file, msg):
else:
raise Utils.WafError("Bad answer format '%s' in %s" % (line, ca_file))
f.close()
add_answer(ca_file, msg, ANSWER_UNKNOWN)
return ANSWER_UNKNOWN
......@@ -77,24 +90,47 @@ class cross_Popen(Utils.pproc.Popen):
'''cross-compilation wrapper for Popen'''
def __init__(*k, **kw):
(obj, args) = k
if '--cross-execute' in args:
# when --cross-execute is set, then change the arguments
# to use the cross emulator
i = args.index('--cross-execute')
newargs = args[i+1].split()
newargs.extend(args[0:i])
args = newargs
elif '--cross-answers' in args:
use_answers = False
ans = ANSWER_UNKNOWN
# Three possibilities:
# 1. Only cross-answers - try the cross-answers file, and if
# there's no corresponding answer, add to the file and mark
# the configure process as unfinished.
# 2. Only cross-execute - get the answer from cross-execute
# 3. Both - try the cross-answers file, and if there is no
# corresponding answer - use cross-execute to get an answer,
# and add that answer to the file.
if '--cross-answers' in args:
# when --cross-answers is set, then change the arguments
# to use the cross answers if available
use_answers = True
i = args.index('--cross-answers')
ca_file = args[i+1]
msg = args[i+2]
ans = cross_answer(ca_file, msg)
if '--cross-execute' in args and ans == ANSWER_UNKNOWN:
# when --cross-execute is set, then change the arguments
# to use the cross emulator
i = args.index('--cross-execute')
newargs = shlex.split(args[i+1])
newargs.extend(args[0:i])
if use_answers:
p = real_Popen(newargs,
stdout=Utils.pproc.PIPE,
stderr=Utils.pproc.PIPE)
ce_out, ce_err = p.communicate()
ans = (p.returncode, ce_out)
add_answer(ca_file, msg, ans)
else:
args = newargs
if use_answers:
if ans == ANSWER_UNKNOWN:
global cross_answers_incomplete
cross_answers_incomplete = True
add_answer(ca_file, msg, ans)
(retcode, retstring) = ans
args = ['/bin/sh', '-c', "echo -n '%s'; exit %d" % (retstring, retcode)]
real_Popen.__init__(*(obj, args), **kw)
......@@ -115,7 +151,8 @@ def SAMBA_CROSS_ARGS(conf, msg=None):
if conf.env.CROSS_EXECUTE:
ret.extend(['--cross-execute', conf.env.CROSS_EXECUTE])
elif conf.env.CROSS_ANSWERS:
if conf.env.CROSS_ANSWERS:
if msg is None:
raise Utils.WafError("Cannot have NULL msg in cross-answers")
ret.extend(['--cross-answers', os.path.join(Options.launch_dir, conf.env.CROSS_ANSWERS), msg])
......
......@@ -964,7 +964,8 @@ savedeps_version = 3
savedeps_inputs = ['samba_deps', 'samba_includes', 'local_include', 'local_include_first', 'samba_cflags',
'source', 'grouping_library', 'samba_ldflags', 'allow_undefined_symbols',
'use_global_deps', 'global_include' ]
savedeps_outputs = ['uselib', 'uselib_local', 'add_objects', 'includes', 'ccflags', 'ldflags', 'samba_deps_extended']
savedeps_outputs = ['uselib', 'uselib_local', 'add_objects', 'includes',
'ccflags', 'ldflags', 'samba_deps_extended', 'final_libs']
savedeps_outenv = ['INC_PATHS']
savedeps_envvars = ['NONSHARED_BINARIES', 'GLOBAL_DEPENDENCIES', 'EXTRA_CFLAGS', 'EXTRA_LDFLAGS', 'EXTRA_INCLUDES' ]
savedeps_caches = ['GLOBAL_DEPENDENCIES', 'TARGET_TYPE', 'INIT_FUNCTIONS', 'SYSLIB_DEPS']
......
......@@ -86,12 +86,6 @@ def vcs_dir_contents(path):
env = dict(os.environ)
env["GIT_DIR"] = os.path.join(repo, ".git")
break
elif os.path.isdir(os.path.join(repo, ".bzr")):
ls_files_cmd = [ 'bzr', 'ls', '--recursive', '--versioned',
os_path_relpath(path, repo)]
cwd = repo
env = None
break
repo = os.path.dirname(repo)
if repo == "/":
raise Exception("unsupported or no vcs for %s" % path)
......
import os
import subprocess
def find_git(env=None):
"""Find the git binary."""
if env is not None and 'GIT' in env:
return env['GIT']
# Get version from GIT
if os.path.exists("/usr/bin/git"):
# this is useful when doing make dist without configuring
return "/usr/bin/git"
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.
: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 has_submodules(path):
# 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))
......@@ -59,90 +59,97 @@ def install_library(self):
bld = self.bld
install_ldflags = install_rpath(self)
build_ldflags = build_rpath(bld)
if not Options.is_install or not getattr(self, 'samba_install', True):
# just need to set the build rpath if we are not installing
self.env.RPATH = build_ldflags
return
# setup the install path, expanding variables
install_path = getattr(self, 'samba_inst_path', None)
if install_path is None:
if getattr(self, 'private_library', False):
install_path = '${PRIVATELIBDIR}'
else:
install_path = '${LIBDIR}'
install_path = bld.EXPAND_VARIABLES(install_path)
target_name = self.target
if install_ldflags != build_ldflags:
# we will be creating a new target name, and using that for the
# install link. That stops us from overwriting the existing build
# target, which has different ldflags
self.done_install_library = True
t = self.clone('default')
t.posted = False
t.target += '.inst'
self.env.RPATH = build_ldflags
else:
t = self
t.env.RPATH = install_ldflags
default_env = bld.all_envs['default']
try:
if self.env['IS_EXTRA_PYTHON']:
bld.all_envs['default'] = bld.all_envs['extrapython']
dev_link = None
install_ldflags = install_rpath(self)
build_ldflags = build_rpath(bld)
# in the following the names are:
# - inst_name is the name with .inst. in it, in the build
# directory
# - install_name is the name in the install directory
# - install_link is a symlink in the install directory, to install_name
if not Options.is_install or not getattr(self, 'samba_install', True):
# just need to set the build rpath if we are not installing
self.env.RPATH = build_ldflags
return
if getattr(self, 'samba_realname', None):
install_name = self.samba_realname
install_link = None
if getattr(self, 'soname', ''):
install_link = self.soname
if getattr(self, 'samba_type', None) == 'PYTHON':
inst_name = bld.make_libname(t.target, nolibprefix=True, python=True)
# setup the install path, expanding variables
install_path = getattr(self, 'samba_inst_path', None)
if install_path is None:
if getattr(self, 'private_library', False):
install_path = '${PRIVATELIBDIR}'
else:
install_path = '${LIBDIR}'
install_path = bld.EXPAND_VARIABLES(install_path)
target_name = self.target
if install_ldflags != build_ldflags:
# we will be creating a new target name, and using that for the
# install link. That stops us from overwriting the existing build
# target, which has different ldflags
self.done_install_library = True
t = self.clone(self.env)
t.posted = False
t.target += '.inst'
self.env.RPATH = build_ldflags
else:
t = self
t.env.RPATH = install_ldflags
dev_link = None
# in the following the names are:
# - inst_name is the name with .inst. in it, in the build
# directory
# - install_name is the name in the install directory
# - install_link is a symlink in the install directory, to install_name
if getattr(self, 'samba_realname', None):
install_name = self.samba_realname
install_link = None
if getattr(self, 'soname', ''):
install_link = self.soname
if getattr(self, 'samba_type', None) == 'PYTHON':
inst_name = bld.make_libname(t.target, nolibprefix=True, python=True)
else:
inst_name = bld.make_libname(t.target)
elif self.vnum:
vnum_base = self.vnum.split('.')[0]
install_name = bld.make_libname(target_name, version=self.vnum)
install_link = bld.make_libname(target_name, version=vnum_base)
inst_name = bld.make_libname(t.target)
if not self.private_library:
# only generate the dev link for non-bundled libs
dev_link = bld.make_libname(target_name)
elif getattr(self, 'soname', ''):
install_name = bld.make_libname(target_name)
install_link = self.soname
inst_name = bld.make_libname(t.target)
elif self.vnum:
vnum_base = self.vnum.split('.')[0]
install_name = bld.make_libname(target_name, version=self.vnum)
install_link = bld.make_libname(target_name, version=vnum_base)
inst_name = bld.make_libname(t.target)
if not self.private_library:
# only generate the dev link for non-bundled libs
dev_link = bld.make_libname(target_name)
elif getattr(self, 'soname', ''):
install_name = bld.make_libname(target_name)
install_link = self.soname
inst_name = bld.make_libname(t.target)
else:
install_name = bld.make_libname(target_name)
install_link = None
inst_name = bld.make_libname(t.target)
if t.env.SONAME_ST:
# ensure we get the right names in the library
if install_link:
t.env.append_value('LINKFLAGS', t.env.SONAME_ST % install_link)
else:
t.env.append_value('LINKFLAGS', t.env.SONAME_ST % install_name)
t.env.SONAME_ST = ''
install_name = bld.make_libname(target_name)
install_link = None
inst_name = bld.make_libname(t.target)
# tell waf to install the library
bld.install_as(os.path.join(install_path, install_name),
os.path.join(self.path.abspath(bld.env), inst_name),
chmod=<