; Douglas Thrift's Search Engine NSIS Installer Script ; ; Douglas Thrift ; ; $Id$ !include "MUI.nsh" !ifndef DTSE_VERSION | DTSE_MAJOR | DTSE_MINOR !error "DTSE_VERSION, DTSE_MAJOR, and DTSE_MINOR must be defined" !endif !define DTSE "Douglas Thrift's Search Engine" !define DTSE_UNINST_REG \ "Software\Microsoft\Windows\CurrentVersion\Uninstall\${DTSE}" InstallDir "$PROGRAMFILES\${DTSE}" !ifdef DTSE_MINGW & DTSE_OPENSSL Name "${DTSE} ${DTSE_VERSION} MinGW OpenSSL" OutFile "dtse-${DTSE_VERSION}-mingw-openssl-win32.exe" !else ifdef DTSE_MINGW Name "${DTSE} ${DTSE_VERSION} MinGW" OutFile "dtse-${DTSE_VERSION}-mingw-win32.exe" !else ifdef DTSE_OPENSSL Name "${DTSE} ${DTSE_VERSION} OpenSSL" OutFile "dtse-${DTSE_VERSION}-openssl-win32.exe" !else Name "${DTSE} ${DTSE_VERSION}" OutFile "dtse-${DTSE_VERSION}-win32.exe" !endif SetCompressor /SOLID lzma ShowInstDetails show ShowUninstDetails show ; Installer Settings !define MUI_HEADERIMAGE !define MUI_HEADERIMAGE_BITMAP dtse-header.bmp !define MUI_HEADERIMAGE_RIGHT !define MUI_WELCOMEFINISHPAGE_3LINES !define MUI_WELCOMEFINISHPAGE_BITMAP dtse-splash.bmp !define MUI_COMPONENTSPAGE_SMALLDESC !define MUI_FINISHPAGE_NOAUTOCLOSE !define MUI_FINISHPAGE_SHOWREADME "$INSTDIR\README.html" !define MUI_FINISHPAGE_SHOWREADME_NOTCHECKED !define MUI_FINISHPAGE_LINK \ "Douglas Thrift's Computers Website | Search Engine" !define MUI_FINISHPAGE_LINK_LOCATION \ "http://computers.douglasthrift.net/searchengine/" !define MUI_FINISHPAGE_NOREBOOTSUPPORT ; Uninstaller Settings !define MUI_UNWELCOMEFINISHPAGE_3LINES !define MUI_UNWELCOMEFINISHPAGE_BITMAP dtse-splash.bmp !define MUI_UNCOMPONENTSPAGE_SMALLDESC !define MUI_UNFINISHPAGE_NOAUTOCLOSE !define MUI_UNFINISHPAGE_NOREBOOTSUPPORT ; Installer Pages !insertmacro MUI_PAGE_WELCOME !insertmacro MUI_PAGE_LICENSE "LICENSE.rtf" !insertmacro MUI_PAGE_COMPONENTS !insertmacro MUI_PAGE_DIRECTORY !insertmacro MUI_PAGE_INSTFILES !insertmacro MUI_PAGE_FINISH ; Uninstaller Pages !insertmacro MUI_UNPAGE_WELCOME !insertmacro MUI_UNPAGE_CONFIRM !insertmacro MUI_UNPAGE_COMPONENTS !insertmacro MUI_UNPAGE_INSTFILES !insertmacro MUI_UNPAGE_FINISH !insertmacro MUI_LANGUAGE "English" Var perl Var nt Var root Var input Var output Var line Var prefix Section "Search Engine" SecSearch SectionIn 1 RO ; base SetOutPath "$INSTDIR" File "LICENSE" File "LICENSE.html" File "README" File "README.html" File "osi-certified-90x75.png" WriteUninstaller "$INSTDIR\uninst.exe" ; bin SetOutPath "$INSTDIR\bin" File "Search.exe" File "Search.ico" Call SearchPrompt ; http SetOutPath "$INSTDIR\http" File "search.cgi.in" Call Configure Delete "search.cgi.in" File "dtse_pb.png" ; data SetOutPath "$INSTDIR\data" ; start menu CreateDirectory "$SMPROGRAMS\${DTSE} ${DTSE_VERSION}" StrCmp "$nt" "true" winnt win9x winnt: CreateShortCut \ "$SMPROGRAMS\${DTSE} ${DTSE_VERSION}\Search Engine Prompt.lnk" \ "%ComSpec%" '/k "$INSTDIR\bin\SearchPrompt.cmd"' \ "$INSTDIR\bin\Search.ico" 0 "" "" \ "Command Prompt for configuring ${DTSE}" Goto next win9x: GetFullPathName /SHORT $0 "$INSTDIR" CreateShortCut \ "$SMPROGRAMS\${DTSE} ${DTSE_VERSION}\Search Engine Prompt.pif" \ "%ComSpec%" "/e:4096 /k $0\bin\SearchPrompt.bat" \ "$INSTDIR\bin\Search.ico" 0 "" "" \ "Search Engine Prompt" Goto next next: CreateShortCut "$SMPROGRAMS\${DTSE} ${DTSE_VERSION}\License.lnk" \ "$INSTDIR\LICENSE.html" "" "" "" "" "" "${DTSE} License" CreateShortCut "$SMPROGRAMS\${DTSE} ${DTSE_VERSION}\ReadMe.lnk" \ "$INSTDIR\README.html" "" "" "" "" "" "${DTSE} ReadMe" CreateShortCut "$SMPROGRAMS\${DTSE} ${DTSE_VERSION}\Uninstall.lnk" \ "$INSTDIR\uninst.exe" "" "" "" "" "" "Uninstall ${DTSE}" ; registry StrCmp $root "HKLM" hklm hkcu hklm: !ifdef DTSE_MINGW & DTSE_OPENSSL WriteRegStr HKLM "${DTSE_UNINST_REG}" "Comments" \ "Compiled with MinGW and OpenSSL." !else ifdef DTSE_MINGW WriteRegStr HKLM "${DTSE_UNINST_REG}" "Comments" "Compiled with MinGW." !else ifdef DTSE_OPENSSL WriteRegStr HKLM "${DTSE_UNINST_REG}" "Comments" \ "Compiled with OpenSSL." !endif WriteRegStr HKLM "${DTSE_UNINST_REG}" "Contact" "Douglas Thrift" WriteRegStr HKLM "${DTSE_UNINST_REG}" "DisplayIcon" \ "$INSTDIR\bin\Search.ico,0" WriteRegStr HKLM "${DTSE_UNINST_REG}" "DisplayName" \ "${DTSE} ${DTSE_VERSION}" WriteRegStr HKLM "${DTSE_UNINST_REG}" "DisplayVersion" \ "${DTSE_VERSION}" WriteRegStr HKLM "${DTSE_UNINST_REG}" "InstallLocation" "$INSTDIR" WriteRegDWORD HKLM "${DTSE_UNINST_REG}" "NoModify" 1 WriteRegDWORD HKLM "${DTSE_UNINST_REG}" "NoRepair" 1 WriteRegStr HKLM "${DTSE_UNINST_REG}" "Publisher" "DouglasThrift.net" WriteRegStr HKLM "${DTSE_UNINST_REG}" "Readme" "$INSTDIR\README.html" WriteRegStr HKLM "${DTSE_UNINST_REG}" "UninstallString" \ "$INSTDIR\uninst.exe" WriteRegStr HKLM "${DTSE_UNINST_REG}" "URLInfoAbout" \ "http://computers.douglasthrift.net/searchengine/" WriteRegDWORD HKLM "${DTSE_UNINST_REG}" "VersionMajor" ${DTSE_MAJOR} WriteRegDWORD HKLM "${DTSE_UNINST_REG}" "VersionMinor" ${DTSE_MINOR} Goto done hkcu: !ifdef DTSE_MINGW & DTSE_OPENSSL WriteRegStr HKCU "${DTSE_UNINST_REG}" "Comments" \ "Compiled with MinGW and OpenSSL." !else ifdef DTSE_MINGW WriteRegStr HKCU "${DTSE_UNINST_REG}" "Comments" "Compiled with MinGW." !else ifdef DTSE_OPENSSL WriteRegStr HKCU "${DTSE_UNINST_REG}" "Comments" \ "Compiled with OpenSSL." !endif WriteRegStr HKCU "${DTSE_UNINST_REG}" "Contact" "Douglas Thrift" WriteRegStr HKCU "${DTSE_UNINST_REG}" "DisplayIcon" \ "$INSTDIR\bin\Search.ico,0" WriteRegStr HKCU "${DTSE_UNINST_REG}" "DisplayName" \ "${DTSE} ${DTSE_VERSION}" WriteRegStr HKCU "${DTSE_UNINST_REG}" "DisplayVersion" \ "${DTSE_VERSION}" WriteRegStr HKCU "${DTSE_UNINST_REG}" "InstallLocation" "$INSTDIR" WriteRegDWORD HKCU "${DTSE_UNINST_REG}" "NoModify" 1 WriteRegDWORD HKCU "${DTSE_UNINST_REG}" "NoRepair" 1 WriteRegStr HKCU "${DTSE_UNINST_REG}" "Publisher" "DouglasThrift.net" WriteRegStr HKCU "${DTSE_UNINST_REG}" "Readme" "$INSTDIR\README.html" WriteRegStr HKCU "${DTSE_UNINST_REG}" "UninstallString" \ "$INSTDIR\uninst.exe" WriteRegStr HKCU "${DTSE_UNINST_REG}" "URLInfoAbout" \ "http://computers.douglasthrift.net/searchengine/" WriteRegDWORD HKCU "${DTSE_UNINST_REG}" "VersionMajor" ${DTSE_MAJOR} WriteRegDWORD HKCU "${DTSE_UNINST_REG}" "VersionMinor" ${DTSE_MINOR} Goto done done: SectionEnd Section "Template Files" SecTemplate ; data SetOutPath "$INSTDIR\data" File "header.html" File "body.html" File "footer.html" File "notfound.html" File "pages.html" SectionEnd Section "un.Search Engine" un.SecSearch SectionIn 1 RO ; base Delete "$INSTDIR\LICENSE" Delete "$INSTDIR\LICENSE.html" Delete "$INSTDIR\README" Delete "$INSTDIR\README.html" Delete "$INSTDIR\osi-certified-90x75.png" ; bin Delete "$INSTDIR\bin\Search.exe" Delete "$INSTDIR\bin\Search.ico" Delete "$INSTDIR\bin\SearchPrompt.cmd" Delete "$INSTDIR\bin\SearchPrompt.bat" RMDir "$INSTDIR\bin" ; http Delete "$INSTDIR\http\search.cgi" Delete "$INSTDIR\http\search.cgi.in" Delete "$INSTDIR\http\dtse_pb.png" Delete "$INSTDIR\http\Thumbs.db" RMDir "$INSTDIR\http" ; data RMDir "$INSTDIR\data" ; start menu Delete "$SMPROGRAMS\${DTSE} ${DTSE_VERSION}\Search Engine Prompt.lnk" Delete "$SMPROGRAMS\${DTSE} ${DTSE_VERSION}\Search Engine Prompt.pif" Delete "$SMPROGRAMS\${DTSE} ${DTSE_VERSION}\License.lnk" Delete "$SMPROGRAMS\${DTSE} ${DTSE_VERSION}\ReadMe.lnk" Delete "$SMPROGRAMS\${DTSE} ${DTSE_VERSION}\Uninstall.lnk" RMDir "$SMPROGRAMS\${DTSE} ${DTSE_VERSION}" ; registry StrCmp $root "HKLM" +1 +3 DeleteRegKey HKLM "${DTSE_UNINST_REG}" Goto +2 DeleteRegKey HKCU "${DTSE_UNINST_REG}" ; base Delete "$INSTDIR\uninst.exe" RMDir "$INSTDIR" SectionEnd Section "un.Template Files" un.SecTemplate ; data Delete "$INSTDIR\data\header.html" Delete "$INSTDIR\data\body.html" Delete "$INSTDIR\data\footer.html" Delete "$INSTDIR\data\notfound.html" Delete "$INSTDIR\data\pages.html" RMDIR "$INSTDIR\data" ; base RMDir "$INSTDIR" SectionEnd LangString DESC_SecSearch ${LANG_ENGLISH} \ "The core components of ${DTSE} ${DTSE_VERSION}." LangString DESC_SecTemplate ${LANG_ENGLISH} \ "The default template files for ${DTSE} ${DTSE_VERSION}." !insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN !insertmacro MUI_DESCRIPTION_TEXT ${SecSearch} $(DESC_SecSearch) !insertmacro MUI_DESCRIPTION_TEXT ${SecTemplate} $(DESC_SecTemplate) !insertmacro MUI_FUNCTION_DESCRIPTION_END !insertmacro MUI_UNFUNCTION_DESCRIPTION_BEGIN !insertmacro MUI_DESCRIPTION_TEXT ${un.SecSearch} $(DESC_SecSearch) !insertmacro MUI_DESCRIPTION_TEXT ${un.SecTemplate} $(DESC_SecTemplate) !insertmacro MUI_UNFUNCTION_DESCRIPTION_END Function .oninit DTUtil::GetArgs loop: Pop $0 IfErrors +4 StrCmp $0 "-perl" +1 loop Pop $perl IfErrors +1 next ReadRegStr $perl HKCU "Software\Perl" "BinDir" IfErrors machine next machine: ReadRegStr $perl HKLM "Software\Perl" "BinDir" IfErrors manual next manual: SearchPath $perl "perl.exe" IfErrors +1 next MessageBox MB_OK|MB_ICONEXCLAMATION "Perl is not installed." Quit next: !ifdef DTSE_OPENSSL !ifdef DTSE_MINGW SearchPath $0 "libssl32.dll" !else SearchPath $0 "ssleay32.dll" !endif IfErrors +3 SearchPath $0 "libeay32.dll" IfErrors +1 +3 MessageBox MB_OK|MB_ICONEXCLAMATION "OpenSSL is not installed." Quit !endif StrCpy $root "HKLM" DTUtil::CheckNT Pop $nt StrCmp "$nt" "true" multi done multi: WriteRegDWORD HKLM "" "cheese" 0 IfErrors +1 +3 StrCpy $root "HKCU" Goto done DeleteRegValue HKLM "" "cheese" SetShellVarContext all done: FunctionEnd Function un.oninit StrCpy $root "HKLM" DTUtil::CheckNT Pop $nt StrCmp "$nt" "true" multi done multi: WriteRegDWORD HKLM "" "cheese" 0 IfErrors +1 +3 StrCpy $root "HKCU" Goto done DeleteRegValue HKLM "" "cheese" SetShellVarContext all done: FunctionEnd Function SearchPrompt StrCmp "$nt" "true" winnt win9x winnt: DetailPrint "Write: SearchPrompt.cmd" FileOpen $output "SearchPrompt.cmd" "w" FileWrite $output "@echo off$\r$\n" FileWrite $output "path $INSTDIR\bin;%PATH%$\r$\n" FileWrite $output "prompt [Search$$SEngine]$$$$$$S$\r$\n" Goto done win9x: DetailPrint "Write: SearchPrompt.bat" FileOpen $output "SearchPrompt.bat" "w" GetFullPathName /SHORT $0 "$INSTDIR" FileWrite $output "@echo off$\r$\n" FileWrite $output "path $0\bin;%PATH%$\r$\n" FileWrite $output "prompt [Search Engine]$$$$ $$S$\r$\n" Goto done done: FileWrite $output "Search -help$\r$\n" FileClose $output FunctionEnd Function Configure DetailPrint "Perl: $perl" DetailPrint "Write: search.cgi" FileOpen $input "search.cgi.in" "r" FileOpen $output "search.cgi" "w" GetFullPathName /SHORT $prefix "$INSTDIR" Push "$prefix" Push "\" Push "/" Call StrReplace Pop $prefix read: FileRead $input $line IfErrors done write write: ; replace @which_perl@ Push "$line" Push "@which_perl@" Push "$perl" Call StrReplace Pop $line ; replace @prefix@ Push "$line" Push "@prefix@" Push "$prefix" Call StrReplace Pop $line ; replace @exec_prefix@ Push "$line" Push "@exec_prefix@" Push "$${prefix}" Call StrReplace Pop $line ; replace @bindir@ Push "$line" Push "@bindir@" Push "$${exec_prefix}/bin" Call StrReplace Pop $line ; replace @EXEEXT@ Push "$line" Push "@EXEEXT@" Push ".exe" Call StrReplace Pop $line FileWrite $output $line Goto read done: FileClose $input FileClose $output FunctionEnd Function StrReplace Exch $0 Exch Exch $1 Exch Exch 2 Exch $2 Push $3 Push $4 Push $5 Push $6 Push $7 Push $R0 Push $R1 Push $R2 StrCpy $3 "-1" StrCpy $5 "" StrLen $6 $1 StrLen $7 $0 Loop: IntOp $3 $3 + 1 StrCpy $4 $2 $6 $3 StrCmp $4 "" ExitLoop StrCmp $4 $1 Replace Goto Loop Replace: StrCpy $R0 $2 $3 IntOp $R2 $3 + $6 StrCpy $R1 $2 "" $R2 StrCpy $2 $R0$0$R1 IntOp $3 $3 + $7 Goto Loop ExitLoop: StrCpy $0 $2 Pop $R2 Pop $R1 Pop $R0 Pop $7 Pop $6 Pop $5 Pop $4 Pop $3 Pop $2 Pop $1 Exch $0 FunctionEnd