Fix msvc x64 build and openssl for msc.
[quassel.git] / scripts / build / NullsoftInstaller.nsi
1 ; basic script template for NullsoftInstallerPackager
2 ;
3 ; Copyright 2013 Patrick von Reth <vonreth@kde.org>
4 ; Copyright 2010 Patrick Spendrin <ps_ml@gmx.de>
5 ; adapted from marble.nsi
6
7 var ToBeRunned
8 var nameOfToBeRunend
9
10 !define productname "Quassel"
11 !define company "KDE"
12
13 !include MUI2.nsh
14 !include LogicLib.nsh
15 !include SnoreNotify.nsh
16
17
18 ; registry stuff
19 !define regkey "Software\${company}\${productname}"
20 !define uninstkey "Software\Microsoft\Windows\CurrentVersion\Uninstall\Quassel"
21
22 !define startmenu "$SMPROGRAMS\${productname}"
23 !define uninstaller "uninstall.exe"
24
25 Var StartMenuFolder
26
27 !define PRODUCT_WEB_SITE http://quassel-irc.org/
28 !define MyApp_AppUserModelId  QuasselProject.QuasselIRC
29 !define SnoreToastExe "$INSTDIR\SnoreToast.exe"
30
31 ;Start Menu Folder Page Configuration
32 !define MUI_STARTMENUPAGE_REGISTRY_ROOT "HKLM"
33 !define MUI_STARTMENUPAGE_REGISTRY_KEY "${regkey}"
34 !define MUI_STARTMENUPAGE_REGISTRY_VALUENAME "Start Menu Folder"
35
36 InstType "Minimal"
37 InstType "Full"
38 ;--------------------------------
39
40
41 XPStyle on
42 ShowInstDetails hide
43 ShowUninstDetails hide
44
45 SetCompressor /SOLID lzma
46
47 Name ${productname}
48 Caption "${caption}"
49
50 OutFile "${setupname}"
51
52 !define MUI_ICON ${gitDir}\pics\quassel.ico
53
54 !insertmacro MUI_PAGE_WELCOME
55
56 ;!insertmacro MUI_PAGE_LICENSE
57 #${license}
58 ;!insertmacro MUI_PAGE_LICENSE
59
60 !insertmacro MUI_PAGE_DIRECTORY
61
62 !insertmacro MUI_PAGE_STARTMENU Application $StartMenuFolder
63
64 !define MUI_COMPONENTSPAGE_NODESC
65 !insertmacro MUI_PAGE_COMPONENTS
66
67 !insertmacro MUI_PAGE_INSTFILES
68
69 !define MUI_FINISHPAGE_RUN $ToBeRunned
70 !define MUI_FINISHPAGE_RUN_TEXT $nameOfToBeRunend
71 !define MUI_FINISHPAGE_LINK "Visit project homepage"
72 !define MUI_FINISHPAGE_LINK_LOCATION "${PRODUCT_WEB_SITE}"
73 !insertmacro MUI_PAGE_FINISH
74
75 ;uninstaller
76 !insertmacro MUI_UNPAGE_WELCOME
77 !insertmacro MUI_UNPAGE_CONFIRM
78 !insertmacro MUI_UNPAGE_INSTFILES
79 !insertmacro MUI_UNPAGE_FINISH
80 ;-------
81
82 !insertmacro MUI_LANGUAGE "English"
83
84 SetDateSave on
85 SetDatablockOptimize on
86 CRCCheck on
87 SilentInstall normal
88
89 InstallDir "${defaultinstdir}\${productname}"
90 InstallDirRegKey HKLM "${regkey}" ""
91
92
93 ;--------------------------------
94 AutoCloseWindow false
95
96
97 ; beginning (invisible) section
98 Section "--hidden Quassel Base" QUASSEL_BASE
99    SectionIn RO
100    SetOutPath $INSTDIR
101    SetShellVarContext all
102    StrCpy $ToBeRunned ""
103
104     WriteRegStr HKLM "${regkey}" "Install_Dir" "$INSTDIR"
105     WriteRegStr HKLM "${regkey}" "Version" "${version}"
106     WriteRegStr HKLM "${regkey}" "" "$INSTDIR\uninstall.exe"
107
108     WriteRegStr HKLM "${uninstkey}" "DisplayName" "Quassel (remove only)"
109     WriteRegStr HKLM "${uninstkey}" "DisplayIcon" "$INSTDIR\${MUI_ICON}"
110     WriteRegStr HKLM "${uninstkey}" "DisplayVersion" "${version}"
111     WriteRegStr HKLM "${uninstkey}" "URLInfoAbout" "${PRODUCT_WEB_SITE}"
112     WriteRegStr HKLM "${uninstkey}" "UninstallString" '"$INSTDIR\${uninstaller}"'
113     WriteRegStr HKLM "${uninstkey}" "Publisher" "${company}"
114
115   SetOutPath $INSTDIR
116
117
118     ; package all files, recursively, preserving attributes
119     ; assume files are in the correct places
120
121     File /a /r /x "*.nsi" /x "*quassel.exe" /x "*quasselclient.exe" /x "*quasselcore.exe" /x "${setupname}" "${srcdir}\*.*"
122     File /a  ${MUI_ICON}
123
124     !if "${vcredist}" != "none"
125         File /a /oname=vcredist.exe "${vcredist}"
126         ExecWait '"$INSTDIR\vcredist.exe" /passive'
127         Delete "$INSTDIR\vcredist.exe"
128     !endif
129
130     WriteUninstaller "${uninstaller}"
131
132
133     ;Create shortcuts
134     !insertmacro MUI_STARTMENU_WRITE_BEGIN Application
135         CreateDirectory "$SMPROGRAMS\$StartMenuFolder"
136         CreateShortCut "$SMPROGRAMS\$StartMenuFolder\Uninstall.lnk" "$INSTDIR\uninstall.exe"
137     !insertmacro MUI_STARTMENU_WRITE_END
138 SectionEnd
139
140
141 Section "Quassel"  QUASSEL_ALL_IN_ONE
142     SectionIn 1 2
143     SetOutPath $INSTDIR
144     StrCpy $ToBeRunned "$INSTDIR\quassel.exe"
145     StrCpy $nameOfToBeRunend "Run Quassel"
146     File /a /oname=quassel.exe "${srcdir}\quassel.exe"
147     !insertmacro MUI_STARTMENU_WRITE_BEGIN Application
148         !insertmacro SnoreShortcut "$SMPROGRAMS\$StartMenuFolder\Quassel.lnk" "$INSTDIR\quassel.exe" "${MyApp_AppUserModelId}"
149     !insertmacro MUI_STARTMENU_WRITE_END
150 SectionEnd
151
152 Section /o "QuasselClient"  QUASSEL_CLIENT
153     SectionIn 2
154     SetOutPath $INSTDIR
155     ${If} $ToBeRunned == ""
156         StrCpy $ToBeRunned "$INSTDIR\quasselclient.exe"
157         StrCpy $nameOfToBeRunend "Run QuasselClient"
158     ${Endif}
159     File /a /oname=quasselclient.exe "${srcdir}\quasselclient.exe"
160     !insertmacro MUI_STARTMENU_WRITE_BEGIN Application
161         !insertmacro SnoreShortcut "$SMPROGRAMS\$StartMenuFolder\Quassel Client.lnk" "$INSTDIR\quasselclient.exe" "${MyApp_AppUserModelId}"
162     !insertmacro MUI_STARTMENU_WRITE_END
163 SectionEnd
164
165 Section /o "QuasselCore"  QUASSEL_CORE
166     SectionIn 2
167     SetOutPath $INSTDIR
168     ${If} $ToBeRunned == ""
169         StrCpy $ToBeRunned "$INSTDIR\quasselcore.exe"
170         StrCpy $nameOfToBeRunend "Run QuasselCore"
171     ${Endif}
172      File /a /oname=quasselcore.exe "${srcdir}\quasselcore.exe"
173     !insertmacro MUI_STARTMENU_WRITE_BEGIN Application
174         CreateShortCut "$SMPROGRAMS\$StartMenuFolder\Quassel Core.lnk" "$INSTDIR\quasselcore.exe"
175     !insertmacro MUI_STARTMENU_WRITE_END
176 SectionEnd
177
178 ; Section /o "QuasselCoreService"  QUASSEL_CORE_SERVICE
179     ; SimpleSC::ExistsService "QuasselCore"
180     ; Pop $0 ; returns an errorcode if the service doesn't exists (<>0)/service exists (0)
181     ; ${If} $0 == 0
182         ; MessageBox MB_OK|MB_ICONSTOP "Install Service QUassel failed - Reason: Service already exists"
183     ; ${Else}
184         ; SimpleSC::InstallService "QuasselCore" "QuasselCore" "16" "2" "$INSTDIR\bin\quasselcore.exe" "" "" ""
185         ; Pop $0 ; returns an errorcode (<>0) otherwise success (0)
186             ; ${If} $0 != 0
187                 ; Push $0
188                 ; SimpleSC::GetErrorMessage
189                 ; Pop $0
190                 ; MessageBox MB_OK|MB_ICONSTOP "Install of Service QUassel failed - Reason: $0"
191             ; ${Else}
192                 ; SimpleSC::StartService "QuasselCore" "" 30
193                 ; Pop $0 ; returns an errorcode (<>0) otherwise success (0)
194                 ; ${If} $0 != 0
195                     ; Push $0
196                     ; SimpleSC::GetErrorMessage
197                     ; Pop $0
198                     ; MessageBox MB_OK|MB_ICONSTOP "Install of Service QUassel failed - Reason: $0"
199                 ; ${EndIf}
200             ; ${EndIf}
201     ; ${EndIf}
202 ; SectionEnd
203
204 ; Uninstaller
205 ; All section names prefixed by "Un" will be in the uninstaller
206
207 UninstallText "This will uninstall Quassel."
208
209 Section "Uninstall"
210     SetShellVarContext all
211     SetShellVarContext all
212
213     DeleteRegKey HKLM "${uninstkey}"
214     DeleteRegKey HKLM "${regkey}"
215
216     !insertmacro MUI_STARTMENU_GETFOLDER Application $StartMenuFolder
217
218
219   ; SimpleSC::ExistsService "QuasselCore"
220   ; Pop $0   ; returns an errorcode if the service doesn't exists (<>0)/service exists (0)
221   ; ${If} $0 == 0
222     ; SimpleSC::ServiceIsStopped "QuasselCore"
223     ; Pop $0 ; returns an errorcode (<>0) otherwise success (0)
224     ; Pop $1 ; returns 1 (service is stopped) - returns 0 (service is not stopped)
225     ; ${If} $0 == 0
226     ; ${AndIf} $1 == 0
227         ; SimpleSC::StopService "QuasselCore" 1 30
228         ; Pop $0 ; returns an errorcode (<>0) otherwise success (0)
229         ; ${If} $0 != 0
230             ; Push $0
231             ; SimpleSC::GetErrorMessage
232             ; Pop $0
233             ; MessageBox MB_OK|MB_ICONSTOP "Stopping failed - Reason: $0"
234         ; ${Else}
235              ; SimpleSC::RemoveService "QuasselCore"
236              ; Pop $0 ; returns an errorcode (<>0) otherwise success (0)
237              ; ${If} $0 != 0
238                     ; Push $0
239                     ; SimpleSC::GetErrorMessage
240                     ; Pop $0
241                     ; MessageBox MB_OK|MB_ICONSTOP "Remove fails - Reason: $0"
242                 ; ${EndIf}
243         ; ${EndIf}
244     ; ${EndIf}
245   ; ${EndIf}
246
247     RMDir /r "$SMPROGRAMS\$StartMenuFolder"
248     RMDir /r "$INSTDIR"
249 SectionEnd
250
251 Function .onSelChange
252     ${If} ${SectionIsSelected} ${QUASSEL_CORE}
253     ${OrIf}  ${SectionIsSelected} ${QUASSEL_CLIENT}
254     ${OrIf}  ${SectionIsSelected} ${QUASSEL_ALL_IN_ONE}
255         GetDlgItem $0 $HWNDPARENT 1
256         EnableWindow $0 1
257     ${Else}
258         GetDlgItem $0 $HWNDPARENT 1
259         EnableWindow $0 0
260     ${EndIf}
261 FunctionEnd
262
263 Function .onInit
264     ReadRegStr $R0 HKLM "${uninstkey}" "UninstallString"
265     StrCmp $R0 "" done
266     ReadRegStr $INSTDIR HKLM "${regkey}" "Install_Dir"
267     ;Run the uninstaller
268     ;uninst:
269     ClearErrors
270     ExecWait '$R0 _?=$INSTDIR' ;Do not copy the uninstaller to a temp file
271     done:
272 FunctionEnd