Fix windows uninstall does not remove start menu shortcuts YAZ-860
[yaz-moved-to-github.git] / win / yaz.nsi
1 ; This file is part of the YAZ toolkit.
2 ; Copyright (C) Index Data
3 ; See the file LICENSE for details.
4
5 !include EnvVarUpdate.nsh
6 !include version.nsi
7
8 !include "MUI.nsh"
9
10 !define VS_REDIST_EXE vcredist_${VSARCH}.exe
11 !define VS_REDIST_FULL "c:\Program Files (x86)\Microsoft Visual Studio ${VSVER}.0\VC\redist\1033\${VS_REDIST_EXE}"
12
13 ; For example can be found with regedit:
14 ;  Microsoft Visual C++ 2013 x86 Minimum Runtime
15 !if "${VSARCH}" = "x64"
16 ; 64-bit
17 !if "${VSVER}" = "12"
18 !define VS_REDIST_KEY "SOFTWARE\Classes\Installer\Products\6E8D947A316B3EB3F8F540C548BE2AB9"
19 !endif
20 !if "${VSVER}" = "14"
21 !endif
22
23 InstallDir "$PROGRAMFILES64\YAZ"
24 !else
25 ; 32-bit
26 !if "${VSVER}" = "12"
27 !define VS_REDIST_KEY "SOFTWARE\Classes\Installer\Products\21EE4A31AE32173319EEFE3BD6FDFFE3"
28 !endif
29 !if "${VSVER}" = "14"
30 !endif
31
32 InstallDir "$PROGRAMFILES\YAZ"
33 !endif
34
35
36 RequestExecutionLevel admin
37
38 SetCompressor bzip2
39
40 Name "YAZ"
41 Caption "Index Data YAZ ${VERSION} Setup"
42 OutFile "yaz_${VERSION}.exe"
43
44 LicenseText "You must read the following license before installing:"
45 LicenseData license.txt
46
47 ComponentText "This will install the YAZ Toolkit on your computer:"
48 InstType "Full (w/ Source)"
49 InstType "Lite (w/o Source)"
50
51 InstallDirRegKey HKLM "SOFTWARE\Index Data\YAZ" ""
52
53
54 ;----------------------------
55 ; Pages
56
57
58   !insertmacro MUI_PAGE_LICENSE "license.txt"
59   !insertmacro MUI_PAGE_COMPONENTS
60   !insertmacro MUI_PAGE_DIRECTORY
61   !insertmacro MUI_PAGE_INSTFILES
62   
63   !insertmacro MUI_UNPAGE_CONFIRM
64   !insertmacro MUI_UNPAGE_INSTFILES
65 ; Page components
66 ; Page directory
67 ; Page instfiles
68
69 ; UninstPage uninstConfirm
70 ; UninstPage instfiles
71
72 ;--------------------------------
73 ;Languages
74  
75 !insertmacro MUI_LANGUAGE "English"
76
77 ;--------------------------------
78
79 Section "" ; (default section)
80         SetOutPath "$INSTDIR"
81         ; add files / whatever that need to be installed here.
82         WriteRegStr HKLM "SOFTWARE\Index Data\YAZ" "" "$INSTDIR"
83         WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\YAZ" "DisplayName" "YAZ ${VERSION} (remove only)"
84         WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\YAZ" "UninstallString" '"$INSTDIR\uninst.exe"'
85         ; write out uninstaller
86         WriteUninstaller "$INSTDIR\uninst.exe"
87         SetOutPath $SMPROGRAMS\YAZ
88         CreateShortCut "$SMPROGRAMS\YAZ\YAZ Program Directory.lnk" \
89                  "$INSTDIR"
90         WriteINIStr "$SMPROGRAMS\YAZ\YAZ Home page.url" \
91               "InternetShortcut" "URL" "http://www.indexdata.com/yaz/"
92         CreateShortCut "$SMPROGRAMS\YAZ\Uninstall YAZ.lnk" \
93                 "$INSTDIR\uninst.exe"
94         SetOutPath $INSTDIR
95         File LICENSE.txt
96         File ..\README
97         File ..\NEWS
98         SetOutPath $INSTDIR
99         SetOutPath $INSTDIR\ztest
100         File ..\ztest\dummy-grs
101         File ..\ztest\dummy-words
102         SetOutPath $INSTDIR\etc
103         File ..\etc\*.xml
104         File ..\etc\*.xsl
105         File ..\etc\pqf.properties
106
107 SectionEnd ; end of default section
108
109 Section "YAZ Runtime" YAZ_Runtime
110         SectionIn 1 2
111         SetOutPath $INSTDIR\bin
112 !if "${VS_REDIST_FULL}" != ""
113         File "${VS_REDIST_FULL}"
114         ReadRegDword $1 HKLM "${VS_REDIST_KEY}" "Version"
115         ${If} $1 == ""
116           ExecWait '"$INSTDIR\bin\${VS_REDIST_EXE}" /passive /nostart'
117         ${endif}
118         Delete "$INSTDIR\bin\${VS_REDIST_EXE}"
119 !endif
120         IfFileExists "$INSTDIR\bin\yaz-ztest.exe" 0 Noservice
121         ExecWait '"$INSTDIR\bin\yaz-ztest.exe" -remove'
122 Noservice:
123         File ..\bin\*.dll
124         File ..\bin\*.exe
125         SetOutPath $SMPROGRAMS\YAZ
126         CreateShortCut "$SMPROGRAMS\YAZ\YAZ Client.lnk" \
127                  "$INSTDIR\bin\yaz-client.exe"
128         SetOutPath $SMPROGRAMS\YAZ\Server
129         CreateShortCut "$SMPROGRAMS\YAZ\Server\Server on console on port 9999.lnk" \
130                  "$INSTDIR\bin\yaz-ztest.exe" '-w"$INSTDIR\ztest"'
131         CreateShortCut "$SMPROGRAMS\YAZ\Server\Install Z39.50 service on port 210.lnk" \
132                   "$INSTDIR\bin\yaz-ztest.exe" '-installa tcp:@:210'
133         CreateShortCut "$SMPROGRAMS\YAZ\Server\Remove Z39.50 service.lnk" \
134                  "$INSTDIR\bin\yaz-ztest.exe" '-remove'
135 SectionEnd
136
137 Section "YAZ Development" YAZ_Development
138         SectionIn 1 2
139         SetOutPath $INSTDIR\include\yaz
140         File ..\include\yaz\*.h
141         SetOutPath $INSTDIR\lib
142         File ..\lib\yaz*.lib
143 SectionEnd
144
145 Section "YAZ Documentation" YAZ_Documentation
146         SectionIn 1 2
147         SetOutPath $INSTDIR\doc
148         File /nonfatal /r ..\doc\*.css
149         File /nonfatal /r ..\doc\*.ent
150         File /nonfatal /r ..\doc\*.html
151         File /r ..\doc\*.xml
152         File /r ..\doc\*.png
153         File /nonfatal /r ..\doc\*.xsl
154         SetOutPath $SMPROGRAMS\YAZ
155         CreateShortCut "$SMPROGRAMS\YAZ\HTML Documentation.lnk" \
156                  "$INSTDIR\doc\index.html"
157 SectionEnd
158
159 Section "YAZ Source" YAZ_Source
160         SectionIn 1
161         SetOutPath $INSTDIR
162         File ..\IDMETA
163         File /r ..\*.c
164         File /r /x yaz ..\*.h
165         SetOutPath $INSTDIR\util
166         File ..\util\yaz-asncomp
167         SetOutPath $INSTDIR\src
168         File ..\src\*.y
169         File ..\src\*.tcl
170         File ..\src\*.csv
171         File ..\src\*.asn
172         File ..\src\codetables*.xml
173         SetOutPath $INSTDIR\test
174         File ..\test\marc*.*
175         File ..\test\*.sh
176         File ..\test\*.xml
177         File ..\test\*.asn
178         SetOutPath $INSTDIR\win
179         File makefile
180         File *.nsi
181         File *.rc
182 SectionEnd
183
184 Section "YAZ4J" YAZ4J
185         SectionIn 1 2
186         SetOutPath $INSTDIR\bin
187         File /nonfatal ..\bin\yaz4j.dll
188         SetOutPath $INSTDIR\java
189         File /nonfatal ..\java\yaz4j.jar
190 SectionEnd
191
192 Section "YAZ Path" YAZ_PATH
193         SectionIn 1 2
194         ${EnvVarUpdate} $0 "PATH" "A" "HKLM" "$INSTDIR\bin"
195 SectionEnd
196
197 ; begin uninstall settings/section
198 UninstallText "This will uninstall YAZ ${VERSION} from your system"
199
200 Section Uninstall
201         ExecWait '"$INSTDIR\bin\yaz-ztest" -remove'
202         RMDir /r $SMPROGRAMS\YAZ
203         Delete "$INSTDIR\uninst.exe"
204         DeleteRegKey HKLM "SOFTWARE\Index Data\YAZ"
205         DeleteRegKey HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\YAZ"
206         RMDir /r $INSTDIR
207         ${un.EnvVarUpdate} $0 "PATH" "R" "HKLM" "$INSTDIR\bin"
208         IfFileExists $INSTDIR 0 Removed 
209                 MessageBox MB_OK|MB_ICONEXCLAMATION \
210                  "Note: $INSTDIR could not be removed."
211 Removed:
212 SectionEnd
213
214 ;--------------------------------
215 ;Descriptions
216
217   ;Language strings
218 LangString DESC_YAZ_Runtime ${LANG_ENGLISH} "YAZ runtime files needed in order for YAZ to run, such as DLLs."
219 LangString DESC_YAZ_Development ${LANG_ENGLISH} "Header files and import libraries required for developing software using YAZ."
220 LangString DESC_YAZ_Documentation ${LANG_ENGLISH} "YAZ Users' guide and reference in HTML. Describes both YAZ applications and the API."
221 LangString DESC_YAZ_Source ${LANG_ENGLISH} "Source code of YAZ. Required if you need to rebuild YAZ (for debugging purposes)."
222 LangString DESC_YAZ4J ${LANG_ENGLISH} "Java wrapper for the ZOOM API of YAZ."
223 LangString DESC_YAZ_PATH ${LANG_ENGLISH} "Update PATH to include binaries of YAZ."
224
225 ;Assign language strings to sections
226 !insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
227 !insertmacro MUI_DESCRIPTION_TEXT ${YAZ_Runtime} $(DESC_YAZ_Runtime)
228 !insertmacro MUI_DESCRIPTION_TEXT ${YAZ_Development} $(DESC_YAZ_Development)
229 !insertmacro MUI_DESCRIPTION_TEXT ${YAZ_Documentation} $(DESC_YAZ_Documentation)
230 !insertmacro MUI_DESCRIPTION_TEXT ${YAZ_Source} $(DESC_YAZ_Source)
231 !insertmacro MUI_DESCRIPTION_TEXT ${YAZ4J} $(DESC_YAZ4J)
232 !insertmacro MUI_DESCRIPTION_TEXT ${YAZ_PATH} $(DESC_YAZ_PATH)
233 !insertmacro MUI_FUNCTION_DESCRIPTION_END
234
235 ; eof