Fixed a 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\*.sif"
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\*.sif"
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_png\mod_png.nsh"
166 !include "@srcdir@\src\modules\mod_ppm\mod_ppm.nsh"
167 !include "@srcdir@\src\modules\mod_yuv420p\mod_yuv420p.nsh"
168 SectionGroupEnd
169 SectionGroupEnd
170
171 SectionGroup "un.PlugIns"
172 SectionGroup "un.Layers"
173 !include "@srcdir@\src\modules\lyr_std\unlyr_std.nsh"
174 !include "@srcdir@\src\modules\lyr_freetype\unlyr_freetype.nsh"
175 !include "@srcdir@\src\modules\mod_filter\unmod_filter.nsh"
176 !include "@srcdir@\src\modules\mod_gradient\unmod_gradient.nsh"
177 !include "@srcdir@\src\modules\mod_noise\unmod_noise.nsh"
178 !include "@srcdir@\src\modules\mod_particle\unmod_particle.nsh"
179 !include "@srcdir@\src\modules\mod_geometry\unmod_geometry.nsh"
180 SectionGroupEnd
181 SectionGroup "un.Render Targets"
182 !include "@srcdir@\src\modules\mod_bmp\unmod_bmp.nsh"
183 !include "@srcdir@\src\modules\mod_dv\unmod_dv.nsh"
184 !include "@srcdir@\src\modules\mod_ffmpeg\unmod_ffmpeg.nsh"
185 !include "@srcdir@\src\modules\mod_gif\unmod_gif.nsh"
186 !include "@srcdir@\src\modules\mod_imagemagick\unmod_imagemagick.nsh"
187 !include "@srcdir@\src\modules\mod_jpeg\unmod_jpeg.nsh"
188 !include "@srcdir@\src\modules\mod_png\unmod_png.nsh"
189 !include "@srcdir@\src\modules\mod_ppm\unmod_ppm.nsh"
190 !include "@srcdir@\src\modules\mod_yuv420p\unmod_yuv420p.nsh"
191 SectionGroupEnd
192 SectionGroupEnd
193
194 Function .onInit
195         ; Get installer location
196         ReadRegStr $R0 HKLM "${SYNFIG_UNINSTALL_KEY}" "UninstallString"
197 ;       IfErrors 0 +2
198 ;       ReadRegStr $R0 HKCU "${SYNFIG_UNINSTALL_KEY}" "UninstallString"
199         
200         StrCmp $R0 "" done
201
202         ; Get current installed version
203         ReadRegStr $R1 HKLM "${SYNFIG_UNINSTALL_KEY}" "DisplayVersion"
204 ;       IfErrors 0 +2
205 ;       ReadRegStr $R1 HKCU "${SYNFIG_UNINSTALL_KEY}" "DisplayVersion"
206
207 ;  StrCmp $R1 ${PRODUCT_VERSION} done
208
209         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
210
211         ; Run the uninstaller
212         
213         ClearErrors
214         ; CopyFiles "$R0" $TEMP
215         ExecWait '$R0 _?=$INSTDIR'
216         IfErrors no_remove_uninstaller
217         Delete $R0
218         RMDir $INSTDIR
219
220 no_remove_uninstaller:
221 ;    Delete "$TEMP\$R0"
222         
223     ; Check that the user completed the uninstallation by examining the registry
224     ReadRegStr $R0 HKLM "${SYNFIG_UNINSTALL_KEY}" "UninstallString"
225         StrCmp $R0 "" done abortInstall
226         ReadRegStr $R0 HKCU "${SYNFIG_UNINSTALL_KEY}" "UninstallString"
227         StrCmp $R0 "" done abortInstall
228
229 abortInstall:
230     MessageBox MB_OK|MB_ICONEXCLAMATION "Unable to uninstall previous version of @PACKAGE_NAME@"
231     Abort
232
233 done:
234     BringToFront
235
236 FunctionEnd