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