comparison tools/makeinst-script.sh.in @ 5420:ec1f5c04ca0b

* tools/makeinst-script.sh.in: add multiuser options to nsis installer (Bug #58320)
author John Donoghue <john.donoghue@ieee.org>
date Thu, 21 May 2020 18:46:07 -0400
parents 4d6716dcec28
children 020bb2fcd3e2
comparison
equal deleted inserted replaced
5419:9b64cc7cb488 5420:ec1f5c04ca0b
31 else 31 else
32 OCTAVE_SUBDIR= 32 OCTAVE_SUBDIR=
33 fi 33 fi
34 34
35 if [ "@ENABLE_WINDOWS_64@" == "yes" ]; then 35 if [ "@ENABLE_WINDOWS_64@" == "yes" ]; then
36 OCTAVE_INSTDIR="\$PROGRAMFILES64\\GNU Octave\\Octave-\${OCTAVE_VERSION}" 36 USE_PROGRAMFILES64=
37 else 37 else
38 OCTAVE_INSTDIR="\$PROGRAMFILES\\GNU Octave\\Octave-\${OCTAVE_VERSION}" 38 USE_PROGRAMFILES64=';'
39 fi 39 fi
40 40
41 if [ -e $OCTAVE_SOURCE/$OCTAVE_SUBDIR/bin/libopenblas.dll ]; then 41 if [ -e $OCTAVE_SOURCE/$OCTAVE_SUBDIR/bin/libopenblas.dll ]; then
42 DEFAULT_BLAS="OpenBLAS" 42 DEFAULT_BLAS="OpenBLAS"
43 else 43 else
72 !define COPYRIGHT "Copyright © 2013-2020 John W. Eaton and others." 72 !define COPYRIGHT "Copyright © 2013-2020 John W. Eaton and others."
73 !define DESCRIPTION "GNU Octave is a high-level programming language, primarily intended for numerical computations." 73 !define DESCRIPTION "GNU Octave is a high-level programming language, primarily intended for numerical computations."
74 !define INSTALLER_FILES "$TOPDIR/installer-files" 74 !define INSTALLER_FILES "$TOPDIR/installer-files"
75 !define INSTALLER_NAME "$INSTALLER_NAME" 75 !define INSTALLER_NAME "$INSTALLER_NAME"
76 !define MAIN_APP_EXE "octave-firsttime.vbs" 76 !define MAIN_APP_EXE "octave-firsttime.vbs"
77 !define INSTALL_TYPE "SetShellVarContext current" 77 !define PRODUCT_ROOT_KEY "SHCTX"
78 !define PRODUCT_ROOT_KEY "HKLM"
79 !define PRODUCT_KEY "Software\\Octave-$VERSION" 78 !define PRODUCT_KEY "Software\\Octave-$VERSION"
79 !define PRODUCT_UNINST_KEY "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Octave-$VERSION"
80 !define PRODUCT_UNINST_ROOT_KEY "SHCTX"
80 81
81 ###################################################################### 82 ######################################################################
82 83
83 VIProductVersion "\${VERSION}" 84 VIProductVersion "\${VERSION}"
84 VIAddVersionKey "ProductName" "\${APP_NAME}" 85 VIAddVersionKey "ProductName" "\${APP_NAME}"
94 Caption "\${APP_NAME}" 95 Caption "\${APP_NAME}"
95 OutFile "\${INSTALLER_NAME}" 96 OutFile "\${INSTALLER_NAME}"
96 BrandingText "\${APP_NAME}" 97 BrandingText "\${APP_NAME}"
97 XPStyle on 98 XPStyle on
98 ManifestDPIAware true 99 ManifestDPIAware true
99 InstallDir "$OCTAVE_INSTDIR" 100 ManifestSupportedOS all
101 Unicode true
102 RequestExecutionLevel user
103 # multiuser will modify this
104 InstallDir "\$PROGRAMFILES\\GNU Octave\\Octave-\${OCTAVE_VERSION}"
100 Icon "\${INSTALLER_FILES}/octave-logo.ico" 105 Icon "\${INSTALLER_FILES}/octave-logo.ico"
101 106
102 ###################################################################### 107 ######################################################################
103 ; StrFunc usage 108 ; StrFunc usage
104 !include "StrFunc.nsh" 109 !include "StrFunc.nsh"
105 \${StrRep} 110 \${StrRep}
106 ###################################################################### 111 ######################################################################
112 ; Multi user
113 !define MULTIUSER_EXECUTIONLEVEL Highest
114 ;!define MULTIUSER_INSTALLMODE_DEFAULT_CURRENTUSER
115 !define MULTIUSER_INSTALLMODE_INSTDIR "GNU Octave\\Octave-\${OCTAVE_VERSION}"
116 ${USE_PROGRAMFILES64}!define MULTIUSER_USE_PROGRAMFILES64
117 !define MULTIUSER_MUI
118 !define MULTIUSER_INSTALLMODE_COMMANDLINE
119 Var MultiUser.UninstallKey
120 Var MultiUser.Local
121 !include MultiUser.nsh
122 ######################################################################
107 ; MUI settings 123 ; MUI settings
108 !include "MUI2.nsh" 124 !include "MUI2.nsh"
109 125
110 ; custom dialogs 126 ; custom dialogs
111 !include nsDialogs.nsh 127 !include nsDialogs.nsh
127 ; Theme 143 ; Theme
128 !define MUI_ICON "\${INSTALLER_FILES}/octave-logo.ico" 144 !define MUI_ICON "\${INSTALLER_FILES}/octave-logo.ico"
129 !define MUI_UNICON "$TOP_BUILD_DIR/usr/share/nsis/Contrib/Graphics/Icons/orange-uninstall.ico" 145 !define MUI_UNICON "$TOP_BUILD_DIR/usr/share/nsis/Contrib/Graphics/Icons/orange-uninstall.ico"
130 !define MUI_HEADERIMAGE_BITMAP "\${INSTALLER_FILES}/octave-hdr.bmp" 146 !define MUI_HEADERIMAGE_BITMAP "\${INSTALLER_FILES}/octave-hdr.bmp"
131 !define MUI_WELCOMEFINISHPAGE_BITMAP "\${INSTALLER_FILES}/octave.bmp" 147 !define MUI_WELCOMEFINISHPAGE_BITMAP "\${INSTALLER_FILES}/octave.bmp"
132 148 !define MUI_UNWELCOMEFINISHPAGE_BITMAP "\${INSTALLER_FILES}/octave.bmp"
149
150 ; Pages
133 !insertmacro MUI_PAGE_WELCOME 151 !insertmacro MUI_PAGE_WELCOME
134 152
135 !define MUI_LICENSEPAGE_TEXT_BOTTOM "The source code for Octave is freely redistributable under the terms of the GNU General Public License (GPL) as published by the Free Software Foundation." 153 !define MUI_LICENSEPAGE_TEXT_BOTTOM "The source code for Octave is freely redistributable under the terms of the GNU General Public License (GPL) as published by the Free Software Foundation."
136 !define MUI_LICENSEPAGE_BUTTON "Next >" 154 !define MUI_LICENSEPAGE_BUTTON "Next >"
137 !insertmacro MUI_PAGE_LICENSE "\${INSTALLER_FILES}/gpl-3.0.txt" 155 !insertmacro MUI_PAGE_LICENSE "\${INSTALLER_FILES}/gpl-3.0.txt"
156
157 !insertmacro MULTIUSER_PAGE_INSTALLMODE
138 158
139 Page custom octaveOptionsPage octaveOptionsLeave 159 Page custom octaveOptionsPage octaveOptionsLeave
140 160
141 !define MUI_PAGE_CUSTOMFUNCTION_LEAVE CheckPrevInstallAndDest 161 !define MUI_PAGE_CUSTOMFUNCTION_LEAVE CheckPrevInstallAndDest
142 !insertmacro MUI_PAGE_DIRECTORY 162 !insertmacro MUI_PAGE_DIRECTORY
146 !define MUI_FINISHPAGE_RUN "\$WINDIR\\explorer.exe" 166 !define MUI_FINISHPAGE_RUN "\$WINDIR\\explorer.exe"
147 !define MUI_FINISHPAGE_RUN_PARAMETERS "\$INSTDIR\\\${MAIN_APP_EXE}" 167 !define MUI_FINISHPAGE_RUN_PARAMETERS "\$INSTDIR\\\${MAIN_APP_EXE}"
148 !define MUI_FINISHPAGE_SHOWREADME "\$INSTDIR\\README.html" 168 !define MUI_FINISHPAGE_SHOWREADME "\$INSTDIR\\README.html"
149 !insertmacro MUI_PAGE_FINISH 169 !insertmacro MUI_PAGE_FINISH
150 170
171 ; uninstaller
151 !insertmacro MUI_UNPAGE_CONFIRM 172 !insertmacro MUI_UNPAGE_CONFIRM
152 173
153 !insertmacro MUI_UNPAGE_INSTFILES 174 !insertmacro MUI_UNPAGE_INSTFILES
154 175
155 !insertmacro MUI_UNPAGE_FINISH 176 !insertmacro MUI_UNPAGE_FINISH
156 177
157 !insertmacro MUI_LANGUAGE "English" 178 !insertmacro MUI_LANGUAGE "English"
158 179
159 ###################################################################### 180 ######################################################################
160 181
161 RequestExecutionLevel admin 182 !macro DequoteString_ un
183 Function \${un}DequoteString_
184 ; just removed any '"' found
185 Exch \$R0 # r0 is now the string
186 Push \$R1
187 Push \$R2
188 Push \$R3
189
190 Strcpy \$R3 "" # dequoted value
191 StrCmp \$R0 "" \${un}dequote_end
192
193 StrCpy \$R1 0 # r1 = counter
194 \${un}dequote_loop:
195
196 StrCpy \$R2 \$R0 1 \$R1 # R2 = character in string to check
197 StrCmp \$R2 "" \${un}dequote_end # end of string
198 StrCmp \$R2 '"' \${un}dequote_next
199 # no quote
200 StrCpy \$R3 \$R3\$R2
201 \${un}dequote_next:
202 IntOp \$R1 \$R1 + 1
203 GoTo \${un}dequote_loop
204
205 \${un}dequote_end:
206 StrCpy \$R0 \$R3
207
208 Pop \$R3
209 Pop \$R2
210 Pop \$R1
211 Exch \$R0
212 FunctionEnd
213 !macroend
214
215 !insertmacro DequoteString_ "un."
216 !insertmacro DequoteString_ ""
217
218 !macro DequoteString un InStr OutVar
219 Push '\${InStr}'
220 Call \${un}DequoteString_
221 Pop '\${OutVar}'
222 !macroend
223 !define DequoteString '!insertmacro DequoteString ""'
224 !define un.DequoteString '!insertmacro DequoteString "un."'
162 225
163 ###################################################################### 226 ######################################################################
164
165 ; custom options page functions 227 ; custom options page functions
166 228
167 Var InstallAllUsers
168 Var InstallAllUsersCtrl
169 Var InstallShortcuts 229 Var InstallShortcuts
170 Var InstallShortcutsCtrl 230 Var InstallShortcutsCtrl
171 Var RegisterOctaveFileType 231 Var RegisterOctaveFileType
172 Var RegisterOctaveFileTypeCtrl 232 Var RegisterOctaveFileTypeCtrl
173 Var InstallBlasLibCtrl 233 Var InstallBlasLibCtrl
174 Var InstallBlasLib 234 Var InstallBlasLib
175 235
176 Function octaveOptionsPage 236 Function octaveOptionsPage
237
238 # will append (Local) to reg key
239 \${If} \$MultiUser.InstallMode == "CurrentUser"
240 StrCpy \$MultiUser.UninstallKey "\${PRODUCT_UNINST_KEY} (Local)"
241 StrCpy \$MultiUser.Local " (Local)"
242 \${Else}
243 StrCpy \$MultiUser.UninstallKey "\${PRODUCT_UNINST_KEY}"
244 StrCpy \$MultiUser.Local ""
245 \${EndIf}
246
247 Call CheckCurrVersion
248
177 Push \$0 249 Push \$0
178 nsDialogs::Create 1018 250 nsDialogs::Create 1018
179 Pop \$0 251 Pop \$0
180 252
181 \${If} \$0 == error 253 \${If} \$0 == error
182 Abort 254 Abort
183 \${EndIf} 255 \${EndIf}
184 256
185 \${NSD_CreateCheckBox} 0 0 100% 12u "Install for all users" 257 \${NSD_CreateCheckBox} 0 0 100% 12u "Create desktop shortcuts"
186 Pop \$InstallAllUsersCtrl
187 \${NSD_SetState} \$InstallAllUsersCtrl \$InstallAllUsers
188
189 \${NSD_CreateCheckBox} 0 20u 100% 12u "Create desktop shortcuts"
190 Pop \$InstallShortcutsCtrl 258 Pop \$InstallShortcutsCtrl
191 \${NSD_SetState} \$InstallShortcutsCtrl \$InstallShortcuts 259 \${NSD_SetState} \$InstallShortcutsCtrl \$InstallShortcuts
192 260
193 \${NSD_CreateCheckBox} 0 40u 100% 12u "Register .m file type with Octave" 261 \${NSD_CreateCheckBox} 0 20u 100% 12u "Register .m file type with Octave"
194 Pop \$RegisterOctaveFileTypeCtrl 262 Pop \$RegisterOctaveFileTypeCtrl
195 \${NSD_SetState} \$RegisterOctaveFileTypeCtrl \$RegisterOctaveFileType 263 \${NSD_SetState} \$RegisterOctaveFileTypeCtrl \$RegisterOctaveFileType
196 264
197 \${NSD_CreateLabel} 0 70u 110u 12u "BLAS library implementation:" 265 \${NSD_CreateLabel} 0 50u 110u 12u "BLAS library implementation:"
198 Pop \$0 266 Pop \$0
199 267
200 \${NSD_CreateDropList} 120u 70u 100u 80u "" 268 \${NSD_CreateDropList} 100u 70u 100u 80u ""
201 Pop \$InstallBlasLibCtrl 269 Pop \$InstallBlasLibCtrl
202 EOF 270 EOF
203 # add option to install libopenblas if we have the dll present 271 # add option to install libopenblas if we have the dll present
204 if [ -e $OCTAVE_SOURCE/$OCTAVE_SUBDIR/bin/libopenblas.dll ]; then 272 if [ -e $OCTAVE_SOURCE/$OCTAVE_SUBDIR/bin/libopenblas.dll ]; then
205 cat >> $OUTFILE << EOF 273 cat >> $OUTFILE << EOF
217 nsDialogs::Show 285 nsDialogs::Show
218 Pop \$0 286 Pop \$0
219 FunctionEnd 287 FunctionEnd
220 288
221 Function octaveOptionsLeave 289 Function octaveOptionsLeave
222 \${NSD_GetState} \$InstallAllUsersCtrl \$InstallAllUsers
223 \${NSD_GetState} \$InstallShortcutsCtrl \$InstallShortcuts 290 \${NSD_GetState} \$InstallShortcutsCtrl \$InstallShortcuts
224 \${NSD_GetState} \$RegisterOctaveFileTypeCtrl \$RegisterOctaveFileType 291 \${NSD_GetState} \$RegisterOctaveFileTypeCtrl \$RegisterOctaveFileType
225 \${DropList_GetCurSel} \$InstallBlasLibCtrl \$InstallBlasLib 292 \${DropList_GetCurSel} \$InstallBlasLibCtrl \$InstallBlasLib
226 FunctionEnd 293 FunctionEnd
227 294
228 ###################################################################### 295 ######################################################################
296 Function un.onInit
297 !insertmacro MULTIUSER_UNINIT
298
299 # find installer info
300 Push \$R0
301 uninst_check_installs:
302 Call un.FindThisUninstallReg
303 Pop \$R0
304
305 # if 0 it couldnt find us
306 StrCmp \$R0 0 0 uninst_check_local
307
308 \${if} \$MultiUser.Privileges == "Admin"
309 # if admin, maybe was forced to admin from Add Remove Apps
310 MessageBox MB_ICONEXCLAMATION|MB_OK "Could not find uninstallation information in registry.\$\nTry running the unistaller from the start menu or from the installation folder \$\"\$INSTDIR\$\"." /SD IDOK
311 \${Else}
312 MessageBox MB_ICONEXCLAMATION|MB_OK "Could not find uninstallation information in registry for \$(^Name) installed in \$\"\$INSTDIR\$\".\$\nCan not uninstall!" /SD IDOK
313 \${EndIf}
314 Abort
315
316 uninst_check_local:
317 # if 1 was local only
318 StrCmp \$R0 1 0 uninst_set_admin
319
320 Call un.MultiUser.InstallMode.CurrentUser
321
322 GoTo uninst_cont_un
323
324 uninst_set_admin:
325 # if 2, was a allusers install
326 Call un.MultiUser.InstallMode.AllUsers
327
328 uninst_cont_un:
329
330 \${If} \$MultiUser.InstallMode == "CurrentUser"
331 StrCpy \$MultiUser.UninstallKey "\${PRODUCT_UNINST_KEY} (Local)"
332 StrCpy \$MultiUser.Local " (Local)"
333 \${Else}
334 StrCpy \$MultiUser.UninstallKey "\${PRODUCT_UNINST_KEY}"
335 StrCpy \$MultiUser.Local ""
336 \${EndIf}
337
338 Pop \$R0
339 FunctionEnd
229 340
230 Function .onInit 341 Function .onInit
342 !insertmacro MULTIUSER_INIT
343
344 # will append (Local) to reg key
345 \${If} \$MultiUser.InstallMode == "CurrentUser"
346 StrCpy \$MultiUser.UninstallKey "\${PRODUCT_UNINST_KEY} (Local)"
347 StrCpy \$MultiUser.Local " (Local)"
348 \${Else}
349 StrCpy \$MultiUser.UninstallKey "\${PRODUCT_UNINST_KEY}"
350 StrCpy \$MultiUser.Local ""
351 \${EndIf}
352
231 ; set default options 353 ; set default options
232 StrCpy \$InstallAllUsers \${BST_CHECKED}
233 StrCpy \$InstallShortcuts \${BST_CHECKED} 354 StrCpy \$InstallShortcuts \${BST_CHECKED}
234 StrCpy \$RegisterOctaveFileType \${BST_CHECKED} 355 StrCpy \$RegisterOctaveFileType \${BST_CHECKED}
235 StrCpy \$InstallBlasLib 0 356 StrCpy \$InstallBlasLib 0
236 357
237 ; process cmand line options 358 ; process command line options
238 \${GetParameters} \$R0 359 \${GetParameters} \$R0
239 ClearErrors 360 ClearErrors
240 \${GetOptions} "\$R0" "/REGISTER_FILE_TYPES=" \$0 361 \${GetOptions} "\$R0" "/REGISTER_FILE_TYPES=" \$0
241 IfErrors no_register_opt 362 IfErrors no_register_opt
242 \${If} \$0 == 0 363 \${If} \$0 == 0
249 \${If} \$0 == 0 370 \${If} \$0 == 0
250 StrCpy \$InstallShortcuts \${BST_UNCHECKED} 371 StrCpy \$InstallShortcuts \${BST_UNCHECKED}
251 \${EndIf} 372 \${EndIf}
252 no_shortcuts_opt: 373 no_shortcuts_opt:
253 ClearErrors 374 ClearErrors
254 \${GetOptions} "\$R0" "/INSTALL_ALL_USERS=" \$0
255 IfErrors no_all_users_opt
256 \${If} \$0 == 0
257 StrCpy \$InstallAllUsers \${BST_UNCHECKED}
258 \${EndIf}
259 no_all_users_opt:
260 ClearErrors
261 375
262 Call CheckWinVer 376 Call CheckWinVer
263 Call CheckCurrVersion
264 \${If} @ENABLE_JAVA@ == yes 377 \${If} @ENABLE_JAVA@ == yes
265 Call CheckJRE 378 Call CheckJRE
266 \${EndIf} 379 \${EndIf}
267 InitPluginsDir 380 InitPluginsDir
268 FunctionEnd 381 FunctionEnd
269 382
270 ; file section 383 ; file section
271 Section "MainFiles" 384 Section "MainFiles"
272 ; set context based on whether installing for user or all
273 \${If} \$InstallAllUsers == \${BST_CHECKED}
274 SetShellVarContext all
275 \${Else}
276 SetShellVarContext current
277 \${Endif}
278 385
279 ; include the README 386 ; include the README
280 SetOutPath "\$INSTDIR" 387 SetOutPath "\$INSTDIR"
281 File "$OCTAVE_SOURCE/README.html" 388 File "$OCTAVE_SOURCE/README.html"
282 389
319 Pop \$0 426 Pop \$0
320 427
321 ; run post-install script 428 ; run post-install script
322 GetFullPathName /SHORT \$1 \$INSTDIR 429 GetFullPathName /SHORT \$1 \$INSTDIR
323 DetailPrint "Running post install script (May take a while) ..." 430 DetailPrint "Running post install script (May take a while) ..."
324 ;ExecWait "\$1\\post-install.bat"
325 ; run in hidden console window 431 ; run in hidden console window
326 nsExec::Exec /TIMEOUT=60000 '"\$1\\post-install.bat"' 432 nsExec::Exec /TIMEOUT=90000 '"\$1\\post-install.bat"'
327 Pop \$0 433 Pop \$0
328 SectionEnd 434 SectionEnd
329 435
330 Section make_uninstaller 436 Section make_uninstaller
331 ; Write the uninstall keys for Windows 437 ; Write the uninstall keys for Windows
332 SetOutPath "\$INSTDIR" 438 SetOutPath "\$INSTDIR"
333 WriteRegStr HKLM "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Octave-$VERSION" "DisplayName" "Octave $VERSION" 439 WriteRegStr \${PRODUCT_UNINST_ROOT_KEY} "\$MultiUser.UninstallKey" "DisplayName" "Octave $VERSION\$MultiUser.Local"
334 WriteRegStr HKLM "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Octave-$VERSION" "DisplayVersion" "$VERSION" 440 WriteRegStr \${PRODUCT_UNINST_ROOT_KEY} "\$MultiUser.UninstallKey" "DisplayVersion" "$VERSION"
335 WriteRegStr HKLM "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Octave-$VERSION" "DisplayIcon" "\$INSTDIR\\$ICON" 441 WriteRegStr \${PRODUCT_UNINST_ROOT_KEY} "\$MultiUser.UninstallKey" "DisplayIcon" "\$INSTDIR\\$ICON"
336 WriteRegStr HKLM "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Octave-$VERSION" "UninstallString" "\$INSTDIR\\uninstall.exe" 442 WriteRegStr \${PRODUCT_UNINST_ROOT_KEY} "\$MultiUser.UninstallKey" "UninstallString" "\$\"\$INSTDIR\\uninstall.exe\$\" /\$MultiUser.InstallMode"
337 WriteRegDWORD HKLM "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Octave-$VERSION" "NoModify" 1 443 WriteRegStr \${PRODUCT_UNINST_ROOT_KEY} "\$MultiUser.UninstallKey" "QuietUninstallString" "\$\"\$INSTDIR\\uninstall.exe\$\" /\$MultiUser.InstallMode /S"
338 WriteRegDWORD HKLM "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Octave-$VERSION" "NoRepair" 1 444 WriteRegDWORD \${PRODUCT_UNINST_ROOT_KEY} "\$MultiUser.UninstallKey" "NoModify" 1
339 WriteRegStr HKLM "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Octave-$VERSION" "Publisher" "\${APP_NAME}" 445 WriteRegDWORD \${PRODUCT_UNINST_ROOT_KEY} "\$MultiUser.UninstallKey" "NoRepair" 1
340 WriteRegDWORD HKLM "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Octave-$VERSION" "EstimatedSize" $SIZE 446 WriteRegStr \${PRODUCT_UNINST_ROOT_KEY} "\$MultiUser.UninstallKey" "Publisher" "\${APP_NAME}"
341 \${If} \$InstallAllUsers == \${BST_CHECKED} 447 WriteRegDWORD \${PRODUCT_UNINST_ROOT_KEY} "\$MultiUser.UninstallKey" "EstimatedSize" $SIZE
342 WriteRegDWORD HKLM "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Octave-$VERSION" "AllUsers" 1 448 WriteRegStr \${PRODUCT_UNINST_ROOT_KEY} "\$MultiUser.UninstallKey" "InstallMode" "\$MultiUser.InstallMode"
343 \${EndIf} 449 WriteRegStr \${PRODUCT_UNINST_ROOT_KEY} "\$MultiUser.UninstallKey" "InstallLocation" "\$INSTDIR"
344 WriteUninstaller "uninstall.exe" 450 WriteUninstaller "uninstall.exe"
345 SectionEnd 451 SectionEnd
346 452
347 ; start menu (currently hardcoded) 453 ; start menu (currently hardcoded)
348 Section "Shortcuts" 454 Section "Shortcuts"
349 455
350 CreateDirectory "\$SMPROGRAMS\\GNU Octave $VERSION" 456 # will append (Local) to menus in local mode
351 CreateShortCut "\$SMPROGRAMS\\GNU Octave $VERSION\\Uninstall.lnk" "\$INSTDIR\\uninstall.exe" "" "\$INSTDIR\\uninstall.exe" 0 457 CreateDirectory "\$SMPROGRAMS\\GNU Octave $VERSION\$MultiUser.Local"
458 CreateShortCut "\$SMPROGRAMS\\GNU Octave $VERSION\$MultiUser.Local\\Uninstall.lnk" "\$INSTDIR\\uninstall.exe" "" "\$INSTDIR\\uninstall.exe" 0
352 SetOutPath "%USERPROFILE%" 459 SetOutPath "%USERPROFILE%"
353 CreateShortCut "\$SMPROGRAMS\\GNU Octave $VERSION\\Octave-$VERSION (CLI).lnk" "%SYSTEMROOT%\\system32\\wscript.exe" "\$\\"\$INSTDIR\\octave.vbs\$\\" --no-gui" "\$INSTDIR\\$ICON" 0 SW_SHOWMINIMIZED 460 CreateShortCut "\$SMPROGRAMS\\GNU Octave $VERSION\$MultiUser.Local\\Octave-$VERSION\$MultiUser.Local (CLI).lnk" "%SYSTEMROOT%\\system32\\wscript.exe" "\$\\"\$INSTDIR\\octave.vbs\$\\" --no-gui" "\$INSTDIR\\$ICON" 0 SW_SHOWMINIMIZED
354 CreateShortCut "\$SMPROGRAMS\\GNU Octave $VERSION\\Octave-$VERSION (GUI).lnk" "%SYSTEMROOT%\\system32\\wscript.exe" "\$\\"\$INSTDIR\\octave.vbs\$\\" --gui" "\$INSTDIR\\$ICON" 0 SW_SHOWMINIMIZED 461 CreateShortCut "\$SMPROGRAMS\\GNU Octave $VERSION\$MultiUser.Local\\Octave-$VERSION\$MultiUser.Local (GUI).lnk" "%SYSTEMROOT%\\system32\\wscript.exe" "\$\\"\$INSTDIR\\octave.vbs\$\\" --gui" "\$INSTDIR\\$ICON" 0 SW_SHOWMINIMIZED
355 SetOutPath "\$INSTDIR" 462 SetOutPath "\$INSTDIR"
356 463
357 ; fix the shortcuts for appid 464 ; fix the shortcuts for appid
358 ; run in hidden console window 465 ; run in hidden console window
359 nsExec::Exec /TIMEOUT=30000 '"\$INSTDIR\\$OCTAVE_SUBDIR\\bin\\win7appid.exe" "\$SMPROGRAMS\\GNU Octave $VERSION\\Octave-$VERSION (GUI).lnk" "gnu.octave.$VERSION"' 466 nsExec::Exec /TIMEOUT=30000 '"\$INSTDIR\\$OCTAVE_SUBDIR\\bin\\win7appid.exe" "\$SMPROGRAMS\\GNU Octave $VERSION\$MultiUser.Local\\Octave-$VERSION\$MultiUser.Local (GUI).lnk" "gnu.octave.$VERSION"'
360 Pop \$0 467 Pop \$0
361 EOF 468 EOF
362 # shortcut for cmd win 469 # shortcut for cmd win
363 if [ -f $OCTAVE_SOURCE/cmdshell.bat ]; then 470 if [ -f $OCTAVE_SOURCE/cmdshell.bat ]; then
364 echo "CreateShortCut '\$SMPROGRAMS\\GNU Octave $VERSION\\Bash Shell.lnk' '\$INSTDIR\\cmdshell.bat' '' '' 0" >> $OUTFILE 471 echo "CreateShortCut '\$SMPROGRAMS\\GNU Octave $VERSION\$MultiUser.Local\\Bash Shell.lnk' '\$INSTDIR\\cmdshell.bat' '' '' 0" >> $OUTFILE
365 fi 472 fi
366 # if we have documentation files, create shortcuts 473 # if we have documentation files, create shortcuts
367 if [ -d $OCTAVE_SOURCE/$OCTAVE_SUBDIR/share/doc/octave ]; then 474 if [ -d $OCTAVE_SOURCE/$OCTAVE_SUBDIR/share/doc/octave ]; then
368 cat >> $OUTFILE << EOF 475 cat >> $OUTFILE << EOF
369 CreateDirectory "\$SMPROGRAMS\\GNU Octave $VERSION\\Documentation" 476 CreateDirectory "\$SMPROGRAMS\\GNU Octave $VERSION\$MultiUser.Local\\Documentation"
370 CreateShortCut "\$SMPROGRAMS\\GNU Octave $VERSION\\Documentation\\Octave C++ Classes (PDF).lnk" "\$INSTDIR\\$OCTAVE_SUBDIR\\share\\doc\\octave\\liboctave.pdf" "" "" 0 477 CreateShortCut "\$SMPROGRAMS\\GNU Octave $VERSION\$MultiUser.Local\\Documentation\\Octave C++ Classes (PDF).lnk" "\$INSTDIR\\$OCTAVE_SUBDIR\\share\\doc\\octave\\liboctave.pdf" "" "" 0
371 CreateShortCut "\$SMPROGRAMS\\GNU Octave $VERSION\\Documentation\\Octave C++ Classes (HTML).lnk" "\$INSTDIR\\$OCTAVE_SUBDIR\\share\\doc\\octave\\liboctave.html\\index.html" "" "" 0 478 CreateShortCut "\$SMPROGRAMS\\GNU Octave $VERSION\$MultiUser.Local\\Documentation\\Octave C++ Classes (HTML).lnk" "\$INSTDIR\\$OCTAVE_SUBDIR\\share\\doc\\octave\\liboctave.html\\index.html" "" "" 0
372 CreateShortCut "\$SMPROGRAMS\\GNU Octave $VERSION\\Documentation\\Octave (PDF).lnk" "\$INSTDIR\\$OCTAVE_SUBDIR\\share\\doc\\octave\\octave.pdf" "" "" 0 479 CreateShortCut "\$SMPROGRAMS\\GNU Octave $VERSION\$MultiUser.Local\\Documentation\\Octave (PDF).lnk" "\$INSTDIR\\$OCTAVE_SUBDIR\\share\\doc\\octave\\octave.pdf" "" "" 0
373 CreateShortCut "\$SMPROGRAMS\\GNU Octave $VERSION\\Documentation\\Octave (HTML).lnk" "\$INSTDIR\\$OCTAVE_SUBDIR\\share\\doc\\octave\\octave.html\\index.html" "" "" 0 480 CreateShortCut "\$SMPROGRAMS\\GNU Octave $VERSION\$MultiUser.Local\\Documentation\\Octave (HTML).lnk" "\$INSTDIR\\$OCTAVE_SUBDIR\\share\\doc\\octave\\octave.html\\index.html" "" "" 0
374 EOF 481 EOF
375 fi 482 fi
376 483
377 cat >> $OUTFILE << EOF 484 cat >> $OUTFILE << EOF
378 485
387 Pop \$R1 ; Ver 494 Pop \$R1 ; Ver
388 495
389 ; if no version found - need set INST DIR and VER will use 496 ; if no version found - need set INST DIR and VER will use
390 StrCmp \$R1 "" set_ver_str 497 StrCmp \$R1 "" set_ver_str
391 498
499 ClearErrors
392 ; valid install found - get info from registry 500 ; valid install found - get info from registry
393 ReadRegStr \$R0 HKLM "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Octave-\$R1" "UninstallString" 501 ReadRegStr \$R0 SHCTX "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Octave-\$R1" InstallLocation"
502 IfErrors sc_no_install_path
503 StrCmp \$R0 "" sc_no_install_path sc_install_path
504 sc_no_install_path:
505 # make dir from installer path
506 ReadRegStr \$R0 SHCTX "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Octave-\$R1" "UninstallString"
394 \${GetParent} \$R0 \$R0 507 \${GetParent} \$R0 \$R0
395 ReadRegStr \$R2 HKLM "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Octave-\$R1" "DisplayIcon" 508
509 sc_install_path:
510
511 # remove any '"' in our path
512 \${DequoteString} \$R0 \$R0
513
514 ReadRegStr \$R2 SHCTX "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Octave-\$R1" "DisplayIcon"
396 GoTo have_ver_str 515 GoTo have_ver_str
397 set_ver_str: 516 set_ver_str:
398 StrCpy \$R1 "$VERSION" 517 StrCpy \$R1 "$VERSION"
399 StrCpy \$R0 "\$INSTDIR" 518 StrCpy \$R0 "\$INSTDIR"
400 StrCpy \$R2 "\$INSTDIR\\$ICON" 519 StrCpy \$R2 "\$INSTDIR\\$ICON"
401 520
402 have_ver_str: 521 have_ver_str:
403 SetOutPath "%USERPROFILE%" 522 SetOutPath "%USERPROFILE%"
404 CreateShortCut "\$desktop\\GNU Octave (CLI).lnk" "%SYSTEMROOT%\\system32\\wscript.exe" "\$\\"\$R0\\octave.vbs\$\\" --no-gui" "\$R2" 0 SW_SHOWMINIMIZED 523 CreateShortCut "\$desktop\\GNU Octave\$MultiUser.Local (CLI).lnk" "%SYSTEMROOT%\\system32\\wscript.exe" "\$\\"\$R0\\octave.vbs\$\\" --no-gui" "\$R2" 0 SW_SHOWMINIMIZED
405 CreateShortCut "\$desktop\\GNU Octave (GUI).lnk" "%SYSTEMROOT%\\system32\\wscript.exe" "\$\\"\$R0\\octave.vbs\$\\" --gui" "\$R2" 0 SW_SHOWMINIMIZED 524 CreateShortCut "\$desktop\\GNU Octave\$MultiUser.Local (GUI).lnk" "%SYSTEMROOT%\\system32\\wscript.exe" "\$\\"\$R0\\octave.vbs\$\\" --gui" "\$R2" 0 SW_SHOWMINIMIZED
406 525
407 nsExec::Exec /TIMEOUT=30000 '"\$INSTDIR\\$OCTAVE_SUBDIR\\bin\\win7appid.exe" "\$desktop\\GNU Octave (GUI).lnk" "gnu.octave.\$R1"' 526 nsExec::Exec /TIMEOUT=30000 '"\$INSTDIR\\$OCTAVE_SUBDIR\\bin\\win7appid.exe" "\$desktop\\GNU Octave\$MultiUser.Local (GUI).lnk" "gnu.octave.\$R1"'
408 Pop \$0 527 Pop \$0
409 528
410 Pop \$R2 529 Pop \$R2
411 Pop \$R1 530 Pop \$R1
412 Pop \$R0 531 Pop \$R0
422 \${EndIf} 541 \${EndIf}
423 542
424 SectionEnd 543 SectionEnd
425 544
426 Section "FileTypeRego" 545 Section "FileTypeRego"
427 ; Octave document 546
428 WriteRegStr HKCR "Octave.Document.$VERSION" "" "GNU Octave Script" 547 WriteRegStr SHCTX "Software\\Classes\\Octave.Document.$VERSION" "FriendlyAppName" "GNU Octave $VERSION"
429 WriteRegStr HKCR "Octave.Document.$VERSION\\DefaultIcon" "" "\$INSTDIR\\$ICON" 548 WriteRegStr SHCTX "Software\\Classes\\Octave.Document.$VERSION\\DefaultIcon" "" "\$INSTDIR\\$ICON"
430 ; document actions 549 WriteRegStr SHCTX "Software\\Classes\\Octave.Document.$VERSION\\shell\\open\\command" "" "wscript \$\\"\$INSTDIR\\octave.vbs\$\\" --gui --persist --eval \$\\"edit '%1'\$\\""
431 WriteRegStr HKCR "Octave.Document.$VERSION\\shell\\open\\command" "" "wscript \$\\"\$INSTDIR\\octave.vbs\$\\" --gui --persist --eval \$\\"edit '%1'\$\\""
432 550
433 \${If} \$RegisterOctaveFileType == \${BST_CHECKED} 551 \${If} \$RegisterOctaveFileType == \${BST_CHECKED}
434 ReadRegStr \$0 HKCR ".m" "" 552
435 StrCmp "\$0" "" no_back_type 553 ReadRegStr \$0 SHCTX "Software\\Classes\\.m" ""
436 WriteRegStr HKCR ".m" "backup_val" "\$0" 554 StrCmp "\$0" "" ctx_no_back_type
437 no_back_type: 555 WriteRegStr SHCTX "Software\\Classes\\.m" "backup_val" "\$0"
438 WriteRegStr HKCR ".m" "" "Octave.Document.$VERSION" 556 ctx_no_back_type:
439 WriteRegDWORD HKLM "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Octave-$VERSION" "RegisteredFileType" 1 557 WriteRegStr SHCTX "Software\\Classes\\.m" "" "Octave.Document.$VERSION"
558
559 WriteRegDWORD \${PRODUCT_UNINST_ROOT_KEY} "\$MultiUser.UninstallKey" "RegisteredFileType" 1
440 \${EndIf} 560 \${EndIf}
561
441 SectionEnd 562 SectionEnd
442 563
443 Section "Uninstall" 564 Section "Uninstall"
444 565
445 ReadRegDWORD \$0 HKLM "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Octave-$VERSION" "AllUsers" 566 ReadRegDWORD \$0 \${PRODUCT_UNINST_ROOT_KEY} "\$MultiUser.UninstallKey" "RegisteredFileType"
446 IfErrors not_all_users
447
448 SetShellVarContext all
449
450 not_all_users:
451 ReadRegDWORD \$0 HKLM "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Octave-$VERSION" "RegisteredFileType"
452 IfErrors not_registered_file 567 IfErrors not_registered_file
453 568
454 ; only try remove if is set to our version of octave 569 ; only try remove if is set to our version of octave
455 ReadRegStr \$0 HKCR ".m" "" 570 ReadRegStr \$0 SHCTX "Software\\Classes\\.m" ""
456 StrCmp \$0 "Octave.Document.$VERSION" 0 not_registered_file 571 StrCmp \$0 "Octave.Document.$VERSION" 0 not_registered_file
457 572
458 ReadRegStr \$0 HKCR ".m" "backup_val" 573 ReadRegStr \$0 SHCTX "Software\\Classes\\.m" "backup_val"
459 IfErrors not_backup_file 574 IfErrors not_backup_file
460 575
461 # retore backup 576 # retore backup
462 WriteRegStr HKCR ".m" "" "\$0" 577 WriteRegStr SHCTX "Software\\Classes\\.m" "" "\$0"
463 578
464 DeleteRegValue HKCR ".m" "backup_val" 579 DeleteRegValue SHCTX "Software\\Classes\\.m" "backup_val"
465 580
466 ; dont delete .m if just restored backup 581 ; dont delete .m if just restored backup
467 Goto not_registered_file 582 Goto not_registered_file
468 not_backup_file: 583 not_backup_file:
469 DeleteRegKey HKCR ".m" 584 DeleteRegValue SHCTX "Software\\Classes" ".m"
470 585
471 not_registered_file: 586 not_registered_file:
472 ; delete file type 587
473 DeleteRegKey HKCR "Octave.Document.$VERSION" 588 DeleteRegKey SHCTX "Software\\Classes\\Octave.Document.$VERSION"
474 589 DeleteRegKey \${PRODUCT_UNINST_ROOT_KEY} "\$MultiUser.UninstallKey"
475 DeleteRegKey HKLM "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Octave-$VERSION"
476 DeleteRegKey HKLM "Software\\Octave-$VERSION"
477 590
478 ; Remove shortcuts 591 ; Remove shortcuts
479 Delete "\$SMPROGRAMS\\GNU Octave $VERSION\\Documentation\\*.*" 592 Delete "\$SMPROGRAMS\\GNU Octave $VERSION\$MultiUser.Local\\Documentation\\*.*"
480 RMDir "\$SMPROGRAMS\\GNU Octave $VERSION\\Documentation" 593 RMDir "\$SMPROGRAMS\\GNU Octave $VERSION\$MultiUser.Local\\Documentation"
481 594
482 Delete "\$SMPROGRAMS\\GNU Octave $VERSION\\*.*" 595 Delete "\$SMPROGRAMS\\GNU Octave $VERSION\$MultiUser.Local\\*.*"
483 RMDir "\$SMPROGRAMS\\GNU Octave $VERSION" 596 RMDir "\$SMPROGRAMS\\GNU Octave $VERSION\$MultiUser.Local"
484 597
485 ; TODO: only delete if no other version of octave available 598 ; TODO: only delete if no other version of octave available
486 599
487 Push \$R0 600 Push \$R0
488 Push \$R1 601 Push \$R1
492 Pop \$R1 ; Ver 605 Pop \$R1 ; Ver
493 606
494 ; no installs detected - remove shortcuts 607 ; no installs detected - remove shortcuts
495 StrCmp \$R1 "" remove_desktop_shortcuts 608 StrCmp \$R1 "" remove_desktop_shortcuts
496 609
610 ClearErrors
497 ; if install detected, get the path and icon 611 ; if install detected, get the path and icon
498 ReadRegStr \$R0 HKLM "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Octave-\$R1" "UninstallString" 612 ReadRegStr \$R0 SHCTX "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Octave-\$R1" "InstallLocation"
613 IfErrors no_install_path
614 StrCmp \$R0 "" no_install_path install_path
615 no_install_path:
616 # old installers uninstall string was just the name of the installer, so try make path from that
617 ReadRegStr \$R0 SHCTX "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Octave-\$R1" "UninstallString"
499 \${GetParent} \$R0 \$R0 618 \${GetParent} \$R0 \$R0
619 install_path:
620 ClearErrors
621
622 # remove any '"' in our path
623 \${un.DequoteString} \$R0 \$R0
624
625 StrCmp \$R0 "" remove_desktop_shortcuts
500 626
501 ReadRegStr \$R2 HKLM "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Octave-\$R1" "DisplayIcon" 627 ReadRegStr \$R2 SHCTX "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Octave-\$R1" "DisplayIcon"
502 628
503 IfFileExists "\$desktop\\GNU Octave (CLI).lnk" 0 check_gui_shortcut 629 IfFileExists "\$desktop\\GNU Octave\$MultiUser.Local (CLI).lnk" 0 check_gui_shortcut
504 SetOutPath "%USERPROFILE%" 630 SetOutPath "%USERPROFILE%"
505 CreateShortCut "\$desktop\\GNU Octave (CLI).lnk" "%SYSTEMROOT%\system32\wscript.exe" "\$\\"\$R0\\octave.vbs\$\\" --no-gui" "\$R2" 0 SW_SHOWMINIMIZED 631 CreateShortCut "\$desktop\\GNU Octave\$MultiUser.Local (CLI).lnk" "%SYSTEMROOT%\system32\wscript.exe" "\$\\"\$R0\\octave.vbs\$\\" --no-gui" "\$R2" 0 SW_SHOWMINIMIZED
506 632
507 check_gui_shortcut: 633 check_gui_shortcut:
508 IfFileExists "\$desktop\\GNU Octave (GUI).lnk" 0 done_remove_desktop_shortcuts 634 IfFileExists "\$desktop\\GNU Octave\$MultiUser.Local (GUI).lnk" 0 done_remove_desktop_shortcuts
509 SetOutPath "%USERPROFILE%" 635 SetOutPath "%USERPROFILE%"
510 CreateShortCut "\$desktop\\GNU Octave (GUI).lnk" "%SYSTEMROOT%\system32\wscript.exe" "\$\\"\$R0\\octave.vbs\$\\" --gui" "\$R2" 0 SW_SHOWMINIMIZED 636 CreateShortCut "\$desktop\\GNU Octave\$MultiUser.Local (GUI).lnk" "%SYSTEMROOT%\system32\wscript.exe" "\$\\"\$R0\\octave.vbs\$\\" --gui" "\$R2" 0 SW_SHOWMINIMIZED
511 nsExec::Exec /TIMEOUT=30000 '"\$INSTDIR\\$OCTAVE_SUBDIR\\bin\\win7appid.exe" "\$desktop\\GNU Octave (GUI).lnk" "gnu.octave.\$R1"' 637 nsExec::Exec /TIMEOUT=30000 '"\$INSTDIR\\$OCTAVE_SUBDIR\\bin\\win7appid.exe" "\$desktop\\GNU Octave\$MultiUser.Local (GUI).lnk" "gnu.octave.\$R1"'
512 Pop \$0 638 Pop \$0
513 639
514 GoTo done_remove_desktop_shortcuts 640 GoTo done_remove_desktop_shortcuts
515 641
516 remove_desktop_shortcuts: 642 remove_desktop_shortcuts:
517 Delete "\$desktop\\GNU Octave (CLI).lnk" 643 Delete "\$desktop\\GNU Octave\$MultiUser.Local (CLI).lnk"
518 Delete "\$desktop\\GNU Octave (GUI).lnk" 644 Delete "\$desktop\\GNU Octave\$MultiUser.Local (GUI).lnk"
519 645
520 done_remove_desktop_shortcuts: 646 done_remove_desktop_shortcuts:
521 Pop \$R2 647 Pop \$R2
522 Pop \$R1 648 Pop \$R1
523 Pop \$R0 649 Pop \$R0
533 echo " RmDir \"\$INSTDIR\\$winf\"" >> $OUTFILE 659 echo " RmDir \"\$INSTDIR\\$winf\"" >> $OUTFILE
534 done 660 done
535 661
536 # last bit of the uninstaller 662 # last bit of the uninstaller
537 cat >> $OUTFILE << EOF 663 cat >> $OUTFILE << EOF
664
665 Delete "\$INSTDIR\\uninstall.exe"
666
538 Delete "\$INSTDIR\\*.*" 667 Delete "\$INSTDIR\\*.*"
539 ClearErrors 668 ClearErrors
540 RmDir "\$INSTDIR" 669 RmDir "\$INSTDIR"
541 670
542 ; didnt remove directory ? most likely from not all files removed 671 ; didnt remove directory ? most likely from not all files removed
543 IfErrors 0 uninstall_done 672 IfErrors 0 uninstall_done
673 ClearErrors
544 MessageBox MB_YESNO "One or more folders were not uninstalled because they contain extra files. Try to delete them?" /SD IDYES IDNO uninstall_done 674 MessageBox MB_YESNO "One or more folders were not uninstalled because they contain extra files. Try to delete them?" /SD IDYES IDNO uninstall_done
545 RMDir /r "\$INSTDIR" 675 RMDir /r "\$INSTDIR"
546 676
547 IfErrors 0 uninstall_done 677 IfErrors 0 uninstall_done
548 MessageBox MB_YESNO "One of more files were still not uninstalled. Do you want to delete them on the next reboot?" /SD IDYES IDNO uninstall_done 678 MessageBox MB_YESNO "One of more files were still not uninstalled. Do you want to delete them on the next reboot?" /SD IDYES IDNO uninstall_done
561 691
562 StrCpy \$R0 "" 692 StrCpy \$R0 ""
563 StrCpy \$R1 0 693 StrCpy \$R1 0
564 694
565 ; loop through installed programs to find octave installs 695 ; loop through installed programs to find octave installs
566 octave_ver_loop: 696 \${un}octave_ver_loop:
567 EnumRegKey \$R2 HKLM "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\" \$R1 697 EnumRegKey \$R2 \${PRODUCT_UNINST_ROOT_KEY} "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\" \$R1
568 StrCmp \$R2 "" latest_octave_done 698 StrCmp \$R2 "" \${un}latest_octave_done
569 699
570 ; len(octave) = 6 700 ; len(octave) = 6
571 StrCpy \$R3 \$R2 6 701 StrCpy \$R3 \$R2 6
572 StrCmp \$R3 "Octave" +1 next_ver_loop 702 StrCmp \$R3 "Octave" 0 \${un}next_ver_loop
573 703
574 ; to verify the install check with the installer exists have uninstaller 704 ; to verify the install check with the installer exists have uninstaller
575 ReadRegStr \$R3 HKLM "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\\$R2" "UninstallString" 705 # TODO
576 ifFileExists \$R3 0 next_ver_loop 706 #ReadRegStr \$R3 \${PRODUCT_UNINST_ROOT_KEY} "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\\$R2" "UninstallString"
577 707 #ifFileExists \$R3 0 \${un}next_ver_loop
708
709 # if uninstalling dont count ourselves
710 \${If} "\${un}" == "un."
711 StrCmp \$R2 "Octave-$VERSION\$MultiUser.Local" \${un}skip_ver_set
578 ; grab version part of octave 712 ; grab version part of octave
579 StrCpy \$R0 \$R2 "" 7 713 StrCpy \$R0 \$R2 "" 7
580 714 \${un}skip_ver_set:
581 next_ver_loop: 715
716 \${Else}
717 ; grab version part of octave
718 StrCpy \$R0 \$R2 "" 7
719 \${EndIf}
720
721 \${un}next_ver_loop:
582 IntOp \$R1 \$R1 + 1 722 IntOp \$R1 \$R1 + 1
583 GoTo octave_ver_loop 723 GoTo \${un}octave_ver_loop
584 724
585 latest_octave_done: 725 \${un}latest_octave_done:
586 Pop \$R3 726 Pop \$R3
587 Pop \$R2 727 Pop \$R2
588 Pop \$R1 728 Pop \$R1
589 Exch \$R0 729 Exch \$R0
590 ; stack now has octave version on top 730 ; stack now has octave version on top
653 793
654 ; Function to check whether already installed this version 794 ; Function to check whether already installed this version
655 Function CheckCurrVersion 795 Function CheckCurrVersion
656 Push \$0 796 Push \$0
657 ClearErrors 797 ClearErrors
658 ReadRegStr \$0 HKLM "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Octave-$VERSION" "DisplayName" 798 ReadRegStr \$0 \${PRODUCT_UNINST_ROOT_KEY} "\$MultiUser.UninstallKey" "DisplayName"
659 IfErrors curr_check_ok 799 IfErrors curr_check_ok
660 MessageBox MB_OK|MB_ICONSTOP "Another Octave installation (with the same version) has been detected. Please uninstall it first." 800 MessageBox MB_OK|MB_ICONSTOP "Another Octave installation (with the same version) has been detected. Please uninstall it first."
661 Abort 801 Quit
662 curr_check_ok: 802 curr_check_ok:
663 pop \$0 803 pop \$0
664 FunctionEnd 804 FunctionEnd
665 805
666 ; Check whether prev install is here and no spaces or special chars in dest name 806 ; Check whether prev install is here and no spaces or special chars in dest name
685 StrCmp \$R0 "%" space_found 825 StrCmp \$R0 "%" space_found
686 StrCmp \$R0 "^" space_found 826 StrCmp \$R0 "^" space_found
687 IntOp \$R1 \$R1 + 1 827 IntOp \$R1 \$R1 + 1
688 GoTo space_loop 828 GoTo space_loop
689 space_found: 829 space_found:
690 MessageBox MB_OK|MB_ICONEXCLAMATION "Octave should not be installed to a destination folder containing &%()^ or spaces. Please select another destination." 830 MessageBox MB_OK|MB_ICONEXCLAMATION "Octave should not be installed to a destination folder containing &%()^. Please select another destination."
691 Abort 831 Abort
692 space_end: 832 space_end:
693 Pop \$R1 833 Pop \$R1
694 Pop \$R0 834 Pop \$R0
695 835
700 ; Function to check Java Runtime Environment 840 ; Function to check Java Runtime Environment
701 Function CheckJRE 841 Function CheckJRE
702 ; looks in: 842 ; looks in:
703 ; 1 - JAVA_HOME environment variable 843 ; 1 - JAVA_HOME environment variable
704 ; 2 - the registry 844 ; 2 - the registry
705 EOF
706 cat >> $OUTFILE << EOF
707 845
708 Push \$R0 846 Push \$R0
709 Push \$R1 847 Push \$R1
710 848
711 # get the version 849 # get the version
735 MessageBox MB_ICONEXCLAMATION|MB_YESNO "Octave has the capability to call Java libraries, but the installer was unable to find a Java Runtime Environment (JRE) on this system. Octave will still function without a JRE, only certain specific functions will be disabled. If a JRE is installed later, Octave should be able to detect and use it automatically. Continue with installation?" /SD IDYES IDYES continue 873 MessageBox MB_ICONEXCLAMATION|MB_YESNO "Octave has the capability to call Java libraries, but the installer was unable to find a Java Runtime Environment (JRE) on this system. Octave will still function without a JRE, only certain specific functions will be disabled. If a JRE is installed later, Octave should be able to detect and use it automatically. Continue with installation?" /SD IDYES IDYES continue
736 Abort 874 Abort
737 continue: 875 continue:
738 Pop \$R1 876 Pop \$R1
739 Pop \$R0 877 Pop \$R0
878 FunctionEnd
879
880 Function un.FindThisUninstallReg
881 # look to find where we were installed for this particular version and then return
882 # 0 no install found (shouldnt happen)
883 # 1 local install was found
884 # 2 allusers install was found
885 Push \$R0
886 Push \$R1
887
888 StrCpy \$R0 0
889
890 find_check_reg_hkcu:
891 # check for local installs
892 ReadRegStr \$R1 HKCU "\${PRODUCT_UNINST_KEY} (Local)" "InstallLocation"
893 StrCmp \$R1 "" 0 find_have_reg_hkcu
894
895 ReadRegStr \$R1 HKCU "\${PRODUCT_UNINST_KEY} (Local)" "UninstallString"
896 StrCmp \$R1 "" find_check_reg_hklm 0
897
898 \${GetParent} \$R1 \$R1
899
900 find_have_reg_hkcu:
901 \${un.DequoteString} \$R1 \$R1
902
903 # is this the match ?
904 StrCmp \$R1 "\$INSTDIR" 0 find_check_reg_hklm
905
906 StrCpy \$R0 1
907 GoTo find_check_reg_done
908 find_check_reg_hklm:
909 # check for all installs
910 ReadRegStr \$R1 HKLM "\${PRODUCT_UNINST_KEY}" "InstallLocation"
911 StrCmp \$R1 "" 0 find_have_reg_hklm
912
913 ReadRegStr \$R1 HKLM "\${PRODUCT_UNINST_KEY}" "UninstallString"
914 StrCmp \$R1 "" find_check_reg_done 0
915
916 \${GetParent} \$R1 \$R1
917
918 find_have_reg_hklm:
919 \${un.DequoteString} \$R1 \$R1
920
921 # is this the match ?
922 StrCmp \$R1 "\$INSTDIR" 0 find_check_reg_done
923
924 StrCpy \$R0 2
925
926 find_check_reg_done:
927 Pop \$R1
928 # restore r0, but result on stack
929 Exch \$R0
930 FunctionEnd
931
740 EOF 932 EOF
741 cat >> $OUTFILE << EOF
742
743 FunctionEnd
744 EOF