src = task.inputs[0].srcpath(task.env)
tgt = task.outputs[0].bldpath(task.env)
- version = samba_version_file(src)
+ have_git = 'GIT' in task.env
+
+ version = samba_version_file(src, have_git=have_git)
string = str(version)
f = open(tgt, 'w')
t = bld.SAMBA_GENERATOR('VERSION',
rule=write_version_header,
source= 'VERSION',
- target=target)
+ target=target,
+ always=True)
Build.BuildContext.SAMBA_MKVERSION = SAMBA_MKVERSION
-import os;
-import subprocess;
+import Utils;
class samba_version(object):
- def __init__(self, version_dict):
+ def __init__(self, version_dict, have_git=False):
'''Determine the version number of samba
See VERSION for the format. Entries on that file are
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();
+ if have_git:
+ git = Utils.cmd_output('git show --pretty=format:"%h%n%ct%n%H%n%cd" --stat HEAD', silent=True)
+ else:
+ git = ''
+
+ if git == '':
+ SAMBA_VERSION_STRING += "-GIT-UNKNOWN"
+ else:
+ lines = git.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
class samba_version_file(samba_version):
- def __init__(self, version_file):
+ def __init__(self, version_file, have_git=False):
'''Parse the version information from a VERSION file'''
f = open(version_file, 'r')
version_dict = {}
print "Failed to parse line %s from %s" % (line, version_file)
raise
- super(samba_version_file, self).__init__(version_dict)
-
+ super(samba_version_file, self).__init__(version_dict, have_git=have_git)
blddir = 'bin'
APPNAME='samba'
+VERSION=None
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
+def load_version(have_git=False):
+ '''load samba versions either from ./VERSION or git
+ return a version object for detailed breakdown'''
+ import samba_utils, Utils
+ if not have_git:
+ env = samba_utils.LOAD_ENVIRONMENT()
+ have_git = 'GIT' in env
+ version = wafsamba.samba_version_file("./VERSION", have_git=have_git)
+ Utils.g_module.VERSION = version.STRING
+ return version
+
samba_dist.DIST_DIRS('.')
def configure(conf):
+ version = load_version(have_git=True)
+
conf.DEFINE('PACKAGE_NAME', 'samba', quote=True)
conf.DEFINE('PACKAGE_STRING', 'Samba ' + version.STRING, quote=True)
conf.DEFINE('PACKAGE_TARNAME', 'samba', quote=True)
# of commands in --help
def build(bld):
'''build all targets'''
+ load_version()
pass
def dist():
'''makes a tarball for distribution'''
+ load_version()
samba_dist.dist()
def distcheck():
'''test that distribution tarball builds and installs'''
+ load_version()
import Scripting
d = Scripting.distcheck
d(subdir='source4')