-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implementation for Zip Install (Non-Portable) #2320
Changes from 4 commits
9da58fa
bbba7c7
de2688c
b40196d
516b992
399367b
f6e4f88
e260da9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT License. | ||
#include "pch.h" | ||
#include "ArchiveFlow.h" | ||
#include "winget/Archive.h" | ||
|
||
namespace AppInstaller::CLI::Workflow | ||
{ | ||
void ExtractInstallerFromArchive(Execution::Context& context) | ||
{ | ||
const auto& installerPath = context.Get<Execution::Data::InstallerPath>(); | ||
const auto& installerParentPath = installerPath.parent_path(); | ||
|
||
HRESULT hr = AppInstaller::Archive::ExtractArchive(installerPath, installerParentPath); | ||
ryfu-msft marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
if (SUCCEEDED(hr)) | ||
{ | ||
AICLI_LOG(CLI, Info, << "Successfully extracted archive to: " << installerParentPath ); | ||
context.SetFlags(Execution::ContextFlag::InstallerExtractedFromArchive); | ||
} | ||
else | ||
{ | ||
AICLI_LOG(CLI, Info, << "Failed to extract archive to: " << installerParentPath); | ||
ryfu-msft marked this conversation as resolved.
Show resolved
Hide resolved
|
||
context.Reporter.Error() << Resource::String::ExtractArchiveFailed << std::endl; | ||
AICLI_TERMINATE_CONTEXT(APPINSTALLER_CLI_ERROR_EXTRACT_ARCHIVE_FAILED); | ||
} | ||
} | ||
|
||
void VerifyAndSetNestedInstaller(Execution::Context& context) | ||
{ | ||
const auto& installer = context.Get<Execution::Data::Installer>().value(); | ||
const auto& installerPath = context.Get<Execution::Data::InstallerPath>(); | ||
const auto& installerParentPath = installerPath.parent_path(); | ||
const auto& relativeFilePath = ConvertToUTF16(installer.NestedInstallerFiles[0].RelativeFilePath); | ||
ryfu-msft marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
std::filesystem::path nestedInstallerPath = installerParentPath / relativeFilePath; | ||
|
||
if (!std::filesystem::exists(nestedInstallerPath)) | ||
{ | ||
AICLI_LOG(CLI, Error, << "Unable to locate nested installer at: " << nestedInstallerPath); | ||
context.Reporter.Error() << Resource::String::NestedInstallerNotFound << ' ' << nestedInstallerPath << std::endl; | ||
AICLI_TERMINATE_CONTEXT(APPINSTALLER_CLI_ERROR_NESTEDINSTALLER_NOT_FOUND); | ||
} | ||
else | ||
{ | ||
AICLI_LOG(CLI, Info, << "Setting installerPath to: " << nestedInstallerPath); | ||
context.Add<Execution::Data::InstallerPath>(nestedInstallerPath); | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT License. | ||
#pragma once | ||
#include "ExecutionContext.h" | ||
|
||
namespace AppInstaller::CLI::Workflow | ||
{ | ||
void ExtractInstallerFromArchive(Execution::Context& context); | ||
ryfu-msft marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
void VerifyAndSetNestedInstaller(Execution::Context& context); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,11 +9,13 @@ | |
#include "ShellExecuteInstallerHandler.h" | ||
#include "MSStoreInstallerHandler.h" | ||
#include "MsiInstallFlow.h" | ||
#include "ArchiveFlow.h" | ||
#include "PortableFlow.h" | ||
#include "WorkflowBase.h" | ||
#include "Workflows/DependenciesFlow.h" | ||
#include <AppInstallerDeployment.h> | ||
#include <winget/ARPCorrelation.h> | ||
#include <winget/Archive.h> | ||
#include <Argument.h> | ||
#include <Command.h> | ||
|
||
|
@@ -322,7 +324,18 @@ namespace AppInstaller::CLI::Workflow | |
|
||
bool isUpdate = WI_IsFlagSet(context.GetFlags(), Execution::ContextFlag::InstallerExecutionUseUpdate); | ||
|
||
switch (installer.InstallerType) | ||
InstallerTypeEnum installerType; | ||
|
||
if (WI_IsFlagSet(context.GetFlags(), Execution::ContextFlag::InstallerExtractedFromArchive)) | ||
{ | ||
installerType = installer.NestedInstallerType; | ||
} | ||
else | ||
{ | ||
installerType = installer.InstallerType; | ||
} | ||
|
||
switch (installerType) | ||
{ | ||
case InstallerTypeEnum::Exe: | ||
case InstallerTypeEnum::Burn: | ||
|
@@ -337,7 +350,7 @@ namespace AppInstaller::CLI::Workflow | |
ExecuteUninstaller; | ||
context.ClearFlags(Execution::ContextFlag::InstallerExecutionUseUpdate); | ||
} | ||
if (ShouldUseDirectMSIInstall(installer.InstallerType, context.Args.Contains(Execution::Args::Type::Silent))) | ||
if (ShouldUseDirectMSIInstall(installerType, context.Args.Contains(Execution::Args::Type::Silent))) | ||
{ | ||
context << DirectMSIInstall; | ||
} | ||
|
@@ -364,11 +377,22 @@ namespace AppInstaller::CLI::Workflow | |
} | ||
context << PortableInstall; | ||
break; | ||
case InstallerTypeEnum::Zip: | ||
context << ArchiveInstall; | ||
break; | ||
default: | ||
THROW_HR(HRESULT_FROM_WIN32(ERROR_NOT_SUPPORTED)); | ||
} | ||
} | ||
|
||
void ArchiveInstall(Execution::Context& context) | ||
{ | ||
context << | ||
ExtractInstallerFromArchive << | ||
VerifyAndSetNestedInstaller << | ||
ExecuteInstaller; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This flow will be less efficient for portables; we should just extract directly to the final location. Not sure if that works great with the database tracking files though. We might need to be less efficient just so any files we could lose track of are in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am thinking that portables will require more tasks than the one I have currently specified.
Once we enter the portable install flow, we can then use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. My gut is to create There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added |
||
} | ||
|
||
void ShellExecuteInstall(Execution::Context& context) | ||
{ | ||
context << | ||
|
@@ -524,7 +548,8 @@ namespace AppInstaller::CLI::Workflow | |
void EnsureSupportForInstall(Execution::Context& context) | ||
{ | ||
context << | ||
Workflow::EnsureSupportForPortableInstall; | ||
Workflow::EnsureSupportForPortableInstall << | ||
Workflow::EnsureNonPortableTypeForArchiveInstall; | ||
} | ||
|
||
void InstallMultiplePackages::operator()(Execution::Context& context) const | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are a few options here:
IsArchiveType
Option 3 seems to be the least amount of adding additional context data and the easiest. Is there any case in which we wouldn't use the nested type for an archive?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed
InstallerExtractedFromArchive
context flag.Added
ExecuteInstallerForInstallerType
which selects the appropriate install flow based on the installerType to handle whether to useInstallerType
orNestedInstallerType