| 1 | # This file is part of the McStas neutron ray-trace simulation package |
|---|
| 2 | # Copyright (C) 1997-2004, All rights reserved |
|---|
| 3 | # Risoe National Laborartory, Roskilde, Denmark |
|---|
| 4 | # Institut Laue Langevin, Grenoble, France |
|---|
| 5 | # |
|---|
| 6 | # This program is free software; you can redistribute it and/or modify |
|---|
| 7 | # it under the terms of the GNU General Public License as published by |
|---|
| 8 | # the Free Software Foundation; version 2 of the License. |
|---|
| 9 | # |
|---|
| 10 | # This program is distributed in the hope that it will be useful, |
|---|
| 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 13 | # GNU General Public License for more details. |
|---|
| 14 | # |
|---|
| 15 | # You should have received a copy of the GNU General Public License |
|---|
| 16 | # along with this program; if not, write to the Free Software |
|---|
| 17 | # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|---|
| 18 | # |
|---|
| 19 | # mcstas.nsi: input file for the McStas NullSoft installer |
|---|
| 20 | # |
|---|
| 21 | |
|---|
| 22 | !define TEMP1 $R0 |
|---|
| 23 | |
|---|
| 24 | !ifndef VERSION |
|---|
| 25 | !define VERSION "MCSTAS_VERSION" |
|---|
| 26 | !endif |
|---|
| 27 | |
|---|
| 28 | |
|---|
| 29 | !include MUI.nsh |
|---|
| 30 | !include Sections.nsh |
|---|
| 31 | |
|---|
| 32 | Name "McStas plus tools" |
|---|
| 33 | OutFile "McStas-${VERSION}-i686-Win32.exe" |
|---|
| 34 | |
|---|
| 35 | ##=========================================================================== |
|---|
| 36 | ## Modern UI Pages |
|---|
| 37 | ##=========================================================================== |
|---|
| 38 | |
|---|
| 39 | !define MUI_WELCOMEFINISHPAGE_BITMAP "mcstas.bmp" |
|---|
| 40 | !define MUI_WELCOMEPAGE_TEXT "This wizard will guide you through the installation of \ |
|---|
| 41 | McStas release ${VERSION} on Win32 systems.\ |
|---|
| 42 | \n\nMcStas is a ray-tracing Monte Carlo neutron simulator (see <http://www.mcstas.org>).\ |
|---|
| 43 | \n\nThis installer will set up McStas and support tools on your computer.\ |
|---|
| 44 | \n\nNOTE: If you have a previous, working installation of McStas on your machine, you should be able\ |
|---|
| 45 | to skip installation of the 'support tools' (skip by unchecking everything but McStas when prompted).\ |
|---|
| 46 | \n\nNOTE: Please install all software on C:\ and do NOT USE SPACES in the McStas installation\ |
|---|
| 47 | directory name." |
|---|
| 48 | |
|---|
| 49 | |
|---|
| 50 | !insertmacro MUI_PAGE_WELCOME |
|---|
| 51 | !insertmacro MUI_PAGE_LICENSE "LICENSE.rtf" |
|---|
| 52 | |
|---|
| 53 | !define MUI_PAGE_CUSTOMFUNCTION_PRE SelectFilesCheck |
|---|
| 54 | !define MUI_PAGE_CUSTOMFUNCTION_LEAVE ComponentsLeave |
|---|
| 55 | !insertmacro MUI_PAGE_COMPONENTS |
|---|
| 56 | |
|---|
| 57 | ## This is the title on the first Directory page |
|---|
| 58 | #!define MUI_DIRECTORYPAGE_TEXT_TOP "$(MUI_DIRECTORYPAGE_TEXT_TOP_A)" |
|---|
| 59 | |
|---|
| 60 | !define MUI_PAGE_CUSTOMFUNCTION_PRE SelectFilesA |
|---|
| 61 | #!insertmacro MUI_PAGE_DIRECTORY |
|---|
| 62 | !insertmacro MUI_PAGE_INSTFILES |
|---|
| 63 | |
|---|
| 64 | Page custom SetCustom |
|---|
| 65 | |
|---|
| 66 | ## This is the title on the second Directory page |
|---|
| 67 | !define MUI_DIRECTORYPAGE_TEXT_TOP "$(MUI_DIRECTORYPAGE_TEXT_TOP_B)" |
|---|
| 68 | |
|---|
| 69 | !define MUI_PAGE_CUSTOMFUNCTION_PRE SelectFilesB |
|---|
| 70 | !insertmacro MUI_PAGE_DIRECTORY |
|---|
| 71 | !insertmacro MUI_PAGE_INSTFILES |
|---|
| 72 | |
|---|
| 73 | !define MUI_PAGE_CUSTOMFUNCTION_LEAVE DeleteSectionsINI |
|---|
| 74 | |
|---|
| 75 | !define MUI_FINISHPAGE_NOAUTOCLOSE |
|---|
| 76 | !insertmacro MUI_PAGE_FINISH |
|---|
| 77 | |
|---|
| 78 | !insertmacro MUI_LANGUAGE "English" |
|---|
| 79 | |
|---|
| 80 | ##=========================================================================== |
|---|
| 81 | ## Language strings |
|---|
| 82 | ##=========================================================================== |
|---|
| 83 | |
|---|
| 84 | LangString NoSectionsSelected ${LANG_ENGLSH} "You haven't selected any sections!" |
|---|
| 85 | |
|---|
| 86 | LangString MUI_DIRECTORYPAGE_TEXT_TOP_B ${LANG_ENGLSH} "Setup will install \ |
|---|
| 87 | McStas in the following folder... WARNING: Spaces and specials chars are unsupported here!" |
|---|
| 88 | |
|---|
| 89 | ##=========================================================================== |
|---|
| 90 | ## Start sections |
|---|
| 91 | ##=========================================================================== |
|---|
| 92 | |
|---|
| 93 | ## Sections Group 1 |
|---|
| 94 | SectionGroup /e "Support tools" PROG1 |
|---|
| 95 | |
|---|
| 96 | Section "Perl 5.10" |
|---|
| 97 | SetOutPath "$TEMP" |
|---|
| 98 | File ActivePerl-5.10.0.1002-MSWin32-x86-283697.msi |
|---|
| 99 | ExecWait "msiexec /i ActivePerl-5.10.0.1002-MSWin32-x86-283697.msi" |
|---|
| 100 | messagebox mb_ok "Perl installation complete!" |
|---|
| 101 | SectionEnd |
|---|
| 102 | |
|---|
| 103 | Section "Dev-cpp" |
|---|
| 104 | SetOutPath "$TEMP" |
|---|
| 105 | File devcpp-4.9.9.2_setup.exe |
|---|
| 106 | ExecWait "devcpp-4.9.9.2_setup.exe" |
|---|
| 107 | messagebox mb_ok "Dev-CPP installation complete!" |
|---|
| 108 | SectionEnd |
|---|
| 109 | |
|---|
| 110 | Section "Scilab 4.0" |
|---|
| 111 | SetOutPath "$TEMP" |
|---|
| 112 | File scilab-4.0.exe |
|---|
| 113 | ExecWait "scilab-4.0.exe" |
|---|
| 114 | messagebox mb_ok "Scilab installation complete!" |
|---|
| 115 | SectionEnd |
|---|
| 116 | |
|---|
| 117 | Section "Cortona VRML" CORT |
|---|
| 118 | SetOutPath "$TEMP" |
|---|
| 119 | File cortvrml.exe |
|---|
| 120 | ExecWait "cortvrml.exe" |
|---|
| 121 | messagebox mb_ok "Cortona installation complete!" |
|---|
| 122 | SectionEnd |
|---|
| 123 | |
|---|
| 124 | SectionGroupEnd |
|---|
| 125 | |
|---|
| 126 | ## Sections Group 2 |
|---|
| 127 | SectionGroup /e "McStas" PROG2 |
|---|
| 128 | |
|---|
| 129 | Section "McStas ${VERSION} (required)" MCSTAS |
|---|
| 130 | ; Start by going to the temp folder... |
|---|
| 131 | SetOutPath "$TEMP" |
|---|
| 132 | |
|---|
| 133 | File mcstas-${VERSION}-i686-Intel-Win32.zip |
|---|
| 134 | ZipDLL::extractall "mcstas-${VERSION}-i686-Intel-Win32.zip" "" |
|---|
| 135 | SectionIn RO |
|---|
| 136 | |
|---|
| 137 | System::Call 'Kernel32::SetEnvironmentVariableA(t, t) i("NSIS", "AUTO").r0' |
|---|
| 138 | System::Call 'Kernel32::SetEnvironmentVariableA(t, t) i("DEVBIN", "$4").r0' |
|---|
| 139 | System::Call 'Kernel32::SetEnvironmentVariableA(t, t) i("DEVLIB", "$5").r0' |
|---|
| 140 | System::Call 'Kernel32::SetEnvironmentVariableA(t, t) i("PERLBIN", "$3").r0' |
|---|
| 141 | System::Call 'Kernel32::SetEnvironmentVariableA(t, t) i("SCIBIN", "$6").r0' |
|---|
| 142 | System::Call 'Kernel32::SetEnvironmentVariableA(t, t) i("MCSTAS_SITE", "$INSTDIR").r0' |
|---|
| 143 | System::Call 'Kernel32::SetEnvironmentVariableA(t, t) i("MCVERSION", "${VERSION}").r0' |
|---|
| 144 | |
|---|
| 145 | |
|---|
| 146 | ; Execute batch installer |
|---|
| 147 | ExecWait "$TEMP\mcstas-${VERSION}\install.bat" |
|---|
| 148 | |
|---|
| 149 | SectionEnd |
|---|
| 150 | |
|---|
| 151 | Section "Windows setup" WIN |
|---|
| 152 | SectionIn RO |
|---|
| 153 | ; Create desktop link etc. for all users: |
|---|
| 154 | SetShellVarContext all |
|---|
| 155 | |
|---|
| 156 | ; Create desktop and SM link for mcgui.pl |
|---|
| 157 | CreateShortCut "$DESKTOP\McStas.lnk" "$INSTDIR\bin\mcgui.pl" "" "$INSTDIR\bin\mcgui.pl" 0 |
|---|
| 158 | CreateDirectory "$SMPROGRAMS\McStas" |
|---|
| 159 | CreateShortCut "$SMPROGRAMS\McStas\Uninstall.lnk" "$INSTDIR\uninstall.exe" "" "$INSTDIR\uninstall.exe" 0 |
|---|
| 160 | CreateShortCut "$SMPROGRAMS\McStas\McStas.lnk" "$INSTDIR\bin\mcgui.pl" "" "$INSTDIR\bin\mcgui.pl" 0 |
|---|
| 161 | |
|---|
| 162 | ; Write the installation path into the registry |
|---|
| 163 | WriteRegStr HKLM SOFTWARE\McStas "Install_Dir" "$INSTDIR" |
|---|
| 164 | |
|---|
| 165 | ; Write the uninstall keys for Windows |
|---|
| 166 | WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\McStas" "DisplayName" "McStas" |
|---|
| 167 | WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\McStas" "UninstallString" '"$INSTDIR\uninstall.exe"' |
|---|
| 168 | WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\McStas" "NoModify" 1 |
|---|
| 169 | WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\McStas" "NoRepair" 1 |
|---|
| 170 | WriteUninstaller "uninstall.exe" |
|---|
| 171 | |
|---|
| 172 | messagebox mb_ok "McStas install complete! Please log off to complete configuration." |
|---|
| 173 | |
|---|
| 174 | SectionEnd |
|---|
| 175 | |
|---|
| 176 | SectionGroupEnd |
|---|
| 177 | |
|---|
| 178 | ##=========================================================================== |
|---|
| 179 | ## Settings |
|---|
| 180 | ##=========================================================================== |
|---|
| 181 | |
|---|
| 182 | #!define PROG1_InstDir "C:\PROG1" |
|---|
| 183 | !define PROG1_StartIndex ${PROG1} |
|---|
| 184 | !define PROG1_EndIndex ${CORT} |
|---|
| 185 | |
|---|
| 186 | !define PROG2_InstDir "C:\McStas" |
|---|
| 187 | !define PROG2_StartIndex ${PROG2} |
|---|
| 188 | !define PROG2_EndIndex ${WIN} |
|---|
| 189 | |
|---|
| 190 | ##=========================================================================== |
|---|
| 191 | ## Please don't modify below here unless you're a NSIS 'wiz-kid' |
|---|
| 192 | ##=========================================================================== |
|---|
| 193 | |
|---|
| 194 | ## Create $PLUGINSDIR |
|---|
| 195 | Function .onInit |
|---|
| 196 | |
|---|
| 197 | ;Extract InstallOptions files |
|---|
| 198 | ;$PLUGINSDIR will automatically be removed when the installer closes |
|---|
| 199 | |
|---|
| 200 | InitPluginsDir |
|---|
| 201 | File /oname=$PLUGINSDIR\mcstas.ini "mcstas.ini" |
|---|
| 202 | |
|---|
| 203 | FunctionEnd |
|---|
| 204 | |
|---|
| 205 | Function SetCustom |
|---|
| 206 | !insertmacro MUI_HEADER_TEXT "Support app location" "" |
|---|
| 207 | ;Display the InstallOptions dialog |
|---|
| 208 | Push ${TEMP1} |
|---|
| 209 | InstallOptions::dialog "$PLUGINSDIR\mcstas.ini" |
|---|
| 210 | Pop ${TEMP1} |
|---|
| 211 | |
|---|
| 212 | ReadINIStr $3 "$PLUGINSDIR\mcstas.ini" "Field 3" "State" |
|---|
| 213 | ReadINIStr $4 "$PLUGINSDIR\mcstas.ini" "Field 5" "State" |
|---|
| 214 | ReadINIStr $5 "$PLUGINSDIR\mcstas.ini" "Field 7" "State" |
|---|
| 215 | ReadINIStr $6 "$PLUGINSDIR\mcstas.ini" "Field 9" "State" |
|---|
| 216 | |
|---|
| 217 | FunctionEnd |
|---|
| 218 | |
|---|
| 219 | |
|---|
| 220 | ## If user goes back to this page from 1st Directory page |
|---|
| 221 | ## we need to put the sections back to how they were before |
|---|
| 222 | Var IfBack |
|---|
| 223 | Function SelectFilesCheck |
|---|
| 224 | StrCmp $IfBack 1 0 NoCheck |
|---|
| 225 | Call ResetFiles |
|---|
| 226 | NoCheck: |
|---|
| 227 | FunctionEnd |
|---|
| 228 | |
|---|
| 229 | ## Also if no sections are selected, warn the user! |
|---|
| 230 | Function ComponentsLeave |
|---|
| 231 | Push $R0 |
|---|
| 232 | Push $R1 |
|---|
| 233 | |
|---|
| 234 | Call IsPROG1Selected |
|---|
| 235 | Pop $R0 |
|---|
| 236 | Call IsPROG2Selected |
|---|
| 237 | Pop $R1 |
|---|
| 238 | StrCmp $R0 1 End |
|---|
| 239 | StrCmp $R1 1 End |
|---|
| 240 | Pop $R1 |
|---|
| 241 | Pop $R0 |
|---|
| 242 | MessageBox MB_OK|MB_ICONEXCLAMATION "$(NoSectionsSelected)" |
|---|
| 243 | Abort |
|---|
| 244 | |
|---|
| 245 | End: |
|---|
| 246 | Pop $R1 |
|---|
| 247 | Pop $R0 |
|---|
| 248 | FunctionEnd |
|---|
| 249 | |
|---|
| 250 | Function IsPROG1Selected |
|---|
| 251 | Push $R0 |
|---|
| 252 | Push $R1 |
|---|
| 253 | |
|---|
| 254 | StrCpy $R0 ${PROG1_StartIndex} # Group 1 start |
|---|
| 255 | |
|---|
| 256 | Loop: |
|---|
| 257 | IntOp $R0 $R0 + 1 |
|---|
| 258 | SectionGetFlags $R0 $R1 # Get section flags |
|---|
| 259 | IntOp $R1 $R1 & ${SF_SELECTED} |
|---|
| 260 | StrCmp $R1 ${SF_SELECTED} 0 +3 # If section is selected, done |
|---|
| 261 | StrCpy $R0 1 |
|---|
| 262 | Goto Done |
|---|
| 263 | StrCmp $R0 ${PROG1_EndIndex} 0 Loop |
|---|
| 264 | |
|---|
| 265 | Done: |
|---|
| 266 | Pop $R1 |
|---|
| 267 | Exch $R0 |
|---|
| 268 | FunctionEnd |
|---|
| 269 | |
|---|
| 270 | Function IsPROG2Selected |
|---|
| 271 | Push $R0 |
|---|
| 272 | Push $R1 |
|---|
| 273 | |
|---|
| 274 | StrCpy $R0 ${PROG2_StartIndex} # Group 2 start |
|---|
| 275 | |
|---|
| 276 | Loop: |
|---|
| 277 | IntOp $R0 $R0 + 1 |
|---|
| 278 | SectionGetFlags $R0 $R1 # Get section flags |
|---|
| 279 | IntOp $R1 $R1 & ${SF_SELECTED} |
|---|
| 280 | StrCmp $R1 ${SF_SELECTED} 0 +3 # If section is selected, done |
|---|
| 281 | StrCpy $R0 1 |
|---|
| 282 | Goto Done |
|---|
| 283 | StrCmp $R0 ${PROG2_EndIndex} 0 Loop |
|---|
| 284 | |
|---|
| 285 | Done: |
|---|
| 286 | Pop $R1 |
|---|
| 287 | Exch $R0 |
|---|
| 288 | FunctionEnd |
|---|
| 289 | |
|---|
| 290 | ## Here we are selecting first sections to install |
|---|
| 291 | ## by unselecting all the others! |
|---|
| 292 | Function SelectFilesA |
|---|
| 293 | |
|---|
| 294 | # If user clicks Back now, we will know to reselect Group 2's sections for |
|---|
| 295 | # Components page |
|---|
| 296 | StrCpy $IfBack 1 |
|---|
| 297 | |
|---|
| 298 | # We need to save the state of the Group 2 Sections |
|---|
| 299 | # for the next InstFiles page |
|---|
| 300 | Push $R0 |
|---|
| 301 | Push $R1 |
|---|
| 302 | |
|---|
| 303 | StrCpy $R0 ${PROG2_StartIndex} # Group 2 start |
|---|
| 304 | |
|---|
| 305 | Loop: |
|---|
| 306 | IntOp $R0 $R0 + 1 |
|---|
| 307 | SectionGetFlags $R0 $R1 # Get section flags |
|---|
| 308 | WriteINIStr "$PLUGINSDIR\sections.ini" Sections $R0 $R1 # Save state |
|---|
| 309 | !insertmacro UnselectSection $R0 # Then unselect it |
|---|
| 310 | StrCmp $R0 ${PROG2_EndIndex} 0 Loop |
|---|
| 311 | |
|---|
| 312 | # Don't install prog 1? |
|---|
| 313 | Call IsPROG1Selected |
|---|
| 314 | Pop $R0 |
|---|
| 315 | StrCmp $R0 1 +4 |
|---|
| 316 | Pop $R1 |
|---|
| 317 | Pop $R0 |
|---|
| 318 | Abort |
|---|
| 319 | |
|---|
| 320 | # Set current $INSTDIR to PROG1_InstDir define |
|---|
| 321 | #StrCpy $INSTDIR "${PROG1_InstDir}" |
|---|
| 322 | |
|---|
| 323 | Pop $R1 |
|---|
| 324 | Pop $R0 |
|---|
| 325 | FunctionEnd |
|---|
| 326 | |
|---|
| 327 | ## Here we need to unselect all Group 1 sections |
|---|
| 328 | ## and then re-select those in Group 2 (that the user had selected on |
|---|
| 329 | ## Components page) |
|---|
| 330 | Function SelectFilesB |
|---|
| 331 | Push $R0 |
|---|
| 332 | Push $R1 |
|---|
| 333 | |
|---|
| 334 | StrCpy $R0 ${PROG1_StartIndex} # Group 1 start |
|---|
| 335 | |
|---|
| 336 | Loop: |
|---|
| 337 | IntOp $R0 $R0 + 1 |
|---|
| 338 | !insertmacro UnselectSection $R0 # Unselect it |
|---|
| 339 | StrCmp $R0 ${PROG1_EndIndex} 0 Loop |
|---|
| 340 | |
|---|
| 341 | Call ResetFiles |
|---|
| 342 | |
|---|
| 343 | # Don't install prog 2? |
|---|
| 344 | Call IsPROG2Selected |
|---|
| 345 | Pop $R0 |
|---|
| 346 | StrCmp $R0 1 +4 |
|---|
| 347 | Pop $R1 |
|---|
| 348 | Pop $R0 |
|---|
| 349 | Abort |
|---|
| 350 | |
|---|
| 351 | # Set current $INSTDIR to PROG2_InstDir define |
|---|
| 352 | StrCpy $INSTDIR "${PROG2_InstDir}" |
|---|
| 353 | |
|---|
| 354 | Pop $R1 |
|---|
| 355 | Pop $R0 |
|---|
| 356 | FunctionEnd |
|---|
| 357 | |
|---|
| 358 | ## This will set all sections to how they were on the components page |
|---|
| 359 | ## originally |
|---|
| 360 | Function ResetFiles |
|---|
| 361 | Push $R0 |
|---|
| 362 | Push $R1 |
|---|
| 363 | |
|---|
| 364 | StrCpy $R0 ${PROG2_StartIndex} # Group 2 start |
|---|
| 365 | |
|---|
| 366 | Loop: |
|---|
| 367 | IntOp $R0 $R0 + 1 |
|---|
| 368 | ReadINIStr "$R1" "$PLUGINSDIR\sections.ini" Sections $R0 # Get sec flags |
|---|
| 369 | SectionSetFlags $R0 $R1 # Re-set flags for this sec |
|---|
| 370 | StrCmp $R0 ${PROG2_EndIndex} 0 Loop |
|---|
| 371 | |
|---|
| 372 | Pop $R1 |
|---|
| 373 | Pop $R0 |
|---|
| 374 | FunctionEnd |
|---|
| 375 | |
|---|
| 376 | ## Here we are deleting the temp INI file at the end of installation |
|---|
| 377 | Function DeleteSectionsINI |
|---|
| 378 | Delete "$PLUGINSDIR\Sections.ini" |
|---|
| 379 | FlushINI "$PLUGINSDIR\Sections.ini" |
|---|
| 380 | FunctionEnd |
|---|
| 381 | |
|---|
| 382 | ;-------------------------------- |
|---|
| 383 | |
|---|
| 384 | ; Uninstaller |
|---|
| 385 | |
|---|
| 386 | Section "Uninstall" |
|---|
| 387 | |
|---|
| 388 | ; Remove desktop link etc. for all users: |
|---|
| 389 | SetShellVarContext all |
|---|
| 390 | |
|---|
| 391 | ; Remove registry keys |
|---|
| 392 | DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\McStas" |
|---|
| 393 | DeleteRegKey HKLM SOFTWARE\McStas |
|---|
| 394 | |
|---|
| 395 | ; Remove files and uninstaller |
|---|
| 396 | Delete $INSTDIR\uninstall.exe |
|---|
| 397 | |
|---|
| 398 | ; Remove shortcuts, if any |
|---|
| 399 | Delete "$SMPROGRAMS\McStas\*.*" |
|---|
| 400 | |
|---|
| 401 | ; Remove directories and files used |
|---|
| 402 | Delete "$DESKTOP\McStas.lnk" |
|---|
| 403 | RMDir "$SMPROGRAMS\McStas" |
|---|
| 404 | RMDir /R "$INSTDIR" |
|---|
| 405 | |
|---|
| 406 | |
|---|
| 407 | SectionEnd |
|---|