Configure desktop update feed
This commit is contained in:
@@ -0,0 +1,85 @@
|
||||
param(
|
||||
[Parameter(Mandatory = $true)]
|
||||
[string]$Url
|
||||
)
|
||||
|
||||
$ErrorActionPreference = "Stop"
|
||||
|
||||
function Fail($Message) {
|
||||
Write-Error $Message
|
||||
exit 1
|
||||
}
|
||||
|
||||
$parsedUrl = $null
|
||||
if (-not [System.Uri]::TryCreate($Url, [System.UriKind]::Absolute, [ref]$parsedUrl)) {
|
||||
Fail "Desktop update feed URL is not absolute: $Url"
|
||||
}
|
||||
|
||||
if ($parsedUrl.Scheme -ne "https") {
|
||||
Fail "Desktop update feed URL must use HTTPS: $Url"
|
||||
}
|
||||
|
||||
try {
|
||||
$response = Invoke-WebRequest -Uri $Url -UseBasicParsing -TimeoutSec 30
|
||||
} catch {
|
||||
Fail "Desktop update feed request failed for ${Url}: $($_.Exception.Message)"
|
||||
}
|
||||
|
||||
if ($response.StatusCode -ne 200) {
|
||||
Fail "Desktop update feed must return HTTP 200. Actual status: $($response.StatusCode)"
|
||||
}
|
||||
|
||||
try {
|
||||
[xml]$xml = $response.Content
|
||||
} catch {
|
||||
Fail "Desktop update feed is not valid XML: $($_.Exception.Message)"
|
||||
}
|
||||
|
||||
if ($xml.DocumentElement.Name -ne "QSfera") {
|
||||
Fail "Desktop update feed root element must be <QSfera>."
|
||||
}
|
||||
|
||||
$requiredElements = @("version", "versionstring", "web", "downloadurl")
|
||||
foreach ($name in $requiredElements) {
|
||||
if ($null -eq $xml.QSfera.$name) {
|
||||
Fail "Desktop update feed is missing <$name>."
|
||||
}
|
||||
}
|
||||
|
||||
$version = [string]$xml.QSfera.version
|
||||
$versionString = [string]$xml.QSfera.versionstring
|
||||
$web = [string]$xml.QSfera.web
|
||||
$downloadUrl = [string]$xml.QSfera.downloadurl
|
||||
|
||||
if (-not [string]::IsNullOrWhiteSpace($web)) {
|
||||
$webUri = $null
|
||||
if (-not [System.Uri]::TryCreate($web, [System.UriKind]::Absolute, [ref]$webUri) -or $webUri.Scheme -ne "https") {
|
||||
Fail "Desktop update feed <web> must be an absolute HTTPS URL when present."
|
||||
}
|
||||
}
|
||||
|
||||
if ([string]::IsNullOrWhiteSpace($version)) {
|
||||
if (-not [string]::IsNullOrWhiteSpace($downloadUrl)) {
|
||||
Fail "Desktop no-update feed must leave <downloadurl> empty when <version> is empty."
|
||||
}
|
||||
} else {
|
||||
$parsedVersion = $null
|
||||
if (-not [System.Version]::TryParse($version, [ref]$parsedVersion)) {
|
||||
Fail "Desktop update feed <version> must be parseable as a version number."
|
||||
}
|
||||
|
||||
if ([string]::IsNullOrWhiteSpace($versionString)) {
|
||||
Fail "Desktop update feed must set <versionstring> when <version> is present."
|
||||
}
|
||||
|
||||
$downloadUri = $null
|
||||
if (-not [System.Uri]::TryCreate($downloadUrl, [System.UriKind]::Absolute, [ref]$downloadUri) -or $downloadUri.Scheme -ne "https") {
|
||||
Fail "Desktop update feed <downloadurl> must be an absolute HTTPS URL when an update is advertised."
|
||||
}
|
||||
|
||||
if (-not $downloadUri.AbsolutePath.EndsWith(".msi", [System.StringComparison]::OrdinalIgnoreCase)) {
|
||||
Fail "Desktop Windows updater expects an MSI download URL."
|
||||
}
|
||||
}
|
||||
|
||||
Write-Host "QSfera Desktop update feed validation passed: $Url"
|
||||
@@ -1,5 +1,6 @@
|
||||
param(
|
||||
[switch]$RequireSigning,
|
||||
[switch]$VerifyUpdateFeed,
|
||||
[string]$Root = (Resolve-Path (Join-Path $PSScriptRoot "..")).Path
|
||||
)
|
||||
|
||||
@@ -35,6 +36,10 @@ if ($branding -notmatch 'APPLICATION_DEFAULT_SERVER_URL\s+"https://qsfera\.kusof
|
||||
Fail "Desktop default server URL must be https://qsfera.kusoft.xyz."
|
||||
}
|
||||
|
||||
if ($branding -notmatch 'APPLICATION_UPDATE_URL\s+"https://qsfera\.kusoft\.xyz/desktop/updates/stable\.xml"') {
|
||||
Fail "Desktop update feed URL must be https://qsfera.kusoft.xyz/desktop/updates/stable.xml."
|
||||
}
|
||||
|
||||
if ($cmake -notmatch 'option\(WITH_UPDATE_NOTIFICATION\s+"Whether to check for new releases"\s+ON\)') {
|
||||
Fail "Desktop release builds must keep update notifications enabled by default."
|
||||
}
|
||||
@@ -55,6 +60,17 @@ if ($RequireSigning) {
|
||||
if ([string]::IsNullOrWhiteSpace($env:CRAFT_CODESIGN_CERTIFICATE)) {
|
||||
Fail "Production Windows tag releases require CRAFT_CODESIGN_CERTIFICATE."
|
||||
}
|
||||
|
||||
$VerifyUpdateFeed = $true
|
||||
}
|
||||
|
||||
if ($VerifyUpdateFeed) {
|
||||
$feedValidator = Join-Path $PSScriptRoot "validate-desktop-update-feed.ps1"
|
||||
if (-not (Test-Path -LiteralPath $feedValidator)) {
|
||||
Fail "Desktop update feed validator was not found: $feedValidator"
|
||||
}
|
||||
|
||||
& $feedValidator -Url "https://qsfera.kusoft.xyz/desktop/updates/stable.xml"
|
||||
}
|
||||
|
||||
Write-Host "QSfera Desktop production release validation passed."
|
||||
|
||||
Reference in New Issue
Block a user