-
Notifications
You must be signed in to change notification settings - Fork 142
/
Copy pathinstall3.nsi
249 lines (197 loc) · 8.47 KB
/
install3.nsi
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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
Name "Orange"
Icon OrangeInstall.ico
UninstallIcon OrangeInstall.ico
licensedata license.txt
licensetext "Acknowledgments and License Agreement"
OutFile ${OUTFILENAME}
!include "LogicLib.nsh"
!ifdef COMPLETE
!macro installmodule modulename installfile checkfile
${Unless} ${FileExists} ${checkfile}
File ${PARTY}\${installfile}
ExecWait $DESKTOP\${installfile}
Delete $DESKTOP\${installfile}
${EndUnless}
!macroend
!else
Var MissingModules
!macro installmodule modulename installfile checkfile
${Unless} ${FileExists} ${checkfile}
${AndUnless} modulename == ""
${If} $MissingModules == ""
StrCpy $MissingModules ${modulename}
${Else}
StrCpy $MissingModules "$MissingModules, ${modulename}"
${EndIf}
${EndUnless}
!macroend
!endif
!include "${PARTY}\names.inc"
AutoCloseWindow true
ShowInstDetails nevershow
Var PythonDir
Var AdminInstall
Var SITEDIR
Page license
Page instfiles
!define SHELLFOLDERS \
"Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders"
Section Uninstall
MessageBox MB_YESNO "Are you sure you want to remove Orange?$\r$\n$\r$\nThis won't remove any 3rd party software possibly installed with Orange, such as Python or Qt,$\r$\n$\r$\nbut make sure you have not left any of your files in Orange's directories!" /SD IDYES IDNO abort
RmDir /R "$INSTDIR"
${If} $AdminInstall = 0
SetShellVarContext all
${Else}
SetShellVarContext current
${Endif}
RmDir /R "$SMPROGRAMS\Orange"
ReadRegStr $0 HKCU "${SHELLFOLDERS}" AppData
StrCmp $0 "" 0 +2
ReadRegStr $0 HKLM "${SHELLFOLDERS}" "Common AppData"
StrCmp $0 "" +2 0
RmDir /R "$0\Orange"
ReadRegStr $PythonDir HKLM Software\Python\PythonCore\${NPYVER}\InstallPath ""
${If} $PythonDir != ""
DeleteRegKey HKLM "SOFTWARE\Python\PythonCore\${NPYVER}\PythonPath\Orange"
DeleteRegKey HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Orange"
${Else}
DeleteRegKey HKCU "SOFTWARE\Python\PythonCore\${NPYVER}\PythonPath\Orange"
DeleteRegKey HKCU "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Orange"
${Endif}
Delete "$DESKTOP\Orange Canvas.lnk"
DeleteRegKey HKEY_CLASSES_ROOT ".ows"
DeleteRegKey HKEY_CLASSES_ROOT "OrangeCanvas"
MessageBox MB_OK "Orange has been succesfully removed from your system.$\r$\nPython and other applications need to be removed separately.$\r$\n$\r$\nYou may now continue without rebooting your machine." /SD IDOK
abort:
SectionEnd
!macro GetPythonDir
${If} $AdminInstall == 0
ReadRegStr $PythonDir HKCU Software\Python\PythonCore\${NPYVER}\InstallPath ""
StrCmp $PythonDir "" 0 trim_backslash
ReadRegStr $PythonDir HKLM Software\Python\PythonCore\${NPYVER}\InstallPath ""
StrCmp $PythonDir "" return
MessageBox MB_OK "Please ask the administrator to install Orange$\r$\n(this is because Python was installed by him, too)."
Quit
${Else}
ReadRegStr $PythonDir HKLM Software\Python\PythonCore\${NPYVER}\InstallPath ""
StrCmp $PythonDir "" 0 trim_backslash
ReadRegStr $PythonDir HKCU Software\Python\PythonCore\${NPYVER}\InstallPath ""
StrCmp $PythonDir "" return
StrCpy $AdminInstall 0
${EndIf}
trim_backslash:
StrCpy $0 $PythonDir "" -1
${If} $0 == "\"
StrLen $0 $PythonDir
IntOp $0 $0 - 1
StrCpy $PythonDir $PythonDir $0 0
${EndIf}
return:
!macroend
!ifdef COMPLETE
Section ""
StrCmp $PythonDir "" 0 have_python
SetOutPath $DESKTOP
StrCpy $0 ""
askpython:
MessageBox MB_YESNOCANCEL "Orange installer will first launch installation of Python ${NPYVER}.$\r$\nWould you like it to install automatically?$\r$\n(Press No for Custom installation of Python, Cancel to cancel installation of Orange." /SD IDYES IDYES installsilently IDNO installpython
MessageBox MB_YESNO "Orange cannot run without Python.$\r$\nAbort the installation?" IDNO askpython
Quit
installsilently:
StrCpy $0 "/Qb-"
installpython:
File ${PARTY}\${NAME_PYTHON}
${If} $AdminInstall == 1
ExecWait 'msiexec.exe /i "$DESKTOP\${NAME_PYTHON}" ALLUSERS=1 $0' $0
${Else}
ExecWait 'msiexec.exe /i "$DESKTOP\${NAME_PYTHON}" $0' $0
${EndIf}
Delete "$DESKTOP\${NAME_PYTHON}"
!insertMacro GetPythonDir
StrCmp $PythonDir "" 0 have_python
MessageBox MB_OK "Python installation failed.$\r$\nOrange installation cannot continue."
Quit
have_python:
IfFileExists $PythonDir\lib\site-packages\PythonWin have_pythonwin
MessageBox MB_YESNO "Do you want to install PythonWin (recommended)?$\r$\n(Orange installation will continue afterwards.)" /SD IDYES IDNO have_pythonwin
IfFileExists "$SysDir\${NAME_MFC}" have_mfc
SetOutPath $SysDir
File ${PARTY}\${NAME_MFC}
have_mfc:
SetOutPath $DESKTOP
File ${PARTY}\${NAME_PYTHONWIN}
ExecWait "$DESKTOP\${NAME_PYTHONWIN}"
Delete "$DESKTOP\${NAME_PYTHONWIN}"
have_pythonwin:
MessageBox MB_OK "Installation will check for various needed libraries$\r$\nand launch their installers if needed."
SetOutPath $DESKTOP
!insertMacro modules
SectionEnd
!endif
Section ""
ReadRegStr $0 HKCU "${SHELLFOLDERS}" AppData
StrCmp $0 "" 0 +2
ReadRegStr $0 HKLM "${SHELLFOLDERS}" "Common AppData"
StrCmp $0 "" not_installed_before 0
IfFileExists "$0\Orange" 0 not_installed_before
ask_remove_old:
MessageBox MB_YESNOCANCEL "Another version of Orange has been found on the computer.$\r$\nDo you want to keep the existing settings for canvas and widgets?$\r$\n$\r$\nYou can usually safely answer 'Yes'; in case of problems, re-run this installation." /SD IDYES IDYES not_installed_before IDNO remove_old_settings
MessageBox MB_YESNO "Abort the installation?" IDNO ask_remove_old
Quit
remove_old_settings:
RmDir /R "$0\Orange"
not_installed_before:
StrCpy $SITEDIR "$PythonDir\lib\site-packages"
IfFileExists "$SITEDIR\orange\orngEnviron.py" 0 no_old_orange_conflict
Rename "$SITEDIR\orange" "$SITEDIR\orange-old-backup"
no_old_orange_conflict:
SetOutPath "$SITEDIR\Orange.egg-info"
File /r "${ORANGEDIR}.egg-info\*"
StrCpy $INSTDIR "$PythonDir\lib\site-packages\Orange"
SetOutPath "$INSTDIR"
File /r /x .hg ${ORANGEDIR}\*
CreateDirectory "$SMPROGRAMS\Orange"
#CreateShortCut "$SMPROGRAMS\Orange\Orange for Beginners.lnk" "$INSTDIR\doc\ofb\default.htm"
#CreateShortCut "$SMPROGRAMS\Orange\Orange Modules Reference.lnk" "$INSTDIR\doc\modules\default.htm"
#CreateShortCut "$SMPROGRAMS\Orange\Orange Reference Guide.lnk" "$INSTDIR\doc\reference\default.htm"
CreateShortCut "$SMPROGRAMS\Orange\Orange.lnk" "$INSTDIR"
CreateShortCut "$SMPROGRAMS\Orange\Uninstall Orange.lnk" "$INSTDIR\uninst.exe"
SetOutPath $INSTDIR\OrangeCanvas
CreateShortCut "$DESKTOP\Orange Canvas.lnk" "$PythonDir\pythonw.exe" "-m Orange.OrangeCanvas.main" $INSTDIR\OrangeCanvas\icons\orange.ico 0
CreateShortCut "$SMPROGRAMS\Orange\Orange Canvas.lnk" "$PythonDir\pythonw.exe" "-m Orange.OrangeCanvas.main" $INSTDIR\OrangeCanvas\icons\orange.ico 0
WriteRegStr SHELL_CONTEXT "SOFTWARE\Python\PythonCore\${NPYVER}\PythonPath\Orange" "" "$INSTDIR\orng"
WriteRegStr SHELL_CONTEXT "Software\Microsoft\Windows\CurrentVersion\Uninstall\Orange" "DisplayName" "Orange (remove only)"
WriteRegStr SHELL_CONTEXT "Software\Microsoft\Windows\CurrentVersion\Uninstall\Orange" "UninstallString" '"$INSTDIR\uninst.exe"'
WriteRegStr HKEY_CLASSES_ROOT ".ows" "" "OrangeCanvas"
WriteRegStr HKEY_CLASSES_ROOT "OrangeCanvas\DefaultIcon" "" "$INSTDIR\OrangeCanvas\icons\OrangeOWS.ico"
WriteRegStr HKEY_CLASSES_ROOT "OrangeCanvas\Shell\Open\Command\" "" '$PythonDir\python.exe -m Orange.OrangeCanvas.main "%1"'
WriteUninstaller "$INSTDIR\uninst.exe"
SectionEnd
Function .onInit
StrCpy $AdminInstall 1
UserInfo::GetAccountType
Pop $1
SetShellVarContext all
${If} $1 != "Admin"
SetShellVarContext current
StrCpy $AdminInstall 0
${Else}
SetShellVarContext all
StrCpy $AdminInstall 1
${EndIf}
!insertMacro GetPythonDir
!ifndef COMPLETE
StrCmp $PythonDir "" 0 have_python
MessageBox MB_OK "Please install Python first (www.python.org)$\r$\nor download Orange distribution that includes Python."
Quit
have_python:
!insertMacro modules
StrCmp $MissingModules "" continueinst
MessageBox MB_YESNO "Missing module(s): $MissingModules$\r$\n$\r$\nWithout these modules you can still scripts in Orange, but Orange Canvas will not work without them.$\r$\nYou can download and install them later or obtain the Orange installation that includes them.$\r$\n$\r$\nContinue with installation?" /SD IDYES IDYES continueinst
Quit
continueinst:
!endif
FunctionEnd
Function .onInstSuccess
MessageBox MB_OK "Orange has been successfully installed." /SD IDOK
FunctionEnd