-import Utils;
+import Utils
class samba_version(object):
+
def __init__(self, version_dict, have_git=False):
'''Determine the version number of samba
self.ALPHA_RELEASE=None
self.PRE_RELEASE=None
self.RC_RELEASE=None
- self.IS_GIT_SNAPSHOT=True
+ self.IS_SNAPSHOT=True
self.RELEASE_NICKNAME=None
self.VENDOR_SUFFIX=None
self.VENDOR_PATCH=None
setattr(self, a, b)
if self.IS_GIT_SNAPSHOT == "yes":
- self.IS_GIT_SNAPSHOT=True
+ self.IS_SNAPSHOT=True
elif self.IS_GIT_SNAPSHOT == "no":
- self.IS_GIT_SNAPSHOT=False
-
+ self.IS_SNAPSHOT=False
+ else:
+ raise Exception("Unknown value for IS_GIT_SNAPSHOT: %s" % self.IS_GIT_SNAPSHOT)
+
##
## start with "3.0.22"
##
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)
+ 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)
self.RC_RELEASE = int(self.RC_RELEASE)
SAMBA_VERSION_STRING += ("rc%u" % self.RC_RELEASE)
- if self.IS_GIT_SNAPSHOT:
- #Get version from GIT
+ if self.IS_SNAPSHOT:
+ # Get version from GIT
if have_git:
git = Utils.cmd_output('git show --pretty=format:"%h%n%ct%n%H%n%cd" --stat HEAD', silent=True)
else:
if git == '':
SAMBA_VERSION_STRING += "-GIT-UNKNOWN"
else:
- lines = git.splitlines();
+ lines = git.splitlines()
self.GIT_COMMIT_ABBREV = lines[0]
self.GIT_COMMIT_TIME = lines[1]
self.GIT_COMMIT_FULLREV = lines[2]
self.GIT_COMMIT_IS_CLEAN = False
SAMBA_VERSION_STRING += "+"
- self.OFFICIAL_STRING=SAMBA_VERSION_STRING
+ self.OFFICIAL_STRING = SAMBA_VERSION_STRING
if self.VENDOR_SUFFIX is not None:
SAMBA_VERSION_STRING += ("-" + self.VENDOR_SUFFIX)
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
class samba_version_file(samba_version):
+
def __init__(self, version_file, have_git=False):
'''Parse the version information from a VERSION file'''
f = open(version_file, 'r')
version_dict = {}
for line in f:
+ line = line.strip()
+ if line == '':
+ continue
+ if line.startswith("#"):
+ continue
try:
- line = line.strip()
- if line == '':
- continue
- if line.startswith("#"):
- continue
- split_line=line.split("=")
+ 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, have_git=have_git)