win-pvdrivers

view installer.nsi @ 337:e69e4d79ee3f

fixed a few bugs in the installer wrt certs
author James Harper <james.harper@bendigoit.com.au>
date Sun Jun 22 20:37:11 2008 +1000 (2008-06-22)
parents 2fcbd37634a3
children 8c419cbee528
line source
1 !include "MUI.nsh"
2 !include "driver.nsh"
4 !define AppName "Xen PV Drivers"
5 !define StartMenu "$SMPROGRAMS\${AppName}"
6 !define Version "0.9.11-pre4"
7 #!define Version "$%VERSION%"
8 Name "${AppName}"
9 InstallDir "$PROGRAMFILES\${AppName}"
10 OutFile "${AppName} ${Version}.exe"
12 # make sure /GPLPV is not currently active
14 #!define MUI_PAGE_CUSTOMFUNCTION_PRE WelcomePageSetupLinkPre
15 #!define MUI_PAGE_CUSTOMFUNCTION_SHOW WelcomePageSetupLinkShow
16 !define MUI_STARTMENUPAGE
17 !define MUI_COMPONENTSPAGE
18 !define MUI_DIRECTORYPAGE
19 !insertmacro MUI_PAGE_WELCOME
20 !insertmacro MUI_PAGE_COMPONENTS
21 !insertmacro MUI_PAGE_INSTFILES
22 !define MUI_UNINSTALLER
23 !insertmacro MUI_LANGUAGE "English"
25 Section "Common Files"
26 SectionIn RO
27 SetOutPath $INSTDIR
28 File .\doc\Building.txt
29 File .\doc\Installing.txt
30 File .\doc\Readme.txt
31 File .\doc\TODO.txt
32 CreateDirectory "${StartMenu}\"
33 CreateShortCut "${StartMenu}\Building.lnk" "$INSTDIR\Building.txt"
34 CreateShortCut "${StartMenu}\Installing.lnk" "$INSTDIR\Installing.txt"
35 CreateShortCut "${StartMenu}\Readme.lnk" "$INSTDIR\Readme.txt"
36 CreateShortCut "${StartMenu}\TODO.lnk" "$INSTDIR\TODO.txt"
37 CreateShortCut "${StartMenu}\Wiki Page.lnk" "http://wiki.xensource.com/xenwiki/XenWindowsGplPv"
38 WriteUninstaller $INSTDIR\Uninstall.exe
39 CreateShortCut "${StartMenu}\Uninstall.lnk" "$INSTDIR\uninstall.exe"
41 SectionEnd
43 Section "Shutdown Monitor Service" shutdownmon
44 SetOutPath $INSTDIR
46 ExecWait 'NET STOP XenShutdownMon'
47 File .\target\ShutdownMon.exe
48 # CreateShortCut "${StartMenu}\Install Shutdown Service.lnk" "$INSTDIR\ShutdownMon.exe" "-i"
49 # CreateShortCut "${StartMenu}\UnInstall Shutdown Service.lnk" "$INSTDIR\ShutdownMon.exe" "-u"
50 ExecWait '"$INSTDIR\ShutdownMon.exe" -i'
51 ExecWait 'NET START XenShutdownMon'
52 SectionEnd
54 Section "Windows 2000" win2k
55 SetOutPath $INSTDIR
56 File /nonfatal .\ca.cer
57 SetOutPath $INSTDIR\drivers
58 File .\target\win2k\xenpci.inf
59 File .\target\win2k\xennet.inf
60 File .\target\win2k\xenvbd.inf
61 File .\target\win2k\xenscsi.inf
62 File .\target\win2k\xenstub.inf
63 SetOutPath $INSTDIR\drivers\i386
64 File .\target\win2k\i386\xenpci.sys
65 File .\target\win2k\i386\xenhide.sys
66 File .\target\win2k\i386\xennet.sys
67 File .\target\win2k\i386\xenvbd.sys
68 File .\target\win2k\i386\xenscsi.sys
69 File .\target\win2k\i386\xenstub.sys
70 File .\target\win2k\i386\xenconfig.sys
71 SectionEnd
73 Section "Windows XP" winxp
74 SetOutPath $INSTDIR
75 File /nonfatal .\ca.cer
76 SetOutPath $INSTDIR\drivers
77 File .\target\winxp\xenpci.inf
78 File .\target\winxp\xennet.inf
79 File .\target\winxp\xenvbd.inf
80 File .\target\winxp\xenscsi.inf
81 File .\target\winxp\xenstub.inf
82 File /nonfatal .\target\winxp\xengplpv.cat
83 SetOutPath $INSTDIR\drivers\i386
84 File .\target\winxp\i386\xenpci.sys
85 File .\target\winxp\i386\xenhide.sys
86 File .\target\winxp\i386\xennet.sys
87 File .\target\winxp\i386\xenvbd.sys
88 File .\target\winxp\i386\xenscsi.sys
89 File .\target\winxp\i386\xenstub.sys
90 File .\target\winxp\i386\xenconfig.sys
91 SectionEnd
93 Section "Windows 2003 x32" win2k3x32
94 SetOutPath $INSTDIR
95 File /nonfatal .\ca.cer
96 SetOutPath $INSTDIR\drivers
97 File .\target\winnet\xenpci.inf
98 File .\target\winnet\xennet.inf
99 File .\target\winnet\xenvbd.inf
100 File .\target\winnet\xenscsi.inf
101 File .\target\winnet\xenstub.inf
102 File /nonfatal .\target\winnet\xengplpv.cat
103 SetOutPath $INSTDIR\drivers\i386
104 File .\target\winnet\i386\xenpci.sys
105 File .\target\winnet\i386\xenhide.sys
106 File .\target\winnet\i386\xennet.sys
107 File .\target\winnet\i386\xenvbd.sys
108 File .\target\winnet\i386\xenscsi.sys
109 File .\target\winnet\i386\xenstub.sys
110 File .\target\winnet\i386\xenconfig.sys
111 SectionEnd
113 Section "Windows 2003 x64" win2k3x64
114 SetOutPath $INSTDIR
115 File /nonfatal .\ca.cer
116 SetOutPath $INSTDIR\drivers
117 File .\target\winnet\xenpci.inf
118 File .\target\winnet\xennet.inf
119 File .\target\winnet\xenvbd.inf
120 File .\target\winnet\xenscsi.inf
121 File .\target\winnet\xenstub.inf
122 File /nonfatal .\target\winnet\xengplpv.cat
123 SetOutPath $INSTDIR\drivers\amd64
124 File .\target\winnet\amd64\xenpci.sys
125 File .\target\winnet\amd64\xenhide.sys
126 File .\target\winnet\amd64\xennet.sys
127 File .\target\winnet\amd64\xenvbd.sys
128 File .\target\winnet\amd64\xenscsi.sys
129 File .\target\winnet\amd64\xenstub.sys
130 File .\target\winnet\amd64\xenconfig.sys
131 SectionEnd
133 Section "Windows 2008 x32" win2k8x32
134 SetOutPath $INSTDIR
135 File /nonfatal .\ca.cer
136 SetOutPath $INSTDIR\drivers
137 File .\target\winlh\xenpci.inf
138 File .\target\winlh\xennet.inf
139 File .\target\winlh\xenvbd.inf
140 File .\target\winlh\xenscsi.inf
141 File .\target\winlh\xenstub.inf
142 File /nonfatal .\target\winlh\xengplpv.cat
143 SetOutPath $INSTDIR\drivers\i386
144 File .\target\winlh\i386\xenpci.sys
145 File .\target\winlh\i386\xenhide.sys
146 File .\target\winlh\i386\xennet.sys
147 File .\target\winlh\i386\xenvbd.sys
148 File .\target\winlh\i386\xenscsi.sys
149 File .\target\winlh\i386\xenstub.sys
150 File .\target\winlh\i386\xenconfig.sys
151 SectionEnd
153 Section "Windows 2008 x64" win2k8x64
154 SetOutPath $INSTDIR
155 File /nonfatal .\ca.cer
156 SetOutPath $INSTDIR\drivers
157 File .\target\winlh\xenpci.inf
158 File .\target\winlh\xennet.inf
159 File .\target\winlh\xenvbd.inf
160 File .\target\winlh\xenscsi.inf
161 File .\target\winlh\xenstub.inf
162 File /nonfatal .\target\winlh\xengplpv.cat
163 SetOutPath $INSTDIR\drivers\amd64
164 File .\target\winlh\amd64\xenpci.sys
165 File .\target\winlh\amd64\xenhide.sys
166 File .\target\winlh\amd64\xennet.sys
167 File .\target\winlh\amd64\xenvbd.sys
168 File .\target\winlh\amd64\xenscsi.sys
169 File .\target\winlh\amd64\xenstub.sys
170 File .\target\winlh\amd64\xenconfig.sys
171 SectionEnd
173 Section /o "Install Cert" installcert
174 ExecWait 'rundll32.exe cryptext.dll,CryptExtAddCER $INSTDIR\ca.cer'
175 SectionEnd
177 Section "Install Drivers" installdrivers
178 Push "$INSTDIR\drivers"
179 Push "$INSTDIR\drivers\xenpci.inf"
180 Push "PCI\VEN_5853&DEV_0001"
181 Call InstallUpgradeDriver
183 Push "$INSTDIR\drivers"
184 Push "$INSTDIR\drivers\xennet.inf"
185 Push "XEN\VIF"
186 Call InstallUpgradeDriver
188 Push "$INSTDIR\drivers"
189 Push "$INSTDIR\drivers\xenvbd.inf"
190 Push "XEN\VBD"
191 Call InstallUpgradeDriver
193 Push "$INSTDIR\drivers"
194 Push "$INSTDIR\drivers\xenscsi.inf"
195 Push "XEN\VSCSI"
196 Call InstallUpgradeDriver
198 Push "$INSTDIR\drivers"
199 Push "$INSTDIR\drivers\xenstub.inf"
200 Push "XEN\CONSOLE"
201 Call InstallUpgradeDriver
203 Push "$INSTDIR\drivers"
204 Push "$INSTDIR\drivers\xenstub.inf"
205 Push "XEN\VFB"
206 Call InstallUpgradeDriver
208 Push "$INSTDIR\drivers"
209 Push "$INSTDIR\drivers\xenstub.inf"
210 Push "XEN\VKBD"
211 Call InstallUpgradeDriver
212 SectionEnd
214 Var arch
216 Function .onInit
217 Push $0
219 ReadRegStr $0 HKLM SYSTEM\CurrentControlSet\Control SystemStartOptions
220 Push $0
221 Push "GPLPV"
222 Call StrContains
223 Pop $0
224 StrCmp $0 "" no_GPLPV
226 ReadRegStr $0 HKLM SYSTEM\CurrentControlSet\Services\XenHide DisplayName
227 StrCmp $0 "" 0 no_GPLPV
229 MessageBox MB_OK "Warning - GPLPV specified on boot but drivers not installed yet. You should cancel now and boot without GPLPV"
230 no_GPLPV:
232 Call GetWindowsVersion
233 Pop $R0
235 StrCmp $R0 "2000" 0 check_XP
236 StrCpy $arch "win2k"
237 Goto version_done
238 check_XP:
239 StrCmp $R0 "XP" 0 check_2k3
240 StrCpy $arch "winxp"
241 Goto version_done
242 check_2k3:
243 StrCmp $R0 "2003" 0 check_2k8
244 ReadRegStr $0 HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment" PROCESSOR_ARCHITECTURE
245 StrCmp $0 "AMD64" version_2k3x64
246 StrCpy $arch "win2k3x32"
247 Goto version_done
248 version_2k3x64:
249 StrCpy $arch "win2k3x64"
250 Goto version_done
251 check_2k8:
252 StrCmp $R0 "Vista" 0 version_error
253 ReadRegStr $0 HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment" PROCESSOR_ARCHITECTURE
254 StrCmp $0 "AMD64" version_2k8x64
255 StrCpy $arch "win2k8x32"
256 Goto version_done
257 version_2k8x64:
258 StrCpy $arch "win2k8x64"
259 Goto version_done
260 version_error:
261 MessageBox MB_OK "Unable to detect windows version - proceed with caution"
262 StrCpy $arch ""
264 version_done:
265 Call SelectSection
267 # SectionGetFlags ${sec1} $0
268 # IntOp $0 $0 | ${SF_SELECTED}
269 # SectionSetFlags ${sec1} $0
271 Pop $0
272 FunctionEnd
274 Var NewArch
276 Function .onSelChange
277 Push $0
279 StrCmp $arch "win2k" check_xp
280 SectionGetFlags ${win2k} $0
281 IntOp $0 $0 & ${SF_SELECTED}
282 IntCmp $0 ${SF_SELECTED} 0 check_xp check_xp
283 StrCpy $newarch "win2k"
284 check_xp:
285 StrCmp $arch "winxp" check_2k3x32
286 SectionGetFlags ${winxp} $0
287 IntOp $0 $0 & ${SF_SELECTED}
288 IntCmp $0 ${SF_SELECTED} 0 check_2k3x32 check_2k3x32
289 StrCpy $newarch "winxp"
290 check_2k3x32:
291 StrCmp $arch "win2k3x32" check_2k3x64
292 SectionGetFlags ${win2k3x32} $0
293 IntOp $0 $0 & ${SF_SELECTED}
294 IntCmp $0 ${SF_SELECTED} 0 check_2k3x64 check_2k3x64
295 StrCpy $newarch "win2k3x32"
296 check_2k3x64:
297 StrCmp $arch "win2k3x64" check_2k8x32
298 SectionGetFlags ${win2k3x64} $0
299 IntOp $0 $0 & ${SF_SELECTED}
300 IntCmp $0 ${SF_SELECTED} 0 check_2k8x32 check_2k8x32
301 StrCpy $newarch "win2k3x64"
302 check_2k8x32:
303 StrCmp $arch "win2k8x32" check_2k8x64
304 SectionGetFlags ${win2k8x32} $0
305 IntOp $0 $0 & ${SF_SELECTED}
306 IntCmp $0 ${SF_SELECTED} 0 check_2k8x64 check_2k8x64
307 StrCpy $newarch "win2k8x32"
308 check_2k8x64:
309 StrCmp $arch "win2k8x64" done
310 SectionGetFlags ${win2k8x64} $0
311 IntOp $0 $0 & ${SF_SELECTED}
312 IntCmp $0 ${SF_SELECTED} 0 done done
313 StrCpy $newarch "win2k8x64"
314 done:
315 StrCpy $arch $newarch
316 Call SelectSection
318 Pop $0
319 FunctionEnd
321 Function SelectSection
322 Push $0
324 StrCmp $arch "win2k" check_xp
325 SectionGetFlags ${win2k} $0
326 IntOp $0 $0 & ${SECTION_OFF}
327 SectionSetFlags ${win2k} $0
328 check_xp:
329 StrCmp $arch "winxp" check_2k3x32
330 SectionGetFlags ${winxp} $0
331 IntOp $0 $0 & ${SECTION_OFF}
332 SectionSetFlags ${winxp} $0
333 check_2k3x32:
334 StrCmp $arch "win2k3x32" check_2k3x64
335 SectionGetFlags ${win2k3x32} $0
336 IntOp $0 $0 & ${SECTION_OFF}
337 SectionSetFlags ${win2k3x32} $0
338 check_2k3x64:
339 StrCmp $arch "win2k3x64" check_2k8x32
340 SectionGetFlags ${win2k3x64} $0
341 IntOp $0 $0 & ${SECTION_OFF}
342 SectionSetFlags ${win2k3x64} $0
343 check_2k8x32:
344 StrCmp $arch "win2k8x32" check_2k8x64
345 SectionGetFlags ${win2k8x32} $0
346 IntOp $0 $0 & ${SECTION_OFF}
347 SectionSetFlags ${win2k8x32} $0
348 check_2k8x64:
349 StrCmp $arch "win2k8x64" done
350 SectionGetFlags ${win2k8x64} $0
351 IntOp $0 $0 & ${SECTION_OFF}
352 SectionSetFlags ${win2k8x64} $0
353 done:
354 Pop $0
356 FunctionEnd
358 Section "Uninstall"
359 Delete "${StartMenu}\Uninstall.lnk"
360 RMDir "${StartMenu}\"
361 Delete $INSTDIR\uninstall.exe
362 RMDir $INSTDIR
363 SectionEnd
365 Var STR_HAYSTACK
366 Var STR_NEEDLE
367 Var STR_CONTAINS_VAR_1
368 Var STR_CONTAINS_VAR_2
369 Var STR_CONTAINS_VAR_3
370 Var STR_CONTAINS_VAR_4
371 Var STR_RETURN_VAR
373 Function StrContains
374 Exch $STR_NEEDLE
375 Exch 1
376 Exch $STR_HAYSTACK
377 ; Uncomment to debug
378 ;MessageBox MB_OK 'STR_NEEDLE = $STR_NEEDLE STR_HAYSTACK = $STR_HAYSTACK '
379 StrCpy $STR_RETURN_VAR ""
380 StrCpy $STR_CONTAINS_VAR_1 -1
381 StrLen $STR_CONTAINS_VAR_2 $STR_NEEDLE
382 StrLen $STR_CONTAINS_VAR_4 $STR_HAYSTACK
383 loop:
384 IntOp $STR_CONTAINS_VAR_1 $STR_CONTAINS_VAR_1 + 1
385 StrCpy $STR_CONTAINS_VAR_3 $STR_HAYSTACK $STR_CONTAINS_VAR_2 $STR_CONTAINS_VAR_1
386 StrCmp $STR_CONTAINS_VAR_3 $STR_NEEDLE found
387 StrCmp $STR_CONTAINS_VAR_1 $STR_CONTAINS_VAR_4 done
388 Goto loop
389 found:
390 StrCpy $STR_RETURN_VAR $STR_NEEDLE
391 Goto done
392 done:
393 Pop $STR_NEEDLE ;Prevent "invalid opcode" errors and keep the
394 Exch $STR_RETURN_VAR
395 FunctionEnd