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 distftp(self, type, ftp): def ftpUpload(self, ftp, source, target):
if not type: print "Uploading '%s' as '%s' to FTP server '%s'..." % (
raise Exception('Type not specified.') source, target, ftp.host)
ftp.run(source, target)
if not ftp:
raise Exception('FTP info not defined.')
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')
ftp.run(binDir + '/' + src, dest)
print 'Done' print 'Done'
def getDebianArch(self): def distftp(self, type, ftp):
if os.uname()[4][:3] == 'arm': if not type:
return 'armhf' raise Exception('Platform type not specified.')
self.loadConfig()
binDir = self.getGenerator().getBinDir('Release')
packageSource = binDir + '/' + self.dist_name(type)
packageTarget = self.dist_name_rev(type)
self.ftpUpload(ftp, packageSource, packageTarget)
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
# get platform based on current platform pattern = name + '\.' + ext
if os_bits == '32bit':
return 'i386'
elif os_bits == '64bit':
return 'amd64'
else:
raise Exception("unknown os bits: " + os_bits)
def getLinuxPlatform(self): for filename in os.listdir(dir):
if os.uname()[4][:3] == 'arm': if re.search(pattern, filename):
return 'Linux-armv6l' return dir + '/' + filename
# os_bits should be loaded with '32bit' or '64bit' raise Exception('Could not find library name with pattern: ' + pattern)
import platform
(os_bits, other) = platform.architecture()
# get platform based on current platform def getDistributePlatformInfo(self, type):
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) return (platform, ext, libraryExt)
target = '' def dist_name(self, type):
if type == 'mac': (platform, packageExt, libraryExt) = self.getDistributePlatformInfo(type)
target = 'Release' ext = packageExt
for filename in os.listdir(self.getBinDir(target)): 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
@ -1442,6 +1439,15 @@ class InternalCommands:
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'
'\n' '\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)