;;------------------------------------------------------------------------------- ; NULLSOFT NSIS 2.0 installation system ; ; (c) 2003 by Chris Möser alias JOKER from http://localfoo.net ; mailto:joker@localfoo.net ; ; several parts of that script are written by Joost Verburg ; taken form InstallOptions Example Script ;;------------------------------------------------------------------------------- !define MUI_PRODUCT "TSW" !define MUI_VERSION "0.01" !include "MUI.nsh" !define TEMP $R0 ;;-------------------------------- ;; [GLOBAL CONFIGURATION-SETTINGS] ; Name of output file OutFile "TSW-${MUI_VERSION}.exe" ; Set installation directory: InstallDir InstallDir "$PROGRAMFILES\${MUI_PRODUCT}" ; Remember install folder InstallDirRegKey HKCU "Software\${MUI_PRODUCT}" "" ; CRCCheck on/off CRCCheck On ; Set output compression to bzip2 SetCompressor bzip2 ; Show installation details [show/hide] ShowInstDetails hide ; Show un-install details [show/hide] ShowUninstDetails show ;;-------------------------------- ;; [INSTALLER STYLE] !define MUI_ICON "${NSISDIR}\Contrib\Icons\adni18-installer-B.ico" !define MUI_UNICON "${NSISDIR}\Contrib\Icons\adni18-uninstall-B.ico" !define MUI_SPECIALBITMAP "${NSISDIR}\Contrib\Icons\modern-wizard llama.bmp" ;;-------------------------------- ;; [MODERN UI CONFIGURATION] ; To swap every simple page to a specific language, the ; MUI_CUSTOMPAGECOMMANDS are definied first ; Therfore the 'new' directives need to be called with ; MUI_PAGECOMMAND_... (as follows later) !define MUI_CUSTOMPAGECOMMANDS !define MUI_WELCOMEPAGE !define MUI_LICENSEPAGE !define MUI_COMPONENTSPAGE !define MUI_DIRECTORYPAGE !define MUI_ABORTWARNING !define MUI_UNINSTALLER !define MUI_UNCONFIRMPAGE !insertmacro MUI_INTERFACE ;;-------------------------------- ;; [NEW DEFINED PAGES] !insertmacro MUI_PAGECOMMAND_WELCOME !insertmacro MUI_PAGECOMMAND_LICENSE !insertmacro MUI_PAGECOMMAND_COMPONENTS Page custom SetCustomA "$(TEXT_IO_PAGETITLE_A)" Page custom SetCustomB "$(TEXT_IO_PAGETITLE_B)" Page custom SetCustomC "$(TEXT_IO_PAGETITLE_C)" !insertmacro MUI_PAGECOMMAND_DIRECTORY !insertmacro MUI_PAGECOMMAND_INSTFILES ;;-------------------------------- ;; [LANGUAGES] ;german language definition !insertmacro MUI_LANGUAGE "German" !include "tsw_german.nsh" ;english language definition !insertmacro MUI_LANGUAGE "English" !include "tsw_english.nsh" ;;-------------------------------- ;; [LANGUAGE STRINGS ARE OUTSOURCED TO tsw_language.nsh] ;;-------------------------------- ;; [LICENSE INFORMATIONS ARE OUTSOURCED TO tsw_languag.nsh] ;;-------------------------------- ;; [RESERVE FILES] ;Things that need to be extracted on first (keep these lines before any File command!) ;Only useful for BZIP2 compression ;First load corresponding languages.... !insertmacro MUI_RESERVEFILE_LANGDLL ReserveFile "ioA.ini" ReserveFile "ioB.ini" ReserveFile "ioC.ini" !insertmacro MUI_RESERVEFILE_INSTALLOPTIONS ;-------------------------------- ;Installer Sections Section "modern.exe" SecCopyUI ;Add your stuff here SetOutPath "$INSTDIR" File "${NSISDIR}\Contrib\UIs\modern.exe" ;Store install folder WriteRegStr HKCU "Software\${MUI_PRODUCT}" "" $INSTDIR ;Read a value from an InstallOptions INI File !insertmacro MUI_INSTALLOPTIONS_READ ${TEMP} "ioC.ini" "Field 2" "State" StrCmp ${TEMP} "1" "" +2 ;Checked MessageBox MB_OK "A MessageBox..." ;Create uninstaller WriteUninstaller "$INSTDIR\Uninstall.exe" SectionEnd Section "modern2.exe" SecCopyUI2 # ----------------------------------------------------------------------- # Global options for MySQL defined in 'my.ini' SetOutPath "$INSTDIR" File "${NSISDIR}\Contrib\UIs\modern.exe" # Add some more definitions # ----------------------------------------------------------------------- # if mysqld.exe is checked, install my.mysqld.ini # the RadioButton for mysqld.exe is defined in ioA.ini [Field 3] !insertmacro MUI_INSTALLOPTIONS_READ $R0 "ioA.ini" "Field 3" "State" StrCmp $R0 1 "" noOption1 ;check whether the option is selected SetOutPath "$INSTDIR" File "my.mysqld.ini" # ----------------------------------------------------------------------- # This function searches in my-mysqld.ini for several strings # ++basedir++; ++datadir++; ++language++; ++Server++ and replaces them # with installation-path specific strings ClearErrors FileOpen $0 "$INSTDIR\my.mysqld.ini" "r" GetTempFileName $R0 FileOpen $1 $R0 "w" loop: FileRead $0 $2 IfErrors done StrCmp $2 "++basedir++$\r$\n" 0 +3 FileWrite $1 "basedir=$INSTDIR$\r$\n" Goto loop StrCmp $2 "++datadir++$\r$\n" 0 +3 FileWrite $1 "datadir=$INSTDIR\data$\r$\n" Goto loop StrCmp $2 "++language++$\r$\n" 0 +3 FileWrite $1 "#language=$INSTDIR\share\your language$\r$\n" Goto loop StrCmp $2 "++Server++$\r$\n" 0 +3 FileWrite $1 "Server=$INSTDIR\bin\mysqld-nt.exe$\r$\n" Goto loop FileWrite $1 $2 Goto loop done: FileClose $0 FileClose $1 Delete "$INSTDIR\my.mysqld.ini" Rename $R0 "$INSTDIR\my.ini" noOption1: # if mysqld-opt.exe is checked, install my.mysqld-opt.ini # the RadioButton for mysqld-opt.exe is defined in ioA.ini [Field 4] !insertmacro MUI_INSTALLOPTIONS_READ $R0 "ioA.ini" "Field 4" "State" StrCmp $R0 1 "" noOption2 ;check whether the option is selected SetOutPath "$INSTDIR" File "my.mysqld-opt.ini" # ----------------------------------------------------------------------- # This function searches in my-mysqld-opt.ini for several strings # ++basedir++; ++datadir++; ++language++; ++Server++ and replaces them # with installation-path specific strings ClearErrors FileOpen $0 "$INSTDIR\my.mysqld-opt.ini" "r" GetTempFileName $R0 FileOpen $1 $R0 "w" loop2: FileRead $0 $2 IfErrors done2 StrCmp $2 "++basedir++$\r$\n" 0 +3 FileWrite $1 "basedir=$INSTDIR$\r$\n" Goto loop2 StrCmp $2 "++datadir++$\r$\n" 0 +3 FileWrite $1 "datadir=$INSTDIR\data$\r$\n" Goto loop2 StrCmp $2 "++language++$\r$\n" 0 +3 FileWrite $1 "#language=$INSTDIR\share\your language$\r$\n" Goto loop2 StrCmp $2 "++Server++$\r$\n" 0 +3 FileWrite $1 "Server=$INSTDIR\bin\mysqld-opt.exe$\r$\n" Goto loop2 FileWrite $1 $2 Goto loop2 done2: FileClose $0 FileClose $1 Delete "$INSTDIR\my.mysqld-opt.ini" Rename $R0 "$INSTDIR\my.ini" noOption2: # if mysqld-nt.exe is checked, install my.mysqld-nt.ini # the RadioButton for mysqld-nt.exe is defined in ioA.ini [Field 5] !insertmacro MUI_INSTALLOPTIONS_READ $R0 "ioA.ini" "Field 5" "State" StrCmp $R0 1 "" noOption3 ;check whether the option is selected SetOutPath "$INSTDIR" File "my.mysqld-nt.ini" ;;-------------------------------- ;; here we try to edit the some lines in that copied file ClearErrors FileOpen $0 "$INSTDIR\my.mysqld-nt.ini" "r" GetTempFileName $R0 FileOpen $1 $R0 "w" loop3: FileRead $0 $2 IfErrors done3 StrCmp $2 "++basedir++$\r$\n" 0 +3 FileWrite $1 "basedir=$INSTDIR$\r$\n" Goto loop3 StrCmp $2 "++datadir++$\r$\n" 0 +3 FileWrite $1 "datadir=$INSTDIR\data$\r$\n" Goto loop3 StrCmp $2 "++language++$\r$\n" 0 +3 FileWrite $1 "#language=$INSTDIR\share\your language$\r$\n" Goto loop3 StrCmp $2 "++Server++$\r$\n" 0 +3 FileWrite $1 "Server=$INSTDIR\bin\mysqld-nt.exe$\r$\n" Goto loop3 FileWrite $1 $2 Goto loop3 done3: FileClose $0 FileClose $1 Delete "$INSTDIR\my.mysqld-nt.ini" Rename $R0 "$INSTDIR\my.ini" noOption3: # if mysqld-max.exe is checked, install my.mysqld-max.ini # the RadioButton for mysqld-max.exe is defined in ioA.ini [Field 8] !insertmacro MUI_INSTALLOPTIONS_READ $R0 "ioA.ini" "Field 8" "State" StrCmp $R0 1 "" noOption4 ;check whether the option is selected SetOutPath "$INSTDIR" File "my.mysqld-max.ini" ;;-------------------------------- ;; here we try to edit the some lines in that copied file ClearErrors FileOpen $0 "$INSTDIR\my.mysqld-nt.ini" "r" GetTempFileName $R0 FileOpen $1 $R0 "w" loop4: FileRead $0 $2 IfErrors done4 StrCmp $2 "++basedir++$\r$\n" 0 +3 FileWrite $1 "basedir=$INSTDIR$\r$\n" Goto loop4 StrCmp $2 "++datadir++$\r$\n" 0 +3 FileWrite $1 "datadir=$INSTDIR\data$\r$\n" Goto loop4 StrCmp $2 "++language++$\r$\n" 0 +3 FileWrite $1 "#language=$INSTDIR\share\your language$\r$\n" Goto loop4 StrCmp $2 "++Server++$\r$\n" 0 +3 FileWrite $1 "Server=$INSTDIR\bin\mysqld-max.exe$\r$\n" Goto loop4 FileWrite $1 $2 Goto loop4 done4: FileClose $0 FileClose $1 Delete "$INSTDIR\my.mysqld-max.ini" Rename $R0 "$INSTDIR\my.ini" noOption4: # if mysqld-max-nt.exe is checked, install my.mysqld-max-nt.ini # the RadioButton for mysqld-max-nt.exe is defined in ioA.ini [Field 9] !insertmacro MUI_INSTALLOPTIONS_READ $R0 "ioA.ini" "Field 9" "State" StrCmp $R0 1 "" noOption5 ;check whether the option is selected SetOutPath "$INSTDIR" File "my.mysqld-max-nt.ini" ;;-------------------------------- ;; here we try to edit the some lines in that copied file ClearErrors FileOpen $0 "$INSTDIR\my.mysqld-max-nt.ini" "r" GetTempFileName $R0 FileOpen $1 $R0 "w" loop5: FileRead $0 $2 IfErrors done5 StrCmp $2 "++basedir++$\r$\n" 0 +3 FileWrite $1 "basedir=$INSTDIR$\r$\n" Goto loop5 StrCmp $2 "++datadir++$\r$\n" 0 +3 FileWrite $1 "datadir=$INSTDIR\data$\r$\n" Goto loop5 StrCmp $2 "++language++$\r$\n" 0 +3 FileWrite $1 "#language=$INSTDIR\share\your language$\r$\n" Goto loop5 StrCmp $2 "++Server++$\r$\n" 0 +3 FileWrite $1 "Server=$INSTDIR\bin\mysqld-max-nt.exe$\r$\n" Goto loop5 FileWrite $1 $2 Goto loop5 done5: FileClose $0 FileClose $1 Delete "$INSTDIR\my.mysqld-max-nt.ini" Rename $R0 "$INSTDIR\my.ini" noOption5: SectionEnd ;-------------------------------- ;Descriptions !insertmacro MUI_FUNCTIONS_DESCRIPTION_BEGIN !insertmacro MUI_DESCRIPTION_TEXT ${SecCopyUI} $(DESC_SecCopyUI) !insertmacro MUI_DESCRIPTION_TEXT ${SecCopyUI2} $(DESC_SecCopyUI2) !insertmacro MUI_FUNCTIONS_DESCRIPTION_END ;-------------------------------- ;Installer Functions Function .onInit ;Display the language selection !insertmacro MUI_LANGDLL_DISPLAY ;Extract InstallOptions INI Files ;This has to be extracted first!!! !insertmacro MUI_INSTALLOPTIONS_EXTRACT "ioA.ini" !insertmacro MUI_INSTALLOPTIONS_EXTRACT "ioB.ini" !insertmacro MUI_INSTALLOPTIONS_EXTRACT "ioC.ini" !insertmacro MUI_INSTALLOPTIONS_EXTRACT "ioD.ini" FunctionEnd Function SetCustomA !insertmacro MUI_HEADER_TEXT "$(TEXT_IO_TITLE_A)" "$(TEXT_IO_SUBTITLE_A)" !insertmacro MUI_INSTALLOPTIONS_DISPLAY "ioA.ini" FunctionEnd Function SetCustomB !insertmacro MUI_HEADER_TEXT "$(TEXT_IO_TITLE_B)" "$(TEXT_IO_SUBTITLE_B)" !insertmacro MUI_INSTALLOPTIONS_DISPLAY "ioB.ini" FunctionEnd Function SetCustomC !insertmacro MUI_HEADER_TEXT "$(TEXT_IO_TITLE_C)" "$(TEXT_IO_SUBTITLE_C)" !insertmacro MUI_INSTALLOPTIONS_DISPLAY "ioC.ini" FunctionEnd ;-------------------------------- ;Uninstaller Section Section "Uninstall" ;Add your stuff here Delete "$INSTDIR\modern.exe" Delete "$INSTDIR\modern2.exe" Delete "$INSTDIR\mysqld-nt.exe" Delete "$INSTDIR\mysqld-opt.exe" Delete "$INSTDIR\mysqld-max-nt.exe" Delete "$INSTDIR\Uninstall.exe" ; if still existing delete these files... Delete "$INSTDIR\my.mysqld.ini" Delete "$INSTDIR\my.mysqld-nt.ini" Delete "$INSTDIR\my.mysqld-opt.ini" Delete "$INSTDIR\my.mysqld-max.ini" Delete "$INSTDIR\my.mysqld-max-nt.ini" ; When script is finished (and fully functional, ; this file should not be deleted... Delete "$INSTDIR\my.ini" RMDir "$INSTDIR" DeleteRegKey /ifempty HKCU "Software\${MUI_PRODUCT}" SectionEnd