Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 59 additions & 0 deletions contrib/win-installer/test.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,62 @@ function Test-Podman-Machine-Conf-Content {
Write-Host "Verification was successful!`n"
}

function Test-Path-In-Environment-Reg-Key {
param (
[ValidateSet('machine-legacy', 'machine', 'user')]
[string]$scope = $script:scope,
[switch]$expectIsMissing = $false
)
if ($scope -eq 'machine') {
$PodmanFolderPath = $PodmanFolderPathPerMachine
$EnvironmentPathRegistryKey = "HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Environment"
}
elseif ($scope -eq 'machine-legacy') {
$PodmanFolderPath = $PodmanFolderPathPerMachineLegacy
$EnvironmentPathRegistryKey = "HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Environment"
}
else {
$PodmanFolderPath = $PodmanFolderPathPerUser
$EnvironmentPathRegistryKey = "HKCU:\Environment"
}
$EnvironmentPathRegistryKeyValue = "Path"
Write-Host "Verifying if Podman is in PATH...(scope=$scope, expectIsMissing=$expectIsMissing)"
if (! (Test-Path -Path $EnvironmentPathRegistryKey) ) {
throw "Expected $EnvironmentPathRegistryKey but doesn't exist"
}
try {
$rawPath = (Get-ItemProperty -Path $EnvironmentPathRegistryKey -Name $EnvironmentPathRegistryKeyValue -ErrorAction Stop).$EnvironmentPathRegistryKeyValue
}
catch {
throw "Could not read '$EnvironmentPathRegistryKeyValue' from '$EnvironmentPathRegistryKey': $_"
}

if ([string]::IsNullOrWhiteSpace($rawPath)) {
throw "The '$EnvironmentPathRegistryKeyValue' value is empty."
}

$pathEntries = $rawPath -split ';' |
ForEach-Object { $_.Trim() } |
Where-Object { $_ -ne '' }

function Normalize-Path {
param([string]$Path)
return $Path.TrimEnd('\').ToLowerInvariant()
}

$normalizedTarget = Normalize-Path $PodmanFolderPath

$match = $pathEntries | Where-Object { (Normalize-Path $_) -eq $normalizedTarget }

if ( (-not $match) -and (-not $expectIsMissing) ) {
throw "Not found: '$PodmanFolderPath' is NOT present in '${EnvironmentPathRegistryKey}\${EnvironmentPathRegistryKeyValue}'."
}
if ( $match -and $expectIsMissing ) {
throw "Found: '$PodmanFolderPath' is present in '${EnvironmentPathRegistryKey}\${EnvironmentPathRegistryKeyValue}'."
}
Write-Host "Verification was successful!`n"
}

function Uninstall-Podman-Bundle {
param (
# [Parameter(Mandatory)]
Expand Down Expand Up @@ -558,6 +614,7 @@ function Test-Installation {
Test-Podman-Machine-Conf-Content -scope $scope
}
}
Test-Path-In-Environment-Reg-Key -scope $scope
}

function Test-Installation-No-Config {
Expand All @@ -567,6 +624,7 @@ function Test-Installation-No-Config {
)
Test-Podman-Objects-Exist -scope $scope
Test-Podman-Machine-Conf-Exist-Not -scope $scope
Test-Path-In-Environment-Reg-Key -scope $scope
}

function Test-Uninstallation {
Expand All @@ -576,6 +634,7 @@ function Test-Uninstallation {
)
Test-Podman-Objects-Exist-Not -scope $scope
Test-Podman-Machine-Conf-Exist-Not -scope $scope
Test-Path-In-Environment-Reg-Key -scope $scope -expectIsMissing
}

# SCENARIOS
Expand Down
11 changes: 9 additions & 2 deletions contrib/win-installer/wix/podman-main.wxs
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ and other data will be preserved." />
<Feature Id="Complete" Level="1">
<ComponentRef Id="INSTALLDIR_Component" />
<ComponentRef Id="EnvEntriesComponent" />
<ComponentRef Id="EnvEntriesComponentPerMachine" />
<ComponentRef Id="MainExecutable" />
<ComponentRef Id="WinSshProxyExecutable" />
<?if $(var.UseGVProxy) != Skip?>
Expand Down Expand Up @@ -171,9 +172,15 @@ and other data will be preserved." />
</Component>
</Directory>
<Directory Id="EnvEntries">
<Component Id="EnvEntriesComponent" Guid="b662ec43-0e0e-4018-8bf3-061904bb8f5b" Bitness="always64">
<Component Id="EnvEntriesComponent" Guid="b662ec43-0e0e-4018-8bf3-061904bb8f5b" Bitness="always64"
Condition="MSIINSTALLPERUSER=1 AND NOT IS_UPGRADE" >
<CreateFolder />
<Environment Id="UpdatePath" Name="PATH" Action="set" Permanent="no" Part="last" Value="[INSTALLDIR]" />
<Environment Id="UpdatePath" Name="PATH" Action="set" Permanent="no" Part="last" Value="[INSTALLDIR]" System="false"/>
</Component>
<Component Id="EnvEntriesComponentPerMachine" Guid="b0fc674f-1b96-45d4-82a6-cf7d860afb72" Bitness="always64"
Condition="ALLUSERS=1 AND NOT MSIINSTALLPERUSER=1 AND NOT IS_UPGRADE" >
<CreateFolder />
<Environment Id="UpdatePathPerMachine" Name="PATH" Action="set" Permanent="no" Part="last" Value="[INSTALLDIR]" System="true"/>
</Component>
</Directory>
</Package>
Expand Down