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