oficina / equipo Public

hosted: build bubblewrap for AL2023 and pin it for the image

The personal runners' bubblewrap (Debian trixie's 0.11.0 build) needs
glibc 2.38 and cannot load on Amazon Linux 2023 (glibc 2.34).

scripts/build-hosted-bwrap.sh builds upstream bubblewrap 0.11.0 from its
release tarball (sha256 988fd6b2..., the same bytes as Debian's orig
tarball) inside amazonlinux:2023.12.20261102.0 pinned by digest, with
pinned build packages and build-root digest and SOURCE_DATE_EPOCH, twice
in fresh containers, and requires identical bytes and the pin:
1ebd5a3d3d9f2ece1032af3ba3993edac3fb8c189cf2e49bbc06fc8362fc81e2. It
needs GLIBC_2.34 at most and only libcap.so.2 and libc.so.6.

The image's manifest and pins now carry that digest, as
containment.HostedBubblewrapSHA256; internal/release/manifest.json is
unchanged. containment.Config.Hosted selects the hosted pin, and the
hosted runner (checks and certification) sets it. The image's
containment suite is built with -tags hostedimage, so its managers are
hosted ones. The chain test builds its VM runner with -tags hostedchain,
whose hosted managers also accept the personal pin; release-hosted.sh
refuses a runner or vm-init built with any tag. A release still passes
bwrap with --image-inputs.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev pushed by paul@keymail.dev 801a3118fce5d3606de237fcf1bc06dbf6be569d parent ada99ff
18 files changed, +322 −18
  • cmd/equipo-runner/hosted.go +9 −1
  • cmd/equipo-runner/hosted_certify_linux.go +1 −1
  • cmd/equipo-runner/hosted_test.go +11 −0
  • infra/hosted/image/manifest.json +1 −1
  • infra/hosted/image/pins.json +1 −1
  • internal/hostedimage/manifest_test.go +12 −4
  • internal/hostedtest/chain.go +5 −2
  • internal/runner/containment/bubblewrap_chain.go +9 −0
  • internal/runner/containment/bubblewrap_pin.go +25 −0
  • internal/runner/containment/bubblewrap_pin_test.go +38 −0
  • internal/runner/containment/bubblewrap_release.go +7 −0
  • internal/runner/containment/egress_test.go +1 −1
  • internal/runner/containment/linux.go +6 −2
  • internal/runner/containment/linux_test.go +2 −2
  • internal/runner/containment/suite_hosted_test.go +9 −0
  • internal/runner/containment/suite_personal_test.go +7 −0
  • scripts/build-hosted-bwrap.sh +156 −0
  • scripts/release-hosted.sh +22 −3
diff --git a/cmd/equipo-runner/hosted.go b/cmd/equipo-runner/hosted.go
index 92d1d268..12ca2092 100644
--- a/cmd/equipo-runner/hosted.go
+++ b/cmd/equipo-runner/hosted.go
@@ -101,7 +101,7 @@ func serveChecks(ctx context.Context, s *hosted.Session, state string, logger *s
return err
}
}
- m, err := containment.New(containment.Config{Binary: linuxworker.Bwrap, RunnerBinary: self, ScratchRoot: namespaces})
+ m, err := containment.New(hostedContainment(self, namespaces))
if err != nil {
return err
}
@@ -112,6 +112,14 @@ func serveChecks(ctx context.Context, s *hosted.Session, state string, logger *s
return renewing(ctx, s, o.Hosted.Flush, func(ctx context.Context) error { return thin.Run(ctx, c, o) })
}
+// hostedContainment is a hosted VM's containment configuration: the
+// image's bubblewrap, accepted only at the hosted image's pin
+// (containment.HostedBubblewrapSHA256), this runner, and the manager's
+// own root.
+func hostedContainment(self, root string) containment.Config {
+ return containment.Config{Binary: linuxworker.Bwrap, RunnerBinary: self, ScratchRoot: root, Hosted: true}
+}
+
// renewer is a hosted session's renewal (hosted.Session).
type renewer interface {
Run(ctx context.Context, clock func() time.Time) error
diff --git a/cmd/equipo-runner/hosted_certify_linux.go b/cmd/equipo-runner/hosted_certify_linux.go
index 720a1192..f27c00d5 100644
--- a/cmd/equipo-runner/hosted_certify_linux.go
+++ b/cmd/equipo-runner/hosted_certify_linux.go
@@ -136,7 +136,7 @@ func checksSandbox(state string) hostedcert.SandboxRunner {
if err := copyExecutable(self, filepath.Join(work, filepath.Base(sandboxProbe))); err != nil {
return nil, -1, err
}
- m, err := containment.New(containment.Config{Binary: hostedBwrap, RunnerBinary: self, ScratchRoot: scratch})
+ m, err := containment.New(hostedContainment(self, scratch))
if err != nil {
return nil, -1, fmt.Errorf("the containment manager: %w", err)
}
diff --git a/cmd/equipo-runner/hosted_test.go b/cmd/equipo-runner/hosted_test.go
index 8159abc2..5139d9aa 100644
--- a/cmd/equipo-runner/hosted_test.go
+++ b/cmd/equipo-runner/hosted_test.go
@@ -18,6 +18,7 @@ import (
"amadan.net/oficina/equipo/internal/hostedwire"
"amadan.net/oficina/equipo/internal/isolatedjob"
"amadan.net/oficina/equipo/internal/runner/hosted"
+ "amadan.net/oficina/equipo/internal/runner/linuxworker"
)
// hostedBootstrap writes a bootstrap file for purpose into a new state
@@ -211,3 +212,13 @@ func TestHostedRunRenewal(t *testing.T) {
t.Fatalf("after a failed renewal: %v, %d flushes, serving still on", err, flushed.Load())
}
}
+
+// A hosted VM's containment (serving checks and certifying) runs the
+// image's bubblewrap and accepts it only at the hosted image's pin
+// (containment.HostedBubblewrapSHA256), not the personal runners'.
+func TestHostedContainmentUsesHostedPin(t *testing.T) {
+ c := hostedContainment("/usr/local/bin/equipo-runner", "/var/lib/equipo-runner/ns")
+ if !c.Hosted || c.Binary != linuxworker.Bwrap || c.RunnerBinary != "/usr/local/bin/equipo-runner" || c.ScratchRoot != "/var/lib/equipo-runner/ns" {
+ t.Fatalf("hosted containment %+v: want the image's bubblewrap at the hosted pin", c)
+ }
+}
diff --git a/infra/hosted/image/manifest.json b/infra/hosted/image/manifest.json
index ed5881ff..4968ae12 100644
--- a/infra/hosted/image/manifest.json
+++ b/infra/hosted/image/manifest.json
@@ -2,7 +2,7 @@
"RunnerRelease": "",
"RunnerSHA256": "",
"VMInitSHA256": "",
- "BubblewrapSHA256": "0dfa36b98ada69568aaaa741fe210d2150a1441433bd13c428137d6a972a959c",
+ "BubblewrapSHA256": "1ebd5a3d3d9f2ece1032af3ba3993edac3fb8c189cf2e49bbc06fc8362fc81e2",
"GoToolchain": "go1.26.11",
"GoToolchainSHA256": "",
"GitSHA256": "",
diff --git a/infra/hosted/image/pins.json b/infra/hosted/image/pins.json
index 497bdb32..e130dd6f 100644
--- a/infra/hosted/image/pins.json
+++ b/infra/hosted/image/pins.json
@@ -5,7 +5,7 @@
},
"Bubblewrap": {
"URL": "",
- "SHA256": "0dfa36b98ada69568aaaa741fe210d2150a1441433bd13c428137d6a972a959c"
+ "SHA256": "1ebd5a3d3d9f2ece1032af3ba3993edac3fb8c189cf2e49bbc06fc8362fc81e2"
},
"Codex": {
"URL": "",
diff --git a/internal/hostedimage/manifest_test.go b/internal/hostedimage/manifest_test.go
index 1125556c..1fa88c19 100644
--- a/internal/hostedimage/manifest_test.go
+++ b/internal/hostedimage/manifest_test.go
@@ -8,6 +8,7 @@ import (
"strings"
"testing"
+ "amadan.net/oficina/equipo/internal/runner/containment"
"amadan.net/oficina/equipo/internal/vminit"
"amadan.net/rastrillo/rastrillo/budget"
)
@@ -128,7 +129,10 @@ func TestManifestPinsEverything(t *testing.T) {
}
// The checked-in manifest decodes strictly, and its static pins are
- // the release's (internal/release/manifest.json).
+ // the release's (internal/release/manifest.json), but for bubblewrap:
+ // the image carries its own build (scripts/build-hosted-bwrap.sh),
+ // the one a hosted runner's containment accepts, since the personal
+ // runners' Debian build cannot load on Amazon Linux 2023.
root := repoRoot
checked, err := LoadManifest(filepath.Join(root, "infra", "hosted", "image", "manifest.json"))
if err != nil {
@@ -146,9 +150,13 @@ func TestManifestPinsEverything(t *testing.T) {
for _, b := range rel.Binaries {
pins[b.Name] = b.SHA256
}
- if checked.GoToolchain != rel.Go || checked.CodexSHA256 != pins["codex"] || checked.BubblewrapSHA256 != pins["bwrap"] {
- t.Errorf("checked-in pins go=%s codex=%s bwrap=%s, want the release's go=%s codex=%s bwrap=%s",
- checked.GoToolchain, checked.CodexSHA256, checked.BubblewrapSHA256, rel.Go, pins["codex"], pins["bwrap"])
+ if checked.GoToolchain != rel.Go || checked.CodexSHA256 != pins["codex"] {
+ t.Errorf("checked-in pins go=%s codex=%s, want the release's go=%s codex=%s",
+ checked.GoToolchain, checked.CodexSHA256, rel.Go, pins["codex"])
+ }
+ if checked.BubblewrapSHA256 != containment.HostedBubblewrapSHA256 || checked.BubblewrapSHA256 == pins["bwrap"] {
+ t.Errorf("checked-in bwrap=%s, want the hosted build %s (not the personal runners' %s)",
+ checked.BubblewrapSHA256, containment.HostedBubblewrapSHA256, pins["bwrap"])
}
if len(checked.Metadata) == 0 {
t.Error("checked-in manifest has no metadata endpoint for vm-init")
diff --git a/internal/hostedtest/chain.go b/internal/hostedtest/chain.go
index ec6a33ae..055bc009 100644
--- a/internal/hostedtest/chain.go
+++ b/internal/hostedtest/chain.go
@@ -79,10 +79,13 @@ const Every = 200 * time.Millisecond
// the hosted VMs run it as vm-init starts it.
var RunnerBinary string
-// BuildRunner builds cmd/equipo-runner into dir and returns its path.
+// BuildRunner builds cmd/equipo-runner into dir and returns its path. It
+// is a hostedchain build: the VMs run on this machine's bubblewrap (the
+// personal runners' build), which only such a build's hosted containment
+// accepts beside the hosted image's own.
func BuildRunner(dir string) (string, error) {
out := filepath.Join(dir, "equipo-runner")
- cmd := exec.Command("go", "build", "-o", out, "amadan.net/oficina/equipo/cmd/equipo-runner")
+ cmd := exec.Command("go", "build", "-tags", "hostedchain", "-o", out, "amadan.net/oficina/equipo/cmd/equipo-runner")
cmd.Env = append(os.Environ(), "CGO_ENABLED=0")
if b, err := cmd.CombinedOutput(); err != nil {
return "", fmt.Errorf("building equipo-runner: %v: %s", err, b)
diff --git a/internal/runner/containment/bubblewrap_chain.go b/internal/runner/containment/bubblewrap_chain.go
new file mode 100644
index 00000000..b9c5a6e7
--- /dev/null
+++ b/internal/runner/containment/bubblewrap_chain.go
@@ -0,0 +1,9 @@
+//go:build hostedchain
+
+package containment
+
+// chainAcceptsPersonal is true only in a hostedchain test build
+// (internal/hostedtest builds the VMs' runner with that tag): the
+// chain's VMs run on the test machine's bubblewrap, the personal pin.
+// scripts/release-hosted.sh refuses a runner built with any tag.
+const chainAcceptsPersonal = true
diff --git a/internal/runner/containment/bubblewrap_pin.go b/internal/runner/containment/bubblewrap_pin.go
index 1e761d29..52434852 100644
--- a/internal/runner/containment/bubblewrap_pin.go
+++ b/internal/runner/containment/bubblewrap_pin.go
@@ -9,6 +9,14 @@ const BubblewrapSHA256 = "0dfa36b98ada69568aaaa741fe210d2150a1441433bd13c428137d
// namespace tests can run on an arm64 CI machine. No release ships for it.
const BubblewrapSHA256Arm64 = "ef2316fc741885e6d7b422661ea60c20cbe07ec7eb592a4c2370cbcb90843b59"
+// HostedBubblewrapSHA256 is the hosted image's bubblewrap 0.11.0:
+// upstream's release source built on Amazon Linux 2023
+// (scripts/build-hosted-bwrap.sh), for linux/amd64, the MicroVM's
+// architecture. It is infra/hosted/image/manifest.json's
+// BubblewrapSHA256. The Debian build above needs glibc 2.38 and cannot
+// load on Amazon Linux 2023 (glibc 2.34).
+const HostedBubblewrapSHA256 = "1ebd5a3d3d9f2ece1032af3ba3993edac3fb8c189cf2e49bbc06fc8362fc81e2"
+
// BubblewrapPin is the digest of the pinned bubblewrap built for goarch.
// ok is false where there is no pinned build, and nothing starts there.
func BubblewrapPin(goarch string) (pin string, ok bool) {
@@ -20,3 +28,20 @@ func BubblewrapPin(goarch string) (pin string, ok bool) {
}
return "", false
}
+
+// bubblewrapPins are the builds a manager for goarch accepts: the
+// personal pin, or for a hosted manager (Config.Hosted) the hosted
+// image's. A hostedchain test build's hosted manager also accepts the
+// personal pin (chainAcceptsPersonal), since the chain's VMs run on the
+// test machine's bubblewrap; no release is built with that tag.
+func bubblewrapPins(hosted bool, goarch string) []string {
+ personal, ok := BubblewrapPin(goarch)
+ var pins []string
+ if hosted && goarch == "amd64" {
+ pins = append(pins, HostedBubblewrapSHA256)
+ }
+ if ok && (!hosted || chainAcceptsPersonal) {
+ pins = append(pins, personal)
+ }
+ return pins
+}
diff --git a/internal/runner/containment/bubblewrap_pin_test.go b/internal/runner/containment/bubblewrap_pin_test.go
index ae3770e2..18dd317e 100644
--- a/internal/runner/containment/bubblewrap_pin_test.go
+++ b/internal/runner/containment/bubblewrap_pin_test.go
@@ -7,6 +7,7 @@ import (
"os"
"path/filepath"
"runtime"
+ "slices"
"strings"
"testing"
@@ -65,6 +66,43 @@ func TestBubblewrapPins(t *testing.T) {
}
}
+// The hosted image's bubblewrap is its own build (upstream 0.11.0 built
+// on Amazon Linux 2023, which the Debian build cannot load on), accepted
+// only by a hosted manager; a personal manager accepts only the personal
+// pin. Only a hostedchain test build, whose VMs run on this machine's
+// bubblewrap, lets a hosted manager accept the personal pin as well.
+func TestBubblewrapPinsByPlace(t *testing.T) {
+ personal, _ := BubblewrapPin("amd64")
+ if got := bubblewrapPins(false, "amd64"); !slices.Equal(got, []string{personal}) {
+ t.Fatalf("a personal manager accepts %v, want only %s", got, personal)
+ }
+ if len(HostedBubblewrapSHA256) != 64 || HostedBubblewrapSHA256 == personal {
+ t.Fatalf("hosted pin %q: want a 64-digit digest other than the personal build's", HostedBubblewrapSHA256)
+ }
+ hosted := bubblewrapPins(true, "amd64")
+ if !slices.Contains(hosted, HostedBubblewrapSHA256) || slices.Contains(hosted, personal) != chainAcceptsPersonal {
+ t.Fatalf("a hosted manager accepts %v (hostedchain build %v)", hosted, chainAcceptsPersonal)
+ }
+ if slices.Contains(bubblewrapPins(false, "arm64"), HostedBubblewrapSHA256) {
+ t.Fatal("a personal arm64 manager accepts the hosted build")
+ }
+ if got := bubblewrapPins(true, "arm64"); slices.Contains(got, HostedBubblewrapSHA256) || len(got) > 0 && !chainAcceptsPersonal {
+ t.Fatalf("a hosted arm64 manager accepts %v; the hosted image is amd64 only", got)
+ }
+}
+
+// Each place's manager refuses the other place's build: the bubblewrap
+// installed here (the personal build, or in the hosted image's suite the
+// hosted one) does not start a manager for the other place.
+func TestNamespaceBubblewrapOtherPlace(t *testing.T) {
+ m, _ := fixture(t)
+ cfg := m.cfg
+ cfg.Hosted = !hostedSuite
+ if _, err := New(cfg); err == nil || !strings.Contains(err.Error(), "namespace_bubblewrap_digest") {
+ t.Fatalf("a manager for the other place started on this bubblewrap: %v", err)
+ }
+}
+
// The CI box installs exactly the two pinned builds (scripts/ci-box.json).
// It reads the source tree, so it is a TestSource test.
func TestSourceBubblewrapPinsMatchCIBox(t *testing.T) {
diff --git a/internal/runner/containment/bubblewrap_release.go b/internal/runner/containment/bubblewrap_release.go
new file mode 100644
index 00000000..08e6f7fb
--- /dev/null
+++ b/internal/runner/containment/bubblewrap_release.go
@@ -0,0 +1,7 @@
+//go:build !hostedchain
+
+package containment
+
+// chainAcceptsPersonal is false: a hosted manager accepts only the
+// hosted image's bubblewrap (bubblewrapPins).
+const chainAcceptsPersonal = false
diff --git a/internal/runner/containment/egress_test.go b/internal/runner/containment/egress_test.go
index fc2b3644..b244fadb 100644
--- a/internal/runner/containment/egress_test.go
+++ b/internal/runner/containment/egress_test.go
@@ -43,7 +43,7 @@ func egressFixture(t *testing.T, deep ...bool) (*Manager, provider.Launch) {
t.Fatal(e)
}
testci.Tools(t, "bwrap", "python3")
- m, e := New(Config{Binary: "/usr/bin/bwrap", RunnerBinary: binary, ScratchRoot: state})
+ m, e := New(Config{Binary: "/usr/bin/bwrap", RunnerBinary: binary, ScratchRoot: state, Hosted: hostedSuite})
if e != nil {
t.Fatal(e)
}
diff --git a/internal/runner/containment/linux.go b/internal/runner/containment/linux.go
index 1668390d..4c4acfdf 100644
--- a/internal/runner/containment/linux.go
+++ b/internal/runner/containment/linux.go
@@ -14,6 +14,7 @@ import (
"os/exec"
"path/filepath"
"runtime"
+ "slices"
"strconv"
"strings"
"sync"
@@ -28,6 +29,9 @@ import (
type Config struct {
Binary, RunnerBinary, ScratchRoot string
ProviderNetworks []provider.NetworkContract
+ // Hosted is a hosted VM's manager: Binary must be the hosted image's
+ // bubblewrap (HostedBubblewrapSHA256), not the personal runners'.
+ Hosted bool
}
type Manager struct {
waitExit func(context.Context, int) error
@@ -115,9 +119,9 @@ func New(cfg Config) (*Manager, error) {
}
// The pinned build, by its bytes, before it is run even to ask its
// version: a version string is only what a program says of itself.
- want, pinned := BubblewrapPin(runtime.GOARCH)
+ pins := bubblewrapPins(cfg.Hosted, runtime.GOARCH)
raw, e := os.ReadFile(cfg.Binary)
- if sum := sha256.Sum256(raw); e != nil || !pinned || hex.EncodeToString(sum[:]) != want {
+ if sum := sha256.Sum256(raw); e != nil || !slices.Contains(pins, hex.EncodeToString(sum[:])) {
return nil, errors.New("namespace_bubblewrap_digest")
}
cmd := exec.Command(cfg.Binary, "--version")
diff --git a/internal/runner/containment/linux_test.go b/internal/runner/containment/linux_test.go
index 9a57f92a..ff7cbbde 100644
--- a/internal/runner/containment/linux_test.go
+++ b/internal/runner/containment/linux_test.go
@@ -41,7 +41,7 @@ func fixture(t *testing.T) (*Manager, provider.Launch) {
t.Fatal(err)
}
testci.Tools(t, "bwrap", "python3")
- m, err := New(Config{Binary: "/usr/bin/bwrap", RunnerBinary: binary, ScratchRoot: scratch})
+ m, err := New(Config{Binary: "/usr/bin/bwrap", RunnerBinary: binary, ScratchRoot: scratch, Hosted: hostedSuite})
if err != nil {
t.Fatalf("namespace capability missing: %v", err)
}
@@ -412,7 +412,7 @@ func parentFixture() {
if e != nil {
panic(e)
}
- m, e := New(Config{Binary: "/usr/bin/bwrap", RunnerBinary: binary, ScratchRoot: os.Getenv("EQUIPO_TEST_STATE")})
+ m, e := New(Config{Binary: "/usr/bin/bwrap", RunnerBinary: binary, ScratchRoot: os.Getenv("EQUIPO_TEST_STATE"), Hosted: hostedSuite})
if e != nil {
panic(e)
}
diff --git a/internal/runner/containment/suite_hosted_test.go b/internal/runner/containment/suite_hosted_test.go
new file mode 100644
index 00000000..6486f811
--- /dev/null
+++ b/internal/runner/containment/suite_hosted_test.go
@@ -0,0 +1,9 @@
+//go:build hostedimage
+
+package containment
+
+// hostedSuite is true in the hosted image's containment suite
+// (scripts/release-hosted.sh builds it with -tags hostedimage): there
+// /usr/bin/bwrap is the hosted build (HostedBubblewrapSHA256), so the
+// suite's managers are hosted ones (Config.Hosted).
+const hostedSuite = true
diff --git a/internal/runner/containment/suite_personal_test.go b/internal/runner/containment/suite_personal_test.go
new file mode 100644
index 00000000..599b0b66
--- /dev/null
+++ b/internal/runner/containment/suite_personal_test.go
@@ -0,0 +1,7 @@
+//go:build !hostedimage
+
+package containment
+
+// hostedSuite is false: this suite runs on a personal runner's machine
+// (or CI's), whose bubblewrap is the personal pin.
+const hostedSuite = false
diff --git a/scripts/build-hosted-bwrap.sh b/scripts/build-hosted-bwrap.sh
new file mode 100755
index 00000000..038b53b5
--- /dev/null
+++ b/scripts/build-hosted-bwrap.sh
@@ -0,0 +1,156 @@
+#!/usr/bin/env bash
+# Build the hosted image's bubblewrap: upstream bubblewrap 0.11.0, from its
+# release tarball, compiled inside Amazon Linux 2023 so that it links
+# against that system's glibc (2.34) and libcap. The personal runners'
+# build (Debian's, internal/release/manifest.json) needs glibc 2.38 and
+# cannot load in the MicroVM.
+#
+# scripts/build-hosted-bwrap.sh [--repin] OUT_DIR
+#
+# Every input is pinned below: the source tarball by SHA-256, the build
+# container by digest, each build package by its exact version, and the
+# whole build root (every installed package) by one digest. The build runs
+# twice, each time in a fresh container, with SOURCE_DATE_EPOCH and fixed
+# compiler flags and paths, and the two binaries must be the same bytes.
+# The result must also be the pinned hosted bubblewrap
+# (infra/hosted/image/manifest.json's BubblewrapSHA256, which
+# internal/runner/containment's HostedBubblewrapSHA256 equals); --repin
+# skips that last check and prints the new digest, for a deliberate change
+# of any pin here.
+#
+# OUT_DIR receives bwrap and bwrap.buildinfo (the pins, the build root's
+# package list and the digest). A release passes OUT_DIR's bwrap to
+# scripts/release-hosted.sh in its --image-inputs directory.
+#
+# Needs rootless podman and the network (the source tarball and Amazon
+# Linux's package repository). The container image is pulled by digest if
+# it is not already present and is left in place; remove it with
+# podman rmi when done. No AWS account is used.
+set -euo pipefail
+
+BWRAP_VERSION=0.11.0
+BWRAP_URL=https://github.com/containers/bubblewrap/releases/download/v$BWRAP_VERSION/bubblewrap-$BWRAP_VERSION.tar.xz
+# The upstream release tarball. The same bytes are Debian's
+# bubblewrap_0.11.0.orig.tar.xz (bubblewrap_0.11.0-2.dsc).
+BWRAP_SHA256=988fd6b232dafa04b8b8198723efeaccdb3c6aa9c1c7936219d5791a8b7a8646
+# public.ecr.aws/amazonlinux/amazonlinux:2023.12.20261102.0, linux/amd64:
+# the release the hosted image's base (lambda/microvms:al2023-minimal) is
+# built from. Its dnf repository is locked to that release (repoguid).
+IMAGE=public.ecr.aws/amazonlinux/amazonlinux@sha256:3bbae8a3ad757535c4a031e6dbc67b18e6e6cb120436c3f067841da262993455
+PACKAGES=(
+ gcc-11.5.0-5.amzn2023.0.5.x86_64
+ binutils-2.41-50.amzn2023.0.5.x86_64
+ glibc-devel-2.34-231.amzn2023.0.5.x86_64
+ libcap-devel-2.73-1.amzn2023.0.8.x86_64
+ meson-0.63.3-1.amzn2023.0.2.noarch
+ ninja-build-1.10.2-2.amzn2023.0.3.x86_64
+ tar-1.34-1.amzn2023.0.4.x86_64
+ xz-5.2.5-9.amzn2023.0.2.x86_64
+)
+# SHA-256 of the build root's package list (rpm -qa NEVRAs, sorted, one
+# per line) once PACKAGES are installed: nothing else may differ.
+BUILDROOT_SHA256=aeb556a0b03311f45d161f928cf96e8cf44ad797b9a26f982d7db79dc74c370d
+# The release's date (2024-10-30T16:28:43Z), for anything that stamps one.
+SOURCE_DATE_EPOCH=1730305723
+# The highest glibc symbol version the binary may need: AL2023's.
+GLIBC_MAX=2.34
+
+die() { echo "build-hosted-bwrap: $*" >&2; exit 1; }
+sum() { sha256sum "$1" | cut -d ' ' -f 1; }
+
+repin=0
+case ${1:-} in
+--repin) repin=1; shift ;;
+esac
+[[ $# -eq 1 ]] || die "usage: build-hosted-bwrap.sh [--repin] OUT_DIR"
+out=$1
+mkdir -p "$out"
+out=$(cd "$out" && pwd)
+[[ ! -e $out/bwrap ]] || die "$out/bwrap exists"
+
+repo=$(cd "$(dirname "$0")/.." && pwd)
+pin=$(python3 -I -c 'import json, sys; print(json.load(open(sys.argv[1]))["BubblewrapSHA256"])' "$repo/infra/hosted/image/manifest.json")
+
+base=${TMPDIR:-${XDG_CACHE_HOME:-$HOME/.cache}/equipo}
+mkdir -p "$base"
+scratch=$(mktemp -d "$base/build-hosted-bwrap.XXXXXX")
+trap 'rm -rf "$scratch"' EXIT
+trap 'exit 1' HUP INT TERM
+
+echo "build-hosted-bwrap: fetching $BWRAP_URL"
+mkdir -p "$scratch/src"
+curl --fail --silent --show-error --location --max-redirs 5 --proto '=https' --proto-redir '=https' \
+ --max-time 300 --output "$scratch/src/bubblewrap.tar.xz" "$BWRAP_URL" || die "downloading $BWRAP_URL failed"
+[[ $(sum "$scratch/src/bubblewrap.tar.xz") == "$BWRAP_SHA256" ]] || die "the source tarball is not $BWRAP_SHA256"
+
+# The build, run as root inside the container. Fixed paths (/build), a
+# fixed environment, explicit flags, no build directory or date in the
+# binary, the symbol table stripped.
+cat >"$scratch/src/build.sh" <<'EOF'
+set -eu
+dnf --assumeyes --quiet --setopt=install_weak_deps=False install "$@" >/dev/null
+rpm -qa --qf '%{NAME}-%{EPOCH}:%{VERSION}-%{RELEASE}.%{ARCH}\n' | sed 's/-(none):/-/' | LC_ALL=C sort >/out/buildroot.txt
+for p in "$@"; do rpm -q "$p" >/dev/null || { echo "build root: $p is not installed" >&2; exit 1; }; done
+mkdir /build
+cd /build
+tar -xJf /src/bubblewrap.tar.xz
+cd bubblewrap-$BWRAP_VERSION
+meson setup _build --buildtype=plain --prefix=/usr --wrap-mode=nodownload \
+ -Dselinux=disabled -Dman=disabled -Dtests=false -Dbash_completion=disabled -Dzsh_completion=disabled \
+ -Db_pie=true >/dev/null
+ninja -C _build bwrap >/dev/null
+strip --strip-all -o /out/bwrap _build/bwrap
+chmod 0755 /out/bwrap
+test "$(/out/bwrap --version)" = "bubblewrap $BWRAP_VERSION"
+EOF
+
+build() { # N
+ local dir=$scratch/out$1
+ mkdir -p "$dir"
+ echo "build-hosted-bwrap: build $1 in a fresh $IMAGE"
+ podman run --rm --pull=missing \
+ --env LC_ALL=C --env LANG=C --env TZ=UTC --env SOURCE_DATE_EPOCH=$SOURCE_DATE_EPOCH \
+ --env BWRAP_VERSION=$BWRAP_VERSION \
+ --env CFLAGS="-O2 -g0 -pipe -fstack-protector-strong -D_FORTIFY_SOURCE=2 -fno-ident -ffile-prefix-map=/build=. -frandom-seed=bwrap" \
+ --env LDFLAGS="-Wl,-z,relro -Wl,-z,now -Wl,--build-id=sha1" \
+ --volume "$scratch/src:/src:ro" --volume "$dir:/out" \
+ "$IMAGE" sh -eu /src/build.sh "${PACKAGES[@]}" || die "build $1 failed"
+ [[ -f $dir/bwrap ]] || die "build $1 made no bwrap"
+}
+build 1
+build 2
+
+root=$(sum "$scratch/out1/buildroot.txt")
+cmp -s "$scratch/out1/buildroot.txt" "$scratch/out2/buildroot.txt" || die "the two build roots differ"
+if [[ $root != "$BUILDROOT_SHA256" ]]; then
+ ((repin)) || die "the build root is $root, not the pinned $BUILDROOT_SHA256"
+ echo "build-hosted-bwrap: build root $root (pin it as BUILDROOT_SHA256)"
+fi
+a=$(sum "$scratch/out1/bwrap") b=$(sum "$scratch/out2/bwrap")
+[[ $a == "$b" ]] || die "the two builds differ: $a and $b"
+
+# AL2023's glibc must be able to load it.
+need=$(LC_ALL=C objdump -T "$scratch/out1/bwrap" 2>/dev/null | grep -o 'GLIBC_[0-9.]*' | sed 's/GLIBC_//' | sort -uV | tail -1) ||
+ need=$(LC_ALL=C readelf --dyn-syms --wide "$scratch/out1/bwrap" | grep -o 'GLIBC_[0-9.]*' | sed 's/GLIBC_//' | sort -uV | tail -1)
+[[ -n $need ]] || die "cannot read the binary's glibc symbol versions"
+[[ $(printf '%s\n%s\n' "$need" "$GLIBC_MAX" | sort -V | tail -1) == "$GLIBC_MAX" ]] || die "the binary needs GLIBC_$need, over $GLIBC_MAX"
+
+if [[ $a != "$pin" ]]; then
+ ((repin)) || die "the build is $a, not the pinned hosted bubblewrap $pin (infra/hosted/image/manifest.json)"
+ echo "build-hosted-bwrap: new digest $a (pin it in manifest.json, pins.json and containment.HostedBubblewrapSHA256)"
+fi
+
+cp "$scratch/out1/bwrap" "$out/bwrap"
+{
+ echo "bubblewrap $BWRAP_VERSION for the hosted image (scripts/build-hosted-bwrap.sh)"
+ echo "sha256 $a"
+ echo "source $BWRAP_URL"
+ echo "source_sha256 $BWRAP_SHA256"
+ echo "image $IMAGE"
+ echo "source_date_epoch $SOURCE_DATE_EPOCH"
+ echo "glibc_needed $need"
+ echo "buildroot_sha256 $root"
+ echo "buildroot:"
+ sed 's/^/ /' "$scratch/out1/buildroot.txt"
+} >"$out/bwrap.buildinfo"
+echo "build-hosted-bwrap: $out/bwrap $a (built twice, identical)"
diff --git a/scripts/release-hosted.sh b/scripts/release-hosted.sh
index 685a72ae..a46ce876 100755
--- a/scripts/release-hosted.sh
+++ b/scripts/release-hosted.sh
@@ -13,6 +13,14 @@
# pkgs/NAME.rpm), used instead of infra/hosted/image/pins.json's
# URLs and checked against the same pins
#
+# bwrap and codex have no URL (pins.json): no download is the pinned file,
+# so a release always passes both with --image-inputs. bwrap is the hosted
+# image's own bubblewrap, built from upstream's source on Amazon Linux 2023
+# by scripts/build-hosted-bwrap.sh DIR (rootless podman; it checks the
+# result against the pin); codex is the member of the upstream tarball
+# that internal/release/manifest.json pins. The release does not build
+# bwrap itself, so a release machine needs no container runtime.
+#
# The release, tag hosted-VERSION, holds:
# equipo-hosted-controller-linux-arm64, equipo-hosted-proxy-linux-arm64
# the hosts' binaries (t4g, arm64), which their cloud-init downloads by
@@ -22,7 +30,9 @@
# operator's tools
# equipo-runner, equipo-vm-init, containment.test
# the image inputs this repository builds (linux/amd64, the MicroVM's
-# architecture), under the names equipo-hosted-image build reads
+# architecture), under the names equipo-hosted-image build reads;
+# containment.test with -tags hostedimage (its managers are hosted
+# ones, at the hosted bubblewrap's pin), the others with no tags
# litestream-*.tar.gz the pinned Litestream (infra/hosted/release-pins.json),
# copied byte for byte after its digest is checked
# image-source.tar the image's bundle: the exact manifest the image was
@@ -114,8 +124,8 @@ else
note "equipo-hosted-ops is not built: cmd/equipo-hosted-ops does not exist yet (slice 2 Task 33)"
fi
build amd64 equipo-vm-init ./cmd/equipo-vm-init
-echo "release-hosted: building containment.test (linux/amd64)"
-(cd "$src" && GOOS=linux GOARCH=amd64 go test -c -trimpath -ldflags "-s -w" -o "$out/containment.test" ./internal/runner/containment)
+echo "release-hosted: building containment.test (linux/amd64, -tags hostedimage)"
+(cd "$src" && GOOS=linux GOARCH=amd64 go test -c -tags hostedimage -trimpath -ldflags "-s -w" -o "$out/containment.test" ./internal/runner/containment)
# The runner: a runner release kit's, built from this commit.
if [[ -n $kit ]]; then
@@ -131,6 +141,15 @@ else
die "a publish needs --runner-kit (make release-runner at $commit)"
fi
+# The image's binaries say how they were built: the suite with exactly
+# -tags hostedimage, the runner and vm-init with no tags (a hostedchain
+# runner's hosted containment would accept the personal bubblewrap).
+tags() { go version -m "$1" | awk '$1 == "build" && $2 ~ /^-tags=/ { sub(/^-tags=/, "", $2); print $2 }'; }
+[[ $(tags "$out/containment.test") == hostedimage ]] || die "containment.test was not built with -tags hostedimage"
+for b in equipo-runner equipo-vm-init; do
+ [[ -z $(tags "$out/$b") ]] || die "$b was built with -tags $(tags "$out/$b")"
+done
+
# Litestream, by its pinned digests.
pins=$src/infra/hosted/release-pins.json
mapfile -t ls_assets < <(python3 -I -c 'import json, sys