Add win installer patch

Adding a patch to the bundle so that the update from previous version
(v5.3.1) is a minor update, not a major one. A minor update prevents the
full uninstallation of v5.3.1 and an unrequested reboot of the machine.

Signed-off-by: Mario Loriedo <mario.loriedo@gmail.com>
This commit is contained in:
Mario Loriedo
2024-12-11 13:23:21 +01:00
parent d582c39dc8
commit af607d0de4
8 changed files with 321 additions and 76 deletions

View File

@ -7,17 +7,32 @@ if ($Env:CI -eq "true") {
$RELEASE_DIR = "$ENV:CIRRUS_WORKING_DIR\repo" $RELEASE_DIR = "$ENV:CIRRUS_WORKING_DIR\repo"
} else { } else {
$WIN_INST_FOLDER = "$PSScriptRoot\..\win-installer" $WIN_INST_FOLDER = "$PSScriptRoot\..\win-installer"
$ENV:WIN_INST_VER = "9.9.9" $ENV:WIN_INST_VER = "9.9.8"
$RELEASE_DIR = "$PSScriptRoot\..\..\contrib\win-installer\current" $RELEASE_DIR = "$PSScriptRoot\..\..\contrib\win-installer\current"
if ($null -eq $ENV:CONTAINERS_MACHINE_PROVIDER) { $ENV:CONTAINERS_MACHINE_PROVIDER = 'wsl' } if ($null -eq $ENV:CONTAINERS_MACHINE_PROVIDER) { $ENV:CONTAINERS_MACHINE_PROVIDER = 'wsl' }
} }
Push-Location $WIN_INST_FOLDER Push-Location $WIN_INST_FOLDER
# Build Installer # Build and test the windows installer
# Downlaod v5.3.1 installer as `build.ps1` uses it to build the patch
# (podman.msp). `build.ps1` reads `$env:V531_SETUP_EXE_PATH` to get its path.
# The v5.3.1 installer is also used to test the "v5.3.1 -> current" version minor
# update (with patch).
$env:V531_SETUP_EXE_PATH = Get-Podman-Setup-From-GitHub -version "tags/v5.3.1"
# Downlaod the previous installer to test a major update (without patch)
# After v5.3.2 release we should download latest instead of v5.3.0 (i.e.
# `Get-Latest-Podman-Setup-From-GitHub`)
$env:PREV_SETUP_EXE_PATH = Get-Podman-Setup-From-GitHub -version "tags/v5.3.0"
# Note: consumes podman-remote-release-windows_amd64.zip from repo.tar.zst # Note: consumes podman-remote-release-windows_amd64.zip from repo.tar.zst
Run-Command ".\build.ps1 $Env:WIN_INST_VER dev `"$RELEASE_DIR`"" Run-Command ".\build.ps1 $Env:WIN_INST_VER dev `"$RELEASE_DIR`""
# Build a v9.9.9 installer to test an update from current to next version
Run-Command ".\build.ps1 9.9.9 dev `"$RELEASE_DIR`""
Pop-Location Pop-Location
# Run the installer silently and WSL/HyperV install options disabled (prevent reboots) # Run the installer silently and WSL/HyperV install options disabled (prevent reboots)
@ -25,4 +40,7 @@ $command = "$WIN_INST_FOLDER\test-installer.ps1 "
$command += "-scenario all " $command += "-scenario all "
$command += "-provider $ENV:CONTAINERS_MACHINE_PROVIDER " $command += "-provider $ENV:CONTAINERS_MACHINE_PROVIDER "
$command += "-setupExePath `"$WIN_INST_FOLDER\podman-$ENV:WIN_INST_VER-dev-setup.exe`"" $command += "-setupExePath `"$WIN_INST_FOLDER\podman-$ENV:WIN_INST_VER-dev-setup.exe`""
$command += "-previousSetupExePath `"$env:PREV_SETUP_EXE_PATH`""
$command += "-nextSetupExePath `"$WIN_INST_FOLDER\podman-9.9.9-dev-setup.exe`""
$command += "-v531SetupExePath `"$env:V531_SETUP_EXE_PATH`""
Run-Command "${command}" Run-Command "${command}"

View File

@ -1,3 +1,64 @@
# Windows Installer Build # Windows Installer Build
Instructions [have moved here](Build and test the Podman Windows installer](#build-and-test-the-podman-windows-installer)). Instructions [have moved here](Build and test the Podman Windows installer](#build-and-test-the-podman-windows-installer)).
## How to run a full tests scenarios
Manual tests to validate changes the wxs files or a WiX upgrade.
## Preparation
- checkout previous release tag (e.g. 5.3.0)
`git fetch --all --tags --prune && git tag --list v5.* && git checkout tags/v5.3.0`
- make the installer
`./winmake podman && ./winmake docs && ./winmake win-gvproxy && ./winmake installer`
- checkout tag `v5.3.1` make the installer
`./winmake podman && ./winmake docs && ./winmake win-gvproxy && ./winmake installer`
- get the `v5.3.1` msi product id (with superorca)
- checkout the main branch and change the product id on `podman.wxs` to match `v5.3.1` product id
- set `$env:V531_SETUP_EXE_PATH` and make current and next installer
`$env:V531_SETUP_EXE_PATH=<path> && ./winmake podman && ./winmake docs && ./winmake win-gvproxy && ./winmake installer && ./winmake installer 9.9.9`
- patch installertest to make sure it doesn't download the setup.exe from internet but uses the one just built
## Run the tests
1. Uninstall the virtualization providers (WSL and Hyper-V) using the "Windows Features" app
2. Run installtest for both `wsl` and `hyperv` (**as an admin**)
```pwsh
.\contrib\win-installer\test-installer.ps1 `
-scenario all `
-setupExePath ".\contrib\win-installer\podman-5.4.0-dev-setup.exe" `
-previousSetupExePath ".\contrib\win-installer\podman-5.3.0-dev-setup.exe" `
-nextSetupExePath ".\contrib\win-installer\podman-9.9.9-dev-setup.exe" `
-v531SetupExePath ".\contrib\win-installer\podman-5.3.1-dev-setup.exe" `
-provider hyperv
```
3. Manually test the upgrade "from v5.3.1 to current to next"
```pwsh
contrib\win-installer\podman-5.3.1-dev-setup.exe /install /log contrib\win-installer\podman-setup-531.log
contrib\win-installer\podman-5.4.0-dev-setup.exe /install /log contrib\win-installer\podman-setup-540.log
contrib\win-installer\podman-9.9.9-dev-setup.exe /install /log contrib\win-installer\podman-setup-999.log
contrib\win-installer\podman-9.9.9-dev-setup.exe /x /log contrib\win-installer\podman-uninstall-999.log
```
4. manually run the current installer with the option to install wsl and confirm it reboots and install both podman and wsl
5. manually run the current installer with the option to install hyperv and confirm it reboots and install both podman and wsl
6. run installtest for both wsl and hyperv
7. manually run the current installer with the option to install wsl and confirm it doesn't reboot
8. manually run the current installer with the option to install hyperv and confirm it doesn't reboot
## retrieve installed podman msi package information
```pwsh
$Installer = New-Object -ComObject WindowsInstaller.Installer;
$InstallerProducts = $Installer.ProductsEx("", "", 7);
$InstalledProducts = ForEach($Product in $InstallerProducts){
[PSCustomObject]@{ProductCode = $Product.ProductCode();
LocalPackage = $Product.InstallProperty("LocalPackage");
VersionString = $Product.InstallProperty("VersionString");
ProductName = $Product.InstallProperty("ProductName")
}
};
$InstalledProducts | Where-Object {$_.ProductName -match "podman"}
```
and uninstall it with `msiexec /x "{<product-code>}"`

View File

@ -49,12 +49,28 @@ function CheckRequirements() {
CheckCommand "go" "Golang" CheckCommand "go" "Golang"
} }
function Build-531-Patch() {
param(
[ValidateScript({Test-Path $_ -PathType Leaf})]
[string]$v531SetupExePath=$ENV:V531_SETUP_EXE_PATH
)
if (!$v531SetupExePath) {
. $PSScriptRoot\utils.ps1
$v531SetupExePath=Get-Podman-Setup-From-GitHub "tags/v5.3.1"
}
wix burn extract $v531SetupExePath -o $PSScriptRoot\prevPodmanMsi; ExitOnError
Move-Item $PSScriptRoot\prevPodmanMsi\a1 $PSScriptRoot\en-US\prev-podman.wixpdb -Force; ExitOnError
Move-Item $PSScriptRoot\prevPodmanMsi\a0 $PSScriptRoot\en-US\prev-podman.msi -Force; ExitOnError
wix build -define "Version=$ENV:INSTVER" -bindpath $PSScriptRoot\en-US -out $PSScriptRoot\en-US\podman.msp podman-patch.wxs; ExitOnError
}
if ($args.Count -lt 1 -or $args[0].Length -lt 1) { if ($args.Count -lt 1 -or $args[0].Length -lt 1) {
Write-Host "Usage: " $MyInvocation.MyCommand.Name "<version> [dev|prod] [release_dir]" Write-Host "Usage: " $MyInvocation.MyCommand.Name "<version> [dev|prod] [release_dir]"
Write-Host Write-Host
Write-Host 'Uses Env Vars: ' Write-Host 'Uses Env Vars: '
Write-Host ' $ENV:FETCH_BASE_URL - GitHub Repo Address to locate release on' Write-Host ' $ENV:FETCH_BASE_URL - GitHub Repo Address to locate release on'
Write-Host ' $ENV:V531_SETUP_EXE_PATH - Path to v5.3.1 setup.exe used to build the patch'
Write-Host 'Env Settings for signing (optional)' Write-Host 'Env Settings for signing (optional)'
Write-Host ' $ENV:VAULT_ID' Write-Host ' $ENV:VAULT_ID'
Write-Host ' $ENV:APP_ID' Write-Host ' $ENV:APP_ID'
@ -129,6 +145,10 @@ if (Test-Path ./obj) {
dotnet build podman.wixproj /property:DefineConstants="VERSION=$ENV:INSTVER" -o .; ExitOnError dotnet build podman.wixproj /property:DefineConstants="VERSION=$ENV:INSTVER" -o .; ExitOnError
SignItem @("en-US\podman.msi") SignItem @("en-US\podman.msi")
# Build the Patch for 5.3.1
Build-531-Patch
SignItem @("en-US\podman.msp")
dotnet build podman-setup.wixproj /property:DefineConstants="VERSION=$ENV:INSTVER" -o .; ExitOnError dotnet build podman-setup.wixproj /property:DefineConstants="VERSION=$ENV:INSTVER" -o .; ExitOnError
wix burn detach podman-setup.exe -engine engine.exe; ExitOnError wix burn detach podman-setup.exe -engine engine.exe; ExitOnError
SignItem @("engine.exe") SignItem @("engine.exe")

View File

@ -30,6 +30,7 @@
<MsiProperty Name="WITH_HYPERV" Value="[HyperVCheckbox]" /> <MsiProperty Name="WITH_HYPERV" Value="[HyperVCheckbox]" />
<MsiProperty Name="SKIP_CONFIG_FILE_CREATION" Value="[SkipConfigFileCreation]" /> <MsiProperty Name="SKIP_CONFIG_FILE_CREATION" Value="[SkipConfigFileCreation]" />
</MsiPackage> </MsiPackage>
<MspPackage Id="Patch" SourceFile="en-US\podman.msp" Vital="yes" />
<ExePackage DisplayName="WSL Kernel Install" InstallCondition="(MachineProvider = &quot;wsl&quot;) AND (WSLCheckbox = 1) AND (NOT PreviousInstallFolder)" SourceFile="artifacts\podman-wslkerninst.exe" DetectCondition="" Permanent="true" /> <ExePackage DisplayName="WSL Kernel Install" InstallCondition="(MachineProvider = &quot;wsl&quot;) AND (WSLCheckbox = 1) AND (NOT PreviousInstallFolder)" SourceFile="artifacts\podman-wslkerninst.exe" DetectCondition="" Permanent="true" />
</Chain> </Chain>
<OptionalUpdateRegistration /> <OptionalUpdateRegistration />

View File

@ -0,0 +1,21 @@
<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs">
<Patch
AllowRemoval="yes"
Classification="Update"
DisplayName="Podman Patch v$(Version)"
Description="Podman Patch v$(Version)"
Manufacturer="Red Hat Inc.">
<Media Id="1000" Cabinet="PodmanPatch.cab">
<PatchBaseline
Id="podmanPatch"
BaselineFile="podman.msi"
UpdateFile="prev-podman.msi"/>
</Media>
<PatchFamily
Id="PodmanPatches"
Version="$(Version)"
Supersede="yes" />
</Patch>
</Wix>

View File

@ -10,7 +10,7 @@
<?define UseGVProxy = ""?> <?define UseGVProxy = ""?>
<?endif?> <?endif?>
<Package Name="podman" Manufacturer="Red Hat Inc." Version="$(VERSION)" UpgradeCode="a6a9dd9c-0732-44ba-9279-ffe22ea50671"> <Package Name="podman" Manufacturer="Red Hat Inc." Version="$(VERSION)" UpgradeCode="a6a9dd9c-0732-44ba-9279-ffe22ea50671" ProductCode="18107131-1820-4878-8AEE-65AAE37BC1E3">
<Media Id="1" Cabinet="Podman.cab" EmbedCab="yes" /> <Media Id="1" Cabinet="Podman.cab" EmbedCab="yes" />
<MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." RemoveFeatures="Complete" Schedule="afterInstallExecute" /> <MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." RemoveFeatures="Complete" Schedule="afterInstallExecute" />
<Property Id="DiskPrompt" Value="Red Hat's Podman $(VERSION) Installation" /> <Property Id="DiskPrompt" Value="Red Hat's Podman $(VERSION) Installation" />
@ -154,7 +154,7 @@
<StandardDirectory Id="CommonAppDataFolder"> <StandardDirectory Id="CommonAppDataFolder">
<Directory Id="CONFIGDIR" Name="containers"> <Directory Id="CONFIGDIR" Name="containers">
<Directory Id="ContainersConfigSubDir" Name="containers.conf.d"> <Directory Id="ContainersConfigSubDir" Name="containers.conf.d">
<Component Id="MachineProviderConfigFile" Guid="C32C0040-D9AF-4155-AC7E-465B63B6BE3B" Condition="CREATE_MACHINE_PROVIDER_CONFIG_FILE"> <Component Id="MachineProviderConfigFile" Guid="C32C0040-D9AF-4155-AC7E-465B63B6BE3B" Condition="CREATE_MACHINE_PROVIDER_CONFIG_FILE" Transitive="true">
<CreateFolder /> <CreateFolder />
<IniFile Id="MachineProviderConfigFile" Action="createLine" Directory="ContainersConfigSubDir" Section="machine" Name="99-podman-machine-provider.conf" Key="provider" Value="&quot;[MACHINE_PROVIDER]&quot;" /> <IniFile Id="MachineProviderConfigFile" Action="createLine" Directory="ContainersConfigSubDir" Section="machine" Name="99-podman-machine-provider.conf" Key="provider" Value="&quot;[MACHINE_PROVIDER]&quot;" />
</Component> </Component>

View File

@ -4,21 +4,34 @@
# rm .\contrib\win-installer\*.log && # rm .\contrib\win-installer\*.log &&
# rm .\contrib\win-installer\*.exe && # rm .\contrib\win-installer\*.exe &&
# rm .\contrib\win-installer\*.wixpdb && # rm .\contrib\win-installer\*.wixpdb &&
# .\winmake.ps1 installer &&
# .\winmake.ps1 installer 9.9.9 && # .\winmake.ps1 installer 9.9.9 &&
# .\contrib\win-installer\test-installer.ps1 ` # .\contrib\win-installer\test-installer.ps1 `
# -scenario update-without-user-changes ` # -scenario update-without-user-changes `
# -setupExePath ".\contrib\win-installer\podman-9.9.9-dev-setup.exe" ` # -previousSetupExePath ".\contrib\win-installer\podman-5.3.0-dev-setup.exe" `
# -setupExePath ".\contrib\win-installer\podman-5.4.0-dev-setup.exe" `
# -nextSetupExePath ".\contrib\win-installer\podman-9.9.9-dev-setup.exe" `
# -v531SetupExePath ".\contrib\win-installer\podman-5.3.1-dev-setup.exe" `
# -provider hyperv # -provider hyperv
#
# The Param statement must be the first statement, except for comments and any #Require statements. # The Param statement must be the first statement, except for comments and any #Require statements.
param ( param (
[Parameter(Mandatory)] [Parameter(Mandatory)]
[ValidateSet("test-objects-exist", "test-objects-exist-not", "installation-green-field", "installation-skip-config-creation-flag", "installation-with-pre-existing-podman-exe", "update-without-user-changes", "update-with-user-changed-config-file", "update-with-user-removed-config-file", "all")] [ValidateSet("test-objects-exist", "test-objects-exist-not", "installation-green-field", "installation-skip-config-creation-flag", "installation-with-pre-existing-podman-exe",
"update-without-user-changes", "update-with-user-changed-config-file", "update-with-user-removed-config-file",
"update-without-user-changes-from-531", "update-with-user-changed-config-file-from-531", "update-with-user-removed-config-file-from-531",
"update-without-user-changes-to-next", "update-with-user-changed-config-file-to-next", "update-with-user-removed-config-file-to-next",
"all")]
[string]$scenario, [string]$scenario,
[ValidateScript({Test-Path $_ -PathType Leaf})] [ValidateScript({Test-Path $_ -PathType Leaf})]
[string]$setupExePath, [string]$setupExePath,
[ValidateScript({Test-Path $_ -PathType Leaf})] [ValidateScript({Test-Path $_ -PathType Leaf})]
[string]$previousSetupExePath, [string]$previousSetupExePath,
[ValidateScript({Test-Path $_ -PathType Leaf})]
[string]$nextSetupExePath,
[ValidateScript({Test-Path $_ -PathType Leaf})]
[string]$v531SetupExePath,
[ValidateSet("wsl", "hyperv")] [ValidateSet("wsl", "hyperv")]
[string]$provider="wsl", [string]$provider="wsl",
[switch]$installWSL=$false, [switch]$installWSL=$false,
@ -27,6 +40,8 @@ param (
[switch]$skipConfigFileCreation=$false [switch]$skipConfigFileCreation=$false
) )
. $PSScriptRoot\utils.ps1
$MachineConfPath = "$env:ProgramData\containers\containers.conf.d\99-podman-machine-provider.conf" $MachineConfPath = "$env:ProgramData\containers\containers.conf.d\99-podman-machine-provider.conf"
$PodmanFolderPath = "$env:ProgramFiles\RedHat\Podman" $PodmanFolderPath = "$env:ProgramFiles\RedHat\Podman"
$PodmanExePath = "$PodmanFolderPath\podman.exe" $PodmanExePath = "$PodmanFolderPath\podman.exe"
@ -86,22 +101,10 @@ function Install-Podman-With-Defaults {
Write-Host "Installation completed successfully!`n" Write-Host "Installation completed successfully!`n"
} }
function Install-Previous-Podman {
Install-Podman -setupExePath $previousSetupExePath
}
function Install-Previous-Podman-With-Defaults {
Install-Podman-With-Defaults -setupExePath $previousSetupExePath
}
function Install-Current-Podman { function Install-Current-Podman {
Install-Podman -setupExePath $setupExePath Install-Podman -setupExePath $setupExePath
} }
function Install-Current-Podman-With-Defaults {
Install-Podman-With-Defaults -setupExePath $setupExePath
}
function Test-Podman-Objects-Exist { function Test-Podman-Objects-Exist {
Write-Host "Verifying that podman files, folders and registry entries exist..." Write-Host "Verifying that podman files, folders and registry entries exist..."
$WindowsPathsToTest | ForEach-Object { $WindowsPathsToTest | ForEach-Object {
@ -156,10 +159,6 @@ function Uninstall-Current-Podman {
Uninstall-Podman -setupExePath $setupExePath Uninstall-Podman -setupExePath $setupExePath
} }
function Uninstall-Previous-Podman {
Uninstall-Podman -setupExePath $previousSetupExePath
}
function Test-Podman-Objects-Exist-Not { function Test-Podman-Objects-Exist-Not {
Write-Host "Verifying that podman files, folders and registry entries don't exist..." Write-Host "Verifying that podman files, folders and registry entries don't exist..."
$WindowsPathsToTest | ForEach-Object { $WindowsPathsToTest | ForEach-Object {
@ -212,18 +211,39 @@ function Get-Latest-Podman-Setup-From-GitHub {
return $destinationPath return $destinationPath
} }
function Test-Installation {
param (
[ValidateSet("wsl", "hyperv")]
[string]$expectedConf
)
Test-Podman-Objects-Exist
Test-Podman-Machine-Conf-Exist
if ($expectedConf) {
Test-Podman-Machine-Conf-Content -expected $expectedConf
} else {
Test-Podman-Machine-Conf-Content
}
}
function Test-Installation-No-Config {
Test-Podman-Objects-Exist
Test-Podman-Machine-Conf-Exist-Not
}
function Test-Uninstallation {
Test-Podman-Objects-Exist-Not
Test-Podman-Machine-Conf-Exist-Not
}
# SCENARIOS # SCENARIOS
function Start-Scenario-Installation-Green-Field { function Start-Scenario-Installation-Green-Field {
Write-Host "`n===========================================" Write-Host "`n==========================================="
Write-Host " Running scenario: Installation-Green-Field" Write-Host " Running scenario: Installation-Green-Field"
Write-Host "===========================================" Write-Host "==========================================="
Install-Current-Podman Install-Current-Podman
Test-Podman-Objects-Exist Test-Installation
Test-Podman-Machine-Conf-Exist
Test-Podman-Machine-Conf-Content
Uninstall-Current-Podman Uninstall-Current-Podman
Test-Podman-Objects-Exist-Not Test-Uninstallation
Test-Podman-Machine-Conf-Exist-Not
} }
function Start-Scenario-Installation-Skip-Config-Creation-Flag { function Start-Scenario-Installation-Skip-Config-Creation-Flag {
@ -232,11 +252,9 @@ function Start-Scenario-Installation-Skip-Config-Creation-Flag {
Write-Host "=========================================================" Write-Host "========================================================="
$skipConfigFileCreation = $true $skipConfigFileCreation = $true
Install-Current-Podman Install-Current-Podman
Test-Podman-Objects-Exist Test-Installation-No-Config
Test-Podman-Machine-Conf-Exist-Not
Uninstall-Current-Podman Uninstall-Current-Podman
Test-Podman-Objects-Exist-Not Test-Uninstallation
Test-Podman-Machine-Conf-Exist-Not
} }
function Start-Scenario-Installation-With-Pre-Existing-Podman-Exe { function Start-Scenario-Installation-With-Pre-Existing-Podman-Exe {
@ -245,63 +263,98 @@ function Start-Scenario-Installation-With-Pre-Existing-Podman-Exe {
Write-Host "============================================================" Write-Host "============================================================"
New-Fake-Podman-Exe New-Fake-Podman-Exe
Install-Current-Podman Install-Current-Podman
Test-Podman-Objects-Exist Test-Installation-No-Config
Test-Podman-Machine-Conf-Exist-Not
Uninstall-Current-Podman Uninstall-Current-Podman
Test-Podman-Objects-Exist-Not Test-Uninstallation
Test-Podman-Machine-Conf-Exist-Not
} }
function Start-Scenario-Update-Without-User-Changes { function Start-Scenario-Update-Without-User-Changes {
Write-Host "`n==============================================" param (
Write-Host " Running scenario: Update-Without-User-Changes" [ValidateSet("From-Previous", "From-531", "To-Next")]
Write-Host "==============================================" [string]$mode="From-Previous"
Install-Previous-Podman )
Test-Podman-Objects-Exist Write-Host "`n======================================================"
Test-Podman-Machine-Conf-Exist Write-Host " Running scenario: Update-Without-User-Changes-$mode"
Test-Podman-Machine-Conf-Content Write-Host "======================================================"
Install-Current-Podman-With-Defaults switch ($mode) {
Test-Podman-Objects-Exist 'From-Previous' {$i = $previousSetupExePath; $u = $setupExePath}
Test-Podman-Machine-Conf-Exist 'From-531' {$i = $v531SetupExePath; $u = $setupExePath}
Test-Podman-Machine-Conf-Content 'To-Next' {$i = $setupExePath; $u = $nextSetupExePath}
Uninstall-Current-Podman }
Test-Podman-Objects-Exist-Not Install-Podman -setupExePath $i
Test-Podman-Machine-Conf-Exist-Not Test-Installation
Install-Podman-With-Defaults -setupExePath $u
Test-Installation
Uninstall-Podman -setupExePath $u
Test-Uninstallation
}
function Start-Scenario-Update-Without-User-Changes-From-531 {
Start-Scenario-Update-Without-User-Changes -mode "From-531"
}
function Start-Scenario-Update-Without-User-Changes-To-Next {
Start-Scenario-Update-Without-User-Changes -mode "To-Next"
} }
function Start-Scenario-Update-With-User-Changed-Config-File { function Start-Scenario-Update-With-User-Changed-Config-File {
Write-Host "`n=======================================================" param (
Write-Host " Running scenario: Update-With-User-Changed-Config-File" [ValidateSet("From-Previous", "From-531", "To-Next")]
Write-Host "=======================================================" [string]$mode="From-Previous"
Install-Previous-Podman )
Test-Podman-Objects-Exist Write-Host "`n=============================================================="
Test-Podman-Machine-Conf-Exist Write-Host " Running scenario: Update-With-User-Changed-Config-File-$mode"
Test-Podman-Machine-Conf-Content Write-Host "=============================================================="
switch ($mode) {
'From-Previous' {$i = $previousSetupExePath; $u = $setupExePath}
'From-531' {$i = $v531SetupExePath; $u = $setupExePath}
'To-Next' {$i = $setupExePath; $u = $nextSetupExePath}
}
Install-Podman -setupExePath $i
Test-Installation
$newProvider = Switch-Podman-Machine-Conf-Content $newProvider = Switch-Podman-Machine-Conf-Content
Install-Current-Podman-With-Defaults Install-Podman-With-Defaults -setupExePath $u
Test-Podman-Objects-Exist Test-Installation -expectedConf $newProvider
Test-Podman-Machine-Conf-Exist Uninstall-Podman -setupExePath $u
Test-Podman-Machine-Conf-Content -expected $newProvider Test-Uninstallation
Uninstall-Current-Podman }
Test-Podman-Objects-Exist-Not
Test-Podman-Machine-Conf-Exist-Not function Start-Scenario-Update-With-User-Changed-Config-File-From-531 {
Start-Scenario-Update-With-User-Changed-Config-File -mode "From-531"
}
function Start-Scenario-Update-With-User-Changed-Config-File-To-Next {
Start-Scenario-Update-With-User-Changed-Config-File -mode "To-Next"
} }
function Start-Scenario-Update-With-User-Removed-Config-File { function Start-Scenario-Update-With-User-Removed-Config-File {
Write-Host "`n=======================================================" param (
Write-Host " Running scenario: Update-With-User-Removed-Config-File" [ValidateSet("From-Previous", "From-531", "To-Next")]
Write-Host "=======================================================" [string]$mode="From-Previous"
Install-Previous-Podman )
Test-Podman-Objects-Exist Write-Host "`n=============================================================="
Test-Podman-Machine-Conf-Exist Write-Host " Running scenario: Update-With-User-Removed-Config-File-$mode"
Test-Podman-Machine-Conf-Content Write-Host "=============================================================="
switch ($mode) {
'From-Previous' {$i = $previousSetupExePath; $u = $setupExePath}
'From-531' {$i = $v531SetupExePath; $u = $setupExePath}
'To-Next' {$i = $setupExePath; $u = $nextSetupExePath}
}
Install-Podman -setupExePath $i
Test-Installation
Remove-Podman-Machine-Conf Remove-Podman-Machine-Conf
Install-Current-Podman-With-Defaults Install-Podman-With-Defaults -setupExePath $u
Test-Podman-Objects-Exist Test-Installation-No-Config
Test-Podman-Machine-Conf-Exist-Not Uninstall-Podman -setupExePath $u
Uninstall-Current-Podman Test-Uninstallation
Test-Podman-Objects-Exist-Not }
Test-Podman-Machine-Conf-Exist-Not
function Start-Scenario-Update-With-User-Removed-Config-File-From-531 {
Start-Scenario-Update-With-User-Removed-Config-File -mode "From-531"
}
function Start-Scenario-Update-With-User-Removed-Config-File-To-Next {
Start-Scenario-Update-With-User-Removed-Config-File -mode "To-Next"
} }
switch ($scenario) { switch ($scenario) {
@ -326,27 +379,75 @@ switch ($scenario) {
} }
Start-Scenario-Update-Without-User-Changes Start-Scenario-Update-Without-User-Changes
} }
'update-without-user-changes-from-531' {
if (!$v531SetupExePath) {
$v531SetupExePath = Get-Podman-Setup-From-GitHub -version "tags/v5.3.1"
}
Start-Scenario-Update-Without-User-Changes-From-531
}
'update-without-user-changes-to-next' {
if (!$nextSetupExePath) {
throw "Next version installer path is not defined. Use '-nextSetupExePath <setup-exe-path>' to define it."
}
Start-Scenario-Update-Without-User-Changes-To-Next
}
'update-with-user-changed-config-file' { 'update-with-user-changed-config-file' {
if (!$previousSetupExePath) { if (!$previousSetupExePath) {
$previousSetupExePath = Get-Latest-Podman-Setup-From-GitHub $previousSetupExePath = Get-Latest-Podman-Setup-From-GitHub
} }
Start-Scenario-Update-With-User-Changed-Config-File Start-Scenario-Update-With-User-Changed-Config-File
} }
'update-with-user-changed-config-file-from-531' {
if (!$v531SetupExePath) {
$v531SetupExePath = Get-Podman-Setup-From-GitHub -version "tags/v5.3.1"
}
Start-Scenario-Update-With-User-Changed-Config-File-From-531
}
'update-with-user-changed-config-file-to-next' {
if (!$nextSetupExePath) {
throw "Next version installer path is not defined. Use '-nextSetupExePath <setup-exe-path>' to define it."
}
Start-Scenario-Update-With-User-Changed-Config-File-To-Next
}
'update-with-user-removed-config-file' { 'update-with-user-removed-config-file' {
if (!$previousSetupExePath) { if (!$previousSetupExePath) {
$previousSetupExePath = Get-Latest-Podman-Setup-From-GitHub $previousSetupExePath = Get-Latest-Podman-Setup-From-GitHub
} }
Start-Scenario-Update-With-User-Removed-Config-File Start-Scenario-Update-With-User-Removed-Config-File
} }
'update-with-user-removed-config-file-from-531' {
if (!$v531SetupExePath) {
$v531SetupExePath = Get-Podman-Setup-From-GitHub -version "tags/v5.3.1"
}
Start-Scenario-Update-With-User-Removed-Config-File-From-531
}
'update-with-user-removed-config-file-to-next' {
if (!$nextSetupExePath) {
throw "Next version installer path is not defined. Use '-nextSetupExePath <setup-exe-path>' to define it."
}
Start-Scenario-Update-With-User-Removed-Config-File-To-Next
}
'all' { 'all' {
if (!$nextSetupExePath) {
throw "Next version installer path is not defined. Use '-nextSetupExePath <setup-exe-path>' to define it."
}
if (!$previousSetupExePath) { if (!$previousSetupExePath) {
$previousSetupExePath = Get-Latest-Podman-Setup-From-GitHub $previousSetupExePath = Get-Latest-Podman-Setup-From-GitHub
} }
if (!$v531SetupExePath) {
$v531SetupExePath = Get-Podman-Setup-From-GitHub -version "tags/v5.3.1"
}
Start-Scenario-Installation-Green-Field Start-Scenario-Installation-Green-Field
Start-Scenario-Installation-Skip-Config-Creation-Flag Start-Scenario-Installation-Skip-Config-Creation-Flag
Start-Scenario-Installation-With-Pre-Existing-Podman-Exe Start-Scenario-Installation-With-Pre-Existing-Podman-Exe
Start-Scenario-Update-Without-User-Changes Start-Scenario-Update-Without-User-Changes
Start-Scenario-Update-Without-User-Changes-From-531
Start-Scenario-Update-Without-User-Changes-To-Next
Start-Scenario-Update-With-User-Changed-Config-File Start-Scenario-Update-With-User-Changed-Config-File
Start-Scenario-Update-With-User-Changed-Config-File-From-531
Start-Scenario-Update-With-User-Changed-Config-File-To-Next
Start-Scenario-Update-With-User-Removed-Config-File Start-Scenario-Update-With-User-Removed-Config-File
Start-Scenario-Update-With-User-Removed-Config-File-From-531
Start-Scenario-Update-With-User-Removed-Config-File-To-Next
} }
} }

View File

@ -0,0 +1,23 @@
#!/usr/bin/env pwsh
function Get-Latest-Podman-Setup-From-GitHub {
return Get-Podman-Setup-From-GitHub "latest"
}
function Get-Podman-Setup-From-GitHub {
param(
[Parameter(Mandatory)]
[string] $version
)
Write-Host "Downloading the $version Podman windows setup from GitHub..."
$apiUrl = "https://api.github.com/repos/containers/podman/releases/$version"
$response = Invoke-RestMethod -Uri $apiUrl -Headers @{"User-Agent"="PowerShell"} -ErrorAction Stop
$downloadUrl = $response.assets[0].browser_download_url
Write-Host "Downloading URL: $downloadUrl"
$latestTag = $response.tag_name
$destinationPath = "$PSScriptRoot\podman-$latestTag-setup.exe"
Write-Host "Destination Path: $destinationPath"
Invoke-WebRequest -Uri $downloadUrl -OutFile $destinationPath
Write-Host "Command completed successfully!`n"
return $destinationPath
}