mirror of
https://github.com/devvmhq/devvm.git
synced 2026-12-01 14:33:17 -10:00
devvm is about VMs, and Docker's containers aren't VMs: Lima is the default backend and smolvm stays experimental. The backend architecture (Backend, Caps, Require, the registry, backendtest.Fake) stays, so another backend is an addition. Removed: - internal/backend/docker, its registry entry and Names/Experimental's docker half; devvm _docker-connect and _docker-ports (internal/cli/dockerssh.go); assets/docker/unpack.sh. - Test-build overrides DEVVM_DOCKER_KIND, DEVVM_DOCKER_PROC_SYS, DEVVM_LINUX_BUILD_URL/_SHA256, the registry.linuxURL/linuxSHA256 ldflags vars and the CLI tests' Linux-build archive (linux_release). - Interfaces only Docker implemented, with their callers: backend.ProxySocket/ProxySocketOf (the proxy's -listen-unix), DiskUser (ls's and size's disk-over warning, size's disk_used and --json disk_used_gib), Reporter (doctor), LeftoverLister and Leftover (gc --orphans' volumes, networks, containers and images), DockerLayerVM and VMSpec.DockerLayer, SSHTarget.ProxyCommand and vmssh.SSH.Proxy, vmssh.SSH.SessionArgs, CacheEntry.Name. - The docker layer's runtime on a backend that makes VMs for it: vm/dockerlayer.go, KeyDockerLayer, chooseNet's refusal (chooseNet returns a bool now), the refusals at start and devvm network on, ls's "(sysbox)" and --json docker_layer, size_disk_default_unused. - The proxy's relay mode (relay.go, -relay, -relay-to, -listen-unix). - paths.Dirs.Docker and paths.VM.Lifeline. - assets/guest/tools.sh's linked-folder branch; services.sh's DEVVM_LOOP, DEVVM_DOCKERD and DEVVM_SSHD=inetd. - Messages: every docker_* the backend used, docker_layer_runtime, net_docker_layer, net_off_docker_layer, committing_image, pulling_image, unpacking_tools, disk_over, size_disk_default_unused, gc_orphan_volume/_network/_container/_image, docker_connect_failed; gc_orphan_elsewhere reworded. - Tests: docker.txtar, the docker stub's engine (its --from half stays), the ssh stub's login-shell branch; e2e's --backend docker, --engine, the docker host VM and Docker Desktop runs. - Release: one GoReleaser pass, no Linux-build pin in the macOS builds, no Linux devvm in the Homebrew formula's libexec. Linux builds stay. - Docs: backends/docker.md and internals/docker.md, design.md's Docker notes, the Docker column of the feature table, and every page's mentions of the Docker backend, Docker Desktop as one, and Sysbox. Kept: the docker layer in Lima VMs, devcontainer docker-in-docker, --from with images only a local Docker has, Docker Hub references. State written by a Docker VM before this reads as an unknown backend (backend_unknown_vm). Co-Authored-By: Claude Opus 5.5 <[email protected]>
114 lines
6.8 KiB
Bash
Executable File
114 lines
6.8 KiB
Bash
Executable File
#!/bin/bash
|
|
# Build a release's files in dist/ with GoReleaser (.goreleaser.yaml), from git (only what's committed):
|
|
# devvm-<version>-<os>-<arch>.tar.gz the binary and the files it reads, for darwin and linux, arm64 and amd64
|
|
# devvm-<version>.tar.gz the source, which the Homebrew formula builds from
|
|
# SHA256SUMS their checksums, which install.sh checks
|
|
# SHA256SUMS.minisig SHA256SUMS signed with the release key (minisign), which install.sh checks
|
|
# install.sh the install script, set to install this release and to trust the key
|
|
# devvm.rb the Homebrew formula for w3cj/homebrew-tap
|
|
# Nothing is published. The version is VERSION's. The public key is packaging/minisign.pub (committed); the
|
|
# secret key is the maintainer's, at DEVVM_MINISIGN_KEY (default ~/.minisign/devvm.key), never in the repo.
|
|
# scripts/release.sh from the tag v<version>, which must exist and be signed (git tag -s)
|
|
# scripts/release.sh --head from HEAD, for testing (DEVVM_RELEASE_URL: where the source tarball will be;
|
|
# DEVVM_MINISIGN_KEY: a test key, else nothing is signed;
|
|
# DEVVM_MINISIGN_PUB: its public key, else packaging/minisign.pub)
|
|
# Needs goreleaser and minisign, pinned in mise.toml: mise exec -- scripts/release.sh.
|
|
set -euo pipefail
|
|
root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
|
cd "$root"
|
|
die() { echo "release: $*" >&2; exit 1; }
|
|
|
|
v=$(tr -d '[:space:]' < VERSION)
|
|
[[ $v =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]] || die "VERSION isn't x.y.z: '$v'"
|
|
ref=v$v
|
|
[[ ${1:-} != --head ]] || ref=HEAD
|
|
if [[ $ref == HEAD ]]; then obj=HEAD; else obj=$(git rev-parse -q --verify "refs/tags/$ref") || die "no tag $ref: tag the release first (git tag -s $ref)"; fi
|
|
# A release comes from a tag the maintainer signed, not just any tag with the right name. The tag
|
|
# object checked is the one built from: its commit is resolved once, and used for everything below.
|
|
[[ $ref == HEAD ]] || git verify-tag "$obj" >/dev/null 2>&1 ||
|
|
die "tag $ref isn't signed by a key git trusts (make it with git tag -s; see docs/content/docs/contributing/maintaining.md)"
|
|
# And by the release signer, not just any key git trusts: its fingerprint is pinned in this checkout's
|
|
# packaging/release-signer (one per line; # comments), never the tagged commit's, which the tag brings.
|
|
if [[ $ref != HEAD ]]; then
|
|
signers=$root/packaging/release-signer
|
|
[[ -s $signers ]] || die "no packaging/release-signer: write the tag-signing key's fingerprint there (see docs/content/docs/contributing/maintaining.md)"
|
|
raw=$(git verify-tag --raw "$obj" 2>&1) || true
|
|
# GPG: VALIDSIG <signing key> … <primary key>; SSH: "… key SHA256:…".
|
|
fps=$(awk '$1 == "[GNUPG:]" && $2 == "VALIDSIG" { print $3; print $NF }' <<<"$raw"
|
|
grep -oE 'SHA256:[A-Za-z0-9+/]{43}' <<<"$raw" || true)
|
|
fps=$(sort -u <<<"$fps")
|
|
ok=false
|
|
while IFS= read -r fp; do
|
|
[[ -n $fp ]] && grep -v '^#' "$signers" | tr -d ' \t' | grep -xiF "$fp" >/dev/null && ok=true
|
|
done <<<"$fps"
|
|
$ok || die "tag $ref is signed by $(paste -sd' ' - <<<"$fps"), not a key in packaging/release-signer"
|
|
fi
|
|
commit=$(git rev-parse -q --verify "$obj^{commit}") || die "no commit for $ref"
|
|
[[ "$(git show "$commit:VERSION" | tr -d '[:space:]')" == "$v" ]] || die "$ref's VERSION isn't $v"
|
|
pubkey=$(git show "$commit:packaging/minisign.pub" 2>/dev/null | sed -n 2p) || true
|
|
# A test key's public key, for HEAD only: a release verifies with the committed one.
|
|
if [[ $ref == HEAD && -n ${DEVVM_MINISIGN_PUB:-} ]]; then
|
|
pubkey=$(sed -n 2p "$DEVVM_MINISIGN_PUB") || die "can't read $DEVVM_MINISIGN_PUB"
|
|
fi
|
|
key=${DEVVM_MINISIGN_KEY:-$HOME/.minisign/devvm.key}
|
|
sign=true
|
|
if [[ $ref == HEAD && -z ${DEVVM_MINISIGN_KEY:-} ]]; then sign=false
|
|
else
|
|
[[ -n $pubkey ]] || die "no packaging/minisign.pub in $ref: create the release key first (see docs/content/docs/contributing/maintaining.md)"
|
|
[[ -f $key ]] || die "no release key at $key (DEVVM_MINISIGN_KEY)"
|
|
command -v minisign >/dev/null || die "needs minisign to sign the release (mise exec -- scripts/release.sh)"
|
|
fi
|
|
git cat-file -e "$commit:install.sh" 2>/dev/null || die "no install.sh in $ref"
|
|
command -v goreleaser >/dev/null || die "needs goreleaser (mise exec -- scripts/release.sh)"
|
|
url=${DEVVM_RELEASE_URL:-https://github.com/w3cj/devvm/releases/download/v$v}
|
|
|
|
# GoReleaser builds a clone of the commit, so only what's committed goes in, whatever this checkout
|
|
# holds. The version is VERSION's, for HEAD too (DEVVM_VERSION, in .goreleaser.yaml's snapshot).
|
|
out=$root/dist
|
|
tmp=$(mktemp -d "${TMPDIR:-/tmp}/devvm-release.XXXXXX")
|
|
trap 'rm -rf "$tmp"' EXIT
|
|
src=$tmp/src
|
|
{ git clone -q --no-checkout "$root" "$src" && git -C "$src" checkout -q --detach "$commit"; } ||
|
|
die "couldn't check out $ref"
|
|
snap=()
|
|
if [[ $ref == HEAD ]]; then snap=(--snapshot); else export GORELEASER_CURRENT_TAG=$ref; fi
|
|
(cd "$src" && DEVVM_VERSION=$v goreleaser release --clean --skip=publish ${snap[@]+"${snap[@]}"}) || die "goreleaser failed"
|
|
rm -rf "$out"
|
|
mv "$src/dist" "$out"
|
|
|
|
# The built binary for this host says the release's version (GoReleaser's own default sets one devvm
|
|
# doesn't read).
|
|
os=$(uname -s | tr '[:upper:]' '[:lower:]')
|
|
case $(uname -m) in arm64 | aarch64) arch=arm64 ;; x86_64) arch=amd64 ;; *) arch=none ;; esac
|
|
for bin in "$out"/devvm*_"${os}_$arch"*/devvm; do
|
|
[[ -x $bin ]] || continue
|
|
got=$("$bin" --version) || die "$bin --version failed"
|
|
[[ $got == "$v" ]] || die "$bin --version says '$got', not $v"
|
|
done
|
|
|
|
tarball=devvm-$v.tar.gz
|
|
sha=$(awk -v f="$tarball" '$2 == f { print $1 }' "$out/SHA256SUMS")
|
|
[[ $sha =~ ^[0-9a-f]{64}$ ]] || die "SHA256SUMS has no $tarball"
|
|
if $sign; then
|
|
minisign -Sm "$out/SHA256SUMS" -s "$key" -t "devvm $v" || die "couldn't sign SHA256SUMS"
|
|
minisign -Vm "$out/SHA256SUMS" -P "$pubkey" >/dev/null || die "SHA256SUMS.minisig doesn't verify with packaging/minisign.pub"
|
|
else
|
|
pubkey="" # an unsigned test build: its install.sh doesn't expect a signature
|
|
fi
|
|
|
|
git show "$commit:install.sh" |
|
|
awk -v v="$v" -v k="$pubkey" '
|
|
/^release_version=""$/ { $0 = "release_version=\"" v "\""; n++ }
|
|
/^minisign_key=""$/ { $0 = "minisign_key=\"" k "\""; m++ }
|
|
{ print } END { exit !(n == 1 && m == 1) }' \
|
|
> "$out/install.sh" || die "install.sh needs one release_version=\"\" and one minisign_key=\"\" line"
|
|
chmod 755 "$out/install.sh"
|
|
git show "$commit:packaging/homebrew/devvm.rb" |
|
|
awk -v u="$url/$tarball" -v s="$sha" '{ gsub("@URL@", u); gsub("@SHA256@", s); print }' \
|
|
> "$out/devvm.rb"
|
|
|
|
echo "==> dist/ for devvm $v (from $ref):"
|
|
(cd "$out" && ls -l devvm-*.tar.gz SHA256SUMS* install.sh devvm.rb 2>/dev/null) || true
|
|
$sign || echo "(not signed: a test build without DEVVM_MINISIGN_KEY)"
|
|
echo "Attach the archives, SHA256SUMS, SHA256SUMS.minisig and install.sh to the GitHub release v$v; devvm.rb goes in w3cj/homebrew-tap/Formula/."
|