diff --git a/.cirrus.yml b/.cirrus.yml
index fc38608def..c27bb1b3bc 100644
--- a/.cirrus.yml
+++ b/.cirrus.yml
@@ -486,6 +486,11 @@ swagger_task:
win_installer_task:
name: "Verify Win Installer Build"
+ matrix:
+ - env:
+ CONTAINERS_MACHINE_PROVIDER: 'wsl'
+ - env:
+ CONTAINERS_MACHINE_PROVIDER: 'hyperv'
alias: win_installer
only_if: # RHEL never releases podman windows installer binary
$CIRRUS_TAG == '' &&
diff --git a/.gitignore b/.gitignore
index 5e440f1d99..7ea6620913 100644
--- a/.gitignore
+++ b/.gitignore
@@ -44,3 +44,13 @@ result
# Necessary to prevent hack/tree-status.sh false-positive
/*runner_stats.log
.generate-bindings
+contrib/win-installer/artifacts/
+contrib/win-installer/docs/
+contrib/win-installer/fetch/
+contrib/win-installer/podman.msi
+contrib/win-installer/podman-*setup.exe
+contrib/win-installer/engine.exe
+contrib/win-installer/shasums
+contrib/win-installer/pages.wxs
+contrib/win-installer/*.wixobj
+contrib/win-installer/*.wixpdb
diff --git a/contrib/cirrus/win-installer-main.ps1 b/contrib/cirrus/win-installer-main.ps1
index 8bf6764ac3..c951a01f68 100644
--- a/contrib/cirrus/win-installer-main.ps1
+++ b/contrib/cirrus/win-installer-main.ps1
@@ -2,22 +2,59 @@
. $PSScriptRoot\win-lib.ps1
-Set-Location "$ENV:CIRRUS_WORKING_DIR\repo\contrib\win-installer"
+if ($Env:CI -eq "true") {
+ $WIN_INST_FOLDER = "$ENV:CIRRUS_WORKING_DIR\repo\contrib\win-installer"
+ $RELEASE_DIR = "$ENV:CIRRUS_WORKING_DIR\repo"
+} else {
+ $WIN_INST_FOLDER = "$PSScriptRoot\..\win-installer"
+ $ENV:WIN_INST_VER = "9.9.9"
+ $RELEASE_DIR = "$PSScriptRoot\..\.."
+ $ENV:CONTAINERS_MACHINE_PROVIDER = "wsl"
+}
+
+$ConfFilePath = "$env:ProgramData\containers\containers.conf.d\99-podman-machine-provider.conf"
+$WindowsPathsToTest = @("C:\Program Files\RedHat\Podman\podman.exe",
+ "C:\Program Files\RedHat\Podman\win-sshproxy.exe",
+ "$ConfFilePath",
+ "HKLM:\SOFTWARE\Red Hat\Podman")
+
+Set-Location $WIN_INST_FOLDER
# Build Installer
# Note: consumes podman-remote-release-windows_amd64.zip from repo.tbz2
-Run-Command ".\build.ps1 $Env:WIN_INST_VER dev `"$ENV:CIRRUS_WORKING_DIR\repo`""
+Run-Command ".\build.ps1 $Env:WIN_INST_VER dev `"$RELEASE_DIR`""
-# Run the installer silently and WSL install option disabled (prevent reboots, wsl requirements)
+# Run the installer silently and WSL/HyperV install options disabled (prevent reboots)
# We need AllowOldWin=1 for server 2019 (cirrus image), can be dropped after server 2022
-$ret = Start-Process -Wait -PassThru ".\podman-${ENV:WIN_INST_VER}-dev-setup.exe" -ArgumentList "/install /quiet WSLCheckbox=0 AllowOldWin=1 /log inst.log"
+$ret = Start-Process -Wait -PassThru ".\podman-${ENV:WIN_INST_VER}-dev-setup.exe" -ArgumentList "/install /quiet MachineProvider=$ENV:CONTAINERS_MACHINE_PROVIDER WSLCheckbox=0 HyperVCheckbox=0 AllowOldWin=1 /log inst.log"
if ($ret.ExitCode -ne 0) {
Write-Host "Install failed, dumping log"
Get-Content inst.log
throw "Exit code is $($ret.ExitCode)"
}
-if (! ((Test-Path -Path "C:\Program Files\RedHat\Podman\podman.exe") -and `
- (Test-Path -Path "C:\Program Files\RedHat\Podman\win-sshproxy.exe"))) {
- throw "Expected podman.exe and win-sshproxy.exe, one or both not present after install"
+$WindowsPathsToTest | ForEach-Object {
+ if (! (Test-Path -Path $_) ) {
+ throw "Expected $_ but it's not present after uninstall"
+ }
}
+$machineProvider = Get-Content $ConfFilePath | Select-Object -Skip 1 | ConvertFrom-StringData | ForEach-Object { $_.provider }
+if ( $machineProvider -ne "`"$ENV:CONTAINERS_MACHINE_PROVIDER`"" ) {
+ throw "Expected `"$ENV:CONTAINERS_MACHINE_PROVIDER`" as default machine provider but got $machineProvider"
+}
+
Write-Host "Installer verification successful!"
+
+# Run the uninstaller silently to verify that it cleans up properly
+$ret = Start-Process -Wait -PassThru ".\podman-${ENV:WIN_INST_VER}-dev-setup.exe" -ArgumentList "/uninstall /quiet /log uninst.log"
+if ($ret.ExitCode -ne 0) {
+ Write-Host "Uninstall failed, dumping log"
+ Get-Content uninst.log
+ throw "Exit code is $($ret.ExitCode)"
+}
+$WindowsPathsToTest | ForEach-Object {
+ if ( Test-Path -Path $_ ) {
+ throw "Path $_ is still present after uninstall"
+ }
+}
+
+Write-Host "Uninstaller verification successful!"
diff --git a/contrib/win-installer/burn.wxs b/contrib/win-installer/burn.wxs
index ae352e6c90..6a367c5457 100644
--- a/contrib/win-installer/burn.wxs
+++ b/contrib/win-installer/burn.wxs
@@ -17,10 +17,13 @@
+
+
+
@@ -35,9 +38,12 @@
+
+
+
-
+
diff --git a/contrib/win-installer/podman-msihooks/check.c b/contrib/win-installer/podman-msihooks/check.c
index 1a3b10e479..2925c0b8f4 100644
--- a/contrib/win-installer/podman-msihooks/check.c
+++ b/contrib/win-installer/podman-msihooks/check.c
@@ -2,7 +2,9 @@
#include
BOOL isWSLEnabled();
+BOOL isHyperVEnabled();
LPCWSTR boolToNStr(BOOL bool);
+LPCSTR szSvcNameHyperv = TEXT("vmms");
/**
* CheckWSL is a custom action loaded by the Podman Windows installer
@@ -28,6 +30,19 @@ LPCWSTR boolToNStr(BOOL bool);
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 bool) {
return bool ? L"1" : L"0";
}
@@ -51,7 +66,7 @@ BOOL isWSLEnabled() {
// 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)) {
+ NULL, NULL, &startup, &process)) {
return FALSE;
}
@@ -64,3 +79,52 @@ BOOL isWSLEnabled() {
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;
+}
diff --git a/contrib/win-installer/podman.wxs b/contrib/win-installer/podman.wxs
index 84db5e1cc9..d1590c85ef 100644
--- a/contrib/win-installer/podman.wxs
+++ b/contrib/win-installer/podman.wxs
@@ -20,7 +20,83 @@
- NOT (WITH_WSL = 0)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -48,6 +124,22 @@
+
+
+
+
+
+
+
+ CREATE_MACHINE_PROVIDER_CONFIG_FILE
+
+
+
+
@@ -57,16 +149,24 @@
-
+
+
-
- (NOT Installed) AND WSL_INSTALL = 1 AND HAS_WSLFEATURE = 0
-
+
+ (NOT Installed) AND WSL_INSTALL = 1
+
+
+
+ (NOT Installed) AND HYPERV_INSTALL = 1
+
+
+
+
@@ -76,8 +176,10 @@
+
+
@@ -94,8 +196,13 @@
- WSL_INSTALL = 1
- (NOT Installed) AND WSL_INSTALL = 1 AND HAS_WSLFEATURE = 0 AND NOT AFTERREBOOT
+
+
+
+ (NOT Installed)
+ AND ((WSL_INSTALL = 1) OR (HYPERV_INSTALL = 1))
+ AND (NOT AFTERREBOOT)
+
diff --git a/contrib/win-installer/resources/podman-dialog.png b/contrib/win-installer/resources/podman-dialog.png
index cf0c49d984..946bd095ad 100644
Binary files a/contrib/win-installer/resources/podman-dialog.png and b/contrib/win-installer/resources/podman-dialog.png differ
diff --git a/contrib/win-installer/welcome-install-dlg.wxs b/contrib/win-installer/welcome-install-dlg.wxs
index cc0f1c6433..325cd74821 100644
--- a/contrib/win-installer/welcome-install-dlg.wxs
+++ b/contrib/win-installer/welcome-install-dlg.wxs
@@ -1,31 +1,49 @@
-
-
-
-
-
-
-
- NOT Installed
-
-
-
+
+
+
+
+
+
+
+ NOT Installed
+
+
+