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