Changed installer filename to use branch, stage and revision #4898

This commit is contained in:
Jerry (Xinyu Hou) 2015-07-24 15:21:57 -07:00
parent 392f2904aa
commit 41c03b8f37
1 changed files with 37 additions and 39 deletions

View File

@ -848,7 +848,7 @@ class InternalCommands:
pwd = lines[0] pwd = lines[0]
if (dist): if (dist):
self.signFile(pfx, pwd, 'bin/Release', self.dist_name('win')) self.signFile(pfx, pwd, 'bin/Release', self.getDistFilename('win'))
else: else:
self.signFile(pfx, pwd, 'bin/Release', 'synergy.exe') self.signFile(pfx, pwd, 'bin/Release', 'synergy.exe')
self.signFile(pfx, pwd, 'bin/Release', 'synergyc.exe') self.signFile(pfx, pwd, 'bin/Release', 'synergyc.exe')
@ -1086,7 +1086,7 @@ class InternalCommands:
templateFile = open(self.cmake_dir + '/synergy.spec.in') templateFile = open(self.cmake_dir + '/synergy.spec.in')
template = templateFile.read() template = templateFile.read()
template = template.replace('${in:version}', self.getVersionFromCmake()) template = template.replace('${in:version}', self.getVersionNumber())
specPath = rpmDir + '/synergy.spec' specPath = rpmDir + '/synergy.spec'
@ -1094,10 +1094,8 @@ class InternalCommands:
specFile.write(template) specFile.write(template)
specFile.close() specFile.close()
version = self.getVersionFromCmake()
target = '../../bin/synergy-%s-%s.rpm' % ( target = '../../bin/synergy-%s-%s.rpm' % (
version, self.getLinuxPlatform()) self.getVersionForFilename(), self.getLinuxPlatform())
try: try:
self.try_chdir(rpmDir) self.try_chdir(rpmDir)
@ -1123,9 +1121,10 @@ class InternalCommands:
binDir = self.getGenerator().binDir binDir = self.getGenerator().binDir
resDir = self.cmake_dir resDir = self.cmake_dir
version = self.getVersionFromCmake()
package = '%s-%s-%s' % ( package = '%s-%s-%s' % (
self.project, version, self.getLinuxPlatform()) self.project,
self.getVersionForFilename(),
self.getLinuxPlatform())
debDir = '%s/deb' % buildDir debDir = '%s/deb' % buildDir
if os.path.exists(debDir): if os.path.exists(debDir):
@ -1138,7 +1137,7 @@ class InternalCommands:
template = templateFile.read() template = templateFile.read()
template = template.replace('${in:version}', template = template.replace('${in:version}',
self.getVersionFromCmake()) self.getVersionNumber())
template = template.replace('${in:arch}', template = template.replace('${in:arch}',
self.getDebianArch()) self.getDebianArch())
@ -1226,8 +1225,11 @@ class InternalCommands:
self.restore_chdir() self.restore_chdir()
def distSrc(self): def distSrc(self):
version = self.getVersionFromCmake() name = '%s-%s-%s' % (
name = (self.project + '-' + version + '-Source') self.project,
self.getVersionForFilename(),
'Source')
exportPath = self.getGenerator().buildDir + '/' + name exportPath = self.getGenerator().buildDir + '/' + name
if os.path.exists(exportPath): if os.path.exists(exportPath):
@ -1280,7 +1282,7 @@ class InternalCommands:
fileName = "%s-%s-%s.dmg" % ( fileName = "%s-%s-%s.dmg" % (
self.project, self.project,
self.getVersionFromCmake(), self.getVersionForFilename(),
self.getMacPackageName()) self.getMacPackageName())
cmd = "hdiutil create " + fileName + " -srcfolder ./" + name + "/ -ov" cmd = "hdiutil create " + fileName + " -srcfolder ./" + name + "/ -ov"
@ -1296,7 +1298,7 @@ class InternalCommands:
if generator.endswith('Win64'): if generator.endswith('Win64'):
arch = 'x64' arch = 'x64'
version = self.getVersionFromCmake() version = self.getVersionNumber()
args = "/p:DefineConstants=\"Version=%s\"" % version args = "/p:DefineConstants=\"Version=%s\"" % version
self.run_vcbuild( self.run_vcbuild(
@ -1305,7 +1307,7 @@ class InternalCommands:
filename = "%s-%s-Windows-%s.msi" % ( filename = "%s-%s-Windows-%s.msi" % (
self.project, self.project,
version, self.getVersionForFilename(),
arch) arch)
old = "bin/Release/synergy.msi" old = "bin/Release/synergy.msi"
@ -1340,7 +1342,7 @@ class InternalCommands:
templateFile = open(self.cmake_dir + '\Installer.nsi.in') templateFile = open(self.cmake_dir + '\Installer.nsi.in')
template = templateFile.read() template = templateFile.read()
template = template.replace('${in:version}', self.getVersionFromCmake()) template = template.replace('${in:version}', self.getVersionNumber())
template = template.replace('${in:arch}', arch) template = template.replace('${in:arch}', arch)
template = template.replace('${in:vcRedistDir}', vcRedistDir) template = template.replace('${in:vcRedistDir}', vcRedistDir)
template = template.replace('${in:qtDir}', qtDir) template = template.replace('${in:qtDir}', qtDir)
@ -1357,7 +1359,7 @@ class InternalCommands:
if err != 0: if err != 0:
raise Exception('Package failed: ' + str(err)) raise Exception('Package failed: ' + str(err))
def getVersionFromCmake(self): def getVersionNumber(self):
cmakeFile = open('CMakeLists.txt') cmakeFile = open('CMakeLists.txt')
cmake = cmakeFile.read() cmake = cmakeFile.read()
@ -1370,7 +1372,20 @@ class InternalCommands:
revRe = re.search('VERSION_REV (\d+)', cmake) revRe = re.search('VERSION_REV (\d+)', cmake)
rev = revRe.group(1) rev = revRe.group(1)
return major + '.' + minor + '.' + rev return "%s.%s.%s" % (major, minor, rev)
def getVersionStage(self):
cmakeFile = open('CMakeLists.txt')
cmake = cmakeFile.read()
stageRe = re.search('VERSION_STAGE (\w+)', cmake)
return stageRe.group(1)
def getVersionForFilename(self):
versionStage = self.getVersionStage()
gitBranch = self.getGitBranchName()
gitRevision = self.getGitRevision()
return "%s-%s-%s" % (gitBranch, versionStage, gitRevision)
def distftp(self, type, ftp): def distftp(self, type, ftp):
if not type: if not type:
@ -1380,8 +1395,9 @@ class InternalCommands:
binDir = self.getGenerator().getBinDir('Release') binDir = self.getGenerator().getBinDir('Release')
packageSource = binDir + '/' + self.dist_name(type) filename = self.getDistFilename(type)
packageTarget = self.dist_name_rev(type) packageSource = binDir + '/' + filename
packageTarget = filename
ftp.upload(packageSource, packageTarget) ftp.upload(packageSource, packageTarget)
if type != 'src': if type != 'src':
@ -1393,9 +1409,7 @@ class InternalCommands:
def getLibraryDistFilename(self, type, dir, name): def getLibraryDistFilename(self, type, dir, name):
(platform, packageExt, libraryExt) = self.getDistributePlatformInfo(type) (platform, packageExt, libraryExt) = self.getDistributePlatformInfo(type)
branch = self.getGitBranchName() firstPart = '%s-%s-%s' % (name, self.getVersionForFilename(), platform)
revision = self.getGitRevision()
firstPart = '%s-%s-%s-%s' % (name, branch, revision, platform)
filename = '%s.%s' % (firstPart, libraryExt) filename = '%s.%s' % (firstPart, libraryExt)
if type == 'rpm' or type == 'deb': if type == 'rpm' or type == 'deb':
@ -1453,30 +1467,14 @@ class InternalCommands:
return (platform, ext, libraryExt) return (platform, ext, libraryExt)
def dist_name(self, type): def getDistFilename(self, type):
(platform, packageExt, libraryExt) = self.getDistributePlatformInfo(type) pattern = self.getVersionForFilename()
ext = packageExt
pattern = (
re.escape(self.project + '-') + '\d+\.\d+\.\d+' +
re.escape('-' + platform + '.' + ext))
for filename in os.listdir(self.getBinDir('Release')): for filename in os.listdir(self.getBinDir('Release')):
if re.search(pattern, filename): if re.search(pattern, filename):
return filename return filename
# still here? package probably not created yet.
raise Exception('Could not find package name with pattern: ' + pattern) raise Exception('Could not find package name with pattern: ' + pattern)
def dist_name_rev(self, type):
branch = self.getGitBranchName()
revision = self.getGitRevision()
# find the version number (we're puting the rev in after this)
pattern = '(\d+\.\d+\.\d+)'
replace = "%s-%s" % (branch, revision)
return re.sub(pattern, replace, self.dist_name(type))
def getDebianArch(self): def getDebianArch(self):
if os.uname()[4][:3] == 'arm': if os.uname()[4][:3] == 'arm':
return 'armhf' return 'armhf'