From b06544da6f466affaa0ef6681e78673ef05b2c1e Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Thu, 27 Aug 2015 10:47:05 +0200 Subject: [PATCH] wafsamba: detect programmer errors in CHECK_BUNDLED_SYSTEM() All prerequisite libraries of CHECK_BUNDLED_SYSTEM[_PKG](onlyif='lib1 lib2') need to be checked before. That means conf.env['FOUND_SYSTEMLIB_lib1'] and conf.env['FOUND_SYSTEMLIB_lib2'] need to exist independed of its value (True or False). Otherwise this is a logic error. BUG: https://bugzilla.samba.org/show_bug.cgi?id=11458 Signed-off-by: Stefan Metzmacher Reviewed-by: Ralph Boehme Autobuild-User(master): Stefan Metzmacher Autobuild-Date(master): Wed Nov 4 18:38:18 CET 2015 on sn-devel-104 --- buildtools/wafsamba/samba_bundled.py | 50 ++++++++++++++++++------------------ 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/buildtools/wafsamba/samba_bundled.py b/buildtools/wafsamba/samba_bundled.py index a4f841bb998..bfc7ecc8bc7 100644 --- a/buildtools/wafsamba/samba_bundled.py +++ b/buildtools/wafsamba/samba_bundled.py @@ -108,16 +108,6 @@ def LIB_MUST_BE_PRIVATE(conf, libname): return ('ALL' in conf.env.PRIVATE_LIBS or libname in conf.env.PRIVATE_LIBS) -@conf -def CHECK_PREREQUISITES(conf, prereqs): - missing = [] - for syslib in TO_LIST(prereqs): - f = 'FOUND_SYSTEMLIB_%s' % syslib - if not f in conf.env: - missing.append(syslib) - return missing - - @runonce @conf def CHECK_BUNDLED_SYSTEM_PKG(conf, libname, minversion='0.0.0', @@ -142,11 +132,34 @@ def CHECK_BUNDLED_SYSTEM(conf, libname, minversion='0.0.0', this first tries via pkg-config, then if that fails tries by testing for a specified function in the specified lib ''' - if conf.LIB_MUST_BE_BUNDLED(libname): - return False + # We always do a logic validation of 'onlyif' first + missing = [] + if onlyif: + for l in TO_LIST(onlyif): + f = 'FOUND_SYSTEMLIB_%s' % l + if not f in conf.env: + Logs.error('ERROR: CHECK_BUNDLED_SYSTEM(%s) - ' % (libname) + + 'missing prerequisite check for ' + + 'system library %s, onlyif=%r' % (l, onlyif)) + sys.exit(1) + if not conf.env[f]: + missing.append(l) found = 'FOUND_SYSTEMLIB_%s' % libname if found in conf.env: return conf.env[found] + if conf.LIB_MUST_BE_BUNDLED(libname): + conf.env[found] = False + return False + + # see if the library should only use a system version if another dependent + # system version is found. That prevents possible use of mixed library + # versions + if missing: + if not conf.LIB_MAY_BE_BUNDLED(libname): + Logs.error('ERROR: Use of system library %s depends on missing system library/libraries %r' % (libname, missing)) + sys.exit(1) + conf.env[found] = False + return False def check_functions_headers_code(): '''helper function for CHECK_BUNDLED_SYSTEM''' @@ -167,19 +180,6 @@ def CHECK_BUNDLED_SYSTEM(conf, libname, minversion='0.0.0', return False return True - - # see if the library should only use a system version if another dependent - # system version is found. That prevents possible use of mixed library - # versions - if onlyif: - missing = conf.CHECK_PREREQUISITES(onlyif) - if missing: - if not conf.LIB_MAY_BE_BUNDLED(libname): - Logs.error('ERROR: Use of system library %s depends on missing system library/libraries %r' % (libname, missing)) - sys.exit(1) - conf.env[found] = False - return False - minversion = minimum_library_version(conf, libname, minversion) msg = 'Checking for system %s' % libname -- 2.11.4.GIT