win32-openvibe-x.x.x-setup.nsi 11.1 KB
Newer Older
1 2 3 4 5
; define a default for dep dir
!ifndef DEPENDENCIES_DIR
	!define DEPENDENCIES_DIR "..\..\dependencies"
!endif

6 7
	!define OV_VERSION "2.1.0"
	!define OV_VERSION_SHORT "210"
8
	
9
!ifndef OUTFILE
10
	!define OUTFILE "openvibe-${OV_VERSION}-setup.exe"
11 12
!endif
	
jlindgre's avatar
jlindgre committed
13 14 15 16 17
	SetCompressor /FINAL /SOLID lzma
	SetCompressorDictSize 16

	!include "MUI.nsh"
	!include "zipdll.nsh"
18
  
jlindgre's avatar
jlindgre committed
19
	;Name and file
20 21
	!define OV_NAME "OpenViBE ${OV_VERSION}"
	Name "${OV_NAME}"
22
	OutFile ${OUTFILE}
jlindgre's avatar
jlindgre committed
23

24 25 26
	;To detect a previous installation
	!define OV_REGKEY "openvibe${OV_VERSION_SHORT}"
	
jlindgre's avatar
jlindgre committed
27
	;Default installation folder
28
	InstallDir "$PROGRAMFILES\openvibe-${OV_VERSION}"
jlindgre's avatar
jlindgre committed
29 30 31 32 33 34
	Var OLDINSTDIR
	Var DIRECTX_MISSING

;Interface Settings

	!define MUI_ABORTWARNING
35
	
jlindgre's avatar
jlindgre committed
36 37 38 39 40
;Pages

	!insertmacro MUI_PAGE_WELCOME
	!insertmacro MUI_PAGE_LICENSE "..\COPYING"
	!insertmacro MUI_PAGE_DIRECTORY
41
	!insertmacro MUI_PAGE_COMPONENTS	
jlindgre's avatar
jlindgre committed
42 43 44 45 46 47 48 49
	!insertmacro MUI_PAGE_INSTFILES
	!insertmacro MUI_PAGE_FINISH

	!insertmacro MUI_UNPAGE_WELCOME
	!insertmacro MUI_UNPAGE_CONFIRM
	!insertmacro MUI_UNPAGE_INSTFILES
	!insertmacro MUI_UNPAGE_FINISH

50 51

	
jlindgre's avatar
jlindgre committed
52 53 54 55 56 57 58 59 60 61 62 63 64
;Languages

	!insertmacro MUI_LANGUAGE "English"

;Installer and uninstaller icons

	Icon "${NSISDIR}\Contrib\Graphics\Icons\box-install.ico"
	UninstallIcon "${NSISDIR}\Contrib\Graphics\Icons\box-uninstall.ico"

;##########################################################################################################################################################
;##########################################################################################################################################################
;##########################################################################################################################################################

65
  
jlindgre's avatar
jlindgre committed
66 67
Function .onInit

68 69 70 71
	; Note that for logging to work, you will need a logging-enabled build of nsis. 
	; At the time of writing this, you could get one from http://nsis.sourceforge.net/Special_Builds 
	LogSet on
  
jlindgre's avatar
jlindgre committed
72 73 74 75 76 77 78
	UserInfo::GetAccountType
	Pop $R1
	StrCmp $R1 "Admin" has_admin_rights 0
		MessageBox MB_OK "You must be administrator to install OpenViBE" /SD IDOK
		Quit
has_admin_rights:

79
	ReadRegStr $0 HKLM SOFTWARE\${OV_REGKEY} InstallDir
jlindgre's avatar
jlindgre committed
80 81 82

	${If} $0 != ""
		IfFileExists "$0\Uninstall.exe" +1 +5
83
			MessageBox MB_YESNO "A previous installation of ${OV_NAME} is installed under $0.$\nContinuing the install procedure will remove previous installation of ${OV_NAME} (including all files you eventually added in the installation directory).$\nWould you like to accept this removal and continue on installation process ?" /SD IDYES IDNO +1 IDYES +2
jlindgre's avatar
jlindgre committed
84 85 86 87 88
			Abort
		StrCpy $OLDINSTDIR $0
		StrCpy $INSTDIR $0
	${EndIf}

89 90 91 92 93
	; Make OpenViBE section mandatory
	IntOp $0 ${SF_SELECTED} | ${SF_RO}
	IntOp $0 $0 | ${SF_BOLD}
    SectionSetFlags "Section1" $0
	
jlindgre's avatar
jlindgre committed
94 95
FunctionEnd

96
; Returns characters before -, _ or .
97 98 99 100 101 102 103 104 105 106 107
Function GetFirstStrPart
  Exch $R0
  Push $R1
  Push $R2
  StrLen $R1 $R0
  IntOp $R1 $R1 + 1
  loop:
    IntOp $R1 $R1 - 1
    StrCpy $R2 $R0 1 -$R1
    StrCmp $R2 "" exit2
    StrCmp $R2 "-" exit1 
108 109
    StrCmp $R2 "_" exit1
    StrCmp $R2 "." exit1
110 111 112 113 114 115 116 117 118
  Goto loop
  exit1:
    StrCpy $R0 $R0 -$R1
  exit2:
    Pop $R2
    Pop $R1
    Exch $R0
FunctionEnd

jlindgre's avatar
jlindgre committed
119 120 121 122
;##########################################################################################################################################################
;##########################################################################################################################################################
;##########################################################################################################################################################

123
Section "!OpenViBE" Section1
jlindgre's avatar
jlindgre committed
124

125 126
	LogSet on
	
jlindgre's avatar
jlindgre committed
127 128
	${If} $OLDINSTDIR != ""
		RMDir /r $OLDINSTDIR
129
		RMDir /r "$SMPROGRAMS\${OV_NAME}"
jlindgre's avatar
jlindgre committed
130 131 132
	${EndIf}

	SetOutPath $INSTDIR
133
	WriteRegStr HKLM "SOFTWARE\${OV_REGKEY}" "InstallDir" "$INSTDIR"
jlindgre's avatar
jlindgre committed
134 135 136 137 138 139
	WriteUninstaller Uninstall.exe

	CreateDirectory "$INSTDIR\dependencies\arch"
	StrCpy $DIRECTX_MISSING "false"

	SetOutPath "$INSTDIR\dependencies"
140 141
	IfFileExists "$SYSDIR\d3dx9_43.dll" no_need_to_install_directx
	NSISdl::download "https://download.microsoft.com/download/8/4/A/84A35BF1-DAFE-4AE8-82AF-AD2AE20B6B14/directx_Jun2010_redist.exe" "arch\directx-jun2010.exe"
jlindgre's avatar
jlindgre committed
142 143 144 145 146
	Pop $R0 ; Get the return value
		StrCmp $R0 "success" +4
			MessageBox MB_OK "Download failed: $R0$\nCheck your Internet connection and your firewall settings.$\nDirect X won't be installed and 3D functionalities won't be available...$\nYou can install DirectX later to enable 3D functionalities !" /SD IDOK
			StrCpy $DIRECTX_MISSING "true"
			Goto no_need_to_install_directx ; Quit
147
	ExecWait '"arch\directx-jun2010.exe" /T:"$INSTDIR\tmp" /Q'
jlindgre's avatar
jlindgre committed
148
	ExecWait '"$INSTDIR\tmp\DXSETUP.exe" /silent'
149
	RMDir /r "$INSTDIR\tmp"
jlindgre's avatar
jlindgre committed
150 151
no_need_to_install_directx:

152
	; This is the destination path where the zips will be copied to
jlindgre's avatar
jlindgre committed
153
	SetOutPath "$INSTDIR\dependencies\arch"
154
	; The following source paths are relative to this .nsi script location
155 156
	File "${DEPENDENCIES_DIR}\arch\build\windows\*runtime.zip"	
	File "${DEPENDENCIES_DIR}\arch\build\windows\pthread*.zip"		
157
	; All vcredist packages extracted to the same folder
158
	File "${DEPENDENCIES_DIR}\arch\build\windows\vcredist*.zip"
159
	
160
	; The zips are extracted here by the installer
jlindgre's avatar
jlindgre committed
161
	SetOutPath "$INSTDIR\dependencies"
162 163
	
	; Extract all the zip archives
164
	; n.b. this thing will freeze on exec if there is no - or _ in the filename
165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183
	ClearErrors
	FindFirst $R0 $R1 "arch\*.zip"
	ZipLoop:
		IfErrors ZipDone

		; find the base name, push to R2
		Push "$R1"
		Call GetFirstStrPart
		Pop "$R2"

		ZipDLL::extractall "arch\$R1" "$R2"

		ClearErrors
		FindNext $R0 $R1
		Goto ZipLoop
	ZipDone:
	FindClose $R0

	; Zip extract hopefully done now
184
	
jlindgre's avatar
jlindgre committed
185
	SetOutPath "$INSTDIR"
Jussi Lindgren's avatar
Jussi Lindgren committed
186
	; Export binaries
187
	File /nonfatal /r ..\..\dist\extras-Release\bin
jlindgre's avatar
jlindgre committed
188
	; Export launch scripts
189
	File /nonfatal ..\..\dist\extras-Release\*.cmd
jlindgre's avatar
jlindgre committed
190 191
	; File /nonfatal /r ..\dist\doc
	; File /nonfatal /r ..\dist\include
Jussi Lindgren's avatar
Jussi Lindgren committed
192 193 194 195 196
	
	; etc and lib folders are needed for the gtk theme
	File /nonfatal /r /x *.lib ..\..\dist\extras-Release\lib
	File /nonfatal /r ..\..\dist\extras-Release\etc
	
197 198
	File /nonfatal /r ..\..\dist\extras-Release\log
	File /nonfatal /r ..\..\dist\extras-Release\share
jlindgre's avatar
jlindgre committed
199 200 201 202 203 204 205 206 207 208 209 210 211 212
	; File /nonfatal /r ..\dist\tmp

	StrCmp $DIRECTX_MISSING "false" no_need_to_patch_3d_functionnality
	FileOpen $0 "$INSTDIR\share\openvibe\kernel\openvibe.conf" a	
	FileSeek $0 0 END
	FileWrite $0 "$\r$\n"
	FileWrite $0 "#####################################################################################$\r$\n"
	FileWrite $0 "# Patched by installer because DirectX is missing$\r$\n"
	FileWrite $0 "#####################################################################################$\r$\n"
	FileWrite $0 "Kernel_3DVisualisationEnabled = false$\r$\n"
	FileClose $0
no_need_to_patch_3d_functionnality:

	; Overwrite the file that may be in share/, as it contains local definitions to the build machine
213 214
	FileOpen $0 "$INSTDIR\bin\openvibe-set-env.cmd" w
	FileWrite $0 "@echo off$\r$\n"
jlindgre's avatar
jlindgre committed
215 216 217 218 219 220 221 222
	FileWrite $0 "$\r$\n"

	FileWrite $0 "$\r$\n"
	FileWrite $0 "SET OGRE_HOME=$INSTDIR\dependencies\ogre$\r$\n"
	FileWrite $0 "SET VRPNROOT=$INSTDIR\dependencies\vrpn$\r$\n"
	FileWrite $0 "$\r$\n"
	FileWrite $0 "SET PATH=$INSTDIR\dependencies\gtk\bin;%PATH%$\r$\n"
	FileWrite $0 "SET PATH=$INSTDIR\dependencies\cegui\bin;%PATH%$\r$\n"
223
	FileWrite $0 "SET PATH=$INSTDIR\dependencies\cegui\dependencies\bin;%PATH%$\r$\n"	
jlindgre's avatar
jlindgre committed
224 225
	FileWrite $0 "SET PATH=%OGRE_HOME%\bin\release;%OGRE_HOME%\bin\debug;%PATH%$\r$\n"
	FileWrite $0 "SET PATH=%VRPNROOT%\bin;%PATH%$\r$\n"
226
	FileWrite $0 "SET PATH=$INSTDIR\dependencies\pthread\lib;%PATH%$\r$\n"
227
	FileWrite $0 "SET PATH=$INSTDIR\dependencies\vcredist\;%PATH%$\r$\n"	
jlindgre's avatar
jlindgre committed
228
	
229 230 231 232 233 234 235
	FileWrite $0 "$\r$\n"
	FileWrite $0 "REM Apply user-provided Python2.7 paths if available$\r$\n"
	FileWrite $0 "IF NOT !PYTHONHOME27!==!EMPTY!  IF NOT !PYTHONPATH27!==!EMPTY! SET REPLACE_PYTHON=true$\r$\n"
	FileWrite $0 "IF NOT !REPLACE_PYTHON!==!EMPTY! ($\r$\n"
	FileWrite $0 "  SET $\"PYTHONHOME=%PYTHONHOME27%$\"$\r$\n"
	FileWrite $0 "  SET $\"PYTHONPATH=%PYTHONPATH27%$\"$\r$\n"
	FileWrite $0 ")$\r$\n"	
236

jlindgre's avatar
jlindgre committed
237
	FileClose $0
238

jlindgre's avatar
jlindgre committed
239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258
	FileOpen $0 "$INSTDIR\dependencies\cegui\resources.cfg" w
	FileWrite $0 "FileSystem=$INSTDIR\dependencies\cegui\datafiles\configs$\r$\n"
	FileWrite $0 "FileSystem=$INSTDIR\dependencies\cegui\datafiles\fonts$\r$\n"
	FileWrite $0 "FileSystem=$INSTDIR\dependencies\cegui\datafiles\imagesets$\r$\n"
	FileWrite $0 "FileSystem=$INSTDIR\dependencies\cegui\datafiles\layouts$\r$\n"
	FileWrite $0 "FileSystem=$INSTDIR\dependencies\cegui\datafiles\looknfeel$\r$\n"
	FileWrite $0 "FileSystem=$INSTDIR\dependencies\cegui\datafiles\lua_scripts$\r$\n"
	FileWrite $0 "FileSystem=$INSTDIR\dependencies\cegui\datafiles\schemes$\r$\n"
	FileWrite $0 "FileSystem=$INSTDIR\dependencies\cegui\datafiles\xml_schemes$\r$\n"
	FileClose $0

	FileOpen $0 "$INSTDIR\dependencies\gtk\etc\gtk-2.0\gtkrc" w
	FileWrite $0 "gtk-theme-name = $\"Redmond$\"$\r$\n"
	FileWrite $0 "style $\"user-font$\"$\r$\n"
	FileWrite $0 "{$\r$\n"
	FileWrite $0 "	font_name=$\"Sans 8$\"$\r$\n"
	FileWrite $0 "}$\r$\n"
	FileWrite $0 "widget_class $\"*$\" style $\"user-font$\"$\r$\n"
	FileClose $0

259 260 261 262 263 264 265 266 267 268
	CreateDirectory "$SMPROGRAMS\${OV_NAME}"
	CreateDirectory "$SMPROGRAMS\${OV_NAME}\Developer tools"
	CreateShortCut "$SMPROGRAMS\${OV_NAME}\Developer tools\openvibe id generator.lnk"       "$INSTDIR\openvibe-id-generator.cmd"        "" "%SystemRoot%\system32\shell32.dll" 57
	CreateShortCut "$SMPROGRAMS\${OV_NAME}\Developer tools\openvibe plugin inspector.lnk"   "$INSTDIR\openvibe-plugin-inspector.cmd"    "" "%SystemRoot%\system32\shell32.dll" 57
	CreateShortCut "$SMPROGRAMS\${OV_NAME}\Developer tools\openvibe skeleton generator.lnk" "$INSTDIR\openvibe-skeleton-generator.cmd"  "" "%SystemRoot%\system32\shell32.dll" 57
	CreateShortCut "$SMPROGRAMS\${OV_NAME}\openvibe designer.lnk"                           "$INSTDIR\openvibe-designer.cmd"            "" "%SystemRoot%\system32\shell32.dll" 137
	CreateShortCut "$SMPROGRAMS\${OV_NAME}\openvibe acquisition server.lnk"                 "$INSTDIR\openvibe-acquisition-server.cmd"  "" "%SystemRoot%\system32\shell32.dll" 18
	CreateShortCut "$SMPROGRAMS\${OV_NAME}\openvibe vr-demo spaceship.lnk"                  "$INSTDIR\openvibe-vr-demo-spaceship.cmd"   "" "%SystemRoot%\system32\shell32.dll" 200
	CreateShortCut "$SMPROGRAMS\${OV_NAME}\openvibe vr-demo handball.lnk"                   "$INSTDIR\openvibe-vr-demo-handball.cmd"    "" "%SystemRoot%\system32\shell32.dll" 200
	CreateShortCut "$SMPROGRAMS\${OV_NAME}\uninstall.lnk"                                   "$INSTDIR\Uninstall.exe"
jlindgre's avatar
jlindgre committed
269 270 271 272 273 274 275 276 277 278

	
	; AccessControl::EnableFileInheritance "$INSTDIR"
	; AccessControl::GrantOnFile "$INSTDIR" "(BU)" "GenericRead + GenericWrite + GenericExecute + Delete" ; to ensure windows XP back compatibility
	; AccessControl::GrantOnFile "$INSTDIR" "(S-1-5-32-545)" "GenericRead + GenericWrite + GenericExecute + Delete" ; (BU) user group (builtin users) does not exist on win7. this SID replaces it.
SectionEnd

Section "Uninstall"

	RMDir /r $INSTDIR
279
	RMDir /r "$SMPROGRAMS\${OV_NAME}"
jlindgre's avatar
jlindgre committed
280 281

SectionEnd
282 283 284 285 286 287 288

LangString DESC_Section1 ${LANG_ENGLISH} "The OpenViBE package: Designer, Acquisition Server, drivers, examples, etc."

!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
  !insertmacro MUI_DESCRIPTION_TEXT ${Section1} $(DESC_Section1)
!insertmacro MUI_FUNCTION_DESCRIPTION_END