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