; CCS Computer Science ; Finger Daemon Installer ; ; Douglas Thrift ; ; $Id$ !ifndef FINGERD_VERSION | BUILD_X86 | BUILD_X64 !error "FINGERD_VERSION, BUILD_X86, and BUILD_X64 must be defined" !endif !define FINGERD_NAME "CCS CS Finger Daemon" InstallDir "$PROGRAMFILES64\${FINGERD_NAME}" Name "${FINGERD_NAME}" OutFile "fingerd-${FINGERD_VERSION}.exe" SetCompressor /SOLID lzma ShowInstDetails show ShowUninstDetails show XPStyle on RequestExecutionLevel admin !define FINGERD "${FINGERD_NAME} ${FINGERD_VERSION}" !define UNINST_REG "Software\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" !define UNINST_EXE "fingerd-uninst.exe" !define PYTHON_REG "Software\Python\PythonCore\2.7\InstallPath" !define PYTHON_X86_MSI "ActivePython-2.7.1.4-win32-x86.msi" !define PYTHON_X64_MSI "ActivePython-2.7.1.4-win64-x64.msi" !define WIN32_MOD "win32ts" !define WIN32_X86_EXE "pywin32-216.win32-py2.7.exe" !define WIN32_X64_EXE "pywin32-216.win-amd64-py2.7.exe" !define PYTZ_MOD "pytz" !define PYTZ_X86_EXE "pytz-2011b.win32.exe" !define PYTZ_X64_EXE "pytz-2011b.win-amd64.exe" !define WINDOWS_SHARE "\\zweihander\windows" !include "MUI2.nsh" !define MUI_FINISHPAGE_NOAUTOCLOSE !define MUI_FINISHPAGE_RUN !define MUI_FINISHPAGE_RUN_TEXT "Start ${FINGERD_NAME}" !define MUI_FINISHPAGE_RUN_FUNCTION Run !define MUI_UNFINISHPAGE_NOAUTOCLOSE !insertmacro MUI_PAGE_WELCOME !insertmacro MUI_PAGE_DIRECTORY !insertmacro MUI_PAGE_INSTFILES !insertmacro MUI_PAGE_FINISH !insertmacro MUI_UNPAGE_WELCOME !insertmacro MUI_UNPAGE_CONFIRM !insertmacro MUI_UNPAGE_INSTFILES !insertmacro MUI_UNPAGE_FINISH !insertmacro MUI_LANGUAGE "English" !include "WordFunc.nsh" !insertmacro WordReplace !addplugindir plugins Var arch Var python Var pythonw Section "-Uninstall Previous" SetRegView 64 SetShellVarContext all ReadRegStr $0 HKLM "${UNINST_REG}" "UninstallString" ReadRegStr $1 HKLM "${UNINST_REG}" "InstallLocation" IfErrors 0 +2 Return ${WordReplace} "$0" '"' '' '{}' $0 CopyFiles /SILENT $0 "$TEMP\${UNINST_EXE}" ExecWait '"$TEMP\${UNINST_EXE}" /S _?=$1' Delete "$TEMP\${UNINST_EXE}" SectionEnd Section "Python Dependencies" Architecture::Get Pop $arch StrCmpS "$arch" "x86" python StrCmpS "$arch" "amd64" python Abort "Unsupported platform: $arch" python: ReadRegStr $python HKLM "${PYTHON_REG}" "" IfErrors 0 +5 Push "${PYTHON_X86_MSI}" Push "${PYTHON_X64_MSI}" Call InstallMSI Goto python StrLen $0 "$python" IntOp $0 $0 - 1 StrCpy $R0 "$python" 1 $0 StrCmp "$R0" "\" 0 +2 StrCpy $python "$python" $0 StrCpy $pythonw '"$python\pythonw.exe"' pywin32: Push "${WIN32_MOD}" Call PythonModule IfErrors 0 pytz Push "${WIN32_X86_EXE}" Push "${WIN32_X64_EXE}" Call InstallExe Goto pywin32 pytz: Push "${PYTZ_MOD}" Call PythonModule IfErrors 0 +5 Push "${PYTZ_X86_EXE}" Push "${PYTZ_X64_EXE}" Call InstallExe Goto pytz SectionEnd Section "$(^Name)" SetOutPath "$INSTDIR" WriteUninstaller "${UNINST_EXE}" WriteRegStr HKLM "${UNINST_REG}" "DisplayName" "${FINGERD}" WriteRegStr HKLM "${UNINST_REG}" "DisplayVersion" "${FINGERD_VERSION}" WriteRegStr HKLM "${UNINST_REG}" "InstallLocation" "$INSTDIR" WriteRegStr HKLM "${UNINST_REG}" "Publisher" "Douglas Thrift" WriteRegStr HKLM "${UNINST_REG}" "URLInfoAbout" "http://code.douglasthrift.net/trac/ccs/browser/finger" WriteRegStr HKLM "${UNINST_REG}" "UninstallString" "$INSTDIR\${UNINST_EXE}" WriteRegDWORD HKLM "${UNINST_REG}" "NoModify" 1 WriteRegDWORD HKLM "${UNINST_REG}" "NoRepair" 1 File "fingerd.py" StrCmpS "$arch" "x86" 0 +3 File "${BUILD_X86}\_win32net.pyd" Goto +2 File "${BUILD_X64}\_win32net.pyd" ExecWait '$pythonw "$python\Lib\compileall.py" -l .' ExecWait '"$python\python.exe" fingerd.py --startup auto --prompt install' SectionEnd Section "un.$(^Name)" SetRegView 64 SetShellVarContext all ReadRegStr $python HKLM "${PYTHON_REG}" "" IfErrors 0 +2 Abort "Python not installed." StrLen $0 "$python" IntOp $0 $0 - 1 StrCpy $R0 "$python" 1 $0 StrCmp "$R0" "\" 0 +2 StrCpy $python "$python" $0 StrCpy $pythonw '"$python\pythonw.exe"' SetOutPath "$INSTDIR" ExecWait '$pythonw "fingerd.py" stop' ExecWait '$pythonw "fingerd.py" remove' SetOutPath "$PROGRAMFILES64" Delete /REBOOTOK "$INSTDIR\fingerd.py*" Delete /REBOOTOK "$INSTDIR\_win32net.pyd" Delete /REBOOTOK "$INSTDIR\${UNINST_EXE}" RMDir /REBOOTOK "$INSTDIR" DeleteRegKey HKLM "${UNINST_REG}" SectionEnd Function Architecture StrCmpS "$arch" "amd64" 0 +2 Exch Pop $0 FunctionEnd Function InstallExe Call Architecture Pop $0 ExecWait '"${WINDOWS_SHARE}\$0"' $R0 IfErrors 0 +2 Abort "Failed to install $0." FunctionEnd Function InstallMSI Call Architecture Pop $0 ExecWait '"$SYSDIR\msiexec.exe" /i ${WINDOWS_SHARE}\$0' IfErrors 0 +2 Abort "Failed to install $0." FunctionEnd Function PythonModule Pop $0 ExecWait '$pythonw -c "import $0"' FunctionEnd Function Run Exec '$pythonw fingerd.py start' FunctionEnd # vim: autoindent