| 1 | import sys
|
|---|
| 2 | import os
|
|---|
| 3 | import zipfile
|
|---|
| 4 | import fnmatch
|
|---|
| 5 | import shutil
|
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 | execfile("config.py")
|
|---|
| 9 |
|
|---|
| 10 | sys.path.append(BUILD_PYTHON_FOLDER)
|
|---|
| 11 | from VersionHandler import VersionHandler
|
|---|
| 12 |
|
|---|
| 13 | version = VersionHandler(VERSION_TXT)
|
|---|
| 14 | version.read()
|
|---|
| 15 | datestr = version.datestr()
|
|---|
| 16 | vstring = version.version()
|
|---|
| 17 |
|
|---|
| 18 | targets = None
|
|---|
| 19 |
|
|---|
| 20 | def build_targets(str):
|
|---|
| 21 | targets = {}
|
|---|
| 22 | for itm in str.split(';'):
|
|---|
| 23 | tmp = itm.split('=')
|
|---|
| 24 | if len(tmp) == 0:
|
|---|
| 25 | continue
|
|---|
| 26 | elif len(tmp) == 1:
|
|---|
| 27 | targets['nscp'] = tmp[0]
|
|---|
| 28 | else:
|
|---|
| 29 | targets[tmp[0]] = tmp[1]
|
|---|
| 30 | return targets
|
|---|
| 31 |
|
|---|
| 32 |
|
|---|
| 33 |
|
|---|
| 34 | def find_target(key=None):
|
|---|
| 35 | global targets
|
|---|
| 36 | if not targets:
|
|---|
| 37 | targets = build_targets(TARGET_SITE)
|
|---|
| 38 | if not key:
|
|---|
| 39 | key = 'nscp'
|
|---|
| 40 | if not key in targets:
|
|---|
| 41 | return None
|
|---|
| 42 | return targets[key]
|
|---|
| 43 |
|
|---|
| 44 |
|
|---|
| 45 | def scp_file(file):
|
|---|
| 46 | tfile = os.path.basename(file)
|
|---|
| 47 | (name, version, arch) = tfile.split('-')
|
|---|
| 48 | target = None
|
|---|
| 49 | if '_' in name:
|
|---|
| 50 | (name, tag) = name.split('_')
|
|---|
| 51 | target = find_target(tag)
|
|---|
| 52 | if target:
|
|---|
| 53 | print 'Found tagged installer %s for %s'%(tfile, tag)
|
|---|
| 54 | else:
|
|---|
| 55 | print 'Ignoring unconfigured tagged installer: %s (define TARGET_SITE_%s to a destination)'%(tag,tag)
|
|---|
| 56 | else:
|
|---|
| 57 | print 'Found normal installer %s'%tfile
|
|---|
| 58 | target = find_target()
|
|---|
| 59 | if target:
|
|---|
| 60 | print 'Uploading name: %s to %s'%(tfile, target)
|
|---|
| 61 | os.system("%s %s %s"%(SCP_BINARY, file, target))
|
|---|
| 62 |
|
|---|
| 63 | def rename_and_move(file, target):
|
|---|
| 64 | tfile = '%s/%s'%(target, os.path.basename(file))
|
|---|
| 65 | tfile = tfile.replace('win64', 'x64')
|
|---|
| 66 | print "Copying %s to %s"%(file, tfile)
|
|---|
| 67 | shutil.copy(file, tfile)
|
|---|
| 68 |
|
|---|
| 69 | def find_by_pattern(path, pattern):
|
|---|
| 70 | matches = []
|
|---|
| 71 | for root, dirnames, filenames in os.walk(path):
|
|---|
| 72 | if '_CPack_Packages' not in root:
|
|---|
| 73 | for filename in fnmatch.filter(filenames, pattern):
|
|---|
| 74 | matches.append(os.path.join(root, filename))
|
|---|
| 75 | return matches
|
|---|
| 76 |
|
|---|
| 77 | target_name = 'NSCP-%s-%s_symbols.zip'%(vstring, VERSION_ARCH)
|
|---|
| 78 |
|
|---|
| 79 | if BREAKPAD_FOUND == "TRUE":
|
|---|
| 80 | print "Gathering symbols into %s"%target_name
|
|---|
| 81 | matches = find_by_pattern(BUILD_TARGET_EXE_PATH, '*.pdb')
|
|---|
| 82 | zip = zipfile.ZipFile(target_name, 'w', zipfile.ZIP_DEFLATED)
|
|---|
| 83 | for f in matches:
|
|---|
| 84 | print "Processing: %s"%f
|
|---|
| 85 | out = f.replace('.pdb', '.sym')
|
|---|
| 86 | os.system("%s %s > %s"%(BREAKPAD_DUMPSYMS_EXE, f, out))
|
|---|
| 87 | if out.startswith(BUILD_TARGET_EXE_PATH):
|
|---|
| 88 | name = out[len(BUILD_TARGET_EXE_PATH)+1:]
|
|---|
| 89 | else:
|
|---|
| 90 | name = out
|
|---|
| 91 | zip.write(out, name)
|
|---|
| 92 | zip.close()
|
|---|
| 93 |
|
|---|
| 94 | if ARCHIVE_FOLDER != "":
|
|---|
| 95 | print "Archiving files..."
|
|---|
| 96 | target_installer = "%s/%s"%(ARCHIVE_FOLDER,"installers")
|
|---|
| 97 | target_archives = "%s/%s"%(ARCHIVE_FOLDER,"archive")
|
|---|
| 98 | if not os.path.isdir(ARCHIVE_FOLDER):
|
|---|
| 99 | os.mkdir(ARCHIVE_FOLDER)
|
|---|
| 100 | if not os.path.isdir(target_installer):
|
|---|
| 101 | os.mkdir(target_installer)
|
|---|
| 102 | if not os.path.isdir(target_archives):
|
|---|
| 103 | os.mkdir(target_archives)
|
|---|
| 104 |
|
|---|
| 105 | for f in find_by_pattern(BUILD_TARGET_EXE_PATH, '*%s*.msi'%vstring):
|
|---|
| 106 | rename_and_move(f, target_installer)
|
|---|
| 107 | for f in find_by_pattern(BUILD_TARGET_EXE_PATH, '*%s*.zip'%vstring):
|
|---|
| 108 | rename_and_move(f, target_archives)
|
|---|
| 109 |
|
|---|
| 110 | try:
|
|---|
| 111 | if TARGET_SITE != '' and SCP_BINARY != '':
|
|---|
| 112 | print "Distributing files to site..."
|
|---|
| 113 |
|
|---|
| 114 | for f in find_by_pattern(BUILD_TARGET_EXE_PATH, '*%s*.msi'%vstring):
|
|---|
| 115 | scp_file(f)
|
|---|
| 116 | for f in find_by_pattern(BUILD_TARGET_EXE_PATH, '*%s*.zip'%vstring):
|
|---|
| 117 | scp_file(f)
|
|---|
| 118 | except NameError:
|
|---|
| 119 | print 'TARGET_SITE not defined so we wont upload anything...'
|
|---|