feat: support explicit source bundles through the common installer

This commit is contained in:
Codex
2026-10-06 18:31:23 +02:00
parent 785d96ea50
commit 5c05778614
11 changed files with 353 additions and 5 deletions
+35 -1
View File
@@ -19,6 +19,7 @@ import (
// Manifest is the publication/consumer contract. Each platform maps to a single-image digest,
// not a mutable tag or multi-platform index. Maintenance roles use Images["core"].
type Manifest struct {
Distribution string `json:"distribution,omitempty"`
SchemaVersion int `json:"schema_version"`
Version string `json:"version"`
Revision string `json:"revision"`
@@ -30,6 +31,13 @@ type Manifest struct {
Compose []string `json:"compose"`
}
func (m Manifest) Mode() string {
if m.Distribution == "source" {
return "source"
}
return "prebuilt"
}
var hex256 = regexp.MustCompile(`^[a-f0-9]{64}$`)
var imageReference = regexp.MustCompile(`^docker\.io/[a-z0-9][a-z0-9._/-]*@sha256:[a-f0-9]{64}$`)
@@ -37,6 +45,9 @@ func invalidRelease() error {
return errors.New("release manifest or packaged files are incomplete, incompatible or invalid")
}
func (m Manifest) Validate() error {
if m.Distribution != "" && m.Distribution != "prebuilt" && m.Distribution != "source" {
return invalidRelease()
}
if m.SchemaVersion != 1 || m.ValidatorProtocol != Protocol || !regexp.MustCompile(`^[0-9]+\.[0-9]+\.[0-9]+(?:-[A-Za-z0-9.-]+)?$`).MatchString(m.Version) || !regexp.MustCompile(`^[a-f0-9]{40}$`).MatchString(m.Revision) {
return invalidRelease()
}
@@ -56,7 +67,11 @@ func (m Manifest) Validate() error {
return invalidRelease()
}
for platform, ref := range m.Images[service] {
if (platform != "linux/amd64" && platform != "linux/arm64") || !imageReference.MatchString(ref) {
valid := imageReference.MatchString(ref)
if m.Mode() == "source" && (service == "core" || service == "frontend") {
valid = strings.HasPrefix(ref, "sha256:") && hex256.MatchString(strings.TrimPrefix(ref, "sha256:"))
}
if (platform != "linux/amd64" && platform != "linux/arm64") || !valid {
return invalidRelease()
}
}
@@ -110,6 +125,25 @@ func CheckImages(ctx context.Context, runner Runner, m Manifest, platform string
r.Add("image-"+service, "error", "release.images."+service, "Publish the selected Linux architecture before producing an executable plan.")
continue
}
if m.Mode() == "source" && (service == "core" || service == "frontend") {
result, err := docker(ctx, runner, "image", "inspect", "--format", "{{json .}}", ref)
var image struct {
ID string `json:"Id"`
OS string `json:"Os"`
Architecture string `json:"Architecture"`
Config struct {
Labels map[string]string `json:"Labels"`
} `json:"Config"`
}
good := err == nil && result.ExitCode == 0 && json.Unmarshal([]byte(result.Stdout), &image) == nil && image.ID == ref &&
image.OS+"/"+image.Architecture == platform && image.Config.Labels["org.opencontainers.image.revision"] == m.Revision && image.Config.Labels["org.opencontainers.image.version"] == m.Version
outcome := "passed"
if !good {
outcome = "error"
}
r.Add("image-"+service, outcome, "release.images."+service, "Require the explicitly built local image, matching source revision, version and architecture; rebuild the selected source bundle if it is missing.")
continue
}
result, err := docker(ctx, runner, "manifest", "inspect", "--verbose", ref)
var manifest struct {
Descriptor struct {