summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Bokovoy <ab@samba.org>2018-07-04 11:05:10 +0300
committerAndrew Bartlett <abartlet@samba.org>2018-09-05 06:37:27 +0200
commit0a9d98ba1521b711e4987d6709327bcf6ec64b6c (patch)
tree7b8678dc910d8ca3c5030191b1124441b9d6bbdc
parentfdd89fefb523ebbb78247c84289a4894c34b7213 (diff)
downloadsamba-0a9d98ba1521b711e4987d6709327bcf6ec64b6c.tar.gz
ctdb/wscript: rework how version number is retrieved
Using default context functions before waf initialization occured is prone to error. Postpone calling samba_version.* code until we got default context initialized. Signed-off-by: Alexander Bokovoy <ab@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
-rw-r--r--ctdb/wscript46
1 files changed, 25 insertions, 21 deletions
diff --git a/ctdb/wscript b/ctdb/wscript
index 87483e0f713..59deb8cce09 100644
--- a/ctdb/wscript
+++ b/ctdb/wscript
@@ -13,10 +13,9 @@ sys.path.insert(0, top + '/buildtools/wafsamba')
out = 'bin'
from waflib import Options, Logs, Errors, Context
-import wafsamba, samba_dist
-import samba_utils, samba_version
+import wafsamba
+from wafsamba import samba_dist, samba_utils
-env = samba_utils.LOAD_ENVIRONMENT()
if os.path.isfile('./VERSION'):
vdir = '.'
elif os.path.isfile('../VERSION'):
@@ -24,9 +23,6 @@ elif os.path.isfile('../VERSION'):
else:
Logs.error("VERSION file not found")
-version = samba_version.samba_version_file('%s/VERSION' % vdir, vdir, env)
-VERSION = version.STRING.replace('-', '.')
-
default_prefix = Options.default_prefix = '/usr/local'
samba_dist.DIST_DIRS('''ctdb:. lib/replace:lib/replace lib/talloc:lib/talloc
@@ -65,6 +61,17 @@ manpages_ceph = [
'ctdb_mutex_ceph_rados_helper.7',
]
+VERSION = ''
+
+def get_version():
+ if Context.g_module.VERSION:
+ return Context.g_module.VERSION
+ import samba_version
+ env = samba_utils.LOAD_ENVIRONMENT()
+
+ version = samba_version.samba_version_file('%s/VERSION' % vdir, vdir, env)
+ Context.g_module.VERSION = version.STRING.replace('-', '.')
+ return Context.g_module.VERSION
def options(opt):
opt.PRIVATE_EXTENSION_DEFAULT('ctdb')
@@ -334,7 +341,7 @@ def gen_ctdb_version(task):
fp.write('/* This file is auto-generated from waf */\n')
fp.write('#include "version.h"\n')
fp.write('\n')
- fp.write('#define CTDB_VERSION_STRING "%s"\n' % VERSION)
+ fp.write('#define CTDB_VERSION_STRING "%s"\n' % get_version())
fp.close()
@@ -350,7 +357,7 @@ def build(bld):
target='include/ctdb_version.h',
rule=gen_ctdb_version,
dep_vars=['VERSION'])
- t.env.VERSION = VERSION
+ t.env.VERSION = get_version()
bld.env.PKGCONFIGDIR = '${LIBDIR}/pkgconfig'
@@ -1115,9 +1122,8 @@ def testonly(ctx):
def test(ctx):
- from waflib import Scripting
- Scripting.commands.append('build')
- Scripting.commands.append('testonly')
+ Options.commands.append('build')
+ Options.commands.append('testonly')
def autotest(ctx):
@@ -1130,7 +1136,7 @@ def autotest(ctx):
def show_version(ctx):
- print VERSION
+ print get_version()
def manpages(ctx):
@@ -1163,7 +1169,7 @@ def distonly(ctx):
samba_dist.DIST_FILES('ctdb/.distversion:.distversion', extend=True)
t = 'ctdb.spec'
- sed_expr1 = 's/@VERSION@/%s/g' % VERSION
+ sed_expr1 = 's/@VERSION@/%s/g' % get_version()
sed_expr2 = 's/@RELEASE@/%s/g' % '1'
cmd = 'sed -e "%s" -e "%s" packaging/RPM/ctdb.spec.in > %s' % (
sed_expr1, sed_expr2, t)
@@ -1183,14 +1189,13 @@ def distonly(ctx):
def dist():
- from waflib import Scripting
- Scripting.commands.append('manpages')
- Scripting.commands.append('distonly')
+ Options.commands.append('manpages')
+ Options.commands.append('distonly')
def rpmonly(ctx):
opts = os.getenv('RPM_OPTIONS') or ''
- cmd = 'rpmbuild -ta --clean --rmsource %s ctdb-%s.tar.gz' % (opts, VERSION)
+ cmd = 'rpmbuild -ta --clean --rmsource %s ctdb-%s.tar.gz' % (opts, get_version())
ret = samba_utils.RUN_COMMAND(cmd)
if ret != 0:
print('rpmbuild exited with exit status %d' % ret)
@@ -1198,10 +1203,9 @@ def rpmonly(ctx):
def rpm(ctx):
- from waflib import Scripting
- Scripting.commands.append('manpages')
- Scripting.commands.append('distonly')
- Scripting.commands.append('rpmonly')
+ Options.commands.append('manpages')
+ Options.commands.append('distonly')
+ Options.commands.append('rpmonly')
def ctags(ctx):