diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1f45392..a4c946c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -232,19 +232,25 @@ jobs: rootless) net="$HOME/.config/brig/cni/net.d" ;; *) net="$prefix/etc/cni/net.d" ;; esac + # The bundle carries hull, so hull is the default; nerdctl is + # still one setting away. got="$(launcher)" - [ "$got" = "nerdctl $prefix/bin/nerdctl $net" ] \ - || { echo "default launcher: got '$got'"; exit 1; } - got="$(launcher BRIG_RUNTIME=hull)" [ "$got" = "hull $prefix/bin/hull $net" ] \ - || { echo "BRIG_RUNTIME=hull launcher: got '$got'"; exit 1; } + || { echo "default launcher: got '$got'"; exit 1; } + got="$(launcher BRIG_RUNTIME=nerdctl)" + [ "$got" = "nerdctl $prefix/bin/nerdctl $net" ] \ + || { echo "BRIG_RUNTIME=nerdctl launcher: got '$got'"; exit 1; } got="$(launcher BRIG_RUNTIME=hull BRIG_RUNTIME_BIN=/opt/hull NETCONFPATH=/opt/net)" [ "$got" = "hull /opt/hull /opt/net" ] \ || { echo "the launcher overrode the caller's values: got '$got'"; exit 1; } # Sourced again after a switch of runtime, as a second eval of # brig-ctl env does, the launcher drops the binary it set the first - # time and names the new runtime's. + # time and names the new runtime's, in both directions. got="$(env -i HOME="$HOME" PATH=/usr/bin:/bin \ + sh -c ". '$t/etc/brig-env.sh'; BRIG_RUNTIME=nerdctl; . '$t/etc/brig-env.sh'; echo \"\$BRIG_RUNTIME \$BRIG_RUNTIME_BIN\"")" + [ "$got" = "nerdctl $prefix/bin/nerdctl" ] \ + || { echo "the launcher re-sourced for nerdctl kept hull: got '$got'"; exit 1; } + got="$(env -i HOME="$HOME" PATH=/usr/bin:/bin BRIG_RUNTIME=nerdctl \ sh -c ". '$t/etc/brig-env.sh'; BRIG_RUNTIME=hull; . '$t/etc/brig-env.sh'; echo \"\$BRIG_RUNTIME \$BRIG_RUNTIME_BIN\"")" [ "$got" = "hull $prefix/bin/hull" ] \ || { echo "the launcher re-sourced for hull kept nerdctl: got '$got'"; exit 1; } diff --git a/README.md b/README.md index 6bf54b3..74ebec2 100644 --- a/README.md +++ b/README.md @@ -186,24 +186,24 @@ $ curl -fsSL https://raw.githubusercontent.com/NOFireAI/brig-standalone-linux/ma [docs/rootless.md](docs/rootless.md) has the detail, including the two things that still need root once per host, and what a home install gives up. -### hull beside nerdctl +### hull and nerdctl -nerdctl is brig's runtime here. The bundle also carries hull, the runtime brig -drives on macOS, built for Linux: a containerd client that boots the same urunc, -monitors and guest assets. `BRIG_RUNTIME=hull` selects it, and the launcher then -points brig at the bundle's hull rather than its nerdctl: +hull is brig's runtime here, and needs the brig in the bundle to be v0.6.0 or +later: an older brig refuses the shipped profiles on hull. It is the runtime +brig drives on macOS, built for Linux: a containerd client that boots the same urunc, monitors and guest assets, +and puts each networked sandbox on a network gateway of its own, which enforces +the egress policy and serves routes and published ports. nerdctl stays in the +bundle, and `BRIG_RUNTIME=nerdctl` selects it, for instance for an image whose +`USER` is a name, which hull on Linux refuses: ```console -$ BRIG_RUNTIME=hull brig doctor +$ BRIG_RUNTIME=nerdctl brig doctor ``` -It needs a brig that drives hull on Linux, which the `v0.5.0` in this bundle -does not. Even then, hull on Linux boots a sandbox on the shared bridge or with -no network, and brig refuses what it cannot enforce there yet: an egress policy, -a route, `network: isolated` and a published port. The shipped agent profiles -ask for an isolated network, so they stay on nerdctl for now. Every value the -launcher sets still defers to the environment, so `BRIG_RUNTIME_BIN` points brig -at another hull. +A sandbox stays on the runtime that booted it, so one booted on nerdctl before +this release needs `BRIG_RUNTIME=nerdctl` until `brig rm` removes it. Every value +the launcher sets still defers to the environment, so `BRIG_RUNTIME_BIN` points +brig at another hull. The launcher works out the binary each time it is sourced. A shell that has run `eval "$(brig-ctl env)"` has the bundle's `bin/` first on its `PATH`, so `brig` @@ -211,7 +211,7 @@ there is the binary itself and nothing sources the launcher again: set `BRIG_RUNTIME` before the eval, or run the eval again after changing it. ```console -# export BRIG_RUNTIME=hull +# export BRIG_RUNTIME=nerdctl # eval "$(/var/lib/brig/data/bin/brig-ctl env)" ``` diff --git a/scripts/build-bundle.sh b/scripts/build-bundle.sh index a28b710..9a1ee52 100755 --- a/scripts/build-bundle.sh +++ b/scripts/build-bundle.sh @@ -1098,6 +1098,11 @@ fi # a cross compile in a container of the build host's arch, not a --platform # build. No TELEMETRY_ENDPOINT is passed, so this hull never sends telemetry. HULL_INSTALLED=false +# The runtime brig drives when BRIG_RUNTIME names none: hull once the bundle +# carries it, since hull on Linux serves the policies, routes and published +# ports nerdctl does and publishes on a running sandbox too. That takes a brig +# of v0.6.0 or later; an older one refuses the shipped profiles on hull. +DEFAULT_RUNTIME=nerdctl HULL_PINNED="" if [ "$VARIANT" != "stock" ]; then command -v docker >/dev/null 2>&1 || fatal "docker is required to build hull from $HULL_REPO" @@ -1140,6 +1145,7 @@ if [ "$VARIANT" != "stock" ]; then cp "$hsrc/dist/hull_linux_$ARCH" "$DL/hull" || fatal "the hull build left no dist/hull_linux_$ARCH" chmod 0755 "$DL/hull" HULL_INSTALLED=true + DEFAULT_RUNTIME=hull info " built hull $HULL_REF" fi @@ -1531,15 +1537,15 @@ export CNI_PATH="\${CNI_PATH:-$CNI_DIR}" # install prefixes, but reads the variable in preference, so the export keeps # hull and nerdctl on one directory, an install at another prefix included. # -# nerdctl is brig's runtime here, and BRIG_RUNTIME=hull opts in to the hull -# beside it. The binary follows the runtime: a BRIG_RUNTIME=hull handed the +# hull is brig's runtime here when the bundle carries it, and nerdctl +# otherwise; BRIG_RUNTIME names either one. The binary follows the runtime: a BRIG_RUNTIME=hull handed the # nerdctl path would drive nerdctl with hull's command line. A runtime the # bundle does not carry gets no binary, so brig looks for it on PATH or says # it is missing. A BRIG_RUNTIME_BIN that names one of this bundle's runtimes # came from this file, sourced before for whatever runtime was set then (an # earlier eval of brig-ctl env), so it is worked out again. Any other value # is the caller's and stands. -export BRIG_RUNTIME="\${BRIG_RUNTIME:-nerdctl}" +export BRIG_RUNTIME="\${BRIG_RUNTIME:-$DEFAULT_RUNTIME}" case "\${BRIG_RUNTIME_BIN:-}" in "$BIN_DIR/nerdctl"|"$BIN_DIR/hull") unset BRIG_RUNTIME_BIN ;; esac