mirror of https://github.com/containers/podman.git
Remove providers checks from the Windows Installer
This PR removes the file `check.c` and the instructions to build it. The file was still built but the resulting dll was not used by the installer anymore (see https://github.com/containers/podman/pull/25237). Signed-off-by: Mario Loriedo <mario.loriedo@gmail.com>
This commit is contained in:
parent
366538d98f
commit
df4aed78a2
|
|
@ -11,7 +11,6 @@ Windows.
|
||||||
- [Git and go](#git-and-go)
|
- [Git and go](#git-and-go)
|
||||||
- [Pandoc](#pandoc)
|
- [Pandoc](#pandoc)
|
||||||
- [.NET SDK](#net-sdk)
|
- [.NET SDK](#net-sdk)
|
||||||
- [Visual Studio Build Tools](#visual-studio-build-tools)
|
|
||||||
- [Virtualization Provider](#virtualization-provider)
|
- [Virtualization Provider](#virtualization-provider)
|
||||||
- [WSL](#wsl)
|
- [WSL](#wsl)
|
||||||
- [Hyper-V](#hyper-v)
|
- [Hyper-V](#hyper-v)
|
||||||
|
|
@ -88,30 +87,6 @@ used too and can be installed using `dotnet install`:
|
||||||
dotnet tool install --global wix
|
dotnet tool install --global wix
|
||||||
```
|
```
|
||||||
|
|
||||||
### Visual Studio Build Tools
|
|
||||||
|
|
||||||
The installer includes a C program that checks the installation of the
|
|
||||||
pre-required virtualization providers (WSL or Hyper-V). Building this program
|
|
||||||
requires the
|
|
||||||
[Microsoft C/C++ compiler](https://learn.microsoft.com/en-us/cpp/build/building-on-the-command-line?view=msvc-170) and the
|
|
||||||
[PowerShell Module VSSetup](https://github.com/microsoft/vssetup.powershell):
|
|
||||||
|
|
||||||
1. Download the Build Tools for Visual Studio 2022 installer
|
|
||||||
```pwsh
|
|
||||||
Invoke-WebRequest -Uri 'https://aka.ms/vs/17/release/vs_BuildTools.exe' -OutFile "$env:TEMP\vs_BuildTools.exe"
|
|
||||||
```
|
|
||||||
2. Run the installer with the parameter to include the optional C/C++ Tools
|
|
||||||
```pwsh
|
|
||||||
& "$env:TEMP\vs_BuildTools.exe" --passive --wait `
|
|
||||||
--add Microsoft.VisualStudio.Workload.VCTools `
|
|
||||||
--includeRecommended `
|
|
||||||
--remove Microsoft.VisualStudio.Component.VC.CMake.Project
|
|
||||||
```
|
|
||||||
3. Install the PowerShell Module VSSetup
|
|
||||||
```pwsh
|
|
||||||
Install-Module VSSetup
|
|
||||||
```
|
|
||||||
|
|
||||||
### Virtualization Provider
|
### Virtualization Provider
|
||||||
|
|
||||||
Running Podman on Windows requires a virtualization provider. The supported
|
Running Podman on Windows requires a virtualization provider. The supported
|
||||||
|
|
@ -312,8 +287,7 @@ To learn how to use the Podman client, refer to its
|
||||||
## Build and test the Podman Windows installer
|
## Build and test the Podman Windows installer
|
||||||
|
|
||||||
The Podman Windows installer (e.g., `podman-5.1.0-dev-setup.exe`) is a bundle
|
The Podman Windows installer (e.g., `podman-5.1.0-dev-setup.exe`) is a bundle
|
||||||
that includes an msi package (`podman.msi`) and installs the WSL kernel
|
that includes an msi package (`podman.msi`). It's built using the
|
||||||
(`podman-wslkerninst.exe`). It's built using the
|
|
||||||
[WiX Toolset](https://wixtoolset.org/) and the
|
[WiX Toolset](https://wixtoolset.org/) and the
|
||||||
[PanelSwWixExtension](https://github.com/nirbar/PanelSwWixExtension/tree/master5)
|
[PanelSwWixExtension](https://github.com/nirbar/PanelSwWixExtension/tree/master5)
|
||||||
WiX extension. The source code is in the folder `contrib\win-installer`.
|
WiX extension. The source code is in the folder `contrib\win-installer`.
|
||||||
|
|
@ -334,9 +308,6 @@ root) with a name like `podman-5.2.0-dev-setup.exe`.
|
||||||
|
|
||||||
The `installer` target of `winmake.ps1` runs the script
|
The `installer` target of `winmake.ps1` runs the script
|
||||||
`contrib\win-installer\build.ps1` that, in turns, executes:
|
`contrib\win-installer\build.ps1` that, in turns, executes:
|
||||||
|
|
||||||
- `build-hooks.bat`: builds `podman-wslkerninst.exe` (WSL kernel installer) and
|
|
||||||
`podman-msihooks.dll` (helper that checks if WSL and Hyper-V are installed).
|
|
||||||
- `dotnet build podman.wixproj`: builds `podman.msi` from the WiX source files `podman.wxs`,
|
- `dotnet build podman.wixproj`: builds `podman.msi` from the WiX source files `podman.wxs`,
|
||||||
`pages.wxs`, `podman-ui.wxs` and `welcome-install-dlg.wxs`.
|
`pages.wxs`, `podman-ui.wxs` and `welcome-install-dlg.wxs`.
|
||||||
- `dotnet build podman-setup.wixproj`: builds `podman-setup.exe` file from
|
- `dotnet build podman-setup.wixproj`: builds `podman-setup.exe` file from
|
||||||
|
|
@ -519,7 +490,13 @@ tools:
|
||||||
[`.pre-commit-config.yaml`](.pre-commit-config.yaml)
|
[`.pre-commit-config.yaml`](.pre-commit-config.yaml)
|
||||||
|
|
||||||
:information_source: Install [golangci-lint](https://golangci-lint.run) and
|
:information_source: Install [golangci-lint](https://golangci-lint.run) and
|
||||||
[pre-commit](https://pre-commit.com) to run `winmake.ps1 lint`.
|
[pre-commit](https://pre-commit.com) to run `winmake.ps1 lint`:
|
||||||
|
```pwsh
|
||||||
|
winget install -e golangci-lint.golangci-lint
|
||||||
|
winget install -e Python.Python.3.13
|
||||||
|
pip install pre-commit
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
### winmake validatepr
|
### winmake validatepr
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,67 +0,0 @@
|
||||||
function Build-WSLKernelInstaller {
|
|
||||||
param (
|
|
||||||
[string]$wslkerninstFolder,
|
|
||||||
[string]$artifactsFolder
|
|
||||||
);
|
|
||||||
Set-Variable GOARCH=amd64
|
|
||||||
go build -ldflags -H=windowsgui -o "$artifactsFolder\podman-wslkerninst.exe" "$wslkerninstFolder"
|
|
||||||
}
|
|
||||||
|
|
||||||
function Build-MSIHooks {
|
|
||||||
param (
|
|
||||||
[string]$msiHooksFolder,
|
|
||||||
[string]$artifactsFolder
|
|
||||||
);
|
|
||||||
|
|
||||||
# Build using x86 toolchain, see comments in check.c for rationale and details
|
|
||||||
if ( Get-MingW ) {
|
|
||||||
Build-MSIHooks-Using-MingW $msiHooksFolder $artifactsFolder
|
|
||||||
} elseif ( Get-VSBuildTools ) {
|
|
||||||
$vsinstance = Get-VSSetupInstance | Select-VSSetupInstance -Product Microsoft.VisualStudio.Product.BuildTools -Latest
|
|
||||||
Build-MSIHooks-Using-VSBuildTools $msiHooksFolder $artifactsFolder $vsinstance
|
|
||||||
} else {
|
|
||||||
$msg = "A C/C++ compiler is required to build `"$msiHooksFolder\check.c`". "
|
|
||||||
$msg += "Supported compilers are MinGW CC (`"x86_64-w64-mingw32-gcc`") and the "
|
|
||||||
$msg += "`"Microsoft.VisualStudio.Product.BuildTools`" with `"VSSetup`" PowerShell extension."
|
|
||||||
Write-Error -Message $msg -ErrorAction Stop
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function Get-MingW {
|
|
||||||
return Get-Command "x86_64-w64-mingw32-gcc" -errorAction SilentlyContinue
|
|
||||||
}
|
|
||||||
|
|
||||||
function Get-VSBuildTools {
|
|
||||||
return ((Get-Command "Get-VSSetupInstance" -errorAction SilentlyContinue) -and `
|
|
||||||
(@(Get-VSSetupInstance | Select-VSSetupInstance -Product "Microsoft.VisualStudio.Product.BuildTools").Count -gt 0))
|
|
||||||
}
|
|
||||||
|
|
||||||
function Build-MSIHooks-Using-MingW {
|
|
||||||
param (
|
|
||||||
[string]$msiHooksFolder,
|
|
||||||
[string]$artifactsFolder
|
|
||||||
);
|
|
||||||
Set-Variable GOARCH=amd64
|
|
||||||
x86_64-w64-mingw32-gcc $msiHooksFolder/check.c -shared -lmsi -mwindows -o $artifactsFolder/podman-msihooks.dll
|
|
||||||
}
|
|
||||||
|
|
||||||
function Build-MSIHooks-Using-VSBuildTools {
|
|
||||||
param (
|
|
||||||
[string]$msiHooksFolder,
|
|
||||||
[string]$artifactsFolder,
|
|
||||||
[Microsoft.VisualStudio.Setup.Instance]$vsinstance
|
|
||||||
);
|
|
||||||
$vspath = $vsinstance.InstallationPath
|
|
||||||
$vsinstanceid = $vsinstance.InstanceId
|
|
||||||
|
|
||||||
Import-Module "$vspath\Common7\Tools\Microsoft.VisualStudio.DevShell.dll"
|
|
||||||
Enter-VsDevShell $vsinstanceid -DevCmdArguments '-arch=amd64 -host_arch=amd64'
|
|
||||||
cl.exe /W4 /Fo$artifactsFolder\ $msiHooksFolder\check.c Advapi32.lib Msi.lib /link /DLL /out:$artifactsFolder\podman-msihooks.dll
|
|
||||||
}
|
|
||||||
|
|
||||||
$wslkerninstFolder="$PSScriptRoot\..\..\cmd\podman-wslkerninst"
|
|
||||||
$msiHooksFolder="$PSScriptRoot\podman-msihooks"
|
|
||||||
$artifactsFolder="$PSScriptRoot\artifacts"
|
|
||||||
|
|
||||||
Build-WSLKernelInstaller $wslkerninstFolder $artifactsFolder
|
|
||||||
Build-MSIHooks $msiHooksFolder $artifactsFolder
|
|
||||||
|
|
@ -103,11 +103,8 @@ if ($ENV:INSTVER -eq "") {
|
||||||
Exit 1
|
Exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
.\build-hooks.ps1; ExitOnError
|
|
||||||
SignItem @("artifacts/win-sshproxy.exe",
|
SignItem @("artifacts/win-sshproxy.exe",
|
||||||
"artifacts/podman.exe",
|
"artifacts/podman.exe")
|
||||||
"artifacts/podman-msihooks.dll",
|
|
||||||
"artifacts/podman-wslkerninst.exe")
|
|
||||||
$gvExists = Test-Path "artifacts/gvproxy.exe"
|
$gvExists = Test-Path "artifacts/gvproxy.exe"
|
||||||
if ($gvExists) {
|
if ($gvExists) {
|
||||||
SignItem @("artifacts/gvproxy.exe")
|
SignItem @("artifacts/gvproxy.exe")
|
||||||
|
|
|
||||||
|
|
@ -1,130 +0,0 @@
|
||||||
#include <windows.h>
|
|
||||||
#include <MsiQuery.h>
|
|
||||||
|
|
||||||
BOOL isWSLEnabled();
|
|
||||||
BOOL isHyperVEnabled();
|
|
||||||
LPCWSTR boolToNStr(BOOL value);
|
|
||||||
LPCSTR szSvcNameHyperv = TEXT("vmms");
|
|
||||||
|
|
||||||
/**
|
|
||||||
* CheckWSL is a custom action loaded by the Podman Windows installer
|
|
||||||
* to determine whether the system already has WSL installed.
|
|
||||||
*
|
|
||||||
* The intention is that this action is compiled for x86_64, which
|
|
||||||
* can be ran on both Intel and Arm based systems (the latter through
|
|
||||||
* emulation). While the code should build fine on MSVC and clang, the
|
|
||||||
* intended usage is MingW-W64 (cross-compiling gcc targeting Windows).
|
|
||||||
*
|
|
||||||
* Previously this was implemented as a Golang c-shared cgo library,
|
|
||||||
* however, the WoW x86_64 emulation layer struggled with dynamic
|
|
||||||
* hot-loaded transformation of the goruntime into an existing process
|
|
||||||
* (required by MSI custom actions). In the future this could be
|
|
||||||
* converted back, should the emulation issue be resolved.
|
|
||||||
*/
|
|
||||||
|
|
||||||
__declspec(dllexport) UINT __cdecl CheckWSL(MSIHANDLE hInstall) {
|
|
||||||
BOOL hasWSL = isWSLEnabled();
|
|
||||||
// Set a property with the WSL state for the installer to operate on
|
|
||||||
MsiSetPropertyW(hInstall, L"HAS_WSLFEATURE", boolToNStr(hasWSL));
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* CheckHyperV is a custom action loaded by the Podman Windows installer
|
|
||||||
* to determine whether the system already has Hyper-V installed.
|
|
||||||
*/
|
|
||||||
|
|
||||||
__declspec(dllexport) UINT __cdecl CheckHyperV(MSIHANDLE hInstall) {
|
|
||||||
BOOL hasHyperV = isHyperVEnabled();
|
|
||||||
// Set a property with the HyperV state for the installer to operate on
|
|
||||||
MsiSetPropertyW(hInstall, L"HAS_HYPERVFEATURE", boolToNStr(hasHyperV));
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
LPCWSTR boolToNStr(BOOL value) {
|
|
||||||
return value ? L"1" : L"0";
|
|
||||||
}
|
|
||||||
|
|
||||||
BOOL isWSLEnabled() {
|
|
||||||
/*
|
|
||||||
* The simplest, and most reliable check across all variants and versions
|
|
||||||
* of WSL appears to be changing the default version to WSL 2 and check
|
|
||||||
* for errors, which we need to do anyway.
|
|
||||||
*/
|
|
||||||
STARTUPINFOW startup;
|
|
||||||
PROCESS_INFORMATION process;
|
|
||||||
|
|
||||||
ZeroMemory(&startup, sizeof(STARTUPINFOW));
|
|
||||||
startup.cb = sizeof(STARTUPINFOW);
|
|
||||||
|
|
||||||
// These settings hide the console window, so there is no annoying flash
|
|
||||||
startup.dwFlags = STARTF_USESHOWWINDOW;
|
|
||||||
startup.wShowWindow = SW_HIDE;
|
|
||||||
|
|
||||||
// CreateProcessW requires lpCommandLine to be mutable
|
|
||||||
wchar_t cmd[] = L"wsl --set-default-version 2";
|
|
||||||
if (! CreateProcessW(NULL, cmd, NULL, NULL, FALSE, CREATE_NEW_CONSOLE,
|
|
||||||
NULL, NULL, &startup, &process)) {
|
|
||||||
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
DWORD exitCode;
|
|
||||||
WaitForSingleObject(process.hProcess, INFINITE);
|
|
||||||
if (! GetExitCodeProcess(process.hProcess, &exitCode)) {
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
return exitCode == 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
BOOL isHyperVEnabled() {
|
|
||||||
/*
|
|
||||||
* Checks if the Windows service `vmms` is running to
|
|
||||||
* determine if Hyper-V is enabled.
|
|
||||||
*/
|
|
||||||
SC_HANDLE schSCManager;
|
|
||||||
SC_HANDLE schService;
|
|
||||||
SERVICE_STATUS_PROCESS ssStatus;
|
|
||||||
DWORD dwBytesNeeded;
|
|
||||||
|
|
||||||
// Get a handle to the SCM database.
|
|
||||||
schSCManager = OpenSCManager(
|
|
||||||
NULL, // local computer
|
|
||||||
NULL, // servicesActive database
|
|
||||||
SERVICE_QUERY_STATUS); // service query access rights
|
|
||||||
|
|
||||||
if (NULL == schSCManager) {
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get a handle to the service.
|
|
||||||
schService = OpenService(
|
|
||||||
schSCManager,
|
|
||||||
szSvcNameHyperv,
|
|
||||||
SERVICE_QUERY_STATUS);
|
|
||||||
|
|
||||||
if (schService == NULL) {
|
|
||||||
CloseServiceHandle(schSCManager);
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check the status
|
|
||||||
if (!QueryServiceStatusEx(
|
|
||||||
schService, // handle to service
|
|
||||||
SC_STATUS_PROCESS_INFO, // information level
|
|
||||||
(LPBYTE) &ssStatus, // address of structure
|
|
||||||
sizeof(SERVICE_STATUS_PROCESS), // size of structure
|
|
||||||
&dwBytesNeeded ) ) {
|
|
||||||
CloseServiceHandle(schService);
|
|
||||||
CloseServiceHandle(schSCManager);
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
CloseServiceHandle(schService);
|
|
||||||
CloseServiceHandle(schSCManager);
|
|
||||||
|
|
||||||
return ssStatus.dwCurrentState == SERVICE_RUNNING;
|
|
||||||
}
|
|
||||||
|
|
@ -52,8 +52,6 @@
|
||||||
<SetProperty Id="HIDE_PROVIDER_CHOICE" After="AppSearch" Value="1" Sequence="first" Condition="(SKIP_CONFIG_FILE_CREATION = 1) OR (MACHINE_PROVIDER_CONFIG_FILE_PATH) OR (MAIN_EXECUTABLE_FILE_PATH)" />
|
<SetProperty Id="HIDE_PROVIDER_CHOICE" After="AppSearch" Value="1" Sequence="first" Condition="(SKIP_CONFIG_FILE_CREATION = 1) OR (MACHINE_PROVIDER_CONFIG_FILE_PATH) OR (MAIN_EXECUTABLE_FILE_PATH)" />
|
||||||
|
|
||||||
<CustomAction Id="OpenGuide" DllEntry="WixShellExec" Impersonate="yes" BinaryRef="Wix4UtilCA_X86" />
|
<CustomAction Id="OpenGuide" DllEntry="WixShellExec" Impersonate="yes" BinaryRef="Wix4UtilCA_X86" />
|
||||||
<CustomAction Id="CheckWSL" Execute="firstSequence" DllEntry="CheckWSL" BinaryRef="PodmanHooks" />
|
|
||||||
<CustomAction Id="CheckHyperV" Execute="firstSequence" DllEntry="CheckHyperV" BinaryRef="PodmanHooks" />
|
|
||||||
<util:BroadcastEnvironmentChange />
|
<util:BroadcastEnvironmentChange />
|
||||||
<Feature Id="Complete" Level="1">
|
<Feature Id="Complete" Level="1">
|
||||||
<ComponentRef Id="INSTALLDIR_Component" />
|
<ComponentRef Id="INSTALLDIR_Component" />
|
||||||
|
|
@ -82,12 +80,6 @@
|
||||||
<Publish Dialog="ExitDialog" Control="Finish" Event="DoAction" Value="OpenGuide" Condition="(WIXUI_EXITDIALOGOPTIONALCHECKBOX = 1) AND (NOT Installed) AND (NOT UpdateStarted)" />
|
<Publish Dialog="ExitDialog" Control="Finish" Event="DoAction" Value="OpenGuide" Condition="(WIXUI_EXITDIALOGOPTIONALCHECKBOX = 1) AND (NOT Installed) AND (NOT UpdateStarted)" />
|
||||||
</UI>
|
</UI>
|
||||||
|
|
||||||
<InstallExecuteSequence>
|
|
||||||
<Custom Action="CheckWSL" Before="InstallFiles" />
|
|
||||||
<Custom Action="CheckHyperV" Before="InstallFiles" />
|
|
||||||
</InstallExecuteSequence>
|
|
||||||
<Binary Id="PodmanHooks" SourceFile="artifacts/podman-msihooks.dll" />
|
|
||||||
|
|
||||||
<StandardDirectory Id="ProgramFiles6432Folder">
|
<StandardDirectory Id="ProgramFiles6432Folder">
|
||||||
<Directory Id="RedHatPFiles" Name="RedHat">
|
<Directory Id="RedHatPFiles" Name="RedHat">
|
||||||
<Directory Id="INSTALLDIR" Name="Podman">
|
<Directory Id="INSTALLDIR" Name="Podman">
|
||||||
|
|
|
||||||
10
winmake.ps1
10
winmake.ps1
|
|
@ -147,10 +147,20 @@ function Test-Installer{
|
||||||
Exit 1
|
Exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$nextSetupExePath = "$PSScriptRoot\contrib\win-installer\podman-9.9.9-dev-setup.exe"
|
||||||
|
if (!(Test-Path -Path $nextSetupExePath -PathType Leaf)) {
|
||||||
|
Write-Host "The automated tests include testing the upgrade from current version to a future version."
|
||||||
|
Write-Host "That requires a version 9.9.9 of the installer:"
|
||||||
|
Write-Host " .\winmake.ps1 installer 9.9.9"
|
||||||
|
Write-Host "Build it and retry running installertest."
|
||||||
|
Exit 1
|
||||||
|
}
|
||||||
|
|
||||||
$command = "$PSScriptRoot\contrib\win-installer\test-installer.ps1"
|
$command = "$PSScriptRoot\contrib\win-installer\test-installer.ps1"
|
||||||
$command += " -scenario all"
|
$command += " -scenario all"
|
||||||
$command += " -provider $provider"
|
$command += " -provider $provider"
|
||||||
$command += " -setupExePath $setupExePath"
|
$command += " -setupExePath $setupExePath"
|
||||||
|
$command += " -nextSetupExePath $nextSetupExePath"
|
||||||
Run-Command "${command}"
|
Run-Command "${command}"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue