Use LinkableValueNode members functions when possible in the derived valuenodes.
[synfig.git] / synfig-core / 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://synfig.org/"
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\Synfig"
94   CreateShortCut "$SMPROGRAMS\Synfig\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\Synfig\Uninstall Synfig Core.lnk"
123   RMDir "$SMPROGRAMS\Synfig"
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\Synfig"
136         CreateShortCut "$SMPROGRAMS\Synfig\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\Synfig\Examples.lnk"
145         RMDir "$SMPROGRAMS\Synfig"
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\mod_svg\mod_svg.nsh"
157 !include "@srcdir@\src\modules\lyr_freetype\lyr_freetype.nsh"
158 SectionGroupEnd
159 SectionGroup "Render Targets"
160 !include "@srcdir@\src\modules\mod_bmp\mod_bmp.nsh"
161 !include "@srcdir@\src\modules\mod_dv\mod_dv.nsh"
162 !include "@srcdir@\src\modules\mod_ffmpeg\mod_ffmpeg.nsh"
163 !include "@srcdir@\src\modules\mod_gif\mod_gif.nsh"
164 !include "@srcdir@\src\modules\mod_imagemagick\mod_imagemagick.nsh"
165 !include "@srcdir@\src\modules\mod_jpeg\mod_jpeg.nsh"
166 !include "@srcdir@\src\modules\mod_openexr\mod_openexr.nsh"
167 !include "@srcdir@\src\modules\mod_png\mod_png.nsh"
168 !include "@srcdir@\src\modules\mod_ppm\mod_ppm.nsh"
169 !include "@srcdir@\src\modules\mod_yuv420p\mod_yuv420p.nsh"
170 SectionGroupEnd
171 SectionGroupEnd
172
173 SectionGroup "un.PlugIns"
174 SectionGroup "un.Layers"
175 !include "@srcdir@\src\modules\lyr_std\unlyr_std.nsh"
176 !include "@srcdir@\src\modules\lyr_freetype\unlyr_freetype.nsh"
177 !include "@srcdir@\src\modules\mod_filter\unmod_filter.nsh"
178 !include "@srcdir@\src\modules\mod_gradient\unmod_gradient.nsh"
179 !include "@srcdir@\src\modules\mod_noise\unmod_noise.nsh"
180 !include "@srcdir@\src\modules\mod_particle\unmod_particle.nsh"
181 !include "@srcdir@\src\modules\mod_geometry\unmod_geometry.nsh"
182 !include "@srcdir@\src\modules\mod_svg\unmod_svg.nsh"
183 SectionGroupEnd
184 SectionGroup "un.Render Targets"
185 !include "@srcdir@\src\modules\mod_bmp\unmod_bmp.nsh"
186 !include "@srcdir@\src\modules\mod_dv\unmod_dv.nsh"
187 !include "@srcdir@\src\modules\mod_ffmpeg\unmod_ffmpeg.nsh"
188 !include "@srcdir@\src\modules\mod_gif\unmod_gif.nsh"
189 !include "@srcdir@\src\modules\mod_imagemagick\unmod_imagemagick.nsh"
190 !include "@srcdir@\src\modules\mod_jpeg\unmod_jpeg.nsh"
191 !include "@srcdir@\src\modules\mod_openexr\unmod_openexr.nsh"
192 !include "@srcdir@\src\modules\mod_png\unmod_png.nsh"
193 !include "@srcdir@\src\modules\mod_ppm\unmod_ppm.nsh"
194 !include "@srcdir@\src\modules\mod_yuv420p\unmod_yuv420p.nsh"
195 SectionGroupEnd
196 SectionGroupEnd
197
198 Function .onInit
199         ; Get installer location
200         ReadRegStr $R0 HKLM "${SYNFIG_UNINSTALL_KEY}" "UninstallString"
201 ;       IfErrors 0 +2
202 ;       ReadRegStr $R0 HKCU "${SYNFIG_UNINSTALL_KEY}" "UninstallString"
203         
204         StrCmp $R0 "" done
205
206         ; Get current installed version
207         ReadRegStr $R1 HKLM "${SYNFIG_UNINSTALL_KEY}" "DisplayVersion"
208 ;       IfErrors 0 +2
209 ;       ReadRegStr $R1 HKCU "${SYNFIG_UNINSTALL_KEY}" "DisplayVersion"
210
211 ;  StrCmp $R1 ${PRODUCT_VERSION} done
212
213         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
214
215         ; Run the uninstaller
216         
217         ClearErrors
218         ; CopyFiles "$R0" $TEMP
219         ExecWait '$R0 _?=$INSTDIR'
220         IfErrors no_remove_uninstaller
221         Delete $R0
222         RMDir $INSTDIR
223
224 no_remove_uninstaller:
225 ;    Delete "$TEMP\$R0"
226         
227     ; Check that the user completed the uninstallation by examining the registry
228     ReadRegStr $R0 HKLM "${SYNFIG_UNINSTALL_KEY}" "UninstallString"
229         StrCmp $R0 "" done abortInstall
230         ReadRegStr $R0 HKCU "${SYNFIG_UNINSTALL_KEY}" "UninstallString"
231         StrCmp $R0 "" done abortInstall
232
233 abortInstall:
234     MessageBox MB_OK|MB_ICONEXCLAMATION "Unable to uninstall previous version of @PACKAGE_NAME@"
235     Abort
236
237 done:
238     BringToFront
239
240 FunctionEnd