Allow signed updates to more mature release channels

This commit is contained in:
2026-11-26 20:01:54 -06:00
parent 035fb8ddc9
commit 363c29fcdc
10 changed files with 309 additions and 13 deletions

View File

@@ -8,7 +8,9 @@ from urllib.error import HTTPError, URLError
from urllib.parse import quote, urlsplit
from urllib.request import HTTPRedirectHandler, Request, build_opener
from .update_release import MANIFEST, MAX_MANIFEST_SIZE, Release, UpdateError, eligible, source_config, verify_file, verify_manifest
from .update_release import (
MANIFEST, MAX_MANIFEST_SIZE, Release, UpdateError, eligible, exclusion_reason, source_config, verify_file, verify_manifest,
)
from .version import VERSION, version_key
MAX_INDEX_SIZE = 2 * 1024**2
@@ -29,6 +31,7 @@ class Check:
published: str | None
release: Release | None
issues: tuple[str, ...]
exclusions: tuple[str, ...] = ()
class ReleaseClient:
@@ -88,8 +91,10 @@ class ReleaseClient:
break
ordered = sorted(rows, key=version_key, reverse=True)
issues = []
exclusions = []
for version in ordered:
if not eligible(version, installed):
if reason := exclusion_reason(version, installed):
exclusions.append(f"{version}: {reason}")
continue
try:
if len(rows[version]) != 1:
@@ -106,8 +111,8 @@ class ReleaseClient:
except (UpdateError, HTTPError, KeyError, TypeError, AttributeError) as exc:
issues.append(f"{version}: {exc.code if isinstance(exc, HTTPError) else exc}")
continue
return Check(ordered[0], release, tuple(issues))
return Check(ordered[0] if ordered else None, None, tuple(issues))
return Check(ordered[0], release, tuple(issues), tuple(exclusions))
return Check(ordered[0] if ordered else None, None, tuple(issues), tuple(exclusions))
def download(self, release, kind, storage, progress, cancelled):
signed = verify_manifest(release.envelope, self.source["public_key"], release.version)

View File

@@ -10,7 +10,7 @@ from cryptography.exceptions import InvalidSignature
from cryptography.hazmat.primitives.asymmetric.ed25519 import Ed25519PublicKey
from .branding import APP_MODEL_ID
from .version import ROOT, version_key
from .version import CHANNELS, ROOT, version_key
MANIFEST = "arm-update-windows-x64.json"
ARCHITECTURE = "windows-x64"
@@ -106,7 +106,16 @@ def verify_file(path, package):
raise UpdateError("Package SHA-256 does not match the signed manifest")
def eligible(version, installed):
def exclusion_reason(version, installed):
"""Return the policy reason a tag cannot be considered for this installation."""
candidate = version_key(version)
current = version_key(installed)
return candidate >= current and candidate[-1] in (current[-1], 3)
if candidate[:4] < current[:4]:
return f"Numerical version is older than installed {installed}"
if candidate[-1] < current[-1]:
return f"{CHANNELS[candidate[-1]].capitalize()} releases are ineligible for a {CHANNELS[current[-1]]} installation"
return None
def eligible(version, installed):
return exclusion_reason(version, installed) is None

View File

@@ -247,6 +247,8 @@ class UpdatePanel(QGroupBox):
self.status.setText("No eligible verified update is available.")
if value.issues:
self.status.setText(self.status.text() + " Rejected " + "; ".join(value.issues)[:380])
if value.exclusions:
self.status.setText(self.status.text() + " Excluded " + "; ".join(value.exclusions)[:380])
if value.release or not value.issues:
try:
write_atomic(self.last_file, json.dumps(datetime.now().astimezone().isoformat()).encode())