; CCS Computer Science ; Webcam Daemon Installer ; ; Douglas Thrift ; ; $Id$ !ifndef WEBCAM_VERSION !error "WEBCAM_VERSION must be defined" !endif !define WEBCAM_NAME "CCS CS Webcam Daemon" InstallDir "$PROGRAMFILES64\${WEBCAM_NAME}" Name "${WEBCAM_NAME}" OutFile "webcam-${WEBCAM_VERSION}.exe" SetCompressor /SOLID lzma ShowInstDetails show ShowUninstDetails show XPStyle on RequestExecutionLevel admin !define WEBCAM "${WEBCAM_NAME} ${WEBCAM_VERSION}" !define UNINST_REG "Software\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" !define UNINST_EXE "webcam-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 "win32service" !define WIN32_X86_EXE "pywin32-216.win32-py2.7.exe" !define WIN32_X64_EXE "pywin32-216.win-amd64-py2.7.exe" !define PIL_MOD "PIL" !define PIL_X86_EXE "PIL-1.1.7.win32-py2.7.exe" !define PIL_X64_EXE "PIL-1.1.7.win-amd64-py2.7.exe" !define KEYRING_MOD "keyring" !define KEYRING_X86_EXE "keyring-0.5.1.win32-py2.7.exe" !define KEYRING_X64_EXE "keyring-0.5.1.win-amd64-py2.7.exe" !define PYCURL_MOD "pycurl" !define PYCURL_X86_EXE "pycurl-7.19.0.win32-py2.7.exe" !define PYCURL_X64_EXE "pycurl-7.19.0.win-amd64-py2.7.exe" !define WINDOWS_SHARE "\\zweihander\windows" !include "MUI2.nsh" !define MUI_FINISHPAGE_NOAUTOCLOSE !define MUI_FINISHPAGE_RUN !define MUI_FINISHPAGE_RUN_TEXT "Start ${WEBCAM_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 pil Push "${WIN32_X86_EXE}" Push "${WIN32_X64_EXE}" Call InstallExe Goto pywin32 pil: Push "${PIL_MOD}" Call PythonModule IfErrors 0 keyring Push "${PIL_X86_EXE}" Push "${PIL_X64_EXE}" Call InstallExe Goto pil keyring: Push "${KEYRING_MOD}" Call PythonModule IfErrors 0 pycurl Push "${KEYRING_X86_EXE}" Push "${KEYRING_X64_EXE}" Call InstallExe Goto keyring pycurl: Push "${PYCURL_MOD}" Call PythonModule IfErrors 0 +5 Push "${PYCURL_X86_EXE}" Push "${PYCURL_X64_EXE}" Call InstallExe Goto pycurl SectionEnd Section "$(^Name)" SetOutPath "$INSTDIR" WriteUninstaller "${UNINST_EXE}" WriteRegStr HKLM "${UNINST_REG}" "DisplayName" "${WEBCAM}" WriteRegStr HKLM "${UNINST_REG}" "DisplayVersion" "${WEBCAM_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 "cacert.crt" File "LGPL.txt" File "README.txt" File "vidcap.pyd" File "VideoCapture.py" File "webcam.py" ExecWait '$pythonw "$python\Lib\compileall.py" -l .' ExecWait '"$python\python.exe" webcam.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 "webcam.py" stop' ExecWait '$pythonw "webcam.py" remove' SetOutPath "$PROGRAMFILES64" Delete /REBOOTOK "$INSTDIR\cacert.crt" Delete /REBOOTOK "$INSTDIR\LGPL.txt" Delete /REBOOTOK "$INSTDIR\README.txt" Delete /REBOOTOK "$INSTDIR\vidcap.pyd" Delete /REBOOTOK "$INSTDIR\VideoCapture.py*" Delete /REBOOTOK "$INSTDIR\webcam.py*" 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 webcam.py start' FunctionEnd # vim: autoindent