vole
Site
Clone
Read only, no credentials:
https://rodent.software/vole.git
Write over SSH with a registered key:
git clone ssh://git@rodent.software/vole.git
Self-hosted forge that lives in your Git repo.
Package Windows: an MSI built with wixl, and install.ps1
31560d91c4e27f3fdee2652aa3b4b12b8343903d · Keenan Nemetz · 2d ago · parent 9cbfa891
Package Windows: an MSI built with wixl, and install.ps1 The Windows server installs from an MSI now, with install.ps1 on the channel as the one-command path, the same shape as the Linux installer. The MSI is built by wixl (msitools), not the WiX toolset. WiX v5 and v6 refuse to build outside Windows: every relative path is canonicalized against a hardcoded C:\ and the first Directory is rejected, so it cannot run in the release image. I tested both before choosing; wixl 0.101 is what Debian bookworm ships and it produces a package that installs, upgrades, and uninstalls on the Server Core guest. Its limits shaped the design and are recorded in the .wxs header: it silently drops Component/@Permanent and @NeverOverwrite, cannot edit PATH, and cannot schedule rollback actions, so the configuration and the data directory belong to `vole service install` and not to the package. That moved two things into the CLI. `service install` now writes a documented default configuration to %ProgramData%\Vole\vole.toml when it is given none, and initializes the instance database and repository like the Linux post-install step, so the package's only action is the binary registering itself. The same command serves a hand install and a pre-release, which has no MSI. The MSI's upgrade table is written by hand because wixl's MajorUpgrade schedules RemoveExistingProducts in the window Windows Installer rejects (error 2613). RemoveExistingProducts is placed at 1501, the service's stop-and-remove at 3400, and install-and-start after InstallFiles, so an upgrade removes the old product before the new files land and the running executable is never locked. Fixed along the way, found by installing the MSI: secure.HardenFor accepted an access list that was a subset of what it was asked to grant, so a configuration written by SYSTEM looked correct and never got the service account's entry; the service then could not read it and failed to start. HardenFor now requires every requested principal to be present, with a Windows test for the subset case. Release and verify wiring: both images gain wixl and msitools, verify builds the MSI and reads its tables back (wixl exits 0 when a source is missing), and the release builds the Windows binary and, for a stable tag, the MSI, and publishes install.ps1 beside install.sh. A pre-release tag has no MSI: ProductVersion cannot carry a pre-release suffix and wixl cannot express the same-version upgrade, so those releases ship the binary and install.ps1 says so. Docs: install.md gains the Windows method, packaging.md the Windows package and its limits, deploying windows.md the packaged flow (install, configure, first admin, firewall, upgrade, binary fallback, troubleshooting), and RELEASING.md the Windows sign-off a Linux runner cannot perform. Verified on the Server Core 2022 guest: MSI install starts the service and serves HTTP 200, with the config created at the documented default and the data kept; 0.2.1 upgrades over 0.2.0 with one Programs-and-Features entry and the service running; uninstall removes the service and the binary and leaves the config, data, and a marker file; install.ps1 installs from a local mirror after checking SHA256SUMS; reinstall and uninstall are repeatable. Windows unit tests pass there, and `vole workflow run verify` passes locally including the new package step. Part of 01M8SE6GWX1DGYPY6H9YC142C2.
packaging/install.ps1 +181
| @@ -0,0 +1,181 @@ | |||
| 1 | <# | ||
| 2 | .SYNOPSIS | ||
| 3 | Install Vole on Windows. | ||
| 4 | |||
| 5 | .DESCRIPTION | ||
| 6 | The release publishes this file as install.ps1 and serves it at | ||
| 7 | /<repository>/channels/<channel>/install.ps1. It downloads the release's MSI, | ||
| 8 | checks it against the release's SHA256SUMS, and hands it to the Windows | ||
| 9 | Installer, which installs the binary and registers the Vole service. | ||
| 10 | |||
| 11 | Run it from an elevated PowerShell. The MSI is not Authenticode-signed yet, | ||
| 12 | so the strongest check available here is the checksum list fetched from the | ||
| 13 | same HTTPS origin as the MSI. | ||
| 14 | |||
| 15 | .PARAMETER Channel | ||
| 16 | Release channel to follow. Default: stable. | ||
| 17 | |||
| 18 | .PARAMETER Version | ||
| 19 | Install a pinned release instead of following a channel, for example v0.2.0. | ||
| 20 | |||
| 21 | .PARAMETER BaseUrl | ||
| 22 | Origin that serves the release. Default: https://rodent.software/vole. | ||
| 23 | |||
| 24 | .PARAMETER LogPath | ||
| 25 | Write the Windows Installer log to this file instead of a temporary one. | ||
| 26 | |||
| 27 | .PARAMETER DryRun | ||
| 28 | Print the plan and exit without downloading or installing anything. | ||
| 29 | |||
| 30 | .EXAMPLE | ||
| 31 | Invoke-WebRequest https://rodent.software/vole/channels/stable/install.ps1 -OutFile install.ps1 | ||
| 32 | .\install.ps1 | ||
| 33 | |||
| 34 | .EXAMPLE | ||
| 35 | .\install.ps1 -Version v0.2.0 -DryRun | ||
| 36 | #> | ||
| 37 | [CmdletBinding()] | ||
| 38 | param( | ||
| 39 | [string] $Channel = 'stable', | ||
| 40 | [string] $Version, | ||
| 41 | [string] $BaseUrl = 'https://rodent.software/vole', | ||
| 42 | [string] $LogPath, | ||
| 43 | [switch] $DryRun, | ||
| 44 | [switch] $Help | ||
| 45 | ) | ||
| 46 | |||
| 47 | $ErrorActionPreference = 'Stop' | ||
| 48 | $ProgressPreference = 'SilentlyContinue' | ||
| 49 | [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 | ||
| 50 | |||
| 51 | $MsiName = 'vole-windows-amd64.msi' | ||
| 52 | |||
| 53 | function Stop-WithError([string] $Message) { | ||
| 54 | [Console]::Error.WriteLine("vole-install: $Message") | ||
| 55 | exit 1 | ||
| 56 | } | ||
| 57 | |||
| 58 | function Show-Usage { | ||
| 59 | @' | ||
| 60 | Install Vole on Windows. | ||
| 61 | |||
| 62 | Usage: install.ps1 [options] | ||
| 63 | |||
| 64 | Options: | ||
| 65 | -Channel <name> follow this release channel (default: stable) | ||
| 66 | -Version <tag> install a pinned release, for example v0.2.0 | ||
| 67 | -BaseUrl <url> origin that serves the release | ||
| 68 | (default: https://rodent.software/vole) | ||
| 69 | -LogPath <file> write the Windows Installer log here | ||
| 70 | -DryRun print the plan, change nothing | ||
| 71 | -Help show this help | ||
| 72 | |||
| 73 | The script needs an elevated PowerShell. It downloads the release's MSI, checks | ||
| 74 | it against the release's SHA256SUMS, and lets the Windows Installer install the | ||
| 75 | binary and register the Vole service. `vole service install` writes the | ||
| 76 | configuration on first use, and neither the configuration nor the instance's data | ||
| 77 | is part of the package, so uninstalling leaves both in place. | ||
| 78 | '@ | Write-Output | ||
| 79 | } | ||
| 80 | |||
| 81 | if ($Help) { | ||
| 82 | Show-Usage | ||
| 83 | exit 0 | ||
| 84 | } | ||
| 85 | |||
| 86 | if ($Version) { | ||
| 87 | $tag = $Version | ||
| 88 | if (-not $tag.StartsWith('v')) { | ||
| 89 | $tag = "v$tag" | ||
| 90 | } | ||
| 91 | $base = "$BaseUrl/releases/$tag/artifacts" | ||
| 92 | } | ||
| 93 | else { | ||
| 94 | $base = "$BaseUrl/channels/$Channel" | ||
| 95 | } | ||
| 96 | |||
| 97 | if ($DryRun) { | ||
| 98 | Write-Output "would install from $base" | ||
| 99 | Write-Output "would check $MsiName against $base/SHA256SUMS" | ||
| 100 | Write-Output "would run: msiexec /i $MsiName /qn /norestart" | ||
| 101 | exit 0 | ||
| 102 | } | ||
| 103 | |||
| 104 | $principal = New-Object Security.Principal.WindowsPrincipal([Security.Principal.WindowsIdentity]::GetCurrent()) | ||
| 105 | if (-not $principal.IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)) { | ||
| 106 | Stop-WithError 'run this from an elevated PowerShell (Run as administrator)' | ||
| 107 | } | ||
| 108 | |||
| 109 | $work = Join-Path ([IO.Path]::GetTempPath()) ("vole-install-" + [Guid]::NewGuid().ToString('N')) | ||
| 110 | New-Item -ItemType Directory -Path $work | Out-Null | ||
| 111 | $keepWork = $false | ||
| 112 | $installerLog = $LogPath | ||
| 113 | if (-not $installerLog) { | ||
| 114 | $installerLog = Join-Path $work 'install.log' | ||
| 115 | } | ||
| 116 | |||
| 117 | try { | ||
| 118 | Write-Output "installing Vole from $base" | ||
| 119 | |||
| 120 | $sums = Join-Path $work 'SHA256SUMS' | ||
| 121 | try { | ||
| 122 | Invoke-WebRequest -Uri "$base/SHA256SUMS" -OutFile $sums -UseBasicParsing | ||
| 123 | } | ||
| 124 | catch { | ||
| 125 | Stop-WithError "cannot download `"$base/SHA256SUMS`": $($_.Exception.Message)" | ||
| 126 | } | ||
| 127 | |||
| 128 | # SHA256SUMS is `<sha256> <name>`. Finding the MSI's line instead of guessing | ||
| 129 | # its name means a release that stopped shipping one fails here, with the | ||
| 130 | # reason, rather than as a 404 below. | ||
| 131 | $pattern = '^\s*([0-9a-fA-F]{64})\s+\*?' + [regex]::Escape($MsiName) + '\s*$' | ||
| 132 | $entry = Select-String -Path $sums -Pattern $pattern | Select-Object -First 1 | ||
| 133 | if (-not $entry) { | ||
| 134 | $message = "$base publishes no $MsiName." + [Environment]::NewLine + | ||
| 135 | 'Pre-release releases have no MSI yet; install the binary from the release instead:' + [Environment]::NewLine + | ||
| 136 | " $base/vole-windows-amd64.exe" | ||
| 137 | Stop-WithError $message | ||
| 138 | } | ||
| 139 | $expected = $entry.Matches[0].Groups[1].Value.ToLowerInvariant() | ||
| 140 | |||
| 141 | $msi = Join-Path $work $MsiName | ||
| 142 | try { | ||
| 143 | Invoke-WebRequest -Uri "$base/$MsiName" -OutFile $msi -UseBasicParsing | ||
| 144 | } | ||
| 145 | catch { | ||
| 146 | Stop-WithError "cannot download `"$base/$MsiName`": $($_.Exception.Message)" | ||
| 147 | } | ||
| 148 | |||
| 149 | $actual = (Get-FileHash -Path $msi -Algorithm SHA256).Hash.ToLowerInvariant() | ||
| 150 | if ($actual -ne $expected) { | ||
| 151 | Stop-WithError "checksum mismatch for ${MsiName}: expected $expected, got $actual" | ||
| 152 | } | ||
| 153 | |||
| 154 | $arguments = @('/i', "`"$msi`"", '/qn', '/norestart', '/l*v', "`"$installerLog`"") | ||
| 155 | $installer = Start-Process -FilePath msiexec.exe -ArgumentList $arguments -Wait -PassThru | ||
| 156 | switch ($installer.ExitCode) { | ||
| 157 | 0 { $keepWork = $false } | ||
| 158 | 3010 { $keepWork = $false; Write-Output 'installed; a restart is required to finish' } | ||
| 159 | 1641 { $keepWork = $false; Write-Output 'installed; Windows is restarting' } | ||
| 160 | default { | ||
| 161 | $keepWork = $true | ||
| 162 | Stop-WithError "the installer failed with exit code $($installer.ExitCode); log: $installerLog" | ||
| 163 | } | ||
| 164 | } | ||
| 165 | |||
| 166 | Write-Output '' | ||
| 167 | Write-Output 'Vole is installed as the Vole service.' | ||
| 168 | Write-Output 'It starts automatically after a short delay, and restarts after a failure.' | ||
| 169 | Write-Output '' | ||
| 170 | Write-Output 'next:' | ||
| 171 | Write-Output ' & "C:\Program Files\Vole\vole.exe" service status' | ||
| 172 | $config = Join-Path $env:ProgramData 'Vole\vole.toml' | ||
| 173 | Write-Output (' edit "' + $config + '" to set public_url and HTTPS') | ||
| 174 | Write-Output (' & "C:\Program Files\Vole\vole.exe" admin --config "' + $config + '" account invite <name>') | ||
| 175 | Write-Output ' open 80, 443, and 2222 in Windows Firewall as needed; see docs/deploy/windows.md' | ||
| 176 | } | ||
| 177 | finally { | ||
| 178 | if (-not $keepWork -and -not $LogPath) { | ||
| 179 | Remove-Item -Recurse -Force $work -ErrorAction SilentlyContinue | ||
| 180 | } | ||
| 181 | } | ||