This repository has been archived by the owner on Jan 16, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 28
/
package.wxs
173 lines (149 loc) · 7.44 KB
/
package.wxs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
<?xml version="1.0" encoding="utf-8"?>
<?define UpgradeCode = "2056bd8a-bf03-11e6-a625-f0def1753696" ?>
<?ifndef var.SrvBinaryName ?>
<?define var.SrvBinaryName = "nssm.exe" ?>
<?endif?>
<?ifndef var.SrvBinaryFile ?>
<?define var.SrvBinaryFile = "nssm/win32/nssm.exe" ?>
<?endif?>
<?ifndef var.SrvBinaryArgs ?>
<?define var.SrvBinaryArgs = "" ?>
<?endif?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Product Name="OpenNebula Contextualization"
Manufacturer="OpenNebula Systems"
Id="*"
UpgradeCode="$(var.UpgradeCode)"
Language="1033" Codepage="1252"
Version="$(var.Version)">
<Package Id="*" Keywords="Installer"
Description="OpenNebula Windows Contextualization package"
Comments="OpenNebula is a registered trademark of the OpenNebula Systems"
Manufacturer="OpenNebula Systems"
InstallerVersion="100" Languages="1033" Compressed="yes" SummaryCodepage="1252" />
<Media Id="1" Cabinet="cabinet.cab" EmbedCab="yes" />
<Property Id="ARPHELPLINK" Value="https://forum.opennebula.org/" />
<Property Id="ARPURLINFOABOUT" Value="https://github.com/OpenNebula/addon-context-windows" />
<Property Id="ARPNOMODIFY" Value="1"/>
<Property Id="ARPNOREPAIR" Value="1"/>
<!-- Allow package upgrades only -->
<Upgrade Id="$(var.UpgradeCode)">
<UpgradeVersion Minimum="$(var.Version)" OnlyDetect="yes" Property="NEWERVERSIONDETECTED"/>
<UpgradeVersion Minimum="0.0.0" Maximum="$(var.Version)" IncludeMinimum="yes" IncludeMaximum="no" Property="OLDERVERSIONBEINGUPGRADED"/>
</Upgrade>
<Condition Message="Contextualization package is already installed.">INSTALLED OR NOT NEWERVERSIONDETECTED</Condition>
<!-- Check if we have PowerShell installed -->
<Property Id="PSEXE">
<RegistrySearch Id="PSEXE"
Type="raw"
Root="HKLM"
Key="SOFTWARE\Microsoft\PowerShell\1\ShellIds\Microsoft.PowerShell"
Name="Path" />
</Property>
<Condition Message="Windows PowerShell not found.">INSTALLED OR PSEXE</Condition>
<!-- Register property FASTBOOT -->
<Property Id="FASTBOOT">
<RegistrySearch Id="FASTBOOT"
Type="raw"
Root="HKLM"
Key="SYSTEM\CurrentControlSet\Control\Session Manager\Power"
Name="HiberbootEnabled" />
</Property>
<!--
workaround for missing features in wixl implementation...there should be
a couple of ways how to achieve the same with WiX semantics but the wixl
support is limited and running an exe was the only properly working
solution for the time being:
1. overwrite already existing registry
2. do not delete the registry on uninstall...
-->
<Property Id="REG" Value="C:\Windows\System32\reg.exe" />
<!-- Register action DisableFastBoot -->
<!--
wixl from msitools does not support all WiX features - like these:
<SetProperty Id="FASTBOOT" Value="#0" Before="InstallValidate" />
<CustomAction Id="DisableFastBoot" Property="FASTBOOT" Value="#0" />
-->
<CustomAction Id="DisableFastBoot"
Property="REG"
ExeCommand='add "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Power" /v HiberbootEnabled /t REG_DWORD /d 0 /f'
Execute="deferred"
Impersonate="no"
/>
<!-- Install files -->
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFilesFolder" Name="PFiles">
<Directory Id="INSTALLDIR" Name="OpenNebula">
<Component Id="Examples" Guid="fc1207c2-06e9-11ea-ad15-f0def1753696">
<File Id="unattend" Name="unattend.xml" DiskId="1" Source="unattend.xml" KeyPath="yes" />
</Component>
<Component Id="Context" Guid="f5807056-bf0c-11e6-acbe-f0def1753696">
<File Id="context" Name="context.ps1" DiskId="1" Source="src/context.ps1" KeyPath="yes" />
</Component>
<Component Id="Service" Guid="687050a4-c237-11e6-9fe4-54a050d65572">
<File Id="$(var.SrvBinaryName)" Name="$(var.SrvBinaryName)" DiskId="1" Source="$(var.SrvBinaryFile)" KeyPath="yes" />
<ServiceInstall Id="ocInstall" Name="onecontext"
DisplayName="OpenNebula Contextualization Service"
Description="Contextualizes virtual machines running in the OpenNebula cloud"
Type="ownProcess"
Start="auto"
Account="[SYSTEM]"
Arguments="$(var.SrvBinaryArgs)"
ErrorControl="normal">
<ServiceDependency Id="Winmgmt" />
<ServiceDependency Id="PlugPlay" />
<ServiceDependency Id="Tcpip" />
<ServiceDependency Id="Dhcp" />
<ServiceDependency Id="Dnscache" />
</ServiceInstall>
<ServiceControl Id="ocControl" Name="onecontext"
Remove="both"
Stop="both"
Wait="yes" />
<?if $(var.SrvBinaryName) = "nssm.exe" ?>
<RegistryKey Root="HKLM" Key="SYSTEM\CurrentControlSet\Services\onecontext\Parameters">
<RegistryValue Type="string" Name="Application" Value="[PSEXE]" />
<RegistryValue Type="string" Name="AppDirectory" Value="[INSTALLDIR]" />
<RegistryValue Type="string" Name="AppParameters" Value="-NonInteractive -NoProfile -ExecutionPolicy Unrestricted -file "[#context]"" />
</RegistryKey>
<RegistryKey Root="HKLM" Key="SYSTEM\CurrentControlSet\Services\onecontext\Parameters\AppExit">
<!-- You can change this to "Restart" but "Ignore" is compatible behavior with srvany and it will prevent unwanted recontextualization -->
<RegistryValue Type="string" Value="Ignore" />
</RegistryKey>
<?else?>
<RegistryKey Root="HKLM" Key="SYSTEM\CurrentControlSet\Services\onecontext\Parameters">
<RegistryValue Type="string" Name="CommandLine" Value=""[PSEXE]" -NonInteractive -NoProfile -ExecutionPolicy Unrestricted -file "[#context]"" />
<RegistryValue Type="string" Name="PWD" Value="[INSTALLDIR]" />
</RegistryKey>
<?endif?>
</Component>
</Directory>
</Directory>
</Directory>
<!-- Features -->
<Feature Id="Complete" Level="1">
<ComponentRef Id="Context"/>
<ComponentRef Id="Service"/>
<ComponentRef Id="Examples"/>
</Feature>
<InstallExecuteSequence>
<!-- NOTE:
This works for msitools/wixl implementation (v0.98) but according to
WiX documentation:
https://wixtoolset.org/documentation/manual/v3/xsd/wix/custom.html
it should not - 'Before' and 'After' are mutually exclusive...
*BUT* if we do not specify both of them like this the custom action
'DisableFastBoot' will not get the right sequence number - another
fix could be to use only 'Sequence' and somehow figure out the
correct number for it - at the time of the writing it should be
somewhere between 'InstallInitialize' (1500) and 'InstallFinalize'
(6600).
The reason why we need to be between these two stages is the fact
that we must run 'DisableFastBoot' as 'deffered' to get elevated
privileges...
-->
<Custom Action="DisableFastBoot" After="InstallInitialize" Before="InstallFinalize">NOT REMOVE AND FASTBOOT</Custom>
<RemoveExistingProducts After="InstallValidate" />
</InstallExecuteSequence>
</Product>
</Wix>