task #2832 - Manually implement NSIS

This commit is contained in:
Nick Bolton 2011-01-20 02:18:48 +00:00
parent 315c304dde
commit 488622ea00
2 changed files with 203 additions and 28 deletions

View File

@ -444,34 +444,9 @@ class InternalCommands:
# Package is supported by default.
package_unsupported = False
unixTarget = 'release'
confArgs = '-DCONF_CPACK:BOOL=TRUE'
generator = self.get_generator_from_config()
if generator.startswith('Visual Studio'):
if vcRedistDir =='':
raise Exception(
'VC++ redist dir path not specified (--vcredist-dir).')
# forward slashes are easier in cmake
vcRedistDir = vcRedistDir.replace('\\', '/')
vcRedistArch = 'x86'
if generator.endswith('Win64'):
vcRedistArch = 'x64'
vcRedistFile = 'vcredist_' + vcRedistArch + '.exe'
confArgs += (' -DVCREDIST_DIR:STRING=' + vcRedistDir +
' -DVCREDIST_FILE:STRING=' + vcRedistFile)
if (qtDir != ''):
# forward slashes are easier in cmake
confArgs += ' -DQT_DIR:STRING=' + qtDir.replace('\\', '/')
self.configure_internal('', confArgs)
else:
self.configure_internal(unixTarget, confArgs)
if type != 'win':
self.configure_internal(unixTarget, '-DCONF_CPACK:BOOL=TRUE')
if type == None:
self.dist_usage()
@ -497,7 +472,7 @@ class InternalCommands:
elif type == 'win':
if sys.platform == 'win32':
self.dist_run('cpack -G NSIS')
self.distNsis(vcRedistDir, qtDir)
else:
package_unsupported = True
@ -516,6 +491,60 @@ class InternalCommands:
% (type, sys.platform))
def distNsis(self, vcRedistDir, qtDir):
if vcRedistDir == '':
raise Exception(
'VC++ redist dir path not specified (--vcredist-dir).')
if qtDir == '':
raise Exception(
'QT SDK dir path not specified (--qt-dir).')
generator = self.get_generator_from_config()
arch = 'x86'
installDirVar = '$PROGRAMFILES32'
if generator.endswith('Win64'):
arch = 'x64'
installDirVar = '$PROGRAMFILES64'
templateFile = open('cmake\Installer.nsi.in')
template = templateFile.read()
template = template.replace('${in:version}', self.getVersionFromCmake())
template = template.replace('${in:arch}', arch)
template = template.replace('${in:vcRedistDir}', vcRedistDir)
template = template.replace('${in:qtDir}', qtDir)
template = template.replace('${in:installDirVar}', installDirVar)
nsiPath = 'bin\Installer.nsi'
nsiFile = open(nsiPath, 'w')
nsiFile.write(template)
nsiFile.close()
command = 'makensis ' + nsiPath
print 'NSIS command: ' + command
err = os.system(command)
if err != 0:
raise Exception('Package failed: ' + str(err))
def getVersionFromCmake(self):
cmakeFile = open('CMakeLists.txt')
cmake = cmakeFile.read()
majorRe = re.search('VERSION_MAJOR (\d+)', cmake)
major = majorRe.group(1)
minorRe = re.search('VERSION_MINOR (\d+)', cmake)
minor = minorRe.group(1)
revRe = re.search('VERSION_REV (\d+)', cmake)
rev = revRe.group(1)
return major + '.' + minor + '.' + rev
def distftp(self, type, ftp):
if not type:
raise Exception('Type not specified.')

146
cmake/Installer.nsi.in Normal file
View File

@ -0,0 +1,146 @@
; template variables
!define version ${in:version}
!define arch ${in:arch}
!define vcRedistDir ${in:vcRedistDir}
!define qtDir ${in:qtDir}
!define installDirVar ${in:installDirVar}
; normal variables
!define product "Synergy"
!define productOld "Synergy+"
!define packageName "synergy"
!define platform "Windows"
!define publisher "The Synergy Project"
!define helpUrl "http://synergy-foss.org/support"
!define vcRedistFile "vcredist_${arch}.exe"
!define startMenuApp "qsynergy.exe"
!define binDir "..\bin\Release"
!define uninstall "uninstall.exe"
!define icon "..\gui\res\win\QSynergy.ico"
!define controlPanelReg "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall"
!define MUI_ICON ${icon}
!define MUI_UNICON ${icon}
!include "MUI2.nsh"
!insertmacro MUI_PAGE_LICENSE "..\\cmake\\License.rtf"
!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_UNPAGE_WELCOME
!insertmacro MUI_UNPAGE_INSTFILES
!insertmacro MUI_LANGUAGE "English"
Name ${product}
OutFile "${packageName}-${version}-${platform}-${arch}.exe"
InstallDir "${installDirVar}\${product}"
InstallDirRegKey HKEY_LOCAL_MACHINE "SOFTWARE\${product}" ""
Section
SetShellVarContext all
SetOutPath "$INSTDIR"
WriteUninstaller "$INSTDIR\${uninstall}"
; kill all synergy processes (force kill gui)
nsExec::Exec "taskkill /f /im qsynergy.exe"
nsExec::Exec "taskkill /im launcher.exe"
nsExec::Exec "taskkill /im synergys.exe"
nsExec::Exec "taskkill /im synergyc.exe"
; delete dirs from older installers
RMDir /r "$INSTDIR\..\${productOld}"
RMDir /r "$INSTDIR\bin"
RMDir /r "$INSTDIR\redist"
; delete start menu dir from older installers
RMDir /r "$SMPROGRAMS\${product}"
RMDir /r "$SMPROGRAMS\${productOld}"
; always delete any existing uninstall info
DeleteRegKey HKLM "${controlPanelReg}\${product}"
; always remove 1.3 gui
Delete "$INSTDIR\launcher.exe"
SectionEnd
Section "Server and Client" core
; client and server files
File "${binDir}\synergys.exe"
File "${binDir}\synergyc.exe"
File "${binDir}\synrgyhk.dll"
; add new uninstall info
WriteRegStr HKLM "${controlPanelReg}\${product}" "" $INSTDIR
WriteRegStr HKLM "${controlPanelReg}\${product}" "DisplayName" "${product}"
WriteRegStr HKLM "${controlPanelReg}\${product}" "DisplayVersion" "${version}"
WriteRegStr HKLM "${controlPanelReg}\${product}" "DisplayIcon" "$INSTDIR\uninstall.exe"
WriteRegStr HKLM "${controlPanelReg}\${product}" "Publisher" "${publisher}"
WriteRegStr HKLM "${controlPanelReg}\${product}" "UninstallString" "$INSTDIR\uninstall.exe"
WriteRegStr HKLM "${controlPanelReg}\${product}" "URLInfoAbout" "${helpUrl}"
SectionEnd
Section "Graphical User Interface" gui
; gui and qt libs
File "${binDir}\qsynergy.exe"
File "${qtDir}\qt\bin\libgcc_s_dw2-1.dll"
File "${qtDir}\qt\bin\mingwm10.dll"
File "${qtDir}\qt\bin\QtGui4.dll"
File "${qtDir}\qt\bin\QtCore4.dll"
File "${qtDir}\qt\bin\QtNetwork4.dll"
; gui start menu shortcut
SetShellVarContext all
CreateShortCut "$SMPROGRAMS\${product}.lnk" "$INSTDIR\${startMenuApp}"
SectionEnd
Section "Visual C++ Redistributable" vcredist
; copy redist file, run it, then delete when done
File "${vcRedistDir}\${vcRedistFile}"
ExecWait "$INSTDIR\${vcRedistFile} /install /q"
Delete $INSTDIR\${vcRedistFile}
SectionEnd
Section Uninstall
SetShellVarContext all
; kill all synergy processes (force kill gui)
nsExec::Exec "taskkill /f /im qsynergy.exe"
nsExec::Exec "taskkill /im launcher.exe"
nsExec::Exec "taskkill /im synergys.exe"
nsExec::Exec "taskkill /im synergyc.exe"
; delete start menu shortcut
Delete "$SMPROGRAMS\${product}.lnk"
; delete all registry keys
DeleteRegKey HKLM "SOFTWARE\${product}"
DeleteRegKey HKLM "${controlPanelReg}\${product}"
; delete the files that we put there
Delete "$INSTDIR\synergyc.exe"
Delete "$INSTDIR\synergys.exe"
Delete "$INSTDIR\synrgyhk.dll"
Delete "$INSTDIR\synrgyhk.lib"
Delete "$INSTDIR\libgcc_s_dw2-1.dll"
Delete "$INSTDIR\mingwm10.dll"
Delete "$INSTDIR\qsynergy.exe"
Delete "$INSTDIR\QtCore4.dll"
Delete "$INSTDIR\QtGui4.dll"
Delete "$INSTDIR\QtNetwork4.dll"
Delete "$INSTDIR\${uninstall}"
; delete (only if empty, so we don't delete user files)
RMDir "$INSTDIR"
SectionEnd