]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - win/inspircd.nsi
m_callerid Remove redundant includes
[user/henk/code/inspircd.git] / win / inspircd.nsi
1 ;
2 ; InspIRCd -- Internet Relay Chat Daemon
3 ;
4 ;   Copyright (C) 2011 Adam <Adam@anope.org>
5 ;   Copyright (C) 2007 Dennis Friis <peavey@inspircd.org>
6 ;   Copyright (C) 2007 Craig Edwards <craigedwards@brainbox.cc>
7 ;
8 ; This file is part of InspIRCd.  InspIRCd is free software: you can
9 ; redistribute it and/or modify it under the terms of the GNU General Public
10 ; License as published by the Free Software Foundation, version 2.
11 ;
12 ; This program is distributed in the hope that it will be useful, but WITHOUT
13 ; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
14 ; FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
15 ; details.
16 ;
17 ; You should have received a copy of the GNU General Public License
18 ; along with this program.  If not, see <http://www.gnu.org/licenses/>.
19 ;
20
21
22 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
23
24                        ;;;; SET THE BUILD TO BE PACKAGED HERE ;;;;
25
26 !define BUILD "release"
27
28 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
29
30 ; HM NIS Edit Wizard helper defines
31 !define PRODUCT_NAME "InspIRCd"
32 !define PRODUCT_VERSION "2.0"
33 !define PRODUCT_PUBLISHER "InspIRCd Development Team"
34 !define PRODUCT_WEB_SITE "http://www.inspircd.org/"
35 !define PRODUCT_DIR_REGKEY "Software\Microsoft\Windows\CurrentVersion\App Paths\inspircd.exe"
36 !define PRODUCT_UNINST_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}"
37 !define PRODUCT_UNINST_ROOT_KEY "HKLM"
38 !define DOT_MAJOR "2"
39 !define DOT_MINOR "0"
40
41 SetCompressor bzip2
42
43 ; MUI 1.67 compatible ------
44 !include "MUI.nsh"
45
46 ; MUI Settings
47 !define MUI_ABORTWARNING
48 !define MUI_ICON "inspircd.ico"
49 !define MUI_UNICON "inspircd.ico"
50
51 ; Welcome page
52 !insertmacro MUI_PAGE_WELCOME
53 ; License page
54 !define MUI_LICENSEPAGE_CHECKBOX
55 !insertmacro MUI_PAGE_LICENSE "..\docs\COPYING"
56 ; directory page
57 Page directory
58 ; Components page
59 !insertmacro MUI_PAGE_COMPONENTS
60 ; Instfiles page
61 !insertmacro MUI_PAGE_INSTFILES
62
63 ; Uninstaller pages
64 !insertmacro MUI_UNPAGE_INSTFILES
65
66 ; Language files
67 !insertmacro MUI_LANGUAGE "English"
68
69 ; Reserve files
70 !insertmacro MUI_RESERVEFILE_INSTALLOPTIONS
71
72 ; MUI end ------
73
74 Name "${PRODUCT_NAME} ${PRODUCT_VERSION}"
75 OutFile "${PRODUCT_NAME}-${PRODUCT_VERSION}-Setup.exe"
76 InstallDir "$PROGRAMFILES\InspIRCd"
77 InstallDirRegKey HKLM "${PRODUCT_DIR_REGKEY}" ""
78 ShowInstDetails show
79 ShowUnInstDetails show
80
81 Function IsDotNetInstalled
82  
83   StrCpy $0 "0"
84   StrCpy $1 "SOFTWARE\Microsoft\.NETFramework" ;registry entry to look in.
85   StrCpy $2 0
86  
87   StartEnum:
88     ;Enumerate the versions installed.
89     EnumRegKey $3 HKLM "$1\policy" $2
90     
91     ;If we don't find any versions installed, it's not here.
92     StrCmp $3 "" noDotNet notEmpty
93     
94     ;We found something.
95     notEmpty:
96       ;Find out if the RegKey starts with 'v'.  
97       ;If it doesn't, goto the next key.
98       StrCpy $4 $3 1 0
99       StrCmp $4 "v" +1 goNext
100       StrCpy $4 $3 1 1
101       
102       ;It starts with 'v'.  Now check to see how the installed major version
103       ;relates to our required major version.
104       ;If it's equal check the minor version, if it's greater, 
105       ;we found a good RegKey.
106       IntCmp $4 ${DOT_MAJOR} +1 goNext yesDotNetReg
107       ;Check the minor version.  If it's equal or greater to our requested 
108       ;version then we're good.
109       StrCpy $4 $3 1 3
110       IntCmp $4 ${DOT_MINOR} yesDotNetReg goNext yesDotNetReg
111  
112     goNext:
113       ;Go to the next RegKey.
114       IntOp $2 $2 + 1
115       goto StartEnum
116  
117   yesDotNetReg:
118     ;Now that we've found a good RegKey, let's make sure it's actually
119     ;installed by getting the install path and checking to see if the 
120     ;mscorlib.dll exists.
121     EnumRegValue $2 HKLM "$1\policy\$3" 0
122     ;$2 should equal whatever comes after the major and minor versions 
123     ;(ie, v1.1.4322)
124     StrCmp $2 "" noDotNet
125     ReadRegStr $4 HKLM $1 "InstallRoot"
126     ;Hopefully the install root isn't empty.
127     StrCmp $4 "" noDotNet
128     ;build the actuall directory path to mscorlib.dll.
129     StrCpy $4 "$4$3.$2\mscorlib.dll"
130     IfFileExists $4 yesDotNet noDotNet
131  
132   noDotNet:
133     MessageBox MB_OK "You do not have have v${DOT_MAJOR}.${DOT_MINOR} or greater of the .NET framework installed. This is required for the InspIRCd Monitor, however you can still launch the IRCd manually."
134  
135   yesDotNet:
136     ;Everything checks out.  Go on with the rest of the installation.
137     
138 FunctionEnd
139
140 Section "Binary Executable" SEC01
141   Call IsDotNetInstalled
142   CreateDirectory "$SMPROGRAMS\InspIRCd"
143   CreateDirectory "$INSTDIR\logs"
144   CreateDirectory "$INSTDIR\data"
145   CreateShortCut "$SMPROGRAMS\InspIRCd\InspIRCd.lnk" "$INSTDIR\inspircd.exe"
146   SetOutPath "$INSTDIR"
147   SetOverwrite ifnewer
148   File "..\bin\${BUILD}\inspircd.exe"
149   DetailPrint "Installing InspIRCd service..."
150   nsExec::Exec /TIMEOUT=30000 '"$INSTDIR\inspircd.exe" --installservice'
151 SectionEnd
152
153 Section "Config Files" SEC02
154   SetOutPath "$INSTDIR\conf"
155   File "..\docs\*.example"
156 SectionEnd
157
158 Section "Command Handlers" SEC03
159   SetOutPath "$INSTDIR\modules"
160   File "..\bin\${BUILD}\modules\cmd_*.so"
161 SectionEnd
162
163 Section "Modules" SEC04
164   SetOutPath "$INSTDIR\modules"
165   File "..\bin\${BUILD}\modules\m_*.so"
166 SectionEnd
167
168 Section -AdditionalIcons
169   SetOutPath $INSTDIR
170   WriteIniStr "$INSTDIR\${PRODUCT_NAME}.url" "InternetShortcut" "URL" "${PRODUCT_WEB_SITE}"
171   CreateShortCut "$SMPROGRAMS\InspIRCd\InspIRCd Website.lnk" "$INSTDIR\${PRODUCT_NAME}.url"
172   CreateShortCut "$SMPROGRAMS\InspIRCd\Uninstall.lnk" "$INSTDIR\uninst.exe"
173 SectionEnd
174
175 Section -Post
176   WriteUninstaller "$INSTDIR\uninst.exe"
177   WriteRegStr HKLM "${PRODUCT_DIR_REGKEY}" "" "$INSTDIR\inspircd.exe"
178   WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayName" "$(^Name)"
179   WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "UninstallString" "$INSTDIR\uninst.exe"
180   WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayIcon" "$INSTDIR\inspircd.exe"
181   WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayVersion" "${PRODUCT_VERSION}"
182   WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "URLInfoAbout" "${PRODUCT_WEB_SITE}"
183   WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "Publisher" "${PRODUCT_PUBLISHER}"
184   MessageBox MB_ICONINFORMATION|MB_OK "InspIRCd was successfully installed. Remember to edit your configuration file in $INSTDIR\conf!"
185 SectionEnd
186
187 ; Section descriptions
188 !insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
189   !insertmacro MUI_DESCRIPTION_TEXT ${SEC01} "Actual executable"
190   !insertmacro MUI_DESCRIPTION_TEXT ${SEC03} "Command modules"
191   !insertmacro MUI_DESCRIPTION_TEXT ${SEC02} "Default configuration files"
192   !insertmacro MUI_DESCRIPTION_TEXT ${SEC04} "Optional non-SSL modules"
193 !insertmacro MUI_FUNCTION_DESCRIPTION_END
194
195
196 Function un.onUninstSuccess
197   HideWindow
198   MessageBox MB_ICONINFORMATION|MB_OK "$(^Name) was successfully removed from your computer."
199 FunctionEnd
200
201 Function .onInit
202   SectionSetFlags ${SEC01} 17
203   SectionSetFlags ${SEC03} 17
204   StrCpy $INSTDIR "$PROGRAMFILES\InspIRCd"
205 FunctionEnd
206
207 Function un.onInit
208   MessageBox MB_ICONQUESTION|MB_YESNO|MB_DEFBUTTON2 "Are you sure you want to completely remove $(^Name) and all of its components?" IDYES +2
209   Abort
210 FunctionEnd
211
212 Section Uninstall
213   DetailPrint "Uninstalling InspIRCd service..."
214   nsExec::Exec /TIMEOUT=30000 '"$INSTDIR\inspircd.exe" --removeservice'
215   Delete "$INSTDIR\${PRODUCT_NAME}.url"
216   Delete "$INSTDIR\uninst.exe"
217   Delete "$INSTDIR\modules\*.so"
218   Delete "$INSTDIR\conf\*.example"
219   Delete "$INSTDIR\*.log"
220   Delete "$INSTDIR\logs\*"
221   Delete "$INSTDIR\data\*"
222   Delete "$INSTDIR\inspircd.exe"
223   Delete "$SMPROGRAMS\InspIRCd\Uninstall.lnk"
224   Delete "$SMPROGRAMS\InspIRCd\InspIRCd Website.lnk"
225   Delete "$SMPROGRAMS\InspIRCd\InspIRCd.lnk"
226
227   RMDir "$SMPROGRAMS\InspIRCd"
228   RMDir "$INSTDIR\modules"
229   RMDir "$INSTDIR\conf"
230   RMDir "$INSTDIR\logs"
231   RMDir "$INSTDIR\data"
232   RMDir "$INSTDIR"
233
234   DeleteRegKey ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}"
235   DeleteRegKey HKLM "${PRODUCT_DIR_REGKEY}"
236   SetAutoClose true
237 SectionEnd