Typo.
[synfig.git] / synfig-core / trunk / win32inst.nsi.in
1 ; example2.nsi
2 ;
3 ; This script is based on example1.nsi, but it remember the directory, 
4 ; has uninstall support and (optionally) installs start menu shortcuts.
5 ;
6 ; It will install makensisw.exe into a directory that the user selects,
7
8 !include "MUI.nsh"
9
10 ;--------------------------------
11
12 ; The name of the installer
13 Name "@PACKAGE_NAME@ @PACKAGE_VERSION@"
14
15 !define PRODUCT_WEB_SITE "http://www.synfig.com/"
16
17 ; The file to write
18 OutFile "@PACKAGE_TARNAME@-@PACKAGE_VERSION@.exe"
19
20 ; The default installation directory
21 InstallDir $PROGRAMFILES\@PACKAGE_TARNAME@
22
23 !define VERSION_MAJ "@VERSION_MAJ@"
24 !define VERSION_MIN "@VERSION_MIN@"
25 !define VERSION_REV "@VERSION_REV@"
26
27 !define SYNFIG_REG_KEY "Software\@PACKAGE_TARNAME@\@API_VERSION@"
28 !define SYNFIG_UNINSTALL_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\@PACKAGE_TARNAME@"
29 !define SYNFIG_UNINSTALL_EXE "uninstall-@PACKAGE_TARNAME@.exe"
30
31 !define MUI_ABORTWARNING
32
33 ;--------------------------------
34
35 ; Pages
36
37 #Page components
38 #Page directory
39 #Page instfiles
40
41 #UninstPage uninstConfirm
42 #UninstPage instfiles
43
44 ;CustomGuiInit
45
46 !insertmacro MUI_PAGE_WELCOME
47 !insertmacro MUI_PAGE_LICENSE "@srcdir@\COPYING"
48 #!insertmacro MUI_PAGE_LICENSE "@srcdir@\alphalicense.txt"
49 ;Page custom PageReinstall ; PageLeaveReinstall
50 !insertmacro MUI_PAGE_COMPONENTS
51 !insertmacro MUI_PAGE_DIRECTORY
52 !insertmacro MUI_PAGE_INSTFILES
53
54 !insertmacro MUI_UNPAGE_CONFIRM
55 !insertmacro MUI_UNPAGE_COMPONENTS
56 !insertmacro MUI_UNPAGE_INSTFILES
57
58 !insertmacro MUI_LANGUAGE "English"
59
60 ;--------------------------------
61
62 ; The stuff to install
63 Section ""
64
65   SectionIn RO
66   
67   ; Set output path to the installation directory.
68   SetOutPath $INSTDIR\bin
69
70   ; Put file there
71   
72   CreateDirectory "$INSTDIR\etc"
73   Delete $INSTDIR\etc\synfig_modules.cfg
74         
75   ; Write the installation path into the registry
76   WriteRegStr HKLM "${SYNFIG_REG_KEY}" "Path" "$INSTDIR"
77   WriteRegStr HKLM "${SYNFIG_REG_KEY}" "Version" "@PACKAGE_VERSION@"
78   
79   ; Write the uninstall keys for Windows
80   WriteRegStr HKLM "${SYNFIG_UNINSTALL_KEY}" "DisplayName" "@PACKAGE_NAME@"
81   WriteRegStr HKLM "${SYNFIG_UNINSTALL_KEY}" "DisplayVersion" "@PACKAGE_VERSION@"
82   WriteRegStr HKLM "${SYNFIG_UNINSTALL_KEY}" "UninstallString" '"$INSTDIR\${SYNFIG_UNINSTALL_EXE}"'
83   WriteRegDWORD HKLM "${SYNFIG_UNINSTALL_KEY}" "NoModify" 1
84   WriteRegDWORD HKLM "${SYNFIG_UNINSTALL_KEY}" "NoRepair" 1
85   WriteUninstaller "${SYNFIG_UNINSTALL_EXE}"
86   
87 SectionEnd
88
89 ; Optional section (can be disabled by the user)
90 Section "Start Menu Shortcuts"
91
92   SetShellVarContext All
93   CreateDirectory "$SMPROGRAMS\Voria"
94   CreateShortCut "$SMPROGRAMS\Voria\Uninstall Synfig Core.lnk" "$INSTDIR\uninstall-@PACKAGE_TARNAME@.exe" "" "$INSTDIR\uninstall-@PACKAGE_TARNAME@.exe" 0
95   
96 SectionEnd
97
98
99 ;--------------------------------
100
101 ; Uninstaller
102
103 Section "Uninstall"
104   
105   ; Remove registry keys
106   DeleteRegKey HKLM "${SYNFIG_REG_KEY}"
107   DeleteRegKey HKLM "${SYNFIG_UNINSTALL_KEY}"
108
109   ; Remove files and uninstaller
110   Delete $INSTDIR\uninstall-@PACKAGE_TARNAME@.exe
111   Delete $INSTDIR\etc\synfig_modules.cfg
112   RMDir "$INSTDIR\bin"
113   RMDir "$INSTDIR\etc"
114   RMDir "$INSTDIR"
115
116 SectionEnd
117
118 Section "un.Start Menu Shortcuts"
119
120   ; Remove shortcuts, if any
121   SetShellVarContext All
122   Delete "$SMPROGRAMS\Voria\Uninstall Synfig Core.lnk"
123   RMDir "$SMPROGRAMS\Voria"
124
125 SectionEnd
126
127 !include @srcdir@\src\synfig\synfig.nsh
128 !include @srcdir@\src\tool\tool.nsh
129
130 Section "Examples"
131         SetOutPath $INSTDIR\examples
132         File "@srcdir@\examples\*.sifz"
133
134         SetShellVarContext All
135         CreateDirectory "$SMPROGRAMS\Voria"
136         CreateShortCut "$SMPROGRAMS\Voria\Examples.lnk" "$INSTDIR\examples" "" "$INSTDIR\examples" 0
137 SectionEnd
138
139 Section "un.Examples"
140         Delete "$INSTDIR\examples\*.sifz"
141         RMDir "$INSTDIR\examples"
142
143         SetShellVarContext All
144         Delete "$SMPROGRAMS\Voria\Examples.lnk"
145         RMDir "$SMPROGRAMS\Voria"
146 SectionEnd
147
148 SectionGroup "PlugIns"
149 SectionGroup "Layers"
150 !include "@srcdir@\src\modules\lyr_std\lyr_std.nsh"
151 !include "@srcdir@\src\modules\mod_filter\mod_filter.nsh"
152 !include "@srcdir@\src\modules\mod_gradient\mod_gradient.nsh"
153 !include "@srcdir@\src\modules\mod_noise\mod_noise.nsh"
154 !include "@srcdir@\src\modules\mod_particle\mod_particle.nsh"
155 !include "@srcdir@\src\modules\mod_geometry\mod_geometry.nsh"
156 !include "@srcdir@\src\modules\lyr_freetype\lyr_freetype.nsh"
157 SectionGroupEnd
158 SectionGroup "Render Targets"
159 !include "@srcdir@\src\modules\mod_bmp\mod_bmp.nsh"
160 !include "@srcdir@\src\modules\mod_dv\mod_dv.nsh"
161 !include "@srcdir@\src\modules\mod_ffmpeg\mod_ffmpeg.nsh"
162 !include "@srcdir@\src\modules\mod_gif\mod_gif.nsh"
163 !include "@srcdir@\src\modules\mod_imagemagick\mod_imagemagick.nsh"
164 !include "@srcdir@\src\modules\mod_jpeg\mod_jpeg.nsh"
165 !include "@srcdir@\src\modules\mod_openexr\mod_openexr.nsh"
166 !include "@srcdir@\src\modules\mod_png\mod_png.nsh"
167 !include "@srcdir@\src\modules\mod_ppm\mod_ppm.nsh"
168 !include "@srcdir@\src\modules\mod_yuv420p\mod_yuv420p.nsh"
169 SectionGroupEnd
170 SectionGroupEnd
171
172 SectionGroup "un.PlugIns"
173 SectionGroup "un.Layers"
174 !include "@srcdir@\src\modules\lyr_std\unlyr_std.nsh"
175 !include "@srcdir@\src\modules\lyr_freetype\unlyr_freetype.nsh"
176 !include "@srcdir@\src\modules\mod_filter\unmod_filter.nsh"
177 !include "@srcdir@\src\modules\mod_gradient\unmod_gradient.nsh"
178 !include "@srcdir@\src\modules\mod_noise\unmod_noise.nsh"
179 !include "@srcdir@\src\modules\mod_particle\unmod_particle.nsh"
180 !include "@srcdir@\src\modules\mod_geometry\unmod_geometry.nsh"
181 SectionGroupEnd
182 SectionGroup "un.Render Targets"
183 !include "@srcdir@\src\modules\mod_bmp\unmod_bmp.nsh"
184 !include "@srcdir@\src\modules\mod_dv\unmod_dv.nsh"
185 !include "@srcdir@\src\modules\mod_ffmpeg\unmod_ffmpeg.nsh"
186 !include "@srcdir@\src\modules\mod_gif\unmod_gif.nsh"
187 !include "@srcdir@\src\modules\mod_imagemagick\unmod_imagemagick.nsh"
188 !include "@srcdir@\src\modules\mod_jpeg\unmod_jpeg.nsh"
189 !include "@srcdir@\src\modules\mod_openexr\unmod_openexr.nsh"
190 !include "@srcdir@\src\modules\mod_png\unmod_png.nsh"
191 !include "@srcdir@\src\modules\mod_ppm\unmod_ppm.nsh"
192 !include "@srcdir@\src\modules\mod_yuv420p\unmod_yuv420p.nsh"
193 SectionGroupEnd
194 SectionGroupEnd
195
196 Function .onInit
197         ; Get installer location
198         ReadRegStr $R0 HKLM "${SYNFIG_UNINSTALL_KEY}" "UninstallString"
199 ;       IfErrors 0 +2
200 ;       ReadRegStr $R0 HKCU "${SYNFIG_UNINSTALL_KEY}" "UninstallString"
201         
202         StrCmp $R0 "" done
203
204         ; Get current installed version
205         ReadRegStr $R1 HKLM "${SYNFIG_UNINSTALL_KEY}" "DisplayVersion"
206 ;       IfErrors 0 +2
207 ;       ReadRegStr $R1 HKCU "${SYNFIG_UNINSTALL_KEY}" "DisplayVersion"
208
209 ;  StrCmp $R1 ${PRODUCT_VERSION} done
210
211         MessageBox MB_YESNOCANCEL|MB_ICONEXCLAMATION "A previous version of @PACKAGE_NAME@ appears to be installed. Would you like to uninstall it first?" IDNO done IDCANCEL abortInstall
212
213         ; Run the uninstaller
214         
215         ClearErrors
216         ; CopyFiles "$R0" $TEMP
217         ExecWait '$R0 _?=$INSTDIR'
218         IfErrors no_remove_uninstaller
219         Delete $R0
220         RMDir $INSTDIR
221
222 no_remove_uninstaller:
223 ;    Delete "$TEMP\$R0"
224         
225     ; Check that the user completed the uninstallation by examining the registry
226     ReadRegStr $R0 HKLM "${SYNFIG_UNINSTALL_KEY}" "UninstallString"
227         StrCmp $R0 "" done abortInstall
228         ReadRegStr $R0 HKCU "${SYNFIG_UNINSTALL_KEY}" "UninstallString"
229         StrCmp $R0 "" done abortInstall
230
231 abortInstall:
232     MessageBox MB_OK|MB_ICONEXCLAMATION "Unable to uninstall previous version of @PACKAGE_NAME@"
233     Abort
234
235 done:
236     BringToFront
237
238 FunctionEnd