Menu

[r1620]: / CreateRelease.py  Maximize  Restore  History

Download this file

108 lines (89 with data), 4.7 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
# -*- coding: latin-1 -*-
import os
import sys
import glob
import re
import codecs
import shutil
import verchecker
from xml.dom import minidom
getLogProcess = os.popen('svn log --limit=1 --xml')
logData = getLogProcess.read()
dom = minidom.parseString(logData)
logElement = dom.getElementsByTagName('logentry')
rev = logElement[0].getAttribute('revision')
os.system('MakeMonoReleaseMdb.bat')
releaseCompiledDir = 'SharpKom\\bin\\Release'
# Get latest compiled release version
if not os.path.exists(releaseCompiledDir + '\\SharpKom.exe'):
raise Exception('Release version must be compiled')
v = verchecker.calcversioninfo(releaseCompiledDir + '\\SharpKom.exe')
relVer = v.split('.')[-1:][0]
print "Rev " + rev + ", relVer " + relVer
if (rev != relVer):
raise Exception('The latest source version is not compiled as release. The latest version is ' + rev + ' and the latest release is ' + relVer)
# The following extensions will be copied
extensions = ['cs', 'resx', 'csproj', 'sln', 'py', 'ico', 'bmp', 'txt', 'html', 'bat', 'wxs', 'rtf', 'warsetup', 'svg']
destPath = "../SharpKomRelease"
destDir = destPath + "/SharpKom_" + rev
binDir = destDir + "/SharpKOM_bin_" + rev
srcDir = destDir + "/SharpKOM_src_" + rev
if not os.path.exists(destPath):
os.mkdir(destPath)
# Always do this, it it fails the old dir should be cleared first
os.mkdir(destDir)
#os.mkdir(binDir)
os.mkdir(srcDir)
shutil.copytree(os.path.normpath(releaseCompiledDir), os.path.normpath(binDir))
remFile = os.path.normpath(os.path.normpath(binDir) + "\\SharpKom.vshost.exe")
if os.path.exists(remFile):
os.remove(remFile)
remFile = os.path.normpath(os.path.normpath(binDir) + "\\SharpKom.vshost.exe.manifest")
if os.path.exists(remFile):
os.remove(remFile)
# Create a source copy with all relevant files and nothing more
for d in os.walk('.'):
dirpath, dirnames, filenames = d
if not "\\.svn" in dirpath and not dirpath[2:].startswith("FormTests") and not dirpath[2:].startswith("7za457") and not dirpath[2:].startswith("MobileKOM") and not "DockSample" in dirpath:
#print d
#print dirpath
files = [f for f in filenames if [ending for ending in extensions if f.endswith('.' + ending)] and not '.csproj.FileList' in f and not 'System.Printing.dll' in f and not 'PresentationCore.dll' in f]
if files:
print files
newDir = os.path.normpath(os.path.join(srcDir, dirpath))
if not os.path.exists(newDir):
os.makedirs(newDir)
for f in files:
shutil.copyfile(os.path.normpath(os.path.join(dirpath, f)),
os.path.normpath(os.path.join(
os.path.join(srcDir,
dirpath),
f)))
os.system("7za457\\7za.exe a -r -tzip " + os.path.normpath(srcDir) + " " + os.path.normpath(srcDir) + "\\*.* ")
os.system("7za457\\7za.exe a -r -tzip " + os.path.normpath(binDir) + " " + os.path.normpath(binDir) + "\\*.* ")
print ""
print "Creating MSI package"
print os.path.abspath('.')
f = file("Installer\\SharpKomInstaller.wxs")
wxsData = f.read()
f.close()
wxsData = wxsData.replace(".\\SharpKom\\bin\\Release\\", os.path.normpath(binDir) + "\\")
wxsData = wxsData.replace("\"1.0.0\"", "\"" + v + "\"")
reg = re.compile("<Product Id=\"(.*)\" Name=\"#KOM\"")
prodId = reg.findall(wxsData)[0]
wxsData = wxsData.replace(prodId, '*')
f = file(destDir + "\\SharpKomInstaller.wxs", 'w')
f.write(wxsData)
f.close()
runCandle1 = "\"%WIX%bin\\candle.exe\" \"Installer\\SoundScheme.wxs\" -ext \"%WIX%bin\\WixUIExtension.dll\" -ext \"%WIX%bin\\WixUtilExtension.dll\" -ext \"%WIX%bin\\WixNetFxExtension.dll\" -out \"" + destDir + "\\SoundScheme.wixobj\""
runCandle2 = "\"%WIX%bin\\candle.exe\" \"" + destDir + "\\SharpKomInstaller.wxs\" -ext \"%WIX%bin\\WixUIExtension.dll\" -ext \"%WIX%bin\\WixUtilExtension.dll\" -ext \"%WIX%bin\\WixNetFxExtension.dll\" -out \"" + destDir + "\\SharpKomInstaller.wixobj\""
runLight = "\"%WIX%bin\\light.exe\" -out \"" + destDir + "\\SharpKomInstaller_" + rev + ".msi\" \"" + destDir + "\\SharpKomInstaller.wixobj\" \"" + destDir + "\\SoundScheme.wixobj\" -ext \"%WIX%bin\\WixUIExtension.dll\" -ext \"%WIX%bin\\WixUtilExtension.dll\" -ext \"%WIX%bin\\WixNetFxExtension.dll\""
f = file(destDir + "\\makeMsi.bat", 'w')
f.write(runCandle1 + "\n")
f.write(runCandle2 + "\n")
f.write(runLight + "\n")
f.close()
os.system("\"\"" + destDir + "\\makeMsi.bat\"\"")
print ""
print "Done !!!"
print ""