## HEADER PART BEGINS HERE !define SF_USELECTED 0 #!define SF_SELECTED 1 #!define SF_SECGRP 2 #!define SF_BOLD 8 #!define SF_RO 16 #!define SF_EXPAND 32 ############################### !macro SecSelect SecId Push $0 ; IntOp $0 ${SF_SELECTED} | ${SF_RO} StrCpy $0 ${SF_SELECTED} SectionSetFlags ${SecId} $0 SectionSetInstTypes ${SecId} 1 Pop $0 !macroend !define SelectSection '!insertmacro SecSelect' ################################# !macro SecUnSelect SecId Push $0 StrCpy $0 ${SF_USELECTED} ; IntOp $0 ${SF_USELECTED} | ${SF_RO} SectionSetFlags ${SecId} $0 ; SectionSetText ${SecId} "" Pop $0 !macroend !define UnSelectSection '!insertmacro SecUnSelect' ################################### !macro SecExtract SecId Push $0 IntOp $0 ${SF_USELECTED} | ${SF_RO} SectionSetFlags ${SecId} $0 SectionSetInstTypes ${SecId} 2 Pop $0 !macroend !define SetSectionExtract '!insertmacro SecExtract' ################################### !macro Groups GroupId Push $0 SectionGetFlags ${GroupId} $0 IntOp $0 $0 | ${SF_RO} IntOp $0 $0 ^ ${SF_BOLD} IntOp $0 $0 ^ ${SF_EXPAND} SectionSetFlags ${GroupId} $0 Pop $0 !macroend !define SetSectionGroup "!insertmacro Groups" #################################### !macro GroupRO GroupId Push $0 IntOp $0 ${SF_SECGRP} | ${SF_RO} SectionSetFlags ${GroupId} $0 Pop $0 !macroend !define MakeGroupReadOnly '!insertmacro GroupRO' ; File association helper macros ; Written by Saivert ; http://nsis.sourceforge.net/FileAssoc ; ; Features automatic backup system and UPDATEFILEASSOC macro for ; shell change notification. ; ; |> How to use <| ; To associate a file with an application so you can double-click it in explorer, use ; the APP_ASSOCIATE macro like this: ; ; Example: ; !insertmacro APP_ASSOCIATE "txt" "myapp.textfile" "$INSTDIR\myapp.exe,0" \ ; "Open with myapp" "$INSTDIR\myapp.exe $\"%1$\"" ; ; Never insert the APP_ASSOCIATE macro multiple times, it is only ment ; to associate an application with a single file and using the ; the "open" verb as default. To add more verbs (actions) to a file ; use the APP_ASSOCIATE_ADDVERB macro. ; ; Example: ; !insertmacro APP_ASSOCIATE_ADDVERB "myapp.textfile" "edit" "Edit with myapp" \ ; "$INSTDIR\myapp.exe /edit $\"%1$\"" ; ; To have access to more options when registering the file association use the ; APP_ASSOCIATE_EX macro. Here you can specify the verb and what verb is to be the ; standard action (default verb). ; ; And finally: To remove the association from the registry use the APP_UNASSOCIATE ; macro. Here is another example just to wrap it up: ; !insertmacro APP_UNASSOCIATE "txt" "myapp.textfile" ; ; |> Note <| ; When defining your file class string always use the short form of your application title ; then a period (dot) and the type of file. This keeps the file class sort of unique. ; Examples: ; Winamp.Playlist ; NSIS.Script ; Photoshop.JPEGFile ; ; |> Tech info <| ; The registry key layout for a file association is: ; HKEY_CLASSES_ROOT ; = <"description"> ; shell ; = <"menu-item text"> ; command = <"command string"> ; !macro APP_ASSOCIATE EXT FILECLASS DESCRIPTION ICON COMMANDTEXT COMMAND ; Backup the previously associated file class ReadRegStr $R0 HKCR ".${EXT}" "" WriteRegStr HKCR ".${EXT}" "${FILECLASS}_backup" "$R0" WriteRegStr HKCR ".${EXT}" "" "${FILECLASS}" WriteRegStr HKCR "${FILECLASS}" "" `${DESCRIPTION}` WriteRegStr HKCR "${FILECLASS}\DefaultIcon" "" `${ICON}` WriteRegStr HKCR "${FILECLASS}\shell" "" "open" WriteRegStr HKCR "${FILECLASS}\shell\open" "" `${COMMANDTEXT}` WriteRegStr HKCR "${FILECLASS}\shell\open\command" "" `${COMMAND}` !macroend !macro APP_ASSOCIATE_EX EXT FILECLASS DESCRIPTION ICON VERB DEFAULTVERB SHELLNEW COMMANDTEXT COMMAND ; Backup the previously associated file class ReadRegStr $R0 HKCR ".${EXT}" "" WriteRegStr HKCR ".${EXT}" "${FILECLASS}_backup" "$R0" WriteRegStr HKCR ".${EXT}" "" "${FILECLASS}" StrCmp "${SHELLNEW}" "0" +2 WriteRegStr HKCR ".${EXT}\ShellNew" "NullFile" "" WriteRegStr HKCR "${FILECLASS}" "" `${DESCRIPTION}` WriteRegStr HKCR "${FILECLASS}\DefaultIcon" "" `${ICON}` WriteRegStr HKCR "${FILECLASS}\shell" "" `${DEFAULTVERB}` WriteRegStr HKCR "${FILECLASS}\shell\${VERB}" "" `${COMMANDTEXT}` WriteRegStr HKCR "${FILECLASS}\shell\${VERB}\command" "" `${COMMAND}` !macroend !macro APP_ASSOCIATE_ADDVERB FILECLASS VERB COMMANDTEXT COMMAND WriteRegStr HKCR "${FILECLASS}\shell\${VERB}" "" `${COMMANDTEXT}` WriteRegStr HKCR "${FILECLASS}\shell\${VERB}\command" "" `${COMMAND}` !macroend !macro APP_ASSOCIATE_REMOVEVERB FILECLASS VERB DeleteRegKey HKCR `${FILECLASS}\shell\${VERB}` !macroend !macro APP_UNASSOCIATE EXT FILECLASS ; Backup the previously associated file class ReadRegStr $R0 HKCR ".${EXT}" `${FILECLASS}_backup` WriteRegStr HKCR ".${EXT}" "" "$R0" DeleteRegKey HKCR `${FILECLASS}` !macroend !macro APP_ASSOCIATE_GETFILECLASS OUTPUT EXT ReadRegStr ${OUTPUT} HKCR ".${EXT}" "" !macroend ; !defines for use with SHChangeNotify !ifdef SHCNE_ASSOCCHANGED !undef SHCNE_ASSOCCHANGED !endif !define SHCNE_ASSOCCHANGED 0x08000000 !ifdef SHCNF_FLUSH !undef SHCNF_FLUSH !endif !define SHCNF_FLUSH 0x1000 !macro UPDATEFILEASSOC ; Using the system.dll plugin to call the SHChangeNotify Win32 API function so we ; can update the shell. System::Call "shell32::SHChangeNotify(i,i,i,i) (${SHCNE_ASSOCCHANGED}, ${SHCNF_FLUSH}, 0, 0)" !macroend Name "MV3D Dev Environment" OutFile "..\mv3d-dev-environment.exe" InstallDir C:\Projects InstallDirRegKey HKLM "Software\MV3D\DevEnv" "Install_Dir" RequestExecutionLevel admin !include "WinMessages.NSH" !include "LogicLib.NSH" !define BUILDFILES "f:\projects\mv3d\buildfiles" Var lib Var python Var pythonVersion Page license Page components Page directory Page instfiles UninstPage uninstConfirm UninstPage instfiles LicenseText "MV3D is released under the MIT License:" LicenseData "..\LICENSE" Function openLinkNewWindow Push $3 Exch Push $2 Exch Push $1 Exch Push $0 Exch ReadRegStr $0 HKCR "http\shell\open\command" "" # Get browser path DetailPrint $0 StrCpy $2 '"' StrCpy $1 $0 1 StrCmp $1 $2 +2 # if path is not enclosed in " look for space as final char StrCpy $2 ' ' StrCpy $3 1 loop: StrCpy $1 $0 1 $3 DetailPrint $1 StrCmp $1 $2 found StrCmp $1 "" found IntOp $3 $3 + 1 Goto loop found: StrCpy $1 $0 $3 StrCmp $2 " " +2 StrCpy $1 '$1"' Pop $0 Exec '$1 $0' Pop $0 Pop $1 Pop $2 Pop $3 FunctionEnd !macro _OpenURL URL Push "${URL}" Call openLinkNewWindow !macroend !define OpenURL '!insertmacro "_OpenURL"' Function checkModule Pop $0 nsExec::ExecToStack 'python.exe -c "import $0"' Pop $0 Pop $1 ${If} $0 == "0" Push "1" ${Else} Push "0" ${EndIf} FunctionEnd Function getPythonDirs # find python's lib dir nsExec::ExecToStack 'python.exe -c "import sys; print [path for path in sys.path if path.endswith(\"site-packages\")][0]"' Pop $0 Pop $1 ${If} $0 == "0" StrLen $2 $1 IntOp $2 $2 - 2 StrCpy $lib $1 $2 ${EndIf} # find python's exe path nsExec::ExecToStack 'python.exe -c "import sys; print sys.executable"' Pop $0 Pop $1 ${If} $0 == "0" StrLen $2 $1 IntOp $2 $2 - 2 StrCpy $python $1 $2 ${EndIf} FunctionEnd Section "Visual C++ Redistributable Install" MessageBox MB_OK "Next installing Visual C++ Redistributable. Please accept defaults and if it asks to reboot, do so and then re-run the MV3D installer." SetOutPath $TEMP File "${BUILDFILES}\vcredist_x86.exe" ExecWait "$TEMP\vcredist_x86.exe" SectionEnd Section "SVN Install" SetOutPath $TEMP File "${BUILDFILES}\Setup-Subversion-1.6.6.msi" ExecWait 'msiexec /i "$TEMP\Setup-Subversion-1.6.6.msi" /passive' SectionEnd Section "Panda3D Renderer" PANDA_SECTION SetOutPath $TEMP StrCpy $lib "C:\Panda3D-1.7.2\python\lib\site-packages" StrCpy $python "c:\Panda3D-1.7.2\python\python.exe" File "${BUILDFILES}\Panda3D-1.7.2.exe" File "${BUILDFILES}\Panda3D-Runtime-1.0.3.exe" ExecWait "$TEMP\Panda3D-1.7.2.exe" ExecWait "$TEMP\Panda3D-Runtime-1.0.3.exe" Call getPythonDirs !insertmacro APP_ASSOCIATE "py" "Python.File" "C:\Panda3D-1.7.2\python\python.exe,0" "open" "Open with Python" "C:\Panda3D-1.7.2\python\python.exe $\"%1$\" %*" SectionEnd SectionGroup "Ogre3D Renderer" OGRE_GROUP Section "Python Install" PYTHON_SECTION SetOutPath $TEMP StrCpy $lib "c:\python26\lib\site-packages" StrCpy $python "c:\python26\python.exe" File "${BUILDFILES}\python-2.6.6.msi" ExecWait 'msiexec /i "$TEMP\python-2.6.6.msi" /passive' Call getPythonDirs SectionEnd Section "Ogre Install" OGRE_SECTION SetOutPath $lib File /r "${BUILDFILES}\ogre\packages_2.6\*.*" CreateDirectory "c:\program files (x86)\PythonOgre\plugins" SetOutPath "c:\program files (x86)\PythonOgre\plugins" File /r "${BUILDFILES}\ogre\plugins\*.*" SectionEnd SectionGroupEnd SectionGroup "MV3D Prerequisites" Section "Zope" ZOPE_SECTION SectionIn RO SetOutPath $lib File /r "${BUILDFILES}\site-packages\*.*" SectionEnd Section "PIL" PIL_SECTION SectionIn RO MessageBox MB_OK "For the next several installers, please accept defaults." SetOutPath $TEMP File "${BUILDFILES}\PIL-1.1.7.win32-py2.6.exe" ExecWait "$TEMP\PIL-1.1.7.win32-py2.6.exe" SectionEnd Section "PyCrypto" PYCRYPTO_SECTION SectionIn RO SetOutPath $TEMP File "${BUILDFILES}\pycrypto-2.1.0.win32-py2.6.exe" ExecWait "$TEMP\pycrypto-2.1.0.win32-py2.6.exe" SectionEnd Section "PyODE" PYODE_SECTION SectionIn RO SetOutPath $TEMP File "${BUILDFILES}\PyODE-snapshot-2010-03-22.win32-py2.6.exe" ExecWait "$TEMP\PyODE-snapshot-2010-03-22.win32-py2.6.exe" ${If} $python == "c:\Panda3D-1.7.2\python\python.exe" CopyFiles "C:\Panda3D-1.7.2\python\ode.dll" "C:\Panda3D-1.7.2\bin" ${Endif} SectionEnd Section "pyOpenSSL" PYOPENSSL_SECTION SectionIn RO SetOutPath $TEMP File "${BUILDFILES}\pyOpenSSL-0.9.win32-py2.6.exe" ExecWait "$TEMP\pyOpenSSL-0.9.win32-py2.6.exe" File "${BUILDFILES}\Win32OpenSSL-0_9_8g.exe" ExecWait "$TEMP\Win32OpenSSL-0_9_8g.exe" SectionEnd Section "pysqlite" PYSQLITE_SECTION SectionIn RO SetOutPath $TEMP File "${BUILDFILES}\pysqlite-2.6.0.win32-py2.6.exe" ExecWait "$TEMP\pysqlite-2.6.0.win32-py2.6.exe" SectionEnd Section "pywin32" PYWIN32_SECTION SectionIn RO SetOutPath $TEMP File "${BUILDFILES}\pywin32-214.win32-py2.6.exe" ExecWait "$TEMP\pywin32-214.win32-py2.6.exe" SectionEnd Section "wxPython" WXPYTHON_SECTION SectionIn RO SetOutPath $TEMP File "${BUILDFILES}\wxPython2.8-win32-unicode-2.8.11.0-py26.exe" ExecWait "$TEMP\wxPython2.8-win32-unicode-2.8.11.0-py26.exe" SectionEnd Section "pyasn" PYASN_SECTION SectionIn RO SetOutPath $lib\pyasn1 File /r "${BUILDFILES}\pyasn1-0.0.9a\pyasn1\*.*" SectionEnd SectionGroupEnd Section "Combinator Install" SectionIn RO CreateDirectory "$INSTDIR\Divmod\trunk" SetOutPath $INSTDIR\Divmod\trunk File /r ${BUILDFILES}\divmod\*.* WriteRegExpandStr HKCU "Environment" "PYTHONPATH" "$INSTDIR\Divmod\trunk\Combinator" WriteRegExpandStr HKCU "Environment" "COMBINATOR_PATHS" "$INSTDIR\combinator_paths" WriteRegExpandStr HKCU "Environment" "COMBINATOR_PROJECTS" "$INSTDIR" StrLen $1 $python IntOp $1 $1 - 11 StrCpy $0 $python $1 WriteRegExpandStr HKCU "Environment" "PATH" "$0" SendMessage ${HWND_BROADCAST} ${WM_WININICHANGE} 0 "STR:Environment" /TIMEOUT=5000 SetOutPath $TEMP # set up combinator paths. System::Call 'Kernel32::SetEnvironmentVariableA(t, t) i("PYTHONPATH", "$INSTDIR\Divmod\trunk\Combinator").r0' System::Call 'Kernel32::SetEnvironmentVariableA(t, t) i("COMBINATOR_PATHS", "$INSTDIR\combinator_paths").r0' System::Call 'Kernel32::SetEnvironmentVariableA(t, t) i("COMBINATOR_PROJECTS", "$INSTDIR").r0' System::Call 'Kernel32::SetEnvironmentVariableA(t, t) i("PATH", "$0;C:\Program Files (x86)\Subversion\bin").r0' File "${BUILDFILES}\setupDivmod.bat" ExecWait '"$TEMP\setupDivmod.bat"' SectionEnd Section "Twisted" TWISTED_SECTION SectionIn RO # set up combinator paths. System::Call 'Kernel32::SetEnvironmentVariableA(t, t) i("PYTHONPATH", "$INSTDIR\Divmod\trunk\Combinator").r0' System::Call 'Kernel32::SetEnvironmentVariableA(t, t) i("COMBINATOR_PATHS", "$INSTDIR\combinator_paths").r0' System::Call 'Kernel32::SetEnvironmentVariableA(t, t) i("COMBINATOR_PROJECTS", "$INSTDIR").r0' StrLen $1 $python IntOp $1 $1 - 11 StrCpy $0 $python $1 WriteRegExpandStr HKCU "Environment" "PATH" "$0" System::Call 'Kernel32::SetEnvironmentVariableA(t, t) i("PATH", "$0;C:\Program Files (x86)\Subversion\bin").r0' File "${BUILDFILES}\setupTwisted.bat" ExecWait '"$TEMP\setupTwisted.bat"' SectionEnd Section "MV3D Source" SectionIn RO # set up combinator paths. System::Call 'Kernel32::SetEnvironmentVariableA(t, t) i("PYTHONPATH", "$INSTDIR\Divmod\trunk\Combinator").r0' System::Call 'Kernel32::SetEnvironmentVariableA(t, t) i("COMBINATOR_PATHS", "$INSTDIR\combinator_paths").r0' System::Call 'Kernel32::SetEnvironmentVariableA(t, t) i("COMBINATOR_PROJECTS", "$INSTDIR").r0' StrLen $1 $python IntOp $1 $1 - 11 StrCpy $0 $python $1 WriteRegExpandStr HKCU "Environment" "PATH" "$0" System::Call 'Kernel32::SetEnvironmentVariableA(t, t) i("PATH", "$0;C:\Program Files (x86)\Subversion\bin").r0' File "${BUILDFILES}\setupMV3D.bat" ExecWait '"$TEMP\setupMV3D.bat"' ; Write the installation path into the registry WriteRegStr HKLM SOFTWARE\MV3D\DevEnv "Install_Dir" "$INSTDIR" ; Write the uninstall keys for Windows WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\MV3D_DevEnv" "DisplayName" "MV3D Dev Environment" WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\MV3D_DevEnv" "UninstallString" '"$INSTDIR\uninstall.exe"' WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\MV3D_DevEnv" "NoModify" 1 WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\MV3D_DevEnv" "NoRepair" 1 WriteUninstaller "uninstall.exe" SectionEnd Section "Start Menu Shortcuts" CreateDirectory "$SMPROGRAMS\MV3D\Dev" CreateShortCut "$SMPROGRAMS\MV3D\Client\DivCmd.lnk" "$INSTDIR\Divmod\trunk\Combinator\divcmd.bat" SetOutPath "$SMPROGRAMS\MV3D\Dev" File "${BUILDFILES}\RunClient.bat" File "${BUILDFILES}\RunComposer.bat" File "${BUILDFILES}\RunOverseer.bat" SectionEnd Section "Desktop Shortcuts" CreateShortCut "$DESKTOP\DivCmd.lnk" "$INSTDIR\Divmod\trunk\Combinator\divcmd.bat" SectionEnd Section "DirectX Install" SetOutPath $TEMP File "${BUILDFILES}\dxwebsetup.exe" ExecWait "$TEMP\dxwebsetup.exe" SectionEnd Section "Next Steps" ${OpenURL} "http://www.mv3d.com/trac/wiki/DevEnvironmentUse" SectionEnd Function .onInit StrCpy $pythonVersion "None" nsExec::ExecToStack 'python.exe -c "import platform; print platform.python_version()"' Pop $0 Pop $1 ${If} $0 == "0" StrCpy $pythonVersion $1 3 ${EndIf} ${If} $pythonVersion == "2.6" ${UnSelectSection} ${PYTHON_SECTION} # check prereqs Push "zope.interface" Call checkModule Pop $0 ${If} $0 == "1" ${UnSelectSection} ${ZOPE_SECTION} ${EndIf} Push "twisted" Call checkModule Pop $0 ${If} $0 == "1" ${UnSelectSection} ${TWISTED_SECTION} ${EndIf} Push "Image" Call checkModule Pop $0 ${If} $0 == "1" ${UnSelectSection} ${PIL_SECTION} ${EndIf} Push "Crypto" Call checkModule Pop $0 ${If} $0 == "1" ${UnSelectSection} ${PYCrypto_SECTION} ${EndIf} Push "ode" Call checkModule Pop $0 ${If} $0 == "1" ${UnSelectSection} ${PYODE_SECTION} ${EndIf} Push "OpenSSL" Call checkModule Pop $0 ${If} $0 == "1" ${UnSelectSection} ${PYOpenSSL_SECTION} ${EndIf} Push "sqlite3" Call checkModule Pop $0 ${If} $0 == "1" ${UnSelectSection} ${PYSQLITE_SECTION} ${EndIf} Push "pywin" Call checkModule Pop $0 ${If} $0 == "1" ${UnSelectSection} ${PYWIN32_SECTION} ${EndIf} Push "wx" Call checkModule Pop $0 ${If} $0 == "1" ${UnSelectSection} ${WXPYTHON_SECTION} ${EndIf} Push "pyasn1" Call checkModule Pop $0 ${If} $0 == "1" ${UnSelectSection} ${PYASN_SECTION} ${EndIf} Call getPythonDirs ${ElseIfNot} $pythonVersion == "None" MessageBox MB_OKCANCEL "You've got Python $pythonVersion installed. This installer requires 2.6. Your old installation will be intact but will not be active." IDOK isOk IDCANCEL cancel cancel: ABORT isOk: ${EndIf} # Turn off panda by default ${UnSelectSection} ${PANDA_SECTION} FunctionEnd Function .onSelChange # make sure both Python and Panda aren't being installed. SectionGetFlags ${PYTHON_SECTION} $0 IntOp $0 $0 & ${SF_SELECTED} SectionGetFlags ${OGRE_SECTION} $1 IntOp $1 $1 & ${SF_SELECTED} SectionGetFlags ${PANDA_SECTION} $2 IntOp $2 $2 & ${SF_SELECTED} ${If} $0 == ${SF_SELECTED} # python will be installed. ${If} $2 == ${SF_SELECTED} MessageBox MB_OK "You must select either Panda or Ogre but not both." ${EndIf} ${SelectSection} ${OGRE_SECTION} ${UnSelectSection} ${PANDA_SECTION} ${ElseIf} $1 == ${SF_SELECTED} # ogre will be installed. ${If} $2 == ${SF_SELECTED} MessageBox MB_OK "You must select either Panda or Ogre but not both." ${EndIf} ${SelectSection} ${PYTHON_SECTION} ${UnSelectSection} ${PANDA_SECTION} ${ElseIf} $2 == ${SF_SELECTED} # panda will be installed. ${If} $0 == ${SF_SELECTED} MessageBox MB_OK "You must select either Panda or Ogre but not both." ${EndIf} ${If} $1 == ${SF_SELECTED} MessageBox MB_OK "You must select either Panda or Ogre but not both." ${EndIf} ${UnSelectSection} ${OGRE_SECTION} ${UnSelectSection} ${PYTHON_SECTION} ${EndIf} FunctionEnd ;-------------------------------- ; Uninstaller Section "Uninstall" ; Remove registry keys DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\MV3D_DevEnv" DeleteRegKey HKLM SOFTWARE\MV3D\DevEnv DeleteRegKey HKCU "Environment\PYTHONPATH" DeleteRegKey HKCU "Environment\COMBINATOR_PATHS" DeleteRegKey HKCU "Environment\COMBINATOR_PROJECTS" ; Remove files and uninstaller Delete $INSTDIR\*.* ; Remove shortcuts, if any Delete "$SMPROGRAMS\MV3D\Dev\*.*" ; Remove directories used ;RMDir "$SMPROGRAMS\MV3D\Client" RMDir "$INSTDIR" SectionEnd