diff options
| author | Ogulcan Celik <ogulcancelik@gmail.com> | 2026-08-18 22:39:38 +0300 |
|---|---|---|
| committer | Ogulcan Celik <ogulcancelik@gmail.com> | 2026-08-18 22:39:38 +0300 |
| commit | 9fac51722653fa0b0b6a5786166fb18c763424e0 (patch) | |
| tree | a8efd3b30cf29a8fb11138b7444bb9baa0dac2fa /scripts/windows_install_conpty_package_test.ps1 | |
| parent | 0bd445020ea19e0cea13f42a28212db7b2df196d (diff) | |
feat: make Windows generally available
Diffstat (limited to 'scripts/windows_install_conpty_package_test.ps1')
| -rw-r--r-- | scripts/windows_install_conpty_package_test.ps1 | 143 |
1 files changed, 124 insertions, 19 deletions
diff --git a/scripts/windows_install_conpty_package_test.ps1 b/scripts/windows_install_conpty_package_test.ps1 index 95b31c4a..f4c4fc60 100644 --- a/scripts/windows_install_conpty_package_test.ps1 +++ b/scripts/windows_install_conpty_package_test.ps1 @@ -82,7 +82,7 @@ $listener = [System.Net.Sockets.TcpListener]::new([System.Net.IPAddress]::Loopba $listener.Start() $port = ([System.Net.IPEndPoint]$listener.LocalEndpoint).Port $listener.Stop() -$manifest = @{ +$previewManifest = @{ channel = "preview" base_version = "0.0.0" build_id = "installer-test" @@ -94,18 +94,35 @@ $manifest = @{ } } } | ConvertTo-Json -Depth 5 -$manifestPath = Join-Path $webRoot "preview.json" -$manifest | Out-File -LiteralPath $manifestPath -Encoding utf8 +$legacyStableManifest = @{ + version = "0.0.0" + assets = @{} +} | ConvertTo-Json -Depth 5 +$stableManifest = @{ + version = "0.0.1" + assets = @{ + "windows-x86_64" = "http://127.0.0.1:$port/herdr-windows-x86_64.zip" + } + sha256 = @{ + "windows-x86_64" = $hash + } +} | ConvertTo-Json -Depth 5 +$previewManifestPath = Join-Path $webRoot "preview.json" +$stableManifestPath = Join-Path $webRoot "latest.json" +$previewManifest | Out-File -LiteralPath $previewManifestPath -Encoding utf8 +$legacyStableManifest | Out-File -LiteralPath $stableManifestPath -Encoding utf8 $server = $null $oldHerdrHome = $env:HERDR_HOME +$oldProcessPath = $env:Path try { $server = Start-Process python -ArgumentList @("-m", "http.server", "$port", "--bind", "127.0.0.1", "--directory", $webRoot) -PassThru -WindowStyle Hidden $env:HERDR_HOME = Join-Path $root "unused\..\home" - $manifestUrl = "http://127.0.0.1:$port/preview.json" + $previewManifestUrl = "http://127.0.0.1:$port/preview.json" + $stableManifestUrl = "http://127.0.0.1:$port/latest.json" for ($attempt = 0; $attempt -lt 20; $attempt++) { try { - Invoke-WebRequest -Uri $manifestUrl -UseBasicParsing | Out-Null + Invoke-WebRequest -Uri $stableManifestUrl -UseBasicParsing | Out-Null break } catch { if ($attempt -eq 19) { throw } @@ -113,8 +130,31 @@ try { } } + $freshStableHome = Join-Path $root "fresh-stable-home" + $freshStableBin = Join-Path $root "fresh-stable-bin" + $stableManifest | Out-File -LiteralPath $stableManifestPath -Encoding utf8 + $env:HERDR_HOME = $freshStableHome + $env:Path = $oldProcessPath + & $installerPath ` + -ManifestUrl $stableManifestUrl ` + -InstallDir $freshStableBin + $freshStableRelease = Get-ChildItem -LiteralPath (Join-Path $freshStableHome "packages\standalone\releases") -Directory | + Where-Object { $_.Name.StartsWith("0.0.1-") } | + Select-Object -First 1 + if ($null -eq $freshStableRelease) { + throw "fresh installer did not default to the stable Windows package" + } + + $legacyStableManifest | Out-File -LiteralPath $stableManifestPath -Encoding utf8 + $env:HERDR_HOME = Join-Path $root "unused\..\home" + $env:Path = $oldProcessPath + & $installerPath ` + -ManifestUrl $stableManifestUrl ` + -InstallDir $installDir ` + -ExpectedBuildId "installer-test" + # Keep the existing positional web-installer contract, including Retain in slot five. - & "$PSScriptRoot\..\website\install.ps1" "preview" $manifestUrl $installDir "installer-test" 3 + & $installerPath "preview" $previewManifestUrl $installDir "installer-test" 3 $localInstallDir = Join-Path $root "local-bin" $env:HERDR_HOME = Join-Path $root "local-home" @@ -136,7 +176,7 @@ try { $badLocalChecksumRejected = $false try { & $installerPath ` - -ManifestUrl "$manifestUrl/unused" ` + -ManifestUrl "$previewManifestUrl/unused" ` -InstallDir $localInstallDir ` -LocalPackagePath $archive ` -LocalPackageFormat "zip" ` @@ -153,7 +193,7 @@ try { } & $installerPath ` - -ManifestUrl "$manifestUrl/unused" ` + -ManifestUrl "$previewManifestUrl/unused" ` -InstallDir $localInstallDir ` -LocalPackagePath $archive ` -LocalPackageFormat "zip" ` @@ -188,13 +228,14 @@ try { } Remove-Item -LiteralPath (Join-Path $releaseDir.FullName "conpty\conpty.dll") -Force - $badManifest = $manifest | ConvertFrom-Json + $badManifest = $previewManifest | ConvertFrom-Json $badManifest.assets."windows-x86_64".url = "http://127.0.0.1:$port/missing.zip" - $badManifest | ConvertTo-Json -Depth 5 | Out-File -LiteralPath $manifestPath -Encoding utf8 + $badManifest | ConvertTo-Json -Depth 5 | Out-File -LiteralPath $previewManifestPath -Encoding utf8 $downloadFailed = $false try { & "$PSScriptRoot\..\website\install.ps1" ` - -ManifestUrl $manifestUrl ` + -Channel preview ` + -ManifestUrl $previewManifestUrl ` -InstallDir $installDir ` -ExpectedBuildId "installer-test" } catch { @@ -210,7 +251,7 @@ try { throw "failed repair removed the existing release" } - $manifest | Out-File -LiteralPath $manifestPath -Encoding utf8 + $previewManifest | Out-File -LiteralPath $previewManifestPath -Encoding utf8 $stagedConpty = Join-Path $releasesDir ".staging.$($releaseDir.Name).$PID\conpty\conpty.dll" $transientLockState = @{ Handle = $null; Acquired = $false; Released = $false } @@ -245,8 +286,9 @@ try { }.GetNewClosure() $transientLockBreakpoint = Set-PSBreakpoint -Script $installerPath -Variable "backupDir" -Mode Write -Action $lockStagedFileTransiently try { - & "$PSScriptRoot\..\website\install.ps1" ` - -ManifestUrl $manifestUrl ` + & $installerPath ` + -Channel preview ` + -ManifestUrl $previewManifestUrl ` -InstallDir $installDir ` -ExpectedBuildId "installer-test" if (-not $transientLockState.Acquired) { @@ -285,8 +327,9 @@ try { try { $swapFailed = $false try { - & "$PSScriptRoot\..\website\install.ps1" ` - -ManifestUrl $manifestUrl ` + & $installerPath ` + -Channel preview ` + -ManifestUrl $previewManifestUrl ` -InstallDir $installDir ` -ExpectedBuildId "installer-test" } catch { @@ -317,7 +360,8 @@ try { } & "$PSScriptRoot\..\website\install.ps1" ` - -ManifestUrl $manifestUrl ` + -Channel preview ` + -ManifestUrl $previewManifestUrl ` -InstallDir $installDir ` -ExpectedBuildId "installer-test" if (-not (Test-Path -LiteralPath (Join-Path $installDir "conpty\conpty.dll") -PathType Leaf)) { @@ -329,7 +373,8 @@ try { Move-Item -LiteralPath $x64HostDir -Destination $junctionTarget New-Item -ItemType Junction -Path $x64HostDir -Target $junctionTarget | Out-Null & "$PSScriptRoot\..\website\install.ps1" ` - -ManifestUrl $manifestUrl ` + -Channel preview ` + -ManifestUrl $previewManifestUrl ` -InstallDir $installDir ` -ExpectedBuildId "installer-test" $repairedHostDir = Get-Item -LiteralPath (Join-Path $installDir "conpty\x64") -Force @@ -340,7 +385,8 @@ try { $rejected = $false try { & "$PSScriptRoot\..\website\install.ps1" ` - -ManifestUrl $manifestUrl ` + -Channel preview ` + -ManifestUrl $previewManifestUrl ` -InstallDir $installDir ` -ExpectedBuildId "different-build" } catch { @@ -352,8 +398,67 @@ try { if (-not $rejected) { throw "installer accepted a manifest that did not match the updater-selected build" } + + $stableManifest | Out-File -LiteralPath $stableManifestPath -Encoding utf8 + & "$PSScriptRoot\..\website\install.ps1" ` + -Channel stable ` + -ManifestUrl $stableManifestUrl ` + -InstallDir $installDir + $stableReleaseDir = Get-ChildItem -LiteralPath (Join-Path $herdrHome "packages\standalone\releases") -Directory | + Where-Object { $_.Name.StartsWith("0.0.1-") } | + Select-Object -First 1 + if ($null -eq $stableReleaseDir) { + throw "installer did not install the stable Windows package" + } + foreach ($relative in $required) { + if (-not (Test-Path -LiteralPath (Join-Path $installDir $relative) -PathType Leaf)) { + throw "stable installer did not activate required file $relative" + } + } + + $customPreviewManifestPath = Join-Path $webRoot "candidate.json" + $customPreviewManifest = $previewManifest | ConvertFrom-Json + $customPreviewManifest.PSObject.Properties.Remove("channel") + $customPreviewManifest | ConvertTo-Json -Depth 5 | Out-File -LiteralPath $customPreviewManifestPath -Encoding utf8 + $fakeBin = Join-Path $root "fake-existing" + New-Item -ItemType Directory -Force -Path $fakeBin | Out-Null + @' +@echo off +if "%1"=="channel" if "%2"=="show" ( + echo preview + exit /b 0 +) +exit /b 1 +'@ | Out-File -LiteralPath (Join-Path $fakeBin "herdr.cmd") -Encoding ascii + + $preserveHome = Join-Path $root "preserve-home" + $preserveBin = Join-Path $root "preserve-bin" + $env:HERDR_HOME = $preserveHome + $env:Path = "$fakeBin;$oldProcessPath" + & "$PSScriptRoot\..\website\install.ps1" ` + -ManifestUrl "http://127.0.0.1:$port/candidate.json" ` + -InstallDir $preserveBin ` + -ExpectedBuildId "installer-test" + $preservedPreview = Get-ChildItem -LiteralPath (Join-Path $preserveHome "packages\standalone\releases") -Directory | + Where-Object { $_.Name.StartsWith("0.0.0-preview.installer-test-") } | + Select-Object -First 1 + if ($null -eq $preservedPreview) { + throw "installer did not preserve the existing preview channel" + } + + & "$PSScriptRoot\..\website\install.ps1" ` + -Channel stable ` + -ManifestUrl $stableManifestUrl ` + -InstallDir $preserveBin + $explicitStable = Get-ChildItem -LiteralPath (Join-Path $preserveHome "packages\standalone\releases") -Directory | + Where-Object { $_.Name.StartsWith("0.0.1-") } | + Select-Object -First 1 + if ($null -eq $explicitStable) { + throw "explicit stable channel did not override the existing preview channel" + } } finally { $env:HERDR_HOME = $oldHerdrHome + $env:Path = $oldProcessPath if ($null -ne $server -and -not $server.HasExited) { Stop-Process -Id $server.Id -Force -ErrorAction SilentlyContinue } |
