1
;NSIS Modern User Interface
2
;Installer for Open Babel
4
;--------------------------------
9
; ======================================
10
; The main part of this script starts at
12
; ======================================
14
;--------------------------------
15
;AddToPath functions taken from "Path Manipulation" on NSIS wiki
17
!ifndef _AddToPath_nsh
18
!define _AddToPath_nsh
21
!include "WinMessages.NSH"
24
!ifndef WriteEnvStr_RegKey
26
!define WriteEnvStr_RegKey \
27
'HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment"'
29
!define WriteEnvStr_RegKey 'HKCU "Environment"'
33
; AddToPath - Adds the given dir to the search path.
34
; Input - head of the stack
35
; Note - Win9x systems requires reboot
43
# don't add if the path doesn't exist
44
IfFileExists "$0\*.*" "" AddToPath_done
51
StrCmp $2 "" "" AddToPath_done
56
StrCmp $2 "" "" AddToPath_done
57
GetFullPathName /SHORT $3 $0
62
StrCmp $2 "" "" AddToPath_done
67
StrCmp $2 "" "" AddToPath_done
71
StrCmp $1 1 AddToPath_NT
74
FileOpen $1 "$1\autoexec.bat" a
77
IntCmp $2 26 0 +2 +2 # DOS EOF
78
FileSeek $1 -1 END # write over EOF
79
FileWrite $1 "$\r$\nSET PATH=%PATH%;$3$\r$\n"
85
ReadRegStr $1 ${WriteEnvStr_RegKey} "PATH"
86
StrCmp $1 "" AddToPath_NTdoIt
92
WriteRegExpandStr ${WriteEnvStr_RegKey} "PATH" $0
93
SendMessage ${HWND_BROADCAST} ${WM_WININICHANGE} 0 "STR:Environment" /TIMEOUT=5000
102
; RemoveFromPath - Remove a given dir from the path
103
; Input: head of the stack
105
Function un.RemoveFromPath
114
IntFmt $6 "%c" 26 # DOS EOF
118
StrCmp $1 1 unRemoveFromPath_NT
121
FileOpen $1 "$1\autoexec.bat" r
124
GetFullPathName /SHORT $0 $0
125
StrCpy $0 "SET PATH=%PATH%;$0"
126
Goto unRemoveFromPath_dosLoop
128
unRemoveFromPath_dosLoop:
130
StrCpy $5 $3 1 -1 # read last char
131
StrCmp $5 $6 0 +2 # if DOS EOF
132
StrCpy $3 $3 -1 # remove DOS EOF so we can compare
133
StrCmp $3 "$0$\r$\n" unRemoveFromPath_dosLoopRemoveLine
134
StrCmp $3 "$0$\n" unRemoveFromPath_dosLoopRemoveLine
135
StrCmp $3 "$0" unRemoveFromPath_dosLoopRemoveLine
136
StrCmp $3 "" unRemoveFromPath_dosLoopEnd
138
Goto unRemoveFromPath_dosLoop
139
unRemoveFromPath_dosLoopRemoveLine:
141
Goto unRemoveFromPath_dosLoop
143
unRemoveFromPath_dosLoopEnd:
147
Delete "$1\autoexec.bat"
148
CopyFiles /SILENT $4 "$1\autoexec.bat"
150
Goto unRemoveFromPath_done
153
ReadRegStr $1 ${WriteEnvStr_RegKey} "PATH"
154
StrCpy $5 $1 1 -1 # copy last char
155
StrCmp $5 ";" +2 # if last char != ;
156
StrCpy $1 "$1;" # append ;
159
Call un.StrStr ; Find `$0;` in $1
160
Pop $2 ; pos of our dir
161
StrCmp $2 "" unRemoveFromPath_done
162
; else, it is in path
167
StrCpy $5 $1 -$4 # $5 is now the part before the path to remove
168
StrCpy $6 $2 "" $3 # $6 is now the part after the path to remove
171
StrCpy $5 $3 1 -1 # copy last char
172
StrCmp $5 ";" 0 +2 # if last char == ;
173
StrCpy $3 $3 -1 # remove last char
175
WriteRegExpandStr ${WriteEnvStr_RegKey} "PATH" $3
176
SendMessage ${HWND_BROADCAST} ${WM_WININICHANGE} 0 "STR:Environment" /TIMEOUT=5000
178
unRemoveFromPath_done:
190
; AddToEnvVar - Adds the given value to the given environment var
191
; Input - head of the stack $0 environement variable $1=value to add
192
; Note - Win9x systems requires reboot
196
Exch $1 ; $1 has environment variable value
198
Exch $0 ; $0 has environment variable name
200
DetailPrint "Adding $1 to $0"
211
StrCmp $3 "" "" AddToEnvVar_done
217
StrCmp $3 "" "" AddToEnvVar_done
222
StrCmp $2 1 AddToEnvVar_NT
225
FileOpen $2 "$2\autoexec.bat" a
228
IntCmp $3 26 0 +2 +2 # DOS EOF
229
FileSeek $2 -1 END # write over EOF
230
FileWrite $2 "$\r$\nSET $0=%$0%;$4$\r$\n"
233
Goto AddToEnvVar_done
236
ReadRegStr $2 ${WriteEnvStr_RegKey} $0
237
StrCpy $3 $2 1 -1 # copy last char
238
StrCmp $3 ";" 0 +2 # if last char == ;
239
StrCpy $2 $2 -1 # remove last char
240
StrCmp $2 "" AddToEnvVar_NTdoIt
243
WriteRegExpandStr ${WriteEnvStr_RegKey} $0 $1
244
SendMessage ${HWND_BROADCAST} ${WM_WININICHANGE} 0 "STR:Environment" /TIMEOUT=5000
255
; RemoveFromEnvVar - Remove a given value from a environment var
256
; Input: head of the stack
258
Function un.RemoveFromEnvVar
260
Exch $1 ; $1 has environment variable value
262
Exch $0 ; $0 has environment variable name
264
DetailPrint "Removing $1 from $0"
272
IntFmt $7 "%c" 26 # DOS EOF
276
StrCmp $2 1 unRemoveFromEnvVar_NT
279
FileOpen $2 "$2\autoexec.bat" r
282
GetFullPathName /SHORT $1 $1
283
StrCpy $1 "SET $0=%$0%;$1"
284
Goto unRemoveFromEnvVar_dosLoop
286
unRemoveFromEnvVar_dosLoop:
288
StrCpy $6 $4 1 -1 # read last char
289
StrCmp $6 $7 0 +2 # if DOS EOF
290
StrCpy $4 $4 -1 # remove DOS EOF so we can compare
291
StrCmp $4 "$1$\r$\n" unRemoveFromEnvVar_dosLoopRemoveLine
292
StrCmp $4 "$1$\n" unRemoveFromEnvVar_dosLoopRemoveLine
293
StrCmp $4 "$1" unRemoveFromEnvVar_dosLoopRemoveLine
294
StrCmp $4 "" unRemoveFromEnvVar_dosLoopEnd
296
Goto unRemoveFromEnvVar_dosLoop
297
unRemoveFromEnvVar_dosLoopRemoveLine:
299
Goto unRemoveFromEnvVar_dosLoop
301
unRemoveFromEnvVar_dosLoopEnd:
305
Delete "$2\autoexec.bat"
306
CopyFiles /SILENT $5 "$2\autoexec.bat"
308
Goto unRemoveFromEnvVar_done
310
unRemoveFromEnvVar_NT:
311
ReadRegStr $2 ${WriteEnvStr_RegKey} $0
312
StrCpy $6 $2 1 -1 # copy last char
313
StrCmp $6 ";" +2 # if last char != ;
314
StrCpy $2 "$2;" # append ;
317
Call un.StrStr ; Find `$1;` in $2
318
Pop $3 ; pos of our dir
319
StrCmp $3 "" unRemoveFromEnvVar_done
320
; else, it is in path
325
StrCpy $6 $2 -$5 # $6 is now the part before the path to remove
326
StrCpy $7 $3 "" $4 # $7 is now the part after the path to remove
329
StrCpy $6 $4 1 -1 # copy last char
330
StrCmp $6 ";" 0 +2 # if last char == ;
331
StrCpy $4 $4 -1 # remove last char
333
WriteRegExpandStr ${WriteEnvStr_RegKey} $0 $4
334
SendMessage ${HWND_BROADCAST} ${WM_WININICHANGE} 0 "STR:Environment" /TIMEOUT=5000
336
unRemoveFromEnvVar_done:
353
###########################################
354
# Utility Functions #
355
###########################################
359
; output, top of the stack = 1 if NT or 0 if not
364
; ($R0 at this point is 1 or 0)
369
ReadRegStr $0 HKLM "SOFTWARE\Microsoft\Windows NT\CurrentVersion" CurrentVersion
370
StrCmp $0 "" 0 IsNT_yes
383
!insertmacro IsNT "un."
388
; input, top of stack = string to search for
389
; top of stack-1 = string to search in
390
; output, top of stack (replaces with the portion of the string remaining)
391
; modifies no other variables.
394
; Push "this is a long ass string"
398
; ($R0 at this point is "ass string")
402
Exch $R1 ; st=haystack,old$R1, $R1=needle
403
Exch ; st=old$R1,haystack
404
Exch $R2 ; st=old$R1,old$R2, $R2=haystack
416
StrCpy $R5 $R2 $R3 $R4
422
StrCpy $R1 $R2 "" $R4
430
!insertmacro StrStr ""
431
!insertmacro StrStr "un."
433
!endif ; _AddToPath_nsh
435
Function Trim ; Added by Pelaca
439
StrCpy $R2 "$R1" 1 -1
440
StrCmp "$R2" " " RTrim
441
StrCmp "$R2" "$\n" RTrim
442
StrCmp "$R2" "$\r" RTrim
443
StrCmp "$R2" ";" RTrim
453
;--------------------------------
457
!define OBVersion 2.2.0Snapshot1
460
Name "OpenBabel ${OBVERSION}"
461
OutFile "OpenBabel${OBVERSION}_Windows_Installer.exe"
463
;Default installation folder
464
InstallDir "$PROGRAMFILES\OpenBabel-${OBVERSION}"
466
;Get installation folder from registry if available
467
InstallDirRegKey HKCU "Software\OpenBabel ${OBVERSION}" ""
469
;--------------------------------
475
;--------------------------------
478
;!define MUI_ICON "babel.ico"
479
;!define MUI_UNICON "babel.ico"
480
!define MUI_ABORTWARNING
481
!define MUI_HEADERIMAGE
482
!define MUI_HEADERIMAGE_BITMAP "logo_small.bmp"
483
!define MUI_WELCOMEFINISHPAGE_BITMAP "logo_big.bmp"
484
!define MUI_FINISHPAGE_RUN "$INSTDIR/OBGUII.exe"
485
!define MUI_FINISHPAGE_SHOWREADME "http://openbabel.sourceforge.net/wiki/OpenBabelGUI"
487
;--------------------------------
490
!insertmacro MUI_PAGE_WELCOME
491
!insertmacro MUI_PAGE_LICENSE "../../COPYING"
492
!insertmacro MUI_PAGE_DIRECTORY
494
;Start Menu Folder Page Configuration
495
!define MUI_STARTMENUPAGE_REGISTRY_ROOT "HKCU"
496
!define MUI_STARTMENUPAGE_REGISTRY_KEY "Software\OpenBabel ${OBVERSION}"
497
!define MUI_STARTMENUPAGE_REGISTRY_VALUENAME "Start Menu Folder"
498
!insertmacro MUI_PAGE_STARTMENU Application $STARTMENU_FOLDER
500
!insertmacro MUI_PAGE_INSTFILES
501
!insertmacro MUI_PAGE_FINISH
503
!insertmacro MUI_UNPAGE_CONFIRM
504
!insertmacro MUI_UNPAGE_INSTFILES
506
;--------------------------------
509
!insertmacro MUI_LANGUAGE "English"
511
;--------------------------------
514
Section "Dummy Section" SecDummy
516
SetOutPath "$INSTDIR"
518
;ADD YOUR OWN FILES HERE...
519
File /r ExampleFiles\150mols.smi
520
File /r ExampleFiles\FourSmallMols.cml
521
File /r ExampleFiles\serotonin.mol
522
File /r ExampleFiles\oxamide.cml
523
File /oname=License.txt ..\..\COPYING
524
File /oname=OBGUII.exe ..\OpenBabelDLL\OBGUII.exe
525
File /oname=OBGUII.exe.manifest ..\OpenBabelDLL\OBGUII.exe.manifest
526
File ..\OpenBabelDLL\OpenBabelDLL.dll
527
File ..\OpenBabelDLL\babel.exe
528
File ..\OBGUII\OpenBabelGUI.html
533
File ..\..\data\SMARTS_InteLigand.txt
534
File ..\..\data\psa.txt
535
File ..\..\data\mr.txt
536
File ..\..\data\logp.txt
537
File ..\..\data\ghemical.prm
538
File ..\..\data\mmffang.par
539
File ..\..\data\mmffbndk.par
540
File ..\..\data\mmffbond.par
541
File ..\..\data\mmffchg.par
542
File ..\..\data\mmffdef.par
543
File ..\..\data\mmffdfsb.par
544
File ..\..\data\mmffoop.par
545
File ..\..\data\mmffpbci.par
546
File ..\..\data\mmffprop.par
547
File ..\..\data\mmffstbn.par
548
File ..\..\data\mmfftor.par
549
File ..\..\data\mmffvdw.par
550
File ..\..\data\fragments.txt
551
File ..\..\data\plugindefines.txt
552
File ..\..\data\space-groups.txt
553
File ..\..\data\space-groups.xsl
554
File ..\..\data\ringtyp.txt
555
File ..\..\data\UFF.prm
556
File vcredist_x86.exe
558
;Store installation folder
559
WriteRegStr HKCU "Software\OpenBabel ${OBVERSION}" "" $INSTDIR
561
;Install VC++ 2005 redistributable
562
ExecWait '"$INSTDIR/vcredist_x86.exe" /q:a'
565
WriteUninstaller "$INSTDIR\Uninstall.exe"
568
!insertmacro MUI_STARTMENU_WRITE_BEGIN Application
569
SetOutPath "$DESKTOP" ;side-effect is to set working dir for shortcuts
570
CreateDirectory "$SMPROGRAMS\$STARTMENU_FOLDER"
571
CreateShortCut "$SMPROGRAMS\$STARTMENU_FOLDER\Open Babel GUI.lnk" "$INSTDIR\OBGUII.exe"
572
CreateShortCut "$SMPROGRAMS\$STARTMENU_FOLDER\Guide to using Open Babel GUI (web).lnk" "http://openbabel.sourceforge.net/wiki/OpenBabelGUI" "" "$SYSDIR\winhlp32.exe"
573
CreateShortCut "$SMPROGRAMS\$STARTMENU_FOLDER\Guide to using babel (web).lnk" "http://openbabel.sourceforge.net/wiki/Tutorial:Basic_Usage" "" "$SYSDIR\winhlp32.exe"
574
CreateShortCut "$SMPROGRAMS\$STARTMENU_FOLDER\Uninstall.lnk" "$INSTDIR\Uninstall.exe"
575
!insertmacro MUI_STARTMENU_WRITE_END
583
;--------------------------------
587
LangString DESC_SecDummy ${LANG_ENGLISH} "A test section."
589
;Assign language strings to sections
590
!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
591
!insertmacro MUI_DESCRIPTION_TEXT ${SecDummy} $(DESC_SecDummy)
592
!insertmacro MUI_FUNCTION_DESCRIPTION_END
594
;--------------------------------
599
;ADD YOUR OWN FILES HERE...
600
Delete "$INSTDIR\150mols.smi"
601
Delete "$INSTDIR\babel.exe"
602
Delete "$INSTDIR\FourSmallMols.cml"
603
Delete "$INSTDIR\zlib1.dll"
604
Delete "$INSTDIR\SMARTS_InteLigand.txt"
605
Delete "$INSTDIR\psa.txt"
606
Delete "$INSTDIR\mr.txt"
607
Delete "$INSTDIR\logp.txt"
608
Delete "$INSTDIR\ghemical.prm"
609
Delete "$INSTDIR\serotonin.mol"
610
Delete "$INSTDIR\oxamide.cml"
611
Delete "$INSTDIR\OBGUII.exe"
612
Delete "$INSTDIR\OBGUII.exe.manifest"
613
Delete "$INSTDIR\OpenBabelDLL.dll"
614
Delete "$INSTDIR\libxml2.dll"
615
Delete "$INSTDIR\iconv.dll"
616
Delete "$INSTDIR\License.txt"
617
Delete "$INSTDIR\OpenBabelGUI.html"
618
Delete "$INSTDIR\libinchi.dll"
619
Delete "$INSTDIR\Uninstall.exe"
620
Delete "$INSTDIR\vcredist_x86.exe"
623
!insertmacro MUI_STARTMENU_GETFOLDER Application $MUI_TEMP
625
Delete "$SMPROGRAMS\$MUI_TEMP\Uninstall.lnk"
626
Delete "$SMPROGRAMS\$MUI_TEMP\Open Babel GUI.lnk"
627
Delete "$SMPROGRAMS\$MUI_TEMP\Guide to using Open Babel GUI (web).lnk"
628
Delete "$SMPROGRAMS\$MUI_TEMP\Guide to using babel (web).lnk"
632
Call un.RemoveFromPath
634
;Delete empty start menu parent diretories
635
StrCpy $MUI_TEMP "$SMPROGRAMS\$MUI_TEMP"
640
GetFullPathName $MUI_TEMP "$MUI_TEMP\.."
642
IfErrors startMenuDeleteLoopDone
644
StrCmp $MUI_TEMP $SMPROGRAMS startMenuDeleteLoopDone startMenuDeleteLoop
645
startMenuDeleteLoopDone:
647
DeleteRegKey /ifempty HKCU "Software\OpenBabel ${OBVERSION}"
648
DeleteRegKey HKCU "Software\OpenBabelGUI"