Merge branch 'gpg4win-2'
[gpg4win.git] / src / installer-finish.nsi
1 # installer-finish.nsi - Installer for GPG4Win.      -*- coding: latin-1; -*-
2 # Copyright (C) 2005, 2008 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 Var MYTMP
21
22 # Last section is a hidden one.
23 Section
24   WriteUninstaller "$INSTDIR\${PACKAGE}-uninstall.exe"
25
26 !ifdef HAVE_STARTMENU
27   # Check if the start menu entries where requested.
28   !insertmacro MUI_INSTALLOPTIONS_READ $R0 "installer-options.ini" \
29         "Field 2" "State"
30   IntCmp $R0 0 no_start_menu_uninstall
31
32   # Create a shortcut named "new shortcut" in the start menu programs
33   # directory point the new shortcut at the program uninstaller
34   CreateShortCut "$SMPROGRAMS\$STARTMENU_FOLDER\Uninstall.lnk" \
35     "$INSTDIR\${PACKAGE}-uninstall.exe" \
36     "" "$INSTDIR\${PACKAGE}-uninstall.exe" "" SW_SHOWNORMAL "" $(DESC_Menu_uninstall)
37   no_start_menu_uninstall:
38 !endif
39
40   # Windows Add/Remove Programs support
41   # Note that the version is appended to the DisplayName, despite that
42   # this is not necessary as a click on "support information" gives
43   # the version number.  Some tools do that, other don't.  I don't
44   # like it but others want me to do that.  -wk
45   StrCpy $MYTMP "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRETTY_PACKAGE_SHORT}"
46   WriteRegExpandStr HKLM $MYTMP "UninstallString" '"$INSTDIR\${PACKAGE}-uninstall.exe"'
47   WriteRegExpandStr HKLM $MYTMP "InstallLocation" "$INSTDIR"
48   WriteRegStr       HKLM $MYTMP "DisplayName"     "${PRETTY_PACKAGE} (${VERSION})"
49   WriteRegStr       HKLM $MYTMP "DisplayIcon"     "$INSTDIR\bin\kleopatra.exe,0"
50   WriteRegStr       HKLM $MYTMP "DisplayVersion"  "${VERSION}"
51   WriteRegStr       HKLM $MYTMP "Publisher"       "The Gpg4win Project"
52   WriteRegStr       HKLM $MYTMP "URLInfoAbout"    "http://www.gpg4win.org/"
53   WriteRegDWORD     HKLM $MYTMP "NoModify"        "1"
54   WriteRegDWORD     HKLM $MYTMP "NoRepair"        "1"
55 SectionEnd
56
57
58 Section Uninstall
59
60 !ifdef HAVE_STARTMENU
61   # Make sure that the context of the automatic variables has been set to
62   # the "all users" shell folder.  This guarantees that the menu gets written
63   # for all users.  We have already checked that we are running as Admin; or
64   # we printed a warning that installation will not succeed.
65   SetShellVarContext all
66
67   #---------------------------------------------------
68   # Delete the menu entries and any empty parent menus
69   #---------------------------------------------------
70   !insertmacro MUI_STARTMENU_GETFOLDER Application $MYTMP
71   g4wihelp::config_fetch "inst_start_menu_folder"
72   StrCmp $R0 "" +2
73   StrCpy $MYTMP $R0
74   Delete "$SMPROGRAMS\$MYTMP\*.lnk"
75   Delete "$SMPROGRAMS\$MYTMP\$(DESC_Menu_manuals)\*"
76   RMDir "$SMPROGRAMS\$MYTMP\$(DESC_Menu_manuals)"
77
78   RMDir "$SMPROGRAMS\$MYTMP\$(DESC_Desktop_manuals)"
79   StrCpy $MYTMP "$SMPROGRAMS\$MYTMP"
80   startMenuDeleteLoop:
81     ClearErrors
82     RMDir $MYTMP
83     GetFullPathName $MYTMP "$MYTMP\.."
84     IfErrors startMenuDeleteLoopDone
85     StrCmp $MYTMP $SMPROGRAMS startMenuDeleteLoopDone startMenuDeleteLoop
86   startMenuDeleteLoopDone:
87
88   DeleteRegValue HKLM "Software\GNU\${PRETTY_PACKAGE_SHORT}" \
89         "Start Menu Folder"
90
91
92   # Delete Desktop links.
93 !ifdef HAVE_PKG_WINPT
94   Delete "$DESKTOP\WinPT.lnk"
95 !endif
96 !ifdef HAVE_PKG_GPA
97   Delete "$DESKTOP\GPA.lnk"
98 !endif
99 !ifdef HAVE_PKG_KLEOPATRA
100   Delete "$DESKTOP\Kleopatra.lnk"
101 !endif
102 !ifdef HAVE_PKG_SYLPHEED_CLAWS
103   Delete "$DESKTOP\Sylpheed-Claws.lnk"
104   Delete "$DESKTOP\Sylpheed-Claws Manual.lnk" \
105   # We better delete also the name we used prior to 1.0.3
106   Delete "$DESKTOP\Sylpheed.lnk"
107 !endif
108 !ifdef HAVE_PKG_CLAWS_MAIL
109   Delete "$DESKTOP\Claws-Mail.lnk"
110   Delete "$DESKTOP\$(DESC_Desktop_manuals)\Claws-Mail Manual.lnk"
111 !endif
112 !ifdef HAVE_PKG_COMPENDIUM
113   Delete "$DESKTOP\$(DESC_Desktop_manuals)\$(DESC_Name_compendium_de_html).lnk"
114   Delete "$DESKTOP\$(DESC_Desktop_manuals)\$(DESC_Name_compendium_de_html).url"
115   Delete "$DESKTOP\$(DESC_Desktop_manuals)\$(DESC_Name_compendium_de_pdf).lnk"
116   Delete "$DESKTOP\$(DESC_Desktop_manuals)\$(DESC_Name_compendium_en_html).lnk"
117   Delete "$DESKTOP\$(DESC_Desktop_manuals)\$(DESC_Name_compendium_en_html).url"
118   Delete "$DESKTOP\$(DESC_Desktop_manuals)\$(DESC_Name_compendium_en_pdf).lnk"
119 !endif
120 !ifdef HAVE_PKG_MAN_NOVICE_DE
121   Delete "$DESKTOP\$(DESC_Desktop_manuals)\$(DESC_Name_man_novice_de).lnk"
122 !endif
123 !ifdef HAVE_PKG_MAN_NOVICE_EN
124   Delete "$DESKTOP\$(DESC_Desktop_manuals)\$(DESC_Name_man_novice_en).lnk"
125 !endif
126 !ifdef HAVE_PKG_MAN_ADVANCED_DE
127   Delete "$DESKTOP\$(DESC_Desktop_manuals)\$(DESC_Name_man_advanced_de).lnk"
128 !endif
129 !ifdef HAVE_PKG_GPGEE
130   Delete "$DESKTOP\$(DESC_Desktop_manuals)\GPGee Manual.lnk"
131 !endif
132   Delete "$DESKTOP\$(DESC_Desktop_manuals)\GnuPG FAQ.lnk"
133   Delete "$DESKTOP\$(DESC_Desktop_manuals)\Gpg4Win README.lnk"
134   Delete "$DESKTOP\$(DESC_Desktop_manuals)\Gpg4win README.lnk"
135   Delete "$DESKTOP\$(DESC_Desktop_manuals)\Gpg4win HOWTO SMIME.lnk"
136   RMDir "$DESKTOP\$(DESC_Desktop_manuals)"
137
138   # Delete Quick Launch Bar links.
139   StrCmp $QUICKLAUNCH $TEMP no_quick_launch_uninstall
140 !ifdef HAVE_PKG_WINPT
141   Delete "$QUICKLAUNCH\WinPT.lnk"
142 !endif
143 !ifdef HAVE_PKG_GPA
144   Delete "$QUICKLAUNCH\GPA.lnk"
145 !endif
146 !ifdef HAVE_PKG_KLEOPATRA
147   Delete "$QUICKLAUNCH\Kleopatra.lnk"
148 !endif
149 !ifdef HAVE_PKG_SYLPHEED_CLAWS
150   Delete "$QUICKLAUNCH\Sylpheed-Claws.lnk"
151   # We better delete also the name we used prior to 1.0.3
152   Delete "$QUICKLAUNCH\Sylpheed.lnk"
153 !endif
154 !ifdef HAVE_PKG_CLAWS_MAIL
155   Delete "$QUICKLAUNCH\Claws-Mail.lnk"
156 !endif
157 !ifdef HAVE_PKG_COMPENDIUM
158   Delete "$QUICKLAUNCH\$(DESC_Name_compendium_de).lnk"
159   Delete "$QUICKLAUNCH\$(DESC_Name_compendium_en).lnk"
160 !endif
161 !ifdef HAVE_PKG_MAN_NOVICE_DE
162   Delete "$QUICKLAUNCH\$(DESC_Name_man_novice_de).lnk"
163 !endif
164 !ifdef HAVE_PKG_MAN_ADVANCED_DE
165   Delete "$QUICKLAUNCH\$(DESC_Name_man_advanced_de).lnk"
166 !endif
167 !ifdef HAVE_PKG_GPGEE
168   Delete "$QUICKLAUNCH\GPGee Manual.lnk"
169 !endif
170   Delete "$QUICKLAUNCH\GnuPG FAQ.lnk"
171   Delete "$QUICKLAUNCH\Gpg4Win README.lnk"
172 no_quick_launch_uninstall:
173
174 !endif
175
176   Delete "$INSTDIR\${PACKAGE}-uninstall.exe"
177   RMDir "$INSTDIR"
178
179   # If we installed in the default location, try to be really, really
180   # nice with sugar on it to clean up behind us.  In any case, try very
181   # hard to get rid of directories which could have REBOOTOK files.
182   RMDir /REBOOTOK "$INSTDIR\bin"
183   RMDir /REBOOTOK "$INSTDIR"
184
185   # Clean the registry.
186   DeleteRegValue HKLM "Software\${PRETTY_PACKAGE_SHORT}" \
187         "Install Directory"
188   DeleteRegKey /ifempty HKLM "Software\${PRETTY_PACKAGE_SHORT}"
189
190   # Remove Windows Add/Remove Programs support.
191   DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRETTY_PACKAGE_SHORT}"
192 SectionEnd