authoravatarclover caruso<git@paperclover.net>2026-11-17 00:00:01-08:00
committeravatarclover caruso<git@paperclover.net>2026-11-22 00:44:02-08:00
logb30417da1ffc324c910e68dceba6a37585c3fb7c
treeb4430806e873206af08db3ed49058e27a7406e53
parentdc25dbf0f9528632f2d593b93197f9390e0567ac
signature Signed by SSH key SHA256:52mNGHRsVFBDED9IAX5pe+LRWUefqTbxEReunq21QvU

Prepare a separate Windows development image

Install the C++ build tools and Windows SDK, Rust, Node/pnpm, Python and Git from official installers. Keep actual component versions and source hashes in the guest manifest. Assisted-by: gpt-6.1-sol

2 files changed, 91 insertions(+), 2 deletions(-)

guest/windows-development.ps1 created+89
......@@ -0,0 +1,89 @@
1$ErrorActionPreference = 'Stop'
2$ProgressPreference = 'SilentlyContinue'
3$identity = [Security.Principal.WindowsIdentity]::GetCurrent()
4try {
5 $principal = New-Object Security.Principal.WindowsPrincipal($identity)
6 if ($identity.IsSystem -or !$principal.IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)) { throw 'Run this recipe from the elevated desktop account.' }
7} finally { $identity.Dispose() }
8$root = 'C:\Snowglobe'
9$tools = 'C:\ProgramData\SnowglobeDevelopment'
10$downloads = Join-Path $tools 'installers'
11$sources = @()
12New-Item $downloads -ItemType Directory -Force | Out-Null
13
14function Get-Installer([string]$uri, [string]$name, [switch]$Unsigned) {
15 $path = Join-Path $downloads $name
16 Invoke-WebRequest $uri -OutFile $path -UseBasicParsing
17 $signature = Get-AuthenticodeSignature $path
18 if (!$Unsigned -and $signature.Status -ne 'Valid') { throw "The installer signature is invalid: $name" }
19 $script:sources += @{ url = $uri; sha256 = (Get-FileHash $path -Algorithm SHA256).Hash }
20 return $path
21}
22
23function Install-Program([string]$path, [string[]]$arguments) {
24 Add-Content "$root\development.log" ((Get-Date -Format o) + ' installing ' + [IO.Path]::GetFileName($path))
25 $process = Start-Process $path -ArgumentList $arguments -PassThru
26 if (!$process.WaitForExit(1800000)) { throw 'The installer exceeded 30 minutes. Inspect it before retrying.' }
27 if ($process.ExitCode -notin @(0, 3010)) { throw "Installer exited with $($process.ExitCode): $path" }
28}
29
30try {
31 $buildTools = Get-Installer 'https://aka.ms/vs/17/release/vs_BuildTools.exe' 'vs-build-tools.exe'
32 Install-Program $buildTools @('--quiet', '--wait', '--norestart', '--installPath', 'C:\BuildTools',
33 '--add', 'Microsoft.VisualStudio.Workload.VCTools', '--includeRecommended')
34 $node = Get-Installer 'https://nodejs.org/dist/v24.22.3/node-v24.22.3-x64.msi' 'node.msi'
35 Install-Program 'msiexec.exe' @('/i', $node, '/qn', '/norestart')
36 $pythonVersion = '3.14.10'
37 $pythonRoot = Join-Path $tools 'Python'
38 $series = ([Version]$pythonVersion).ToString(2)
39 $existingPython = (Get-ItemProperty "HKLM:\SOFTWARE\Python\PythonCore\$series\InstallPath" -ErrorAction SilentlyContinue).ExecutablePath
40 if ($existingPython -and (Test-Path $existingPython) -and (& $existingPython --version) -eq "Python $pythonVersion") { $pythonRoot = Split-Path $existingPython }
41 $python = Get-Installer "https://www.python.org/ftp/python/$pythonVersion/python-$pythonVersion-amd64.exe" 'python.exe'
42 if (!(Test-Path "$pythonRoot\python.exe") -or (& "$pythonRoot\python.exe" --version) -ne "Python $pythonVersion") {
43 Install-Program $python @('/quiet', 'InstallAllUsers=1', "TargetDir=$pythonRoot",
44 'PrependPath=1', 'Include_test=0', 'InstallLauncherAllUsers=1')
45 }
46 $git = Get-Installer 'https://github.com/git-for-windows/git/releases/download/v2.56.1.windows.1/Git-2.56.1-64-bit.exe' 'git-installer.exe'
47 Install-Program $git @('/VERYSILENT', '/NORESTART', '/NOCANCEL', '/SP-', '/o:PathOption=Cmd')
48
49 $env:CARGO_HOME = Join-Path $tools 'Cargo'
50 $env:RUSTUP_HOME = Join-Path $tools 'Rustup'
51 [Environment]::SetEnvironmentVariable('CARGO_HOME', $env:CARGO_HOME, 'Machine')
52 [Environment]::SetEnvironmentVariable('RUSTUP_HOME', $env:RUSTUP_HOME, 'Machine')
53 $rustUri = 'https://static.rust-lang.org/rustup/dist/x86_64-pc-windows-msvc/rustup-init.exe'
54 $rust = Get-Installer $rustUri 'rustup-init.exe' -Unsigned
55 Invoke-WebRequest ($rustUri + '.sha256') -OutFile ($rust + '.sha256') -UseBasicParsing
56 $expected = ([IO.File]::ReadAllText($rust + '.sha256') -split '\s+')[0]
57 if ((Get-FileHash $rust -Algorithm SHA256).Hash -ine $expected) { throw 'The Rust installer checksum differs.' }
58 Install-Program $rust @('-y', '--default-toolchain', '1.100.0', '--profile', 'minimal', '--no-modify-path')
59
60 $paths = ([Environment]::GetEnvironmentVariable('Path', 'Machine') -split ';') + @($pythonRoot, "$pythonRoot\Scripts", "$env:CARGO_HOME\bin", "$tools\npm")
61 $env:Path = ($paths | Where-Object { $_ } | Select-Object -Unique) -join ';'
62 [Environment]::SetEnvironmentVariable('Path', $env:Path, 'Machine')
63 Install-Program 'C:\Program Files\nodejs\npm.cmd' @('install', '--global', '--prefix', "$tools\npm", 'pnpm@12.21.0', '--no-audit', '--no-fund')
64 & icacls.exe $tools /grant '*S-1-5-32-545:(OI)(CI)M' | Out-Null
65 if ($LASTEXITCODE -ne 0) { throw 'The development tool directory is inaccessible.' }
66
67 $visualStudio = & 'C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe' -products '*' -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -format json | ConvertFrom-Json
68 if (!$visualStudio) { throw 'The C++ build tools are unavailable.' }
69 $manifest = @{
70 createdAt = (Get-Date).ToUniversalTime().ToString('o')
71 recipeSha256 = (Get-FileHash $PSCommandPath -Algorithm SHA256).Hash
72 sources = $sources
73 windows = (Get-CimInstance Win32_OperatingSystem | Select-Object Caption, Version, BuildNumber)
74 visualStudio = @($visualStudio | Select-Object installationVersion, installationPath, isComplete, isRebootRequired)
75 windowsSdk = @(Get-ChildItem 'C:\Program Files (x86)\Windows Kits\10\Include' -Directory | ForEach-Object { $_.Name })
76 rust = (& "$env:CARGO_HOME\bin\rustc.exe" --version)
77 cargo = (& "$env:CARGO_HOME\bin\cargo.exe" --version)
78 node = (& 'C:\Program Files\nodejs\node.exe' --version)
79 pnpm = (& "$tools\npm\pnpm.cmd" --version)
80 python = (& "$pythonRoot\python.exe" --version)
81 git = (Get-Item 'C:\Program Files\Git\cmd\git.exe').VersionInfo.ProductVersion
82 }
83 $manifest | ConvertTo-Json -Depth 8 | Set-Content "$root\development.json" -Encoding UTF8
84 Remove-Item $downloads -Recurse -Force
85 Add-Content "$root\development.log" ((Get-Date -Format o) + ' ready')
86} catch {
87 Add-Content "$root\development.log" ((Get-Date -Format o) + ' failed: ' + $_.Exception.Message)
88 throw
89}
tools/vm-ai.py+2-2
......@@ -84,8 +84,8 @@ def create(request):
8484
8585def manage(request):
8686 if request.get("action") == "presets" and set(request) == {"action", "owner"}:
87 return {"presets": [{"id": p["id"], "os": p["os"], "platform": p["platform"],
88 "arch": p["arch"], "disk_bytes": p["capacity"]} for p in presets()], "limits": LIMITS}
87 return {"presets": [{"id": p["id"], "os": p["os"], "description": p.get("description", ""), "platform": p["platform"],
88 "arch": p["arch"], "disk_bytes": p["capacity"], "recommended": p.get("recommended")} for p in presets()], "limits": LIMITS}
8989 if request.get("action") == "create":
9090 return create(request)
9191 if set(request) != {"action", "name", "owner", "seconds"} or request["action"] not in {"extend", "delete"}: