Skip to content

Commit

Permalink
Download and install Workflow patches for skip dependencies (#3794)
Browse files Browse the repository at this point in the history
  • Loading branch information
yao-msft authored Oct 20, 2023
1 parent b357fe8 commit dfe9a0f
Show file tree
Hide file tree
Showing 8 changed files with 55 additions and 34 deletions.
4 changes: 3 additions & 1 deletion src/AppInstallerCLICore/Commands/InstallCommand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,13 +139,15 @@ namespace AppInstaller::CLI

if (context.Args.Contains(Execution::Args::Type::MultiQuery))
{
bool skipDependencies = Settings::User().Get<Settings::Setting::InstallSkipDependencies>() || context.Args.Contains(Execution::Args::Type::SkipDependencies);
context <<
Workflow::GetMultiSearchRequests <<
Workflow::SearchSubContextsForSingle() <<
Workflow::ReportExecutionStage(Workflow::ExecutionStage::Execution) <<
Workflow::ProcessMultiplePackages(
Resource::String::PackageRequiresDependencies,
APPINSTALLER_CLI_ERROR_MULTIPLE_INSTALL_FAILED);
APPINSTALLER_CLI_ERROR_MULTIPLE_INSTALL_FAILED,
{}, true, skipDependencies);
}
else
{
Expand Down
4 changes: 3 additions & 1 deletion src/AppInstallerCLICore/Commands/UpgradeCommand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -199,13 +199,15 @@ namespace AppInstaller::CLI
}
else
{
bool skipDependencies = Settings::User().Get<Settings::Setting::InstallSkipDependencies>() || context.Args.Contains(Execution::Args::Type::SkipDependencies);
context <<
Workflow::GetMultiSearchRequests <<
Workflow::SearchSubContextsForSingle(OperationType::Upgrade) <<
Workflow::ReportExecutionStage(Workflow::ExecutionStage::Execution) <<
Workflow::ProcessMultiplePackages(
Resource::String::PackageRequiresDependencies,
APPINSTALLER_CLI_ERROR_MULTIPLE_INSTALL_FAILED);
APPINSTALLER_CLI_ERROR_MULTIPLE_INSTALL_FAILED,
{}, true, skipDependencies);
}
}
}
Expand Down
16 changes: 14 additions & 2 deletions src/AppInstallerCLICore/Workflows/ImportExportFlow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "ImportExportFlow.h"
#include "UpdateFlow.h"
#include "PackageCollection.h"
#include "DependenciesFlow.h"
#include "WorkflowBase.h"
#include <winget/RepositorySearch.h>
#include <winget/Runtime.h>
Expand Down Expand Up @@ -305,8 +306,19 @@ namespace AppInstaller::CLI::Workflow

void InstallImportedPackages(Execution::Context& context)
{
context << Workflow::ProcessMultiplePackages(
Resource::String::ImportCommandReportDependencies, APPINSTALLER_CLI_ERROR_IMPORT_INSTALL_FAILED, {}, true, true);
// Inform all dependencies here. During SubContexts processing, dependencies are ignored.
auto& packageSubContexts = context.Get<Execution::Data::PackageSubContexts>();
Manifest::DependencyList allDependencies;
for (auto& packageContext : packageSubContexts)
{
allDependencies.Add(packageContext->Get<Execution::Data::Installer>().value().Dependencies);
}
context.Add<Execution::Data::Dependencies>(allDependencies);

context <<
Workflow::ReportDependencies(Resource::String::ImportCommandReportDependencies) <<
Workflow::ProcessMultiplePackages(
Resource::String::ImportCommandReportDependencies, APPINSTALLER_CLI_ERROR_IMPORT_INSTALL_FAILED, {}, true, true);

if (context.GetTerminationHR() == APPINSTALLER_CLI_ERROR_IMPORT_INSTALL_FAILED)
{
Expand Down
51 changes: 26 additions & 25 deletions src/AppInstallerCLICore/Workflows/InstallFlow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -547,7 +547,7 @@ namespace AppInstaller::CLI::Workflow
Workflow::GetDependenciesFromInstaller <<
Workflow::ReportDependencies(Resource::String::PackageRequiresDependencies) <<
Workflow::EnableWindowsFeaturesDependencies <<
Workflow::ProcessMultiplePackages(Resource::String::PackageRequiresDependencies, APPINSTALLER_CLI_ERROR_INSTALL_DEPENDENCIES, {}, false, true, true, true);
Workflow::ProcessMultiplePackages(Resource::String::PackageRequiresDependencies, APPINSTALLER_CLI_ERROR_INSTALL_DEPENDENCIES, {}, true, true, true, true);
}

void DownloadPackageDependencies(Execution::Context& context)
Expand Down Expand Up @@ -619,40 +619,44 @@ namespace AppInstaller::CLI::Workflow
return;
}

bool downloadInstallerOnly = WI_IsFlagSet(context.GetFlags(), Execution::ContextFlag::InstallerDownloadOnly);

// Show all prompts needed for every package before installing anything
context << Workflow::ShowPromptsForMultiplePackages(m_ensurePackageAgreements);
context << Workflow::ShowPromptsForMultiplePackages(m_ensurePackageAgreements, downloadInstallerOnly);

if (context.IsTerminated())
{
return;
}

bool downloadInstallerOnly = WI_IsFlagSet(context.GetFlags(), Execution::ContextFlag::InstallerDownloadOnly);

// Report dependencies
auto& packageSubContexts = context.Get<Execution::Data::PackageSubContexts>();
if (!packageSubContexts.empty())
if (!m_ignorePackageDependencies)
{
if (downloadInstallerOnly)
auto& packageSubContexts = context.Get<Execution::Data::PackageSubContexts>();

DependencyList allDependencies;

for (auto& packageContext : packageSubContexts)
{
context.Reporter.Info() << Resource::String::DependenciesFlowDownload << std::endl;
allDependencies.Add(packageContext->Get<Execution::Data::Installer>().value().Dependencies);
}
else

if (!allDependencies.Empty())
{
context.Reporter.Info() << Resource::String::DependenciesFlowInstall << std::endl;
if (downloadInstallerOnly)
{
context.Reporter.Info() << Resource::String::DependenciesFlowDownload << std::endl;
}
else
{
context.Reporter.Info() << Resource::String::DependenciesFlowInstall << std::endl;
}
}
}

DependencyList allDependencies;

for (auto& packageContext : packageSubContexts)
{
allDependencies.Add(packageContext->Get<Execution::Data::Installer>().value().Dependencies);
context.Add<Execution::Data::Dependencies>(allDependencies);
context << Workflow::ReportDependencies(m_dependenciesReportMessage);
}

context.Add<Execution::Data::Dependencies>(allDependencies);
context << Workflow::ReportDependencies(m_dependenciesReportMessage);

bool allSucceeded = true;
size_t packagesCount = context.Get<Execution::Data::PackageSubContexts>().size();
size_t packagesProgress = 0;
Expand All @@ -671,14 +675,11 @@ namespace AppInstaller::CLI::Workflow
// Prevent individual exceptions from breaking out of the loop
try
{
if (!m_ignorePackageDependencies)
// Handle dependencies if requested.
if (!m_ignorePackageDependencies && !downloadInstallerOnly)
{
if (!downloadInstallerOnly)
{
currentContext << Workflow::EnableWindowsFeaturesDependencies;
}

currentContext <<
Workflow::EnableWindowsFeaturesDependencies <<
Workflow::CreateDependencySubContexts(m_dependenciesReportMessage) <<
Workflow::ProcessMultiplePackages(m_dependenciesReportMessage, APPINSTALLER_CLI_ERROR_INSTALL_DEPENDENCIES, {}, true, true, true, true);
}
Expand Down
2 changes: 1 addition & 1 deletion src/AppInstallerCLICore/Workflows/InstallFlow.h
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ namespace AppInstaller::CLI::Workflow
// Outputs: None
void InstallPackageInstaller(Execution::Context& context);

// Installs the dependencies for a specific package.
// 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
Expand Down
2 changes: 1 addition & 1 deletion src/AppInstallerCLICore/Workflows/PromptFlow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,7 @@ namespace AppInstaller::CLI::Workflow

void ShowPromptsForMultiplePackages::operator()(Execution::Context& context) const
{
for (auto& prompt : GetPackagePrompts(m_ensureAgreementsAcceptance))
for (auto& prompt : GetPackagePrompts(m_ensureAgreementsAcceptance, m_installerDownloadOnly))
{
// Find which packages need this prompt
std::vector<Execution::Context*> packagesToPrompt;
Expand Down
6 changes: 4 additions & 2 deletions src/AppInstallerCLICore/Workflows/PromptFlow.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,15 @@ namespace AppInstaller::CLI::Workflow
// Outputs: None
struct ShowPromptsForMultiplePackages : public WorkflowTask
{
ShowPromptsForMultiplePackages(bool ensureAgreementsAcceptance) :
WorkflowTask("ShowPromptsForMultiplePackages"), m_ensureAgreementsAcceptance(ensureAgreementsAcceptance) {}
ShowPromptsForMultiplePackages(bool ensureAgreementsAcceptance, bool installerDownloadOnly) :
WorkflowTask("ShowPromptsForMultiplePackages"), m_ensureAgreementsAcceptance(ensureAgreementsAcceptance),
m_installerDownloadOnly(installerDownloadOnly) {}

void operator()(Execution::Context& context) const override;

private:
bool m_ensureAgreementsAcceptance;
bool m_installerDownloadOnly;
};

// If the context is not interactive, terminate it with the given HRESULT.
Expand Down
4 changes: 3 additions & 1 deletion src/AppInstallerCLICore/Workflows/UpdateFlow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -263,11 +263,13 @@ namespace AppInstaller::CLI::Workflow
{
context.Add<Execution::Data::PackageSubContexts>(std::move(packageSubContexts));
context.Reporter.Info() << std::endl;
bool skipDependencies = Settings::User().Get<Settings::Setting::InstallSkipDependencies>() || context.Args.Contains(Execution::Args::Type::SkipDependencies);
context <<
ProcessMultiplePackages(
Resource::String::PackageRequiresDependencies,
APPINSTALLER_CLI_ERROR_UPDATE_ALL_HAS_FAILURE,
{ APPINSTALLER_CLI_ERROR_UPDATE_NOT_APPLICABLE });
{ APPINSTALLER_CLI_ERROR_UPDATE_NOT_APPLICABLE },
true, skipDependencies);
}

if (packagesWithUnknownVersionSkipped > 0)
Expand Down

0 comments on commit dfe9a0f

Please sign in to comment.