90f5545d86274ac34711728070cd5c529ed7d0e4
[gpg4win.git] / src / inst-sections.nsi
1 # inst-sections.nsi - Installer for GPG4Win sections.  -*- coding: latin-1; -*-
2 # Copyright (C) 2005 g10 Code GmbH
3
4 # This file is part of GPG4Win.
5
6 # GPG4Win is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 2 of the License, or
9 # (at your option) any later version.
10
11 # GPG4Win is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 # GNU General Public License for more details.
15
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, write to the Free Software
18 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
19
20 # Sections
21
22 !include "inst-gpg4win.nsi"
23
24 !ifdef HAVE_PKG_GNUPG
25 !include "inst-gnupg.nsi"
26 !endif
27 !ifdef HAVE_PKG_LIBGPG_ERROR
28 !include "inst-libgpg-error.nsi"
29 !endif
30 !ifdef HAVE_PKG_LIBICONV
31 !include "inst-libiconv.nsi"
32 !endif
33 !ifdef HAVE_PKG_PKGCONFIG
34 !include "inst-pkgconfig.nsi"
35 !endif
36 !ifdef HAVE_PKG_ZLIB
37 !include "inst-zlib.nsi"
38 !endif
39 !ifdef HAVE_PKG_CRYPT
40 !include "inst-crypt.nsi"
41 !endif
42 !ifdef HAVE_PKG_REGEX
43 !include "inst-regex.nsi"
44 !endif
45 !ifdef HAVE_PKG_PTHREADS_W32
46 !include "inst-pthreads-w32.nsi"
47 !endif
48 !ifdef HAVE_PKG_GPGME
49 !include "inst-gpgme.nsi"
50 !endif
51 !ifdef HAVE_PKG_GETTEXT
52 !include "inst-gettext.nsi"
53 !endif
54 !ifdef HAVE_PKG_GLIB
55 !include "inst-glib.nsi"
56 !endif
57 !ifdef HAVE_PKG_LIBPNG
58 !include "inst-libpng.nsi"
59 !endif
60 !ifdef HAVE_PKG_GPGOL
61 !include "inst-gpgol.nsi"
62 !endif
63 !ifdef HAVE_PKG_PANGO
64 !include "inst-pango.nsi"
65 !endif
66 !ifdef HAVE_PKG_ATK
67 !include "inst-atk.nsi"
68 !endif
69 !ifdef HAVE_PKG_GTK_
70 !include "inst-gtk+.nsi"
71 !endif
72 !ifdef HAVE_PKG_GPA
73 !include "inst-gpa.nsi"
74 !endif
75 !ifdef HAVE_PKG_WINPT
76 !include "inst-winpt.nsi"
77 !endif
78 !ifdef HAVE_PKG_GPGEE
79 !include "inst-gpgee.nsi"
80 !endif
81 !ifdef HAVE_PKG_SYLPHEED_CLAWS
82 !include "inst-sylpheed-claws.nsi"
83 !endif
84 !ifdef HAVE_PKG_EUDORAGPG
85 !include "inst-eudoragpg.nsi"
86 !endif
87 !ifdef HAVE_PKG_MAN_NOVICE_DE
88 !include "inst-man_novice_de.nsi"
89 !endif
90 !ifdef HAVE_PKG_MAN_ADVANCED_DE
91 !include "inst-man_advanced_de.nsi"
92 !endif
93
94 # We have to invoke the uninstallers in reverse order!
95
96 !ifdef HAVE_PKG_MAN_ADVANCED_DE
97 !include "uninst-man_advanced_de.nsi"
98 !endif
99 !ifdef HAVE_PKG_MAN_NOVICE_DE
100 !include "uninst-man_novice_de.nsi"
101 !endif
102 !ifdef HAVE_PKG_EUDORAGPG
103 !include "uninst-eudoragpg.nsi"
104 !endif
105 !ifdef HAVE_PKG_SYLPHEED_CLAWS
106 !include "uninst-sylpheed-claws.nsi"
107 !endif
108 !ifdef HAVE_PKG_GPGEE
109 !include "uninst-gpgee.nsi"
110 !endif
111 !ifdef HAVE_PKG_WINPT
112 !include "uninst-winpt.nsi"
113 !endif
114 !ifdef HAVE_PKG_GPA
115 !include "uninst-gpa.nsi"
116 !endif
117 !ifdef HAVE_PKG_GTK_
118 !include "uninst-gtk+.nsi"
119 !endif
120 !ifdef HAVE_PKG_ATK
121 !include "uninst-atk.nsi"
122 !endif
123 !ifdef HAVE_PKG_PANGO
124 !include "uninst-pango.nsi"
125 !endif
126 !ifdef HAVE_PKG_GPGOL
127 !include "uninst-gpgol.nsi"
128 !endif
129 !ifdef HAVE_PKG_LIBPNG
130 !include "uninst-libpng.nsi"
131 !endif
132 !ifdef HAVE_PKG_GLIB
133 !include "uninst-glib.nsi"
134 !endif
135 !ifdef HAVE_PKG_GETTEXT
136 !include "uninst-gettext.nsi"
137 !endif
138 !ifdef HAVE_PKG_GPGME
139 !include "uninst-gpgme.nsi"
140 !endif
141 !ifdef HAVE_PKG_PTHREADS_W32
142 !include "uninst-pthreads-w32.nsi"
143 !endif
144 !ifdef HAVE_PKG_REGEX
145 !include "uninst-regex.nsi"
146 !endif
147 !ifdef HAVE_PKG_CRYPT
148 !include "uninst-crypt.nsi"
149 !endif
150 !ifdef HAVE_PKG_ZLIB
151 !include "uninst-zlib.nsi"
152 !endif
153 !ifdef HAVE_PKG_PKGCONFIG
154 !include "uninst-pkgconfig.nsi"
155 !endif
156 !ifdef HAVE_PKG_LIBICONV
157 !include "uninst-libiconv.nsi"
158 !endif
159 !ifdef HAVE_PKG_LIBGPG_ERROR
160 # Note that the uninstaller of libgpg-error is supposed to remove the shareed
161 # directories.  We might want to move this to an extra section.
162 !include "uninst-libgpg-error.nsi"
163 !endif
164 !ifdef HAVE_PKG_GNUPG
165 !include "uninst-gnupg.nsi"
166 !endif
167
168 !include "uninst-gpg4win.nsi"
169
170
171 # Dependency Management
172
173 !include "Sections.nsh"
174
175 Function CalcDepends
176   # This section could very well be autogenerated from the
177   # information in configure.ac.  Note that it doesn't hurt to have
178   # stuff here for packages that we don't include.
179
180   # First clear all indirect dependencies.
181 !ifdef HAVE_PKG_LIBICONV
182   !insertmacro UnselectSection ${SEC_libiconv}
183 !endif
184 !ifdef HAVE_PKG_GETTEXT
185   !insertmacro UnselectSection ${SEC_gettext}
186 !endif
187 !ifdef HAVE_PKG_ZLIB
188   !insertmacro UnselectSection ${SEC_zlib}
189 !endif
190 !ifdef HAVE_PKG_CRYPT
191   !insertmacro UnselectSection ${SEC_crypt}
192 !endif
193 !ifdef HAVE_PKG_REGEX
194   !insertmacro UnselectSection ${SEC_regex}
195 !endif
196 !ifdef HAVE_PKG_PTHREADS_W32
197   !insertmacro UnselectSection ${SEC_pthreads_w32}
198 !endif
199 !ifdef HAVE_PKG_LIBPNG
200   !insertmacro UnselectSection ${SEC_libpng}
201 !endif
202 !ifdef HAVE_PKG_PKGCONFIG
203   !insertmacro UnselectSection ${SEC_pkgconfig}
204 !endif
205 !ifdef HAVE_PKG_GLIB
206   !insertmacro UnselectSection ${SEC_glib}
207 !endif
208 !ifdef HAVE_PKG_ATK
209   !insertmacro UnselectSection ${SEC_atk}
210 !endif
211 !ifdef HAVE_PKG_PANGO
212   !insertmacro UnselectSection ${SEC_pango}
213 !endif
214 !ifdef HAVE_PKG_GTK_
215   !insertmacro UnselectSection ${SEC_gtk_}
216 !endif
217 !ifdef HAVE_PKG_LIBGPG_ERROR
218   !insertmacro UnselectSection ${SEC_libgpg_error}
219 !endif
220 !ifdef HAVE_PKG_GPGME
221   !insertmacro UnselectSection ${SEC_gpgme}
222 !endif
223
224   # Then enable all dependencies in reverse build list order!
225
226 !ifdef HAVE_PKG_GPGEE
227   !insertmacro SectionFlagIsSet ${SEC_gpgee} ${SF_SELECTED} have_gpgee skip_gpgee
228   have_gpgee:
229   !insertmacro SelectSection ${SEC_gpgme}
230   !insertmacro SelectSection ${SEC_gnupg}
231   skip_gpgee:
232 !endif
233
234 !ifdef HAVE_PKG_WINPT
235   !insertmacro SectionFlagIsSet ${SEC_winpt} ${SF_SELECTED} have_winpt skip_winpt
236   have_winpt:
237   !insertmacro SelectSection ${SEC_gpgme}
238   !insertmacro SelectSection ${SEC_gnupg}
239   skip_winpt:
240 !endif
241
242 !ifdef HAVE_PKG_GPA
243   !insertmacro SectionFlagIsSet ${SEC_gpa} ${SF_SELECTED} have_gpa skip_gpa
244   have_gpa:
245   !insertmacro SelectSection ${SEC_zlib}
246   !insertmacro SelectSection ${SEC_gtk_}
247   !insertmacro SelectSection ${SEC_libpng}
248   !insertmacro SelectSection ${SEC_glib}
249   !insertmacro SelectSection ${SEC_gpgme}
250   !insertmacro SelectSection ${SEC_gnupg}
251   skip_gpa:
252 !endif
253
254 !ifdef HAVE_PKG_SYLPHEED_CLAWS
255   !insertmacro SectionFlagIsSet ${SEC_sylpheed} ${SF_SELECTED} have_sylpheed skip_sylpheed
256   have_sylpheed:
257   !insertmacro SelectSection ${SEC_zlib}
258   !insertmacro SelectSection ${SEC_gtk_}
259   !insertmacro SelectSection ${SEC_libpng}
260   !insertmacro SelectSection ${SEC_glib}
261   !insertmacro SelectSection ${SEC_gpgme}
262   !insertmacro SelectSection ${SEC_gnupg}
263   !insertmacro SelectSection ${SEC_pthreads_w32}
264   !insertmacro SelectSection ${SEC_crypt}
265   !insertmacro SelectSection ${SEC_regex}
266   skip_sylpheed:
267 !endif
268
269 !ifdef HAVE_PKG_EUDORAGPG
270   !insertmacro SectionFlagIsSet ${SEC_eudoragpg} ${SF_SELECTED} have_eudoragpg skip_eudoragpg
271   have_eudoragpg:
272   !insertmacro SelectSection ${SEC_zlib}
273   !insertmacro SelectSection ${SEC_gtk_}
274   !insertmacro SelectSection ${SEC_libpng}
275   !insertmacro SelectSection ${SEC_glib}
276   !insertmacro SelectSection ${SEC_gpgme}
277   !insertmacro SelectSection ${SEC_gnupg}
278   skip_eudoragpg:
279 !endif
280
281 !ifdef HAVE_PKG_GTK_
282   !insertmacro SectionFlagIsSet ${SEC_gtk_} \
283                 ${SF_SELECTED} have_gtk_ skip_gtk_
284   have_gtk_:
285   !insertmacro SelectSection ${SEC_atk}
286   !insertmacro SelectSection ${SEC_pango}
287   !insertmacro SelectSection ${SEC_glib}
288   !insertmacro SelectSection ${SEC_libiconv}
289   !insertmacro SelectSection ${SEC_gettext}
290   !insertmacro SelectSection ${SEC_pkgconfig}
291   skip_gtk_:
292 !endif
293
294 !ifdef HAVE_PKG_ATK
295   !insertmacro SectionFlagIsSet ${SEC_atk} \
296                 ${SF_SELECTED} have_atk skip_atk
297   have_atk:
298   !insertmacro SelectSection ${SEC_glib}
299   !insertmacro SelectSection ${SEC_pkgconfig}
300   skip_atk:
301 !endif
302
303 !ifdef HAVE_PKG_PANGO
304   !insertmacro SectionFlagIsSet ${SEC_pango} \
305                 ${SF_SELECTED} have_pango skip_pango
306   have_pango:
307   !insertmacro SelectSection ${SEC_glib}
308   !insertmacro SelectSection ${SEC_pkgconfig}
309   skip_pango:
310 !endif
311
312 !ifdef HAVE_PKG_GPGOL
313   !insertmacro SectionFlagIsSet ${SEC_gpgol} \
314                 ${SF_SELECTED} have_gpgol skip_gpgol
315   have_gpgol:
316   !insertmacro SelectSection ${SEC_gpgme}
317   !insertmacro SelectSection ${SEC_gnupg}
318   skip_gpgol:
319 !endif
320
321 !ifdef HAVE_PKG_LIBPNG
322   !insertmacro SectionFlagIsSet ${SEC_libpng} \
323                 ${SF_SELECTED} have_libpng skip_libpng
324   have_libpng:
325   !insertmacro SelectSection ${SEC_pkgconfig}
326   skip_libpng:
327 !endif
328
329 !ifdef HAVE_PKG_GLIB
330   !insertmacro SectionFlagIsSet ${SEC_glib} \
331                 ${SF_SELECTED} have_glib skip_glib
332   have_glib:
333   !insertmacro SelectSection ${SEC_pkgconfig}
334   skip_glib:
335 !endif
336
337 !ifdef HAVE_PKG_GETTEXT
338   !insertmacro SectionFlagIsSet ${SEC_gettext} \
339                 ${SF_SELECTED} have_gettext skip_gettext
340   have_gettext:
341   !insertmacro SelectSection ${SEC_libiconv}
342   skip_gettext:
343 !endif
344
345 !ifdef HAVE_PKG_GPGME
346   !insertmacro SectionFlagIsSet ${SEC_gpgme} \
347                 ${SF_SELECTED} have_gpgme skip_gpgme
348   have_gpgme:
349   !insertmacro SelectSection ${SEC_libgpg_error}
350   skip_gpgme:
351 !endif
352
353   # Package "zlib" has no dependencies.
354   # Package "pkgconfig" has no dependencies.
355   # Package "libiconv" has no dependencies.
356   # Package "libgpg-error" has no dependencies.
357   # Package "gnupg" has no dependencies.
358
359 FunctionEnd
360
361
362 Function .onInit
363   Call G4wRunOnce
364
365   SetOutPath $TEMP
366   File /oname=gpgspltmp.bmp "${TOP_SRCDIR}/doc/logo/gpg4win-logo-400px.bmp"
367   File /oname=gpgspltmp.wav "${TOP_SRCDIR}/src/gpg4win-splash.wav"
368   g4wihelp::playsound $TEMP\gpgspltmp.wav
369   g4wihelp::showsplash 2500 $TEMP\gpgspltmp.bmp
370
371   Delete $TEMP\gpgspltmp.bmp
372   ; Note that we delete gpgspltmp.wav in .onInst{Failed,Success}
373
374   Call CalcDepends
375 FunctionEnd
376
377
378 Function .onInstFailed
379   Delete $TEMP\gpgspltmp.wav
380 FunctionEnd
381
382 Function .onInstSuccess
383   Delete $TEMP\gpgspltmp.wav
384 FunctionEnd
385
386 Function .onSelChange
387   Call CalcDepends
388 FunctionEnd
389
390
391 # This function is run from the finish page.
392 Function RunOnFinish
393 !ifdef HAVE_PKG_GPA
394     SectionGetFlags ${SEC_gpa} $R0 
395     IntOp $R0 $R0 & ${SF_SELECTED} 
396     IntCmp $R0 ${SF_SELECTED} 0 no_gpa_avail
397        Exec "$INSTDIR\gpa.exe"
398        Return
399    no_gpa_avail:
400 !endif
401 !ifdef HAVE_PKG_WINPT
402     SectionGetFlags ${SEC_winpt} $R0 
403     IntOp $R0 $R0 & ${SF_SELECTED} 
404     IntCmp $R0 ${SF_SELECTED} 0 no_winpt_avail
405        Exec "$INSTDIR\WinPT.exe --keymanager"
406        Return
407    no_winpt_avail:
408 !endif
409   MessageBox MB_OK "$(T_NoKeyManager)"
410 FunctionEnd
411
412
413 # This must be in a central place.  Urgs.
414
415 !insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
416 !ifdef HAVE_PKG_GNUPG
417   !insertmacro MUI_DESCRIPTION_TEXT ${SEC_gnupg} $(DESC_SEC_gnupg)
418 !endif
419 !ifdef HAVE_PKG_GPGOL
420   !insertmacro MUI_DESCRIPTION_TEXT ${SEC_gpgol} $(DESC_SEC_gpgol)
421 !endif
422 !ifdef HAVE_PKG_GPA
423   !insertmacro MUI_DESCRIPTION_TEXT ${SEC_gpa} $(DESC_SEC_gpa)
424 !endif
425 !ifdef HAVE_PKG_WINPT
426   !insertmacro MUI_DESCRIPTION_TEXT ${SEC_winpt} $(DESC_SEC_winpt)
427 !endif
428 !ifdef HAVE_PKG_GPGEE
429   !insertmacro MUI_DESCRIPTION_TEXT ${SEC_gpgee} $(DESC_SEC_gpgee)
430 !endif
431 !ifdef HAVE_PKG_SYLPHEED_CLAWS
432   !insertmacro MUI_DESCRIPTION_TEXT ${SEC_sylpheed} $(DESC_SEC_sylpheed)
433 !endif
434 !ifdef HAVE_PKG_EUDORAGPG
435   !insertmacro MUI_DESCRIPTION_TEXT ${SEC_eudoragpg} $(DESC_SEC_eudoragpg)
436 !endif
437 !ifdef HAVE_PKG_MAN_NOVICE_DE
438   !insertmacro MUI_DESCRIPTION_TEXT ${SEC_man_novice_de} $(DESC_SEC_man_novice_de)
439 !endif
440 !ifdef HAVE_PKG_MAN_ADVANCED_DE
441   !insertmacro MUI_DESCRIPTION_TEXT ${SEC_man_advanced_de} $(DESC_SEC_man_advanced_de)
442 !endif
443 !insertmacro MUI_FUNCTION_DESCRIPTION_END
444
445
446 # This also must be in a central place.  Also Urgs.
447
448 Section "-startmenu"
449
450 !ifdef HAVE_STARTMENU
451   # Make sure that the context of the automatic variables has been set to
452   # the "all users" shell folder.  This guarantees that the menu gets written
453   # for all users.  We have already checked that we are running as Admin; or
454   # we printed a warning that installation will not succeed.
455   SetShellVarContext all
456
457 !insertmacro MUI_STARTMENU_WRITE_BEGIN Application
458     CreateDirectory "$SMPROGRAMS\$STARTMENU_FOLDER"
459
460 !ifdef HAVE_PKG_WINPT
461     SectionGetFlags ${SEC_winpt} $R0 
462     IntOp $R0 $R0 & ${SF_SELECTED} 
463     IntCmp $R0 ${SF_SELECTED} 0 no_winpt_menu 
464     CreateShortCut "$SMPROGRAMS\$STARTMENU_FOLDER\WinPT.lnk" \
465         "$INSTDIR\winpt.exe" \
466         "" "$INSTDIR\winpt.exe" "" SW_SHOWNORMAL "" $(DESC_Menu_winpt)
467    no_winpt_menu:
468 !endif
469
470 !ifdef HAVE_PKG_GPA
471     SectionGetFlags ${SEC_gpa} $R0 
472     IntOp $R0 $R0 & ${SF_SELECTED} 
473     IntCmp $R0 ${SF_SELECTED} 0 no_gpa_menu 
474     CreateShortCut "$SMPROGRAMS\$STARTMENU_FOLDER\GPA.lnk" \
475         "$INSTDIR\gpa.exe" \
476         "" "" "" SW_SHOWNORMAL "" $(DESC_Menu_gpa)
477   no_gpa_menu:
478 !endif
479
480 !ifdef HAVE_PKG_SYLPHEED_CLAWS
481     SectionGetFlags ${SEC_sylpheed} $R0 
482     IntOp $R0 $R0 & ${SF_SELECTED} 
483     IntCmp $R0 ${SF_SELECTED} 0 no_sylpheed_menu 
484     CreateShortCut "$SMPROGRAMS\$STARTMENU_FOLDER\Sylpheed.lnk" \
485         "$INSTDIR\sylpheed-claws.exe" \
486         "" "" "" SW_SHOWNORMAL "" $(DESC_Menu_sylpheed)
487   no_sylpheed_menu:
488 !endif
489
490 !ifdef HAVE_PKG_EUDORAGPG
491     SectionGetFlags ${SEC_eudoragpg} $R0 
492     IntOp $R0 $R0 & ${SF_SELECTED} 
493     IntCmp $R0 ${SF_SELECTED} 0 no_eudoragpg_menu 
494     CreateShortCut "$SMPROGRAMS\$STARTMENU_FOLDER\EudoraGPG Plugin.lnk" \
495         "$INSTDIR\share\eudoragpg\eudoragpg.html" \
496         "" "" "" SW_SHOWNORMAL "" ""
497   no_eudoragpg_menu:
498 !endif
499
500 !ifdef HAVE_PKG_MAN_NOVICE_DE
501     SectionGetFlags ${SEC_man_novice_de} $R0 
502     IntOp $R0 $R0 & ${SF_SELECTED} 
503     IntCmp $R0 ${SF_SELECTED} 0 no_man_novice_de_menu 
504     CreateShortCut \
505         "$SMPROGRAMS\$STARTMENU_FOLDER\$(DESC_Name_man_novice_de).lnk" \
506         "$INSTDIR\share\gpg4win\einsteiger.pdf" \
507         "" "" "" SW_SHOWNORMAL "" $(DESC_Menu_man_novice_de)
508   no_man_novice_de_menu:
509 !endif
510
511 !ifdef HAVE_PKG_MAN_ADVANCED_DE
512     SectionGetFlags ${SEC_man_advanced_de} $R0 
513     IntOp $R0 $R0 & ${SF_SELECTED} 
514     IntCmp $R0 ${SF_SELECTED} 0 no_man_advanced_de_menu 
515     CreateShortCut \
516         "$SMPROGRAMS\$STARTMENU_FOLDER\$(DESC_Name_man_advanced_de).lnk" \
517         "$INSTDIR\share\gpg4win\durchblicker.pdf" \
518         "" "" "" SW_SHOWNORMAL "" $(DESC_Menu_man_advanced_de)
519   no_man_advanced_de_menu:
520 !endif
521
522 !ifdef HAVE_PKG_GPGEE
523     SectionGetFlags ${SEC_gpgee} $R0 
524     IntOp $R0 $R0 & ${SF_SELECTED} 
525     IntCmp $R0 ${SF_SELECTED} 0 no_gpgee_menu 
526     CreateShortCut "$SMPROGRAMS\$STARTMENU_FOLDER\GPGee Manual.lnk" \
527         "$INSTDIR\GPGee.hlp" "" "" "" SW_SHOWNORMAL "" $(DESC_Menu_gpgee_hlp)
528   no_gpgee_menu:
529 !endif
530
531
532     CreateShortCut "$SMPROGRAMS\$STARTMENU_FOLDER\GnuPG FAQ.lnk" \
533                    "$INSTDIR\share\gnupg\faq.html" \
534                    "" "" "" SW_SHOWNORMAL "" $(DESC_Menu_gnupg_faq)
535
536     CreateShortCut "$SMPROGRAMS\$STARTMENU_FOLDER\Gpg4Win README.lnk" \
537                    "$INSTDIR\share\gpg4win\README.$(T_LangCode).txt" \
538                    "" "" "" SW_SHOWNORMAL "" $(DESC_Menu_gpg4win_readme)
539
540
541
542 # No more uninstall link becuase Windows has its wom feature to call
543 #  the uninstaller.
544 #    CreateShortCut "$SMPROGRAMS\$STARTMENU_FOLDER\Uninstall.lnk" \
545 #       "$INSTDIR\${PACKAGE}-uninstall.exe"
546 !insertmacro MUI_STARTMENU_WRITE_END
547 !endif
548 SectionEnd