diff options
-rw-r--r-- | buildtools/wafsamba/samba_patterns.py | 27 | ||||
-rw-r--r-- | buildtools/wafsamba/samba_version.py | 170 | ||||
-rw-r--r-- | buildtools/wafsamba/wafsamba.py | 1 | ||||
-rw-r--r-- | source3/wscript | 18 | ||||
-rw-r--r-- | source4/wscript | 11 |
5 files changed, 208 insertions, 19 deletions
diff --git a/buildtools/wafsamba/samba_patterns.py b/buildtools/wafsamba/samba_patterns.py index cce19d3aee..ae0dbe2cf8 100644 --- a/buildtools/wafsamba/samba_patterns.py +++ b/buildtools/wafsamba/samba_patterns.py @@ -3,15 +3,26 @@ import Task from TaskGen import extension from samba_utils import * +from wafsamba import samba_version_file + +def write_version_header(task): + '''print version.h contents''' + src = task.inputs[0].srcpath(task.env) + tgt = task.outputs[0].bldpath(task.env) + + version = samba_version_file(src) + string = str(version) + + f = open(tgt, 'w') + s = f.write(string) + f.close() + return 0 + def SAMBA_MKVERSION(bld, target): '''generate the version.h header for Samba''' - bld.SET_BUILD_GROUP('setup') - t = bld(rule="cd .. && ${SRC[0].abspath(env)} VERSION ${TGT[0].abspath(env)}", - source= [ "script/mkversion.sh", 'VERSION' ], - target=target, - shell=True, - on_results=True, - before="cc") + t = bld.SAMBA_GENERATOR('VERSION', + rule=write_version_header, + source= 'VERSION', + target=target) Build.BuildContext.SAMBA_MKVERSION = SAMBA_MKVERSION - diff --git a/buildtools/wafsamba/samba_version.py b/buildtools/wafsamba/samba_version.py new file mode 100644 index 0000000000..9832c79f28 --- /dev/null +++ b/buildtools/wafsamba/samba_version.py @@ -0,0 +1,170 @@ +import os; +import subprocess; + +class samba_version(object): + def __init__(self, version_dict): + '''Determine the version number of samba + +See VERSION for the format. Entries on that file are +also accepted as dictionary entries here + ''' + + self.MAJOR=None + self.MINOR=None + self.RELEASE=None + self.REVISION=None + self.TP_RELEASE=None + self.ALPHA_RELEASE=None + self.PRE_RELEASE=None + self.RC_RELEASE=None + self.IS_GIT_SNAPSHOT=True + self.RELEASE_NICKNAME=None + self.VENDOR_SUFFIX=None + self.VENDOR_PATCH=None + + for a, b in version_dict.iteritems(): + if a.startswith("SAMBA_VERSION_"): + setattr(self, a[14:], b) + else: + setattr(self, a, b) + + if self.IS_GIT_SNAPSHOT is "yes": + self.IS_GIT_SNAPSHOT=True + elif self.IS_GIT_SNAPSHOT is "no": + self.IS_GIT_SNAPSHOT=False + + ## + ## start with "3.0.22" + ## + self.MAJOR=int(self.MAJOR) + self.MINOR=int(self.MINOR) + self.RELEASE=int(self.RELEASE) + + SAMBA_VERSION_STRING = ("%u.%u.%u" % (self.MAJOR, self.MINOR, self.RELEASE)) + +## +## maybe add "3.0.22a" or "4.0.0tp11" or "4.0.0alpha1" or "3.0.22pre1" or "3.0.22rc1" +## We do not do pre or rc version on patch/letter releases +## + if self.REVISION is not None: + SAMBA_VERSION_STRING += self.REVISION + if self.TP_RELEASE is not None: + self.TP_RELEASE = int(self.TP_RELEASE) + SAMBA_VERSION_STRING += ("tp%u" % self.TP_RELEASE) + if self.ALPHA_RELEASE is not None: + self.ALPHA_RELEASE = int(self.ALPHA_RELEASE) + SAMBA_VERSION_STRING += ("alpha%u" % self.ALPHA_RELEASE) + if self.PRE_RELEASE is not None: + self.PRE_RELEASE = int(self.PRE_RELEASE) + SAMBA_VERSION_STRING += ("pre%u" % self.PRE_RELEASE) + if self.RC_RELEASE is not None: + self.RC_RELEASE = int(self.RC_RELEASE) + SAMBA_VERSION_STRING += ("rc%u" % self.RC_RELEASE) + + if self.IS_GIT_SNAPSHOT: + #Get version from GIT + try: + git = subprocess.Popen('git show --pretty=format:"%h%n%ct%n%H%n%cd" --stat HEAD', stdout=subprocess.PIPE, close_fds=True, shell=True) + (output, errors) = git.communicate() + lines = output.splitlines(); + self.GIT_COMMIT_ABBREV = lines[0] + self.GIT_COMMIT_TIME = lines[1] + self.GIT_COMMIT_FULLREV = lines[2] + self.GIT_COMMIT_DATE = lines[3] + + SAMBA_VERSION_STRING += ("-GIT-" + self.GIT_COMMIT_ABBREV) + except IndexError: + SAMBA_VERSION_STRING += "-GIT-UNKNOWN" + pass + + self.OFFICIAL_STRING=SAMBA_VERSION_STRING + + if self.VENDOR_SUFFIX is not None: + SAMBA_VERSION_STRING += ("-" + self.VENDOR_SUFFIX) + self.VENDOR_SUFFIX = self.VENDOR_SUFFIX + + if self.VENDOR_PATCH is not None: + SAMBA_VERSION_STRING += ("-" + self.VENDOR_PATCH) + self.VENDOR_PATCH = self.VENDOR_PATCH + + self.STRING = SAMBA_VERSION_STRING + + if self.RELEASE_NICKNAME is not None: + self.STRING_WITH_NICKNAME += (" (" + self.RELEASE_NICKNAME + ")") + self.RELEASE_NICKNAME = self.RELEASE_NICKNAME + else: + self.STRING_WITH_NICKNAME = self.STRING + + def __str__(self): + string="/* Autogenerated by waf */\n" + string+="#define SAMBA_VERSION_MAJOR %u\n" % self.MAJOR + string+="#define SAMBA_VERSION_MINOR %u\n" % self.MINOR + string+="#define SAMBA_VERSION_RELEASE %u\n" % self.RELEASE + if self.REVISION is not None: + string+="#define SAMBA_VERSION_REVISION %u\n" % self.REVISION + + if self.TP_RELEASE is not None: + string+="#define SAMBA_VERSION_TP_RELEASE %u\n" % self.TP_RELEASE + + if self.ALPHA_RELEASE is not None: + string+="#define SAMBA_VERSION_ALPHA_RELEASE %u\n" % self.ALPHA_RELEASE + + if self.PRE_RELEASE is not None: + string+="#define SAMBA_VERSION_PRE_RELEASE %u\n" % self.PRE_RELEASE + + if self.RC_RELEASE is not None: + string+="#define SAMBA_VERSION_RC_RELEASE %u\n" % self.RC_RELEASE + + try: + string+="#define SAMBA_VERSION_GIT_COMMIT_ABBREV " + self.GIT_COMMIT_ABBREV + "\n" + string+="#define SAMBA_VERSION_GIT_COMMIT_TIME " + self.GIT_COMMIT_TIME + "\n" + string+="#define SAMBA_VERSION_GIT_COMMIT_FULLREV " + self.GIT_COMMIT_TIME + "\n" + string+="#define SAMBA_VERSION_GIT_COMMIT_DATE " + self.GIT_COMMIT_DATA + "\n" + except AttributeError: + pass + + string+="#define SAMBA_VERSION_OFFICIAL_STRING \"" + self.OFFICIAL_STRING + "\"\n" + + if self.VENDOR_SUFFIX is not None: + string+="#define SAMBA_VERSION_VENDOR_SUFFIX " + self.VENDOR_SUFFIX + "\n" + if self.VENDOR_PATCH is not None: + string+="#define SAMBA_VERSION_VENDOR_PATCH " + self.VENDOR_PATCH + "\n" + + if self.RELEASE_NICKNAME is not None: + string+="#define SAMBA_VERSION_RELEASE_NICKNAME " + self.RELEASE_NICKNAME + "\n" + + # We need to put this #ifdef in to the headers so that vendors can override the version with a function + string+=''' +#ifdef SAMBA_VERSION_VENDOR_FUNCTION +# define SAMBA_VERSION_STRING SAMBA_VERSION_VENDOR_FUNCTION +#else /* SAMBA_VERSION_VENDOR_FUNCTION */ +# define SAMBA_VERSION_STRING "''' + self.STRING_WITH_NICKNAME + '''" +#endif +''' + string+="/* Version for mkrelease.sh: \nSAMBA_VERSION_STRING=" + self.STRING_WITH_NICKNAME + "\n */\n" + + return string + + +class samba_version_file(samba_version): + def __init__(self, version_file): + '''Parse the version information from a VERSION file''' + f = open(version_file, 'r') + version_dict = {} + for line in f: + try: + line = line.strip() + if line == '': + continue + if line.startswith("#"): + continue + split_line=line.split("=") + if split_line[1] != "": + value = split_line[1].strip('"') + version_dict[split_line[0]] = value + except: + print "Failed to parse line %s from %s" % (line, version_file) + raise + + super(samba_version_file, self).__init__(version_dict) + diff --git a/buildtools/wafsamba/wafsamba.py b/buildtools/wafsamba/wafsamba.py index fd6a5523e9..412b0d2d0a 100644 --- a/buildtools/wafsamba/wafsamba.py +++ b/buildtools/wafsamba/wafsamba.py @@ -9,6 +9,7 @@ from samba_utils import SUBST_VARS_RECURSIVE # bring in the other samba modules from samba_optimisation import * from samba_utils import * +from samba_version import * from samba_autoconf import * from samba_patterns import * from samba_pidl import * diff --git a/source3/wscript b/source3/wscript index c3d4c433de..0911e85718 100644 --- a/source3/wscript +++ b/source3/wscript @@ -11,6 +11,10 @@ import build.charset import samba_utils import samba3 +version = wafsamba.samba_version_file("./VERSION") + +VERSION=version.STRING + def set_options(opt): opt.BUILTIN_DEFAULT('NONE') opt.BUNDLED_EXTENSION_DEFAULT('s3') @@ -49,15 +53,15 @@ def set_options(opt): def configure(conf): from samba_utils import TO_LIST - conf.define('PACKAGE_NAME', 'Samba') - conf.define('PACKAGE_STRING', 'Samba 3') - conf.define('PACKAGE_TARNAME', 'samba') - conf.define('PACKAGE_URL', '') - conf.define('PACKAGE_VERSION', '3') - conf.define('PACKAGE_BUGREPORT', 'samba-technical@samba.org') + conf.DEFINE('PACKAGE_NAME', 'samba', quote=True) + conf.DEFINE('PACKAGE_STRING', 'Samba ' + version.STRING, quote=True) + conf.DEFINE('PACKAGE_TARNAME', 'samba', quote=True) + conf.DEFINE('PACKAGE_URL', "http://www.samba.org/", quote=True) + conf.DEFINE('PACKAGE_VERSION', version.STRING, quote=True) + conf.DEFINE('PACKAGE_BUGREPORT', 'http://bugzilla.samba.org/', quote=True) conf.DEFINE('CONFIG_H_IS_FROM_SAMBA', 1) - conf.DEFINE('_SAMBA_BUILD_', 3, add_to_cflags=True) + conf.DEFINE('_SAMBA_BUILD_', version.MAJOR, add_to_cflags=True) conf.DEFINE('HAVE_CONFIG_H', 1, add_to_cflags=True) if Options.options.developer: conf.ADD_CFLAGS('-DDEVELOPER -DDEBUG_PASSWORD') diff --git a/source4/wscript b/source4/wscript index 05bee1a6fe..f018094f1c 100644 --- a/source4/wscript +++ b/source4/wscript @@ -4,12 +4,15 @@ srcdir = '..' blddir = 'bin' APPNAME='samba' -VERSION='4.0.0-alpha13' import sys, os sys.path.insert(0, srcdir+"/buildtools/wafsamba") import wafsamba, Options, samba_dist, Scripting +version = wafsamba.samba_version_file("./VERSION") + +VERSION=version.STRING + samba_dist.DIST_DIRS('.') # install in /usr/local/samba by default @@ -38,14 +41,14 @@ def set_options(opt): def configure(conf): conf.DEFINE('PACKAGE_NAME', 'samba', quote=True) - conf.DEFINE('PACKAGE_STRING', 'samba 4', quote=True) + conf.DEFINE('PACKAGE_STRING', 'Samba ' + version.STRING, quote=True) conf.DEFINE('PACKAGE_TARNAME', 'samba', quote=True) conf.DEFINE('PACKAGE_URL', "http://www.samba.org/", quote=True) - conf.DEFINE('PACKAGE_VERSION', "4", quote=True) + conf.DEFINE('PACKAGE_VERSION', version.STRING, quote=True) conf.DEFINE('PACKAGE_BUGREPORT', 'http://bugzilla.samba.org/', quote=True) conf.DEFINE('CONFIG_H_IS_FROM_SAMBA', 1) - conf.DEFINE('_SAMBA_BUILD_', 4, add_to_cflags=True) + conf.DEFINE('_SAMBA_BUILD_', version.MAJOR, add_to_cflags=True) conf.DEFINE('HAVE_CONFIG_H', 1, add_to_cflags=True) if Options.options.developer: |