; CCS Computer Science ; Password Daemon Installer ; ; Douglas Thrift ; ; $Id$ !ifndef PASSWDD_VERSION !error "PASSWDD_VERSION must be defined" !endif !define PASSWDD_NAME "CCS CS Password Daemon" InstallDir "$PROGRAMFILES64\${PASSWDD_NAME}" Name "${PASSWDD_NAME}" OutFile "passwdd-${PASSWDD_VERSION}.exe" SetCompressor /SOLID lzma ShowInstDetails show ShowUninstDetails show XPStyle on RequestExecutionLevel admin !define PASSWDD "${PASSWDD_NAME} ${PASSWDD_VERSION}" !define UNINST_REG "Software\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" !define UNINST_EXE "passwdd-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 "win32net" !define WIN32_X86_EXE "pywin32-216.win32-py2.7.exe" !define WIN32_X64_EXE "pywin32-216.win-amd64-py2.7.exe" !define M2CRYPTO_MOD "M2Crypto" !define M2CRYPTO_X86_EXE "M2Crypto-0.21.1.win32-py2.7.exe" !define M2CRYPTO_X64_EXE "M2Crypto-0.21.1.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 ${PASSWDD_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 m2crypto Push "${WIN32_X86_EXE}" Push "${WIN32_X64_EXE}" Call InstallExe Goto pywin32 m2crypto: Push "${M2CRYPTO_MOD}" Call PythonModule IfErrors 0 +5 Push "${M2CRYPTO_X86_EXE}" Push "${M2CRYPTO_X64_EXE}" Call InstallExe Goto m2crypto SectionEnd Section "$(^Name)" SetOutPath "$INSTDIR" WriteUninstaller "${UNINST_EXE}" WriteRegStr HKLM "${UNINST_REG}" "DisplayName" "${PASSWDD}" WriteRegStr HKLM "${UNINST_REG}" "DisplayVersion" "${PASSWDD_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/passwd" WriteRegStr HKLM "${UNINST_REG}" "UninstallString" "$INSTDIR\${UNINST_EXE}" WriteRegDWORD HKLM "${UNINST_REG}" "NoModify" 1 WriteRegDWORD HKLM "${UNINST_REG}" "NoRepair" 1 File "ccscert.crt" File "common.py" File "passwdd.py" ExecWait '$pythonw "$python\Lib\compileall.py" -l .' ExecWait '"$python\python.exe" passwdd.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 "passwdd.py" stop' ExecWait '$pythonw "passwdd.py" remove' SetOutPath "$PROGRAMFILES64" Delete /REBOOTOK "$INSTDIR\common.py*" Delete /REBOOTOK "$INSTDIR\passwdd.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 passwdd.py start' FunctionEnd # vim: autoindent