-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Expand file tree
/
Copy pathInstallFlow.h
More file actions
231 lines (194 loc) · 8.92 KB
/
InstallFlow.h
File metadata and controls
231 lines (194 loc) · 8.92 KB
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
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
#pragma once
#include "ExecutionContext.h"
#include <winget/Manifest.h>
namespace AppInstaller::CLI::Workflow
{
using namespace std::string_view_literals;
// Token specified in installer args will be replaced by proper value.
static constexpr std::string_view ARG_TOKEN_LOGPATH = "<LOGPATH>"sv;
static constexpr std::string_view ARG_TOKEN_INSTALLPATH = "<INSTALLPATH>"sv;
// Determines if an installer type is allowed to install/uninstall in parallel.
bool ExemptFromSingleInstallLocking(AppInstaller::Manifest::InstallerTypeEnum type);
namespace details
{
// These single type install flows should remain "internal" and only ExecuteInstallerForType should be used externally
// so that all installs can properly handle single install locking.
// Runs the installer via ShellExecute.
// Required Args: None
// Inputs: Installer, InstallerPath
// Outputs: None
void ShellExecuteInstall(Execution::Context& context);
// Runs an MSI installer directly via MSI APIs.
// Required Args: None
// Inputs: Installer, InstallerPath
// Outputs: None
void DirectMSIInstall(Execution::Context& context);
// Deploys the MSIX.
// Required Args: None
// Inputs: Manifest?, Installer || InstallerPath
// Outputs: None
void MsixInstall(Execution::Context& context);
// Runs the flow for installing a Portable package.
// Required Args: None
// Inputs: Installer, InstallerPath
// Outputs: None
void PortableInstall(Execution::Context& context);
// Runs the flow for installing a package from an archive.
// Required Args: None
// Inputs: Installer, InstallerPath, Manifest
// Outputs: None
void ArchiveInstall(Execution::Context& context);
// Runs the flow for installing a font package.
// Required Args: None
// Inputs: Installer, InstallerPath, Manifest
// Outputs: None
void FontInstall(Execution::Context& context);
}
// Ensures that there is an applicable installer.
// Required Args: None
// Inputs: Installer
// Outputs: None
void EnsureApplicableInstaller(Execution::Context& context);
// Shows the installation disclaimer.
// Required Args: None
// Inputs: None
// Outputs: None
void ShowInstallationDisclaimer(Execution::Context& context);
// Displays the installations notes after a successful install.
// Required Args: None
// Inputs: InstallationNotes
// Outputs: None
void DisplayInstallationNotes(Execution::Context& context);
// Checks if there are any included arguments that are not supported for the package.
// Required Args: None
// Inputs: Installer
// Outputs: None
void CheckForUnsupportedArgs(Execution::Context& context);
// Admin is required for machine scope install for installer types like portable, msix and msstore.
// Required Args: None
// Inputs: Installer
// Outputs: None
void EnsureRunningAsAdminForMachineScopeInstall(Execution::Context& context);
// Composite flow that chooses what to do based on the installer type.
// Required Args: None
// Inputs: Installer, InstallerPath
// Outputs: None
void ExecuteInstaller(Execution::Context& context);
// Composite flow that chooses what to do based on the installer type.
// Required Args: None
// Inputs: Installer, InstallerPath
// Outputs: None
struct ExecuteInstallerForType : public WorkflowTask
{
ExecuteInstallerForType(Manifest::InstallerTypeEnum installerType) : WorkflowTask("ExecuteInstallerForType"), m_installerType(installerType) {}
void operator()(Execution::Context& context) const override;
private:
Manifest::InstallerTypeEnum m_installerType;
};
// Verifies parameters for install to ensure success.
// Required Args: None
// Inputs:
// Outputs: None
void EnsureSupportForInstall(Execution::Context& context);
// Reports the return code returned by the installer.
// Required Args: None
// Inputs: Manifest, Installer, InstallerResult
// Outputs: None
struct ReportInstallerResult : public WorkflowTask
{
ReportInstallerResult(std::string_view installerType, HRESULT hr, bool isHResult = false) :
WorkflowTask("ReportInstallerResult"),
m_installerType(installerType),
m_hr(hr),
m_isHResult(isHResult) {}
void operator()(Execution::Context& context) const override;
private:
// Installer type used when reporting failures.
std::string_view m_installerType;
// Result to return if the installer failed.
HRESULT m_hr;
// Whether the installer result is an HRESULT. This guides how we show it.
bool m_isHResult;
};
// Reports manifest identity and shows installation disclaimer
// Required Args: None
// Inputs: Manifest
// Outputs: None
void ReportIdentityAndInstallationDisclaimer(Execution::Context& context);
// Installs a specific package installer. See also InstallSinglePackage & ProcessMultiplePackages
// Required Args: None
// Inputs: InstallerPath, Manifest, Installer, PackageVersion, InstalledPackageVersion?
// Outputs: None
void InstallPackageInstaller(Execution::Context& context);
// Emits deferred install/repair success after post-install steps (ARP verification, etc.).
void ReportDeferredInstallSuccess(Execution::Context& context);
// Installs the dependencies for a specific package. CreateDependencySubContexts should have been called before this task.
// Required Args: None
// Inputs: InstallerPath, Manifest, Installer, PackageVersion, InstalledPackageVersion?
// Outputs: None
void InstallDependencies(Execution::Context& context);
// Downloads all of the package dependencies of a specific package. Only used in the 'winget download' and COM download flows.
// Required Args: none
// Inputs: Manifest, Installer
// Outputs: None
void DownloadPackageDependencies(Execution::Context& context);
// Installs a single package. This also does the reporting, user interaction, and installer download
// for single-package installation.
// RequiredArgs: None
// Inputs: Manifest, Installer, PackageVersion, InstalledPackageVersion?
// Outputs: None
void InstallSinglePackage(Execution::Context& context);
// Processes multiple packages by handling download and/or install. This also does the reporting and user interaction needed.
// Required Args: None
// Inputs: PackageSubContexts
// Outputs: None
struct ProcessMultiplePackages : public WorkflowTask
{
// Flags to signal change from default behavior of the task.
enum class Flags : uint32_t
{
None = 0x00,
SkipPackageAgreements = 0x01,
IgnoreDependencies = 0x02,
StopOnFailure = 0x04,
RefreshPathVariable = 0x08,
DownloadOnly = 0x10,
DependenciesOnly = 0x20,
};
ProcessMultiplePackages(
StringResource::StringId dependenciesReportMessage,
HRESULT resultOnFailure,
Flags flags = Flags::None,
std::vector<HRESULT>&& ignorableInstallResults = {});
void operator()(Execution::Context& context) const override;
private:
HRESULT m_resultOnFailure;
std::vector<HRESULT> m_ignorableInstallResults;
StringResource::StringId m_dependenciesReportMessage;
bool m_ignorePackageDependencies;
bool m_ensurePackageAgreements;
bool m_stopOnFailure;
bool m_refreshPathVariable;
bool m_downloadOnly;
bool m_dependenciesOnly;
};
DEFINE_ENUM_FLAG_OPERATORS(ProcessMultiplePackages::Flags);
// Stores the existing set of packages in ARP.
// Required Args: None
// Inputs: Installer
// Outputs: ARPSnapshot
void SnapshotARPEntries(Execution::Context& context);
// Reports on the changes between the stored ARPSnapshot and the current values,
// and stores the product code of the ARP entry found for the package.
// Required Args: None
// Inputs: ARPSnapshot?, Manifest, PackageVersion
// Outputs: CorrelatedAppsAndFeaturesEntries?
void ReportARPChanges(Execution::Context& context);
// Records the installation to the tracking catalog.
// Required Args: None
// Inputs: PackageVersion?, Manifest, Installer, CorrelatedAppsAndFeaturesEntries?
// Outputs: None
void RecordInstall(Execution::Context& context);
}