Simplified the ntreeUpdate function by getting rid of the dependency list and limitin...
[blender-staging.git] / release / windows / installer / 00.sconsblender.nsi
1 ;
2 ;
3 ; Blender Self-Installer for Windows (NSIS - http://nsis.sourceforge.net)
4 ;
5
6 SetCompressor /SOLID lzma
7
8 Name "Blender [VERSION]" 
9
10 RequestExecutionLevel admin
11
12 !include "MUI.nsh"
13 !include "WinVer.nsh"
14 !include "FileFunc.nsh"
15 !include "WordFunc.nsh"
16 !include "nsDialogs.nsh"
17 !include "x64.nsh"
18
19 !define MUI_ABORTWARNING
20
21 !define MUI_WELCOMEPAGE_TEXT  "This wizard will guide you through the installation of Blender. It is recommended that you close all other applications before starting Setup."
22 !define MUI_WELCOMEFINISHPAGE_BITMAP "[RELDIR]\01.installer.bmp"
23 !define MUI_HEADERIMAGE
24 !define MUI_HEADERIMAGE_BITMAP  "[RELDIR]\00.header.bmp"
25 !define MUI_COMPONENTSPAGE_SMALLDESC
26 !define MUI_FINISHPAGE_RUN "$INSTDIR\blender.exe"
27 !define MUI_CHECKBITMAP "[RELDIR]\00.checked.bmp"
28 !define MUI_UNWELCOMEFINISHPAGE_BITMAP "[RELDIR]\01.installer.bmp"
29
30 !insertmacro MUI_PAGE_WELCOME
31 !insertmacro MUI_PAGE_LICENSE "[DISTDIR]\Copyright.txt"
32 !insertmacro MUI_PAGE_COMPONENTS
33     
34 !insertmacro MUI_PAGE_DIRECTORY
35 !insertmacro MUI_PAGE_INSTFILES
36 !insertmacro MUI_PAGE_FINISH
37   
38 !insertmacro MUI_UNPAGE_WELCOME
39 UninstPage custom un.OptionalRemoveConfig un.OptionalRemoveConfigOnLeave
40 !insertmacro MUI_UNPAGE_CONFIRM
41 !insertmacro MUI_UNPAGE_INSTFILES
42 !insertmacro MUI_UNPAGE_FINISH
43
44 !insertmacro Locate
45 !insertmacro VersionCompare
46
47
48 Icon "[RELDIR]\00.installer.ico"
49 UninstallIcon "[RELDIR]\00.installer.ico"
50
51 ;--------------------------------
52 ;Languages
53  
54   !insertmacro MUI_LANGUAGE "English"
55     
56 ;--------------------------------
57 ;Language Strings
58
59   ;Description
60   LangString DESC_InstallFiles ${LANG_ENGLISH} "Copy all required files to the application folder."
61   LangString DESC_StartMenu ${LANG_ENGLISH} "Add shortcut items to the Start Menu. (Recommended)"
62   LangString DESC_DesktopShortcut ${LANG_ENGLISH} "Add a shortcut to Blender on your desktop."
63   LangString DESC_BlendRegister ${LANG_ENGLISH} "Blender can register itself with .blend files to allow double-clicking from Windows Explorer, etc."
64 ;--------------------------------
65 ;Data
66
67 Caption "Blender [VERSION] Installer"
68 OutFile "[DISTDIR]\..\blender-[VERSION]-windows[BITNESS].exe"
69 InstallDir $INSTDIR ; $INSTDIR is set inside .onInit
70 BrandingText "Blender Foundation | http://www.blender.org"
71 ComponentText "This will install Blender [VERSION] on your computer."
72
73 DirText "Use the field below to specify the folder where you want Blender to be copied to. To specify a different folder, type a new name or use the Browse button to select an existing folder."
74
75 SilentUnInstall normal
76
77 Var SHORTVERSION ; This is blender_version_decimal() from path_util.c
78 Var BLENDERCONFIG
79 Var REMOVECONFIG
80
81 ; Custom controls
82 Var HWND
83
84 Var HWND_KEEPCONFIG
85 Var HWND_REMOVECONFIG
86
87 Function .onInit
88   ClearErrors
89   StrCpy $SHORTVERSION "[SHORTVERSION]"
90
91   ${If} ${RunningX64}
92     ${If} "[BITNESS]" == "32"
93     ${OrIf} "[BITNESS]" == "-mingw"
94       StrCpy $INSTDIR "$PROGRAMFILES32\Blender Foundation\Blender" ; Can't use InstallDir inside Section
95     ${ElseIf} "[BITNESS]" == "64"
96       StrCpy $INSTDIR "$PROGRAMFILES64\Blender Foundation\Blender"
97     ${EndIf}
98   ${Else}
99     StrCpy $INSTDIR "$PROGRAMFILES\Blender Foundation\Blender"
100   ${EndIf}
101 FunctionEnd
102
103 Function un.onInit
104   SetShellVarContext current
105   StrCpy $BLENDERCONFIG "$APPDATA\Blender Foundation\Blender"
106   SetShellVarContext all
107 FunctionEnd
108
109 Function un.OptionalRemoveConfig
110   nsDialogs::Create /NOUNLOAD 1018
111   Pop $HWND
112   
113   ${If} $HWND == error
114     Abort
115   ${EndIf}
116   
117   ${NSD_CreateRadioButton} 0 50 100% 12u "Keep configuration files, autosaved .blend files and installed addons (recommended)"
118   Pop $HWND_KEEPCONFIG
119   ${NSD_CreateRadioButton} 0 80 100% 12u "Remove all files, including configuration files, autosaved .blend files and installed addons"
120   Pop $HWND_REMOVECONFIG
121
122   SendMessage $HWND_KEEPCONFIG ${BM_SETCHECK} 1 0
123   
124   nsDialogs::Show
125   
126 FunctionEnd
127
128 Function un.OptionalRemoveConfigOnLeave
129   ${NSD_GetState} $HWND_REMOVECONFIG $R0
130   ${If} $R0 == "1"
131     StrCpy $REMOVECONFIG "1"
132   ${Else}
133     StrCpy $REMOVECONFIG "0"
134   ${EndIf}
135 FunctionEnd
136
137
138 Section "Blender [VERSION] (required)" InstallFiles
139   SectionIn RO
140
141   ; Set output path to the installation directory.
142   SetOutPath $INSTDIR
143   ; The contents of Blender installation root dir
144   [ROOTDIRCONTS]
145   
146   ; All datafiles (python, scripts, datafiles)
147   [DODATAFILES]
148   
149   SetOutPath $INSTDIR
150   ${If} ${RunningX64}
151     SetRegView 64
152   ${EndIf}
153   ; Write the installation path into the registry
154   WriteRegStr HKLM "SOFTWARE\BlenderFoundation" "Install_Dir" "$INSTDIR"
155   WriteRegStr HKLM "SOFTWARE\BlenderFoundation" "ShortVersion" "[SHORTVERSION]"
156   ; Write the uninstall keys for Windows
157   WriteRegStr   HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Blender" "DisplayName" "Blender"
158   WriteRegStr   HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Blender" "Publisher" "Blender Foundation"
159   WriteRegStr   HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Blender" "URLInfoAbout" "http://www.blender.org/"
160   WriteRegStr   HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Blender" "DisplayVersion" "[VERSION]"
161   WriteRegStr   HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Blender" "DisplayIcon" "$INSTDIR\blender.exe"
162   WriteRegStr   HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Blender" "UninstallString" '"$INSTDIR\uninstall.exe"'
163   WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Blender" "NoModify" 1
164   WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Blender" "NoRepair " 1
165   WriteUninstaller "uninstall.exe"
166
167 SectionEnd
168
169 Section "Add Start Menu Shortcuts" StartMenu
170   SetShellVarContext all
171   CreateDirectory "$SMPROGRAMS\Blender Foundation\Blender\"
172   CreateShortCut "$SMPROGRAMS\Blender Foundation\Blender\Uninstall.lnk" "$INSTDIR\uninstall.exe" "" "$INSTDIR\uninstall.exe" 0
173   CreateShortCut "$SMPROGRAMS\Blender Foundation\Blender\Blender.lnk" "$INSTDIR\Blender.exe" "" "$INSTDIR\blender.exe" 0
174   CreateShortCut "$SMPROGRAMS\Blender Foundation\Blender\Readme.lnk" "$INSTDIR\readme.html" "" "" 0
175   CreateShortCut "$SMPROGRAMS\Blender Foundation\Blender\Copyright.lnk" "$INSTDIR\Copyright.txt" "" "$INSTDIR\copyright.txt" 0
176   CreateShortCut "$SMPROGRAMS\Blender Foundation\Blender\GPL-license.lnk" "$INSTDIR\GPL-license.txt" "" "$INSTDIR\GPL-license.txt" 0
177   System::Call 'shell32.dll::SHChangeNotify(i, i, i, i) v (0x08000000, 0, 0, 0)' ; refresh icons
178 SectionEnd
179
180 Section "Add Desktop Shortcut" DesktopShortcut
181   CreateShortCut "$DESKTOP\Blender.lnk" "$INSTDIR\blender.exe" "" "$INSTDIR\blender.exe" 0
182   System::Call 'shell32.dll::SHChangeNotify(i, i, i, i) v (0x08000000, 0, 0, 0)' ; refresh icons
183 SectionEnd
184
185 Section "Open .blend files with Blender" BlendRegister
186   ExecWait '"$INSTDIR\blender.exe" -r'
187 SectionEnd
188
189 UninstallText "This will uninstall Blender [VERSION], and all installed files. Hit 'Uninstall' to continue."
190
191 Section "Uninstall"
192   ; Remove registry keys
193   ${If} ${RunningX64}
194     SetRegView 64
195   ${EndIf}
196   
197   ReadRegStr $SHORTVERSION HKLM "SOFTWARE\BlenderFoundation" "ShortVersion"
198   DeleteRegKey HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Blender"
199   DeleteRegKey HKLM "SOFTWARE\BlenderFoundation"
200   DeleteRegKey HKCR ".blend"
201   DeleteRegKey HKCR "blendfile"
202   DeleteRegKey HKCR "CLSID\{D45F043D-F17F-4e8a-8435-70971D9FA46D}"
203   SetShellVarContext all
204  
205   ; Remove files
206   [DELROOTDIRCONTS]
207   [DELDATAFILES]
208   [DELDATADIRS]
209
210   Delete "$INSTDIR\uninstall.exe"
211
212   ${If} $REMOVECONFIG == "1"
213     RMDir /r "$BLENDERCONFIG\$SHORTVERSION"
214   ${Endif}
215
216   ; Remove install directory if it's empty
217   RMDir $INSTDIR
218   ; Remove shortcuts
219   Delete "$SMPROGRAMS\Blender Foundation\Blender\*.*"
220   Delete "$DESKTOP\Blender.lnk"
221   ; Remove all link related directories and files
222   RMDir "$SMPROGRAMS\Blender Foundation\Blender"
223   RMDir "$SMPROGRAMS\Blender Foundation"
224   
225   System::Call 'shell32.dll::SHChangeNotify(i, i, i, i) v (0x08000000, 0, 0, 0)' ; Refresh icons
226 SectionEnd
227
228 !insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
229   !insertmacro MUI_DESCRIPTION_TEXT ${InstallFiles} $(DESC_InstallFiles)
230   !insertmacro MUI_DESCRIPTION_TEXT ${StartMenu} $(DESC_StartMenu)
231   !insertmacro MUI_DESCRIPTION_TEXT ${DesktopShortcut} $(DESC_DesktopShortcut)
232   !insertmacro MUI_DESCRIPTION_TEXT ${BlendRegister} $(DESC_BlendRegister)
233 !insertmacro MUI_FUNCTION_DESCRIPTION_END
234