Added ns upload support to distftp step #4695

Needed to refactor the 'figure out platform and ext' code.
This commit is contained in:
Nick Bolton 2015-05-25 15:07:32 +01:00
parent d175ad5c70
commit 6ba2ddeb7d
1 changed files with 61 additions and 54 deletions

View File

@ -840,7 +840,7 @@ class InternalCommands:
pwd = lines[0] pwd = lines[0]
if (dist): if (dist):
self.signFile(pfx, pwd, 'bin', self.dist_name('win')) self.signFile(pfx, pwd, 'bin/Release', self.dist_name('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')
@ -1281,7 +1281,7 @@ class InternalCommands:
arch) arch)
old = "bin/Release/synergy.msi" old = "bin/Release/synergy.msi"
new = "bin/%s" % (filename) new = "bin/Release/%s" % (filename)
try: try:
os.remove(new) os.remove(new)
@ -1344,56 +1344,48 @@ class InternalCommands:
return major + '.' + minor + '.' + rev return major + '.' + minor + '.' + rev
def ftpUpload(self, ftp, source, target):
print "Uploading '%s' as '%s' to FTP server '%s'..." % (
source, target, ftp.host)
ftp.run(source, target)
print 'Done'
def distftp(self, type, ftp): def distftp(self, type, ftp):
if not type: if not type:
raise Exception('Type not specified.') raise Exception('Platform type not specified.')
if not ftp:
raise Exception('FTP info not defined.')
self.loadConfig() self.loadConfig()
src = self.dist_name(type)
dest = self.dist_name_rev(type)
print 'Uploading %s to FTP server %s...' % (dest, ftp.host)
binDir = self.getGenerator().getBinDir('Release') binDir = self.getGenerator().getBinDir('Release')
ftp.run(binDir + '/' + src, dest)
print 'Done' packageSource = binDir + '/' + self.dist_name(type)
packageTarget = self.dist_name_rev(type)
def getDebianArch(self): self.ftpUpload(ftp, packageSource, packageTarget)
if os.uname()[4][:3] == 'arm':
return 'armhf' if (type != 'src'):
pluginsDir = binDir + '/plugins'
nsPluginSource = self.findLibraryFile(type, pluginsDir, 'ns')
nsPluginTarget = self.getLibraryDistFilename(type, pluginsDir, 'ns')
self.ftpUpload(ftp, nsPluginSource, nsPluginTarget)
# os_bits should be loaded with '32bit' or '64bit' # os_bits should be loaded with '32bit' or '64bit'
import platform import platform
(os_bits, other) = platform.architecture() (os_bits, other) = platform.architecture()
def findLibraryFile(self, type, dir, name):
(platform, packageExt, libraryExt) = self.getDistributePlatformInfo(type)
ext = libraryExt
pattern = name + '\.' + ext
for filename in os.listdir(dir):
if re.search(pattern, filename):
return dir + '/' + filename
# get platform based on current platform raise Exception('Could not find library name with pattern: ' + pattern)
if os_bits == '32bit':
return 'i386'
elif os_bits == '64bit':
return 'amd64'
else:
raise Exception("unknown os bits: " + os_bits)
def getLinuxPlatform(self): def getDistributePlatformInfo(self, type):
if os.uname()[4][:3] == 'arm':
return 'Linux-armv6l'
# os_bits should be loaded with '32bit' or '64bit'
import platform
(os_bits, other) = platform.architecture()
# get platform based on current platform
if os_bits == '32bit':
return 'Linux-i686'
elif os_bits == '64bit':
return 'Linux-x86_64'
else:
raise Exception("unknown os bits: " + os_bits)
def dist_name(self, type):
ext = None ext = None
libraryExt = None
platform = None platform = None
if type == 'src': if type == 'src':
@ -1401,14 +1393,14 @@ class InternalCommands:
platform = 'Source' platform = 'Source'
elif type == 'rpm' or type == 'deb': elif type == 'rpm' or type == 'deb':
ext = type ext = type
platform = self.getLinuxPlatform() libraryExt = 'so'
platform = self.getLinuxPlatform()
elif type == 'win': elif type == 'win':
# get platform based on last generator used # get platform based on last generator used
ext = 'msi' ext = 'msi'
libraryExt = 'dll'
generator = self.getGeneratorFromConfig().cmakeName generator = self.getGeneratorFromConfig().cmakeName
if generator.find('Win64') != -1: if generator.find('Win64') != -1:
platform = 'Windows-x64' platform = 'Windows-x64'
@ -1417,18 +1409,23 @@ class InternalCommands:
elif type == 'mac': elif type == 'mac':
ext = "dmg" ext = "dmg"
libraryExt = 'dylib'
platform = self.getMacPackageName() platform = self.getMacPackageName()
if not platform: if not platform:
raise Exception('Unable to detect package platform.') raise Exception('Unable to detect distributable platform.')
pattern = re.escape(self.project + '-') + '\d+\.\d+\.\d+' + re.escape('-' + platform + '.' + ext)
target = ''
if type == 'mac':
target = 'Release'
for filename in os.listdir(self.getBinDir(target)): return (platform, ext, libraryExt)
def dist_name(self, type):
(platform, packageExt, libraryExt) = self.getDistributePlatformInfo(type)
ext = packageExt
pattern = (
re.escape(self.project + '-') + '\d+\.\d+\.\d+' +
re.escape('-' + platform + '.' + ext))
for filename in os.listdir(self.getBinDir('Release')):
if re.search(pattern, filename): if re.search(pattern, filename):
return filename return filename
@ -1441,6 +1438,15 @@ class InternalCommands:
replace = "%s-%s" % ( replace = "%s-%s" % (
self.getGitBranchName(), self.getGitRevision()) self.getGitBranchName(), self.getGitRevision())
return re.sub(pattern, replace, self.dist_name(type)) return re.sub(pattern, replace, self.dist_name(type))
def getDebianArch(self):
if os.uname()[4][:3] == 'arm':
return 'armhf'
if os.uname()[4][:3] == 'arm':
return 'Linux-armv6l'
def dist_usage(self): def dist_usage(self):
print ('Usage: %s package [package-type]\n' print ('Usage: %s package [package-type]\n'
@ -1913,10 +1919,11 @@ class CommandHandler:
elif o == '--dir': elif o == '--dir':
dir = a dir = a
ftp = None if not host:
if host: raise Exception('FTP host was not specified.')
ftp = ftputil.FtpUploader(
host, user, password, dir) ftp = ftputil.FtpUploader(
host, user, password, dir)
self.ic.distftp(type, ftp) self.ic.distftp(type, ftp)