2009-02-16 Marcus Brinkmann <marcus@g10code.de>
[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\gpg.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)\*.lnk"
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_DE
113   Delete "$DESKTOP\$(DESC_Desktop_manuals)\$(DESC_Name_compendium_de).lnk"
114 !endif
115 !ifdef HAVE_PKG_MAN_NOVICE_DE
116   Delete "$DESKTOP\$(DESC_Desktop_manuals)\$(DESC_Name_man_novice_de).lnk"
117 !endif
118 !ifdef HAVE_PKG_MAN_NOVICE_EN
119   Delete "$DESKTOP\$(DESC_Desktop_manuals)\$(DESC_Name_man_novice_en).lnk"
120 !endif
121 !ifdef HAVE_PKG_MAN_ADVANCED_DE
122   Delete "$DESKTOP\$(DESC_Desktop_manuals)\$(DESC_Name_man_advanced_de).lnk"
123 !endif
124 !ifdef HAVE_PKG_GPGEE
125   Delete "$DESKTOP\$(DESC_Desktop_manuals)\GPGee Manual.lnk"
126 !endif
127   Delete "$DESKTOP\$(DESC_Desktop_manuals)\GnuPG FAQ.lnk"
128   Delete "$DESKTOP\$(DESC_Desktop_manuals)\Gpg4Win README.lnk"
129   RMDir "$DESKTOP\$(DESC_Desktop_manuals)"
130
131   # Delete Quick Launch Bar links.
132   StrCmp $QUICKLAUNCH $TEMP no_quick_launch_uninstall
133 !ifdef HAVE_PKG_WINPT
134   Delete "$QUICKLAUNCH\WinPT.lnk"
135 !endif
136 !ifdef HAVE_PKG_GPA
137   Delete "$QUICKLAUNCH\GPA.lnk"
138 !endif
139 !ifdef HAVE_PKG_KLEOPATRA
140   Delete "$QUICKLAUNCH\Kleopatra.lnk"
141 !endif
142 !ifdef HAVE_PKG_SYLPHEED_CLAWS
143   Delete "$QUICKLAUNCH\Sylpheed-Claws.lnk"
144   # We better delete also the name we used prior to 1.0.3
145   Delete "$QUICKLAUNCH\Sylpheed.lnk"
146 !endif
147 !ifdef HAVE_PKG_CLAWS_MAIL
148   Delete "$QUICKLAUNCH\Claws-Mail.lnk"
149 !endif
150 !ifdef HAVE_PKG_COMPENDIUM_DE
151   Delete "$QUICKLAUNCH\$(DESC_Name_compendium_de).lnk"
152 !endif
153 !ifdef HAVE_PKG_MAN_NOVICE_DE
154   Delete "$QUICKLAUNCH\$(DESC_Name_man_novice_de).lnk"
155 !endif
156 !ifdef HAVE_PKG_MAN_ADVANCED_DE
157   Delete "$QUICKLAUNCH\$(DESC_Name_man_advanced_de).lnk"
158 !endif
159 !ifdef HAVE_PKG_GPGEE
160   Delete "$QUICKLAUNCH\GPGee Manual.lnk"
161 !endif
162   Delete "$QUICKLAUNCH\GnuPG FAQ.lnk"
163   Delete "$QUICKLAUNCH\Gpg4Win README.lnk"
164 no_quick_launch_uninstall:
165
166 !endif
167
168   Delete "$INSTDIR\${PACKAGE}-uninstall.exe"
169   RMDir "$INSTDIR"
170
171   # If we installed in the default location, try to be really, really
172   # nice with sugar on it to clean up behind us.
173   StrCmp "$INSTDIR" "$PROGRAMFILES\GNU\${INSTALL_DIR}" 0 +2
174   RMDir "$PROGRAMFILES\GNU"
175
176   # Clean the registry.
177   DeleteRegValue HKLM "Software\GNU\${PRETTY_PACKAGE_SHORT}" \
178         "Install Directory"
179   DeleteRegKey /ifempty HKLM "Software\GNU\${PRETTY_PACKAGE_SHORT}"
180   DeleteRegKey /ifempty HKLM "Software\GNU\GnuPG"
181   DeleteRegKey /ifempty HKLM "Software\GNU"
182
183   # Remove Windows Add/Remove Programs support.
184   DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRETTY_PACKAGE_SHORT}"
185 SectionEnd