Files
w3cjandClaude Opus 5.5 bc185ec80e fix(release): every file release.sh writes is 0755 or 0644, whatever the umask
minisign writes its signatures with the process umask, so on a host
whose umask is 0002, as Ubuntu's is, dist/SHA256SUMS.minisig came out
0664, and --ci-sign's SHA256SUMS.ci.minisig, --sign-legacy's signature,
--formula-from's formulas and --ci's folder for the co-signer were
group-writable too. release.sh now sets umask 022 once at its top, for
the host and the container alike, in place of the two copies in build
and modules.

release_head.txtar's modes check builds under umask 0002, checks the
signature is 0644, and labels the catch-all lines so a stray mode can't
pass as an expected one; release_ci.txtar's --ci-sign runs under umask
0002 and checks its signature is 0644. Both failed before the fix.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-12-01 07:35:02 -07:00

830 lines
38 KiB
Plaintext

# scripts/release.sh --head: a test build from HEAD's commit, signed with a
# test key, in a throwaway repo with a goreleaser that writes a small dist/,
# which mise.lock pins as file:// URLs in tools/, which
# DEVVM_RELEASE_TEST_FILE_URLS allows, a podman and a docker that run the
# container's command here, and a curl that logs its arguments.
[!exec:git] skip
[!exec:minisign] skip
env GIT_CONFIG_NOSYSTEM=1
env PATH=$WORK/bin:$PATH
env DEVVM_RELEASE_TEST_FILE_URLS=$WORK/tools
cp bin/podman bin/docker
chmod 755 bin/goreleaser
chmod 755 bin/podman
chmod 755 bin/docker
chmod 755 bin/curl
exec bash repo.sh
# Unsigned without a test key: install.sh trusts no key. The build ran in
# the pinned container, as this system's processor, as root under rootless
# podman, and its Go and GoReleaser came from mise.lock, kept in the cache
# by their SHA-256, downloaded within bounds. First the modules' download
# ran, by this checkout's release.sh, given only go.mod, go.sum and Go,
# read-only, then the build, with no network and the modules read-only,
# writing to an output folder of its own: each in a container named for
# its run (the stub checks the name is its temp folder's), with no
# capabilities, no new privileges, at most 8192 processes and 8 GiB of
# memory, and bash as its entrypoint.
env XDG_CACHE_HOME=$WORK/cache
exec repo/scripts/release.sh --head
stdout '^\(not signed: a test build without DEVVM_MINISIGN_KEY\)$'
stdout '^==> downloading HEAD''s Go modules in docker\.io/library/buildpack-deps:trixie-scm@sha256:[0-9a-f]{64}, under podman as 0:0$'
stdout '^==> building [0-9a-f]{40} in docker\.io/library/buildpack-deps:trixie-scm@sha256:[0-9a-f]{64}, under podman as 0:0$'
exec grep -c '^run --name devvm-release-[A-Za-z0-9]*-1 --rm --platform linux/[a-z0-9]* --user 0:0 --security-opt no-new-privileges --cap-drop ALL --pids-limit 8192 --memory 8g --entrypoint bash -v [^ ]*/in:/in:ro,z -v [^ ]*/mod:/out:z -w /in docker\.io/library/buildpack-deps:trixie-scm@sha256:[0-9a-f]\{64\} /in/release\.sh _modules /in /out$' runtime.log
stdout '^1$'
exec grep -c '^run --name devvm-release-[A-Za-z0-9]*-2 --rm --platform linux/[a-z0-9]* --user 0:0 --security-opt no-new-privileges --cap-drop ALL --pids-limit 8192 --memory 8g --entrypoint bash --network none -v [^ ]*/work:/work:z -v [^ ]*/mod:/mod:ro,z -v [^ ]*/out:/out:z -w /work docker\.io/library/buildpack-deps:trixie-scm@sha256:[0-9a-f]\{64\} /work/release\.sh _build 1\.2\.3 [0-9a-f]\{40\} .* /mod /out$' runtime.log
stdout '^1$'
cmp go-in.log go-in.want
cmp go.log go.want
exec bash -c 'cmp repo/scripts/release.sh container-modules.sh && echo same'
stdout '^same$'
exec bash -c 'ls cache/devvm-release | grep -cE "^[0-9a-f]{64}$"'
stdout '^2$'
exec bash -c 'grep -c -- "^-fsSL --retry 3 --proto =file --proto-redir =https --connect-timeout 30 --max-time 900 --max-filesize 1073741824 -o [^ ]* --url file:///" curl.log'
stdout '^2$'
! exists repo/dist/SHA256SUMS.minisig
grep '^release_version="1.2.3"$' repo/dist/install.sh
grep '^minisign_key=""$' repo/dist/install.sh
# With one: GoReleaser builds a snapshot with VERSION's version, SHA256SUMS
# is signed and verifies, install.sh is set to the release and the key, and
# the formula to each platform's archive.
rm log
exec minisign -G -W -p keys/test.pub -s keys/test.key
env DEVVM_MINISIGN_KEY=$WORK/keys/test.key DEVVM_MINISIGN_PUB=$WORK/keys/test.pub
exec repo/scripts/release.sh --head
! stdout 'not signed'
cmp log log.want
exec minisign -Vm repo/dist/SHA256SUMS -p keys/test.pub
stdout 'Trusted comment: devvm 1.2.3'
exec bash -c 'git -C repo show HEAD:scripts/release.sh | cmp - container-release.sh'
exec bash key.sh
grep '^release_version="1.2.3"$' repo/dist/install.sh
cmp stdout key.want
exec bash sums.sh
cmp stdout sums.want
exec bash formula.sh devvm.rb
cmp stdout formula.want
exec bash formula.sh devvm-rc.rb
cmp stdout formula.want
# An unsigned build never replaces a signed one's dist/: refused before
# it's built, unless DEVVM_RELEASE_DIST names a new folder for it.
env DEVVM_MINISIGN_KEY=
rm log
! exec repo/scripts/release.sh --head
stderr '^release: dist/ holds a signed build, which this unsigned one would replace: move it first, or set DEVVM_RELEASE_DIST to a new folder$'
! exists log
exists repo/dist/SHA256SUMS.minisig
env DEVVM_RELEASE_DIST=$WORK/unsigned
exec repo/scripts/release.sh --head
exists unsigned/SHA256SUMS
exists repo/dist/SHA256SUMS.minisig
env DEVVM_RELEASE_DIST=
env DEVVM_MINISIGN_KEY=$WORK/keys/test.key
# Nor does a build signed with a test key replace one signed with the
# release key, this checkout's packaging/minisign.pub; one signed with
# another test key it does.
exec minisign -G -W -p keys/release.pub -s keys/release.key
cp keys/release.pub repo/packaging/minisign.pub
exec minisign -Sm repo/dist/SHA256SUMS -s keys/release.key -x repo/dist/SHA256SUMS.minisig -t 'devvm 1.2.3'
rm log
! exec repo/scripts/release.sh --head
stderr '^release: dist/ holds a build signed with the release key \(packaging/minisign\.pub\), which this test build would replace: move it first, or set DEVVM_RELEASE_DIST to a new folder$'
! exists log
exec minisign -Vm repo/dist/SHA256SUMS -p keys/release.pub
rm repo/packaging/minisign.pub
exec repo/scripts/release.sh --head
exec minisign -Vm repo/dist/SHA256SUMS -p keys/test.pub
# A release gets both formulas, devvm and devvm-rc, each conflicting with
# the other: they differ only in that.
exec bash -c 'diff repo/dist/devvm.rb repo/dist/devvm-rc.rb || true'
cmp stdout formulas.diff
# --formula-from: the same formulas from a published release's signed
# SHA256SUMS, checked against packaging/minisign.pub and its trusted
# comment; a changed one refused, and one signed as another release's.
mkdir pub
cp repo/dist/SHA256SUMS repo/dist/SHA256SUMS.minisig pub/
cp repo/dist/devvm.rb devvm.rb.built
cp repo/dist/devvm-rc.rb devvm-rc.rb.built
cp keys/test.pub repo/packaging/minisign.pub
exec repo/scripts/release.sh --formula-from $WORK/pub
stdout '^==> dist/devvm\.rb for devvm 1\.2\.3, from '
stdout '^==> dist/devvm-rc\.rb for devvm 1\.2\.3, from '
cmp repo/dist/devvm.rb devvm.rb.built
cmp repo/dist/devvm-rc.rb devvm-rc.rb.built
exec bash -c 'echo 1.2.4 > repo/VERSION'
! exec repo/scripts/release.sh --formula-from $WORK/pub
stderr '^release: \S+/SHA256SUMS is signed as ''devvm 1\.2\.3'', not VERSION''s ''devvm 1\.2\.4''$'
exec git -C repo checkout -q VERSION
exec bash -c 'echo x >> pub/SHA256SUMS'
! exec repo/scripts/release.sh --formula-from $WORK/pub
stderr 'SHA256SUMS doesn''t verify with packaging/minisign.pub$'
# The formula substitution, whole: a prerelease's SHA256SUMS gives only
# devvm-rc.rb, its class, its conflict and each platform's URL and
# checksum in place.
mkdir pubrc
cp sums.rc pubrc/SHA256SUMS
exec minisign -Sm pubrc/SHA256SUMS -s keys/test.key -t 'devvm 1.3.0-rc.1' -x pubrc/SHA256SUMS.minisig
exec bash -c 'echo 1.3.0-rc.1 > repo/VERSION'
rm repo/dist/devvm.rb repo/dist/devvm-rc.rb
exec repo/scripts/release.sh --formula-from $WORK/pubrc
! stdout 'dist/devvm\.rb'
! exists repo/dist/devvm.rb
exec grep -v '^#' repo/dist/devvm-rc.rb
cmp stdout devvm-rc.want
exec git -C repo checkout -q VERSION
rm repo/packaging/minisign.pub
# Only what's committed goes in.
exec tar -tzf repo/dist/devvm-1.2.3.tar.gz
stdout '^devvm-1.2.3/VERSION$'
! stdout uncommitted
# A prerelease's VERSION, 1.3.0-rc.1: its archives, install.sh and the
# trusted comment all name it, it gets only the formula devvm-rc, and the
# formula devvm is said to keep the last release.
exec bash -c 'echo 1.3.0-rc.1 > repo/VERSION && git -C repo commit -qam rc'
exec repo/scripts/release.sh --head
stdout 'GitHub prerelease v1\.3\.0-rc\.1, devvm-rc\.rb to devvmhq/homebrew-tap''s Formula/; the formula devvm keeps the last release\.$'
exists repo/dist/devvm-1.3.0-rc.1-linux-arm64.tar.gz
exists repo/dist/devvm-1.3.0-rc.1.tar.gz
grep '^release_version="1.3.0-rc.1"$' repo/dist/install.sh
! exists repo/dist/devvm.rb
grep '^class DevvmRc < Formula$' repo/dist/devvm-rc.rb
grep '^ conflicts_with "devvmhq/tap/devvm", because: "both install the devvm binary"$' repo/dist/devvm-rc.rb
grep 'releases/download/v1\.3\.0-rc\.1/devvm-1\.3\.0-rc\.1-darwin-arm64\.tar\.gz"$' repo/dist/devvm-rc.rb
exec bash formula.sh devvm-rc.rb
stdout '^https://github.com/devvmhq/devvm/releases/download/v1\.3\.0-rc\.1/devvm-1\.3\.0-rc\.1-linux-amd64\.tar\.gz checksum$'
stdout '^comments$'
exec minisign -Vm repo/dist/SHA256SUMS -p keys/test.pub
stdout 'Trusted comment: devvm 1\.3\.0-rc\.1$'
exec bash -c 'echo 1.2.3 > repo/VERSION && git -C repo commit -qam back'
# A key that doesn't match the public key: refused.
exec minisign -G -W -p keys/other.pub -s keys/other.key
env DEVVM_MINISIGN_PUB=$WORK/keys/other.pub
! exec repo/scripts/release.sh --head
stderr '^release: SHA256SUMS.minisig doesn''t verify with packaging/minisign.pub$'
env DEVVM_MINISIGN_PUB=$WORK/keys/test.pub
# A binary that doesn't say the release's version: refused.
env GR_VERSION=0.0.0
! exec repo/scripts/release.sh --head
stderr 'version says ''0.0.0'', not 1.2.3$'
env GR_VERSION=
# An install.sh without the lines to fill in: refused.
exec bash -c 'printf ''#!/bin/sh\n'' > repo/install.sh && git -C repo commit -qam no-lines'
! exec repo/scripts/release.sh --head
stderr 'install.sh needs one release_version="" and one minisign_key="" line$'
# A VERSION that isn't x.y.z or x.y.z-rc.N: refused.
exec bash -c 'echo 1.2 > repo/VERSION && git -C repo commit -qam bad-version'
! exec repo/scripts/release.sh --head
stderr '^release: VERSION isn''t x.y.z or x.y.z-rc.N: ''1.2''$'
exec bash -c 'echo 1.2.3-RC1 > repo/VERSION && git -C repo commit -qam bad-prerelease'
! exec repo/scripts/release.sh --head
stderr '^release: VERSION isn''t x.y.z or x.y.z-rc.N: ''1.2.3-RC1''$'
# A download that doesn't match mise.lock: refused, and dropped from the
# cache, so the next build downloads it again.
exec bash -c 'echo 1.2.3 > repo/VERSION && printf ''#!/bin/sh\nrelease_version=""\nminisign_key=""\n'' > repo/install.sh && git -C repo commit -qam good'
exec bash -c 'f=$(ls cache/devvm-release | head -1) && echo x >> "cache/devvm-release/$f"'
! exec repo/scripts/release.sh --head
stderr '^release: file://\S+ doesn''t match HEAD''s mise\.lock \(sha256:[0-9a-f]{64}\)$'
exec repo/scripts/release.sh --head
stdout '^==> dist/ for devvm 1\.2\.3 \(from HEAD\):$'
# A commit whose mise.lock has no GoReleaser for this platform: refused.
exec bash -c 'sed "/goreleaser/,\$d" repo/mise.lock > lock && mv lock repo/mise.lock && git -C repo commit -qam no-goreleaser'
! exec repo/scripts/release.sh --head
stderr '^release: HEAD''s mise\.lock has no goreleaser download for linux-(arm64|x64)$'
exec git -C repo revert --no-edit HEAD
# A runtime that isn't there: refused before anything is built.
env DEVVM_RELEASE_RUNTIME=no-such-runtime
! exec repo/scripts/release.sh --head
stderr '^release: needs podman or Docker to build in its container \(DEVVM_RELEASE_RUNTIME names one\)$'
env DEVVM_RELEASE_RUNTIME=
# A build that fails in the container: release.sh says so.
env GR_FAIL=1
! exec repo/scripts/release.sh --head
stderr '^release: goreleaser failed$'
stderr '^release: the build in docker\.io/library/buildpack-deps:trixie-scm@sha256:[0-9a-f]{64} failed$'
env GR_FAIL=
# The container runs as root under a rootless runtime, which maps root to
# you, and as you under a rootful one, as the runtime's info says, never
# its name: podman, rootless by default, then rootful; Docker, rootful by
# default, then in its rootless mode; and podman behind a docker command.
exec repo/scripts/release.sh --head
exec bash user.sh
stdout '^root$'
env RT_ROOTLESS=false
exec repo/scripts/release.sh --head
exec bash user.sh
stdout '^you$'
env RT_ROOTLESS=
env DEVVM_RELEASE_RUNTIME=docker
exec repo/scripts/release.sh --head
stdout ', under docker as \d+:\d+$'
exec bash user.sh
stdout '^you$'
env RT_ROOTLESS=true
exec repo/scripts/release.sh --head
exec bash user.sh
stdout '^root$'
env RT_ROOTLESS=
env RT_PODMAN=1
exec repo/scripts/release.sh --head
exec bash user.sh
stdout '^root$'
env RT_PODMAN=
# A runtime that doesn't answer, such as Docker Desktop when it isn't
# running: refused before anything is built.
env RT_NO_INFO=1
rm runtime.log
! exec repo/scripts/release.sh --head
stderr '^release: docker didn''t say whether it''s rootless: is it running\? \(docker info\)$'
! grep '^run ' runtime.log
env RT_NO_INFO=
env DEVVM_RELEASE_RUNTIME=
# A mise.lock download from anywhere but Go's and GoReleaser's own
# publishers, over https, is refused before curl runs: a URL that starts
# with - would be curl's options (here -K, a config that copies a file),
# and neither http:// nor another host is the publisher's.
rm curl.log
env DEVVM_RELEASE_TEST_FILE_URLS=
exec bash lockurl.sh -K$WORK/curlrc
! exec repo/scripts/release.sh --head
stderr '^release: HEAD''s mise\.lock downloads go from ''-K\S+/curlrc'', not https://dl\.google\.com/go/$'
! exists exfil
exec git -C repo reset -q --hard HEAD~1
exec bash lockurl.sh http://dl.google.com/go/go1.linux-arm64.tar.gz
! exec repo/scripts/release.sh --head
stderr '^release: HEAD''s mise\.lock downloads go from ''http://dl\.google\.com/go/go1\.linux-arm64\.tar\.gz'', not https://dl\.google\.com/go/$'
exec git -C repo reset -q --hard HEAD~1
exec bash lockurl.sh https://dl.google.com.example/go/go1.linux-arm64.tar.gz
! exec repo/scripts/release.sh --head
stderr '^release: HEAD''s mise\.lock downloads go from ''https://dl\.google\.com\.example/go/go1\.linux-arm64\.tar\.gz'', not https://dl\.google\.com/go/$'
exec git -C repo reset -q --hard HEAD~1
exec bash lockurl.sh https://dl.google.com/go/../go1.linux-arm64.tar.gz
! exec repo/scripts/release.sh --head
stderr 'downloads go from ''https://dl\.google\.com/go/\.\./go1\.linux-arm64\.tar\.gz'', not https://dl\.google\.com/go/$'
exec git -C repo reset -q --hard HEAD~1
# Nor .. percent-encoded, which curl decodes: here from the tests' folder
# to secret, outside it.
env DEVVM_RELEASE_TEST_FILE_URLS=$WORK/tools
exec bash lockurl.sh file://$WORK/tools/%2e%2e/secret
! exec repo/scripts/release.sh --head
stderr '^release: HEAD''s mise\.lock downloads go from ''file:///\S+/tools/%2e%2e/secret'', not file:///\S+/tools/$'
exec git -C repo reset -q --hard HEAD~1
env DEVVM_RELEASE_TEST_FILE_URLS=
! exists curl.log
# file:// URLs, the tests' own, only from the folder that
# DEVVM_RELEASE_TEST_FILE_URLS names: not without it, nor with it set to
# anything but a folder, one that doesn't exist or /, nor from another
# folder.
! exec repo/scripts/release.sh --head
stderr '^release: HEAD''s mise\.lock downloads go from ''file:///\S+/tools/go\.tar\.gz'', not https://dl\.google\.com/go/$'
env DEVVM_RELEASE_TEST_FILE_URLS=1
! exec repo/scripts/release.sh --head
stderr '^release: HEAD''s mise\.lock downloads go from ''file:///\S+/tools/go\.tar\.gz'', not https://dl\.google\.com/go/$'
env DEVVM_RELEASE_TEST_FILE_URLS=$WORK/nowhere
! exec repo/scripts/release.sh --head
stderr '^release: HEAD''s mise\.lock downloads go from ''file:///\S+/tools/go\.tar\.gz'', not https://dl\.google\.com/go/$'
env DEVVM_RELEASE_TEST_FILE_URLS=/
! exec repo/scripts/release.sh --head
stderr '^release: HEAD''s mise\.lock downloads go from ''file:///\S+/tools/go\.tar\.gz'', not https://dl\.google\.com/go/$'
mkdir elsewhere
env DEVVM_RELEASE_TEST_FILE_URLS=$WORK/elsewhere
! exec repo/scripts/release.sh --head
stderr '^release: HEAD''s mise\.lock downloads go from ''file:///\S+/tools/go\.tar\.gz'', not file:///\S+/elsewhere/$'
env DEVVM_RELEASE_TEST_FILE_URLS=$WORK/tools
# A mise.lock with two go entries, even the same one twice: refused, not
# read for the last.
exec bash -c 'sed -n "/^\[\[tools\.go\]\]/,/^\[\[tools\.goreleaser\]\]/p" repo/mise.lock | sed "\$d" >> repo/mise.lock && git -C repo commit -qam two-gos'
! exec repo/scripts/release.sh --head
stderr '^release: HEAD''s mise\.lock has 2 go entries, not one$'
exec git -C repo reset -q --hard HEAD~1
# The build's repository holds the commit alone: no tags, though the repo
# has a stray one, no other branch's commits, and no files it shares with
# the repo, and its origin is devvm's on GitHub (log.want).
rm log
exec repo/scripts/release.sh --head
cmp log log.want
# What the build wrote is refused before it's copied, signed or kept when
# it holds anything but files and folders, so nothing here follows a link
# the container made; when its output folder is a link to another; and
# when a file in it is setuid, or writable by anyone, as a build under a
# rootful runtime could leave one of root's. Otherwise each copy is yours,
# 0755 or 0644, whatever the build's file was, and so is the signature
# written here, whatever your umask, such as Ubuntu's 0002.
env GR_OUT=private
exec bash -c 'umask 0002 && exec repo/scripts/release.sh --head'
exec bash modes.sh
cmp stdout modes.want
rm repo/dist
env GR_OUT=link
! exec repo/scripts/release.sh --head
stderr '^release: the build left leak, which isn''t a file or a folder: nothing is signed or kept$'
! exists repo/dist
env GR_OUT=swap
! exec repo/scripts/release.sh --head
stderr '^release: the build''s output folder isn''t the one it was given: nothing is signed or kept$'
! exists repo/dist
env GR_OUT=setuid
! exec repo/scripts/release.sh --head
stderr '^release: the build left su, which isn''t yours, or is setuid, setgid, sticky or writable by anyone: nothing is signed or kept$'
! exists repo/dist
env GR_OUT=writable
! exec repo/scripts/release.sh --head
stderr '^release: the build left notes, which isn''t yours, or is setuid, setgid, sticky or writable by anyone: nothing is signed or kept$'
! exists repo/dist
env GR_OUT=setgid
! exec repo/scripts/release.sh --head
stderr '^release: the build left sg, which isn''t yours, or is setuid, setgid, sticky or writable by anyone: nothing is signed or kept$'
! exists repo/dist
env GR_OUT=sticky
! exec repo/scripts/release.sh --head
stderr '^release: the build left tmp, which isn''t yours, or is setuid, setgid, sticky or writable by anyone: nothing is signed or kept$'
! exists repo/dist
env GR_OUT=writable-folder
! exec repo/scripts/release.sh --head
stderr '^release: the build left shared, which isn''t yours, or is setuid, setgid, sticky or writable by anyone: nothing is signed or kept$'
! exists repo/dist
# A file of another user's would be refused too, which a test can't make
# without root.
# Nor more than 2 GiB of files, which would fill dist/'s disk: here one
# sparse file a byte over.
env GR_OUT=big
! exec repo/scripts/release.sh --head
stderr '^release: the build left more than 2 GiB of files: nothing is signed or kept$'
! exists repo/dist
env GR_OUT=
# A build that runs past the time limit is stopped from here, its
# container removed by name, whatever its image does.
env DEVVM_RELEASE_TIMEOUT=2 GR_SLEEP=1
! exec repo/scripts/release.sh --head
stderr '^release: the build in docker\.io/\S+ ran for 2 seconds, the limit \(DEVVM_RELEASE_TIMEOUT\), so it was stopped$'
grep '^rm -f devvm-release-[A-Za-z0-9]+-2$' runtime.log
env DEVVM_RELEASE_TIMEOUT= GR_SLEEP=
# release.sh stopped mid-build stops its container: Ctrl+C (INT), a closed
# terminal (HUP) and kill (TERM) through its traps, at once, and kill -9
# through the watchdog, which outlives it. Each time the container is
# removed by name, its processes are gone, and so is the temp folder.
exec bash interrupt.sh INT
stderr '^exit 130$'
cmp stdout interrupt.want
exec bash interrupt.sh HUP
stderr '^exit 129$'
cmp stdout interrupt.want
exec bash interrupt.sh TERM
stderr '^exit 143$'
cmp stdout interrupt.want
exec bash interrupt.sh KILL
stderr '^exit 137$'
cmp stdout interrupt-kill.want
env DEVVM_RELEASE_TIMEOUT=x
! exec repo/scripts/release.sh --head
stderr '^release: DEVVM_RELEASE_TIMEOUT isn''t a number of seconds: ''x''$'
env DEVVM_RELEASE_TIMEOUT=
# The image and the build's own code are the commit's, never this
# checkout's: a release_image changed here changes neither. The modules'
# download, which only this checkout's code runs, is in this checkout's.
exec bash -c 'sed "s/^release_image=.*/release_image=docker.io\/library\/changed:x@sha256:$(printf %064d 0)/" repo/scripts/release.sh > rs && cat rs > repo/scripts/release.sh'
exec repo/scripts/release.sh --head
stdout '^==> downloading HEAD''s Go modules in docker\.io/library/changed:x@sha256:0{64}, under '
stdout '^==> building [0-9a-f]{40} in docker\.io/library/buildpack-deps:trixie-scm@sha256:[0-9a-f]{64}, under '
exec bash -c 'grep "^run " runtime.log | tail -1'
! stdout changed
exec bash -c 'git -C repo show HEAD:scripts/release.sh | cmp - container-release.sh'
exec git -C repo checkout -q scripts/release.sh
# So is its Go, this checkout's mise.lock's, never the commit's: here this
# checkout's names another Go, which logs its call as the checkout's. A
# commit whose go.mod needs a newer Go than that is refused before anything
# runs.
exec bash checkout-go.sh
rm go.log
exec repo/scripts/release.sh --head
cmp go.log go-checkout.want
exec git -C repo checkout -q mise.lock
exec bash -c 'printf ''module example.com/x\n\ngo 1.30.1\n'' > repo/go.mod && git -C repo commit -qam newer-go'
rm runtime.log
! exec repo/scripts/release.sh --head
stderr '^release: HEAD''s go\.mod needs Go 1\.30\.1, newer than the 1\.30\.0 this checkout''s mise\.lock pins: build it from a checkout at least as new$'
! grep '^run ' runtime.log
exec git -C repo reset -q --hard HEAD~1
# A commit whose release.sh pins no release_image, from before
# reproducible builds: refused.
exec bash -c 'sed "/^release_image=/d" repo/scripts/release.sh > rs && cat rs > repo/scripts/release.sh && git -C repo commit -qam no-image'
! exec repo/scripts/release.sh --head
stderr '^release: HEAD''s scripts/release\.sh pins no release_image by digest, so it''s from before reproducible builds: build it with its own scripts/release\.sh$'
exec git -C repo reset -q --hard HEAD~1
# --commit builds another commit, with its VERSION, by this checkout's
# release.sh: the commit's own runs only in the container. Here HEAD~1's
# would touch outside here, and its VERSION is 1.2.4.
exec bash outside.sh
exec repo/scripts/release.sh --commit HEAD~1
stdout '^==> dist/ for devvm 1\.2\.4 \(from HEAD~1\):$'
! exists outside
exec bash -c 'grep "^run " runtime.log | tail -1'
stdout ' _build 1\.2\.4 [0-9a-f]{40} '
exec bash -c 'git -C repo show HEAD~1:scripts/release.sh | cmp - container-release.sh'
! exec repo/scripts/release.sh --commit
stderr '^release: --commit needs one commit$'
! exec repo/scripts/release.sh --commit no-such-commit
stderr '^release: no commit no-such-commit$'
# A HEAD without install.sh: refused too.
exec bash -c 'git -C repo rm -q install.sh && git -C repo commit -qam no-install'
! exec repo/scripts/release.sh --head
stderr '^release: no install.sh in HEAD$'
-- repo.sh --
# A repo with release.sh, the formula, an install.sh to fill in, VERSION
# 1.2.3, go.mod and go.sum, and a mise.lock pinning a Go and this test's
# goreleaser (tools.sh), a stray tag, a branch whose commit is in
# other.sha, and a file that isn't committed.
set -eu
mkdir -p repo/scripts repo/packaging/homebrew keys
cp "$DEVVM_REPO/scripts/release.sh" repo/scripts/
cp "$DEVVM_REPO/packaging/homebrew/devvm.rb" repo/packaging/homebrew/
echo 1.2.3 > repo/VERSION
printf 'module example.com/x\n\ngo 1.22\n' > repo/go.mod
: > repo/go.sum
printf '#!/bin/sh\nrelease_version=""\nminisign_key=""\n' > repo/install.sh
bash tools.sh > repo/mise.lock
git -C repo init -q
git -C repo config user.email e@e
git -C repo config user.name e
git -C repo add -A
git -C repo commit -qm r
git -C repo tag v9.9.9
git -C repo checkout -q -b other
echo other > repo/other
git -C repo add other
git -C repo commit -qm other
git -C repo rev-parse HEAD > other.sha
git -C repo checkout -q -
touch repo/uncommitted
-- modes.sh --
# Each file's mode in dist/: the container's install.sh 0755, its 0600
# private 0644, the rest 0644 too, the signature written here 0644, and
# folders 0755, with no other mode: any other is named as one.
cd repo/dist
find . -type f -name install.sh -perm 0755
find . -type f -name private -perm 0644
find . -type f -name SHA256SUMS -perm 0644
find . -type f -name SHA256SUMS.minisig -perm 0644
find . ! -perm 0755 ! -perm 0644 | sed 's/^/other mode: /'
find . -type d ! -perm 0755 | sed 's/^/folder not 0755: /'
-- modes.want --
./install.sh
./private
./SHA256SUMS
./SHA256SUMS.minisig
-- user.sh --
# The user the last build's container ran as: root, you, or its --user.
u=$(grep '^run ' runtime.log | tail -1 | sed -n 's/.* --user \([^ ]*\) .*/\1/p')
case $u in
0:0) echo root ;;
"$(id -u):$(id -g)") echo you ;;
*) echo "${u:-none}" ;;
esac
-- lockurl.sh --
# mise.lock's go downloads from $1, committed, with nothing in the cache,
# and curlrc, a curl config that would copy secret to exfil.
set -eu
echo secret > secret
printf 'upload-file = "%s/secret"\nurl = "file://%s/exfil"\n' "$PWD" "$PWD" > curlrc
awk -v u="$1" '/^\[tools\.go\./ { g = 1 } /^\[tools\.goreleaser\./ { g = 0 }
g && $1 == "url" { $0 = "url = \"" u "\"" } { print }' repo/mise.lock > lock
cat lock > repo/mise.lock
git -C repo commit -qam "go from $1"
rm -rf cache
-- outside.sh --
# HEAD~1: VERSION 1.2.4, and a release.sh that touches outside when it
# runs outside its container; HEAD: back to HEAD~2.
set -eu
awk '{ print } /^root=/ { print "touch \"$WORK/outside\"" }' repo/scripts/release.sh > rs
cat rs > repo/scripts/release.sh
echo 1.2.4 > repo/VERSION
git -C repo commit -qam outside
git -C repo revert --no-edit HEAD >/dev/null
-- interrupt.sh --
# A build that never ends, with release.sh sent signal $1 once its build's
# goreleaser runs; its exit status on stderr, then whether it ended within
# 10 seconds, whether its own trap stopped the container, and what's left: whether the container
# was removed by name, whether goreleaser is gone, and whether release.sh's
# temp folder is. Job control (-m), so release.sh doesn't start with INT
# ignored, as a background job would.
set -mu
rm -f runtime.log gr.pid
GR_SLEEP=1 repo/scripts/release.sh --head > interrupt.log 2>&1 &
pid=$!
i=0
until [[ -s gr.pid ]] || ((i++ > 300)); do sleep 0.1; done
SECONDS=0
kill -s "$1" "$pid"
wait "$pid"
echo "exit $?" >&2
((SECONDS < 10)) && echo prompt
gr=$(cat gr.pid)
i=0
while { kill -0 "$gr" 2>/dev/null || compgen -G "${TMPDIR:-/tmp}/devvm-release.*" >/dev/null; } && ((i++ < 100)); do sleep 0.1; done
grep -q '^release: stopping the container devvm-release-[A-Za-z0-9]*-2$' interrupt.log && echo trapped
grep -q '^rm -f devvm-release-[A-Za-z0-9]*-2$' runtime.log && echo removed
kill -0 "$gr" 2>/dev/null || echo gone
compgen -G "${TMPDIR:-/tmp}/devvm-release.*" >/dev/null || echo clean
-- interrupt.want --
prompt
trapped
removed
gone
clean
-- interrupt-kill.want --
prompt
removed
gone
clean
-- checkout-go.sh --
# This checkout's mise.lock, uncommitted, names another Go, which logs its
# call as the checkout's.
set -eu
mkdir -p tools/checkout/go/bin
sed 's/^echo "go /echo "checkout go /' go > tools/checkout/go/bin/go
chmod 755 tools/checkout/go/bin/go
tar -czf tools/checkout-go.tar.gz -C tools/checkout go
sum=$({ sha256sum tools/checkout-go.tar.gz 2>/dev/null || shasum -a 256 tools/checkout-go.tar.gz; } | cut -c1-64)
awk -v u="file://$PWD/tools/checkout-go.tar.gz" -v c="sha256:$sum" '/^\[tools\.go\./ { g = 1 } /^\[tools\.goreleaser\./ { g = 0 }
g && $1 == "url" { $0 = "url = \"" u "\"" } g && $1 == "checksum" { $0 = "checksum = \"" c "\"" } { print }' repo/mise.lock > lock
cat lock > repo/mise.lock
-- go-checkout.want --
checkout go mod download GOPROXY=https://proxy.golang.org GOVCS=*:off GOWORK=off in go.mod,go.sum
-- bin/curl --
#!/bin/bash
# Logs its arguments, then runs the system's curl.
echo "$*" >> "$WORK/curl.log"
PATH=${PATH#"$WORK/bin:"} exec curl "$@"
-- go-in.want --
go.mod
go.sum
go.tar.gz
release.sh
-- go.want --
go mod download GOPROXY=https://proxy.golang.org GOVCS=*:off GOWORK=off in go.mod,go.sum
-- go --
#!/bin/sh
# Go, downloading modules: it logs its call, its proxy, and the files in
# its folder, then downloads one module's go.mod into the module cache.
echo "go $* GOPROXY=$GOPROXY GOVCS=$GOVCS GOWORK=$GOWORK in $(ls | paste -sd, -)" >> "$WORK/go.log"
mkdir -p "$GOMODCACHE/cache/download/example.com/m/@v"
echo 'module example.com/m' > "$GOMODCACHE/cache/download/example.com/m/@v/v1.0.0.mod"
-- tools.sh --
# A mise.lock's go and goreleaser, for both Linux processors: tarballs of
# go (above) and of bin/goreleaser, by file URL and SHA-256.
set -eu
mkdir -p tools/go/bin
cp go tools/go/bin/go
chmod 755 tools/go/bin/go
tar -czf tools/go.tar.gz -C tools go
tar -czf tools/goreleaser.tar.gz -C bin goreleaser
for t in go goreleaser; do
sum=$({ sha256sum "tools/$t.tar.gz" 2>/dev/null || shasum -a 256 "tools/$t.tar.gz"; } | cut -c1-64)
printf '[[tools.%s]]\nversion = "1.30.0"\n\n' "$t"
for p in linux-arm64 linux-x64; do
printf '[tools.%s."platforms.%s"]\nchecksum = "sha256:%s"\nurl = "file://%s"\n\n' "$t" "$p" "$sum" "$PWD/tools/$t.tar.gz"
done
done
-- bin/podman --
#!/bin/bash
# A container runtime, here: podman, or Docker when it's called docker, or
# podman behind a docker command with RT_PODMAN=1. It logs its arguments.
# --version says which, and info whether it's rootless: RT_ROOTLESS, else
# true for podman and false for Docker; with RT_NO_INFO=1 it can't. run
# runs --entrypoint, then the command, with each -v's container folder
# replaced by its host folder, in -w's folder, with each -e's variable set
# and RT_OUT set to /out's host folder, and keeps its pid by --name, for
# rm -f NAME, which ends it and everything it started. A --name has to be
# devvm-release-<suffix>-<n>, where release.sh's temp folder, which is
# new for each run, is devvm-release.<suffix>. What /in holds goes in
# go-in.log, and its release.sh in container-modules.sh.
set -eu
echo "$*" >> "$WORK/runtime.log"
podman=true
[[ ${0##*/} != docker || -n ${RT_PODMAN:-} ]] || podman=false
tree() { local c; for c in $(pgrep -P "$1"); do tree "$c"; done; kill -9 "$1" 2>/dev/null || true; }
case $1 in
--version)
if $podman; then echo 'podman version 5.6.0'; else echo 'Docker version 28.5.1, build e180ab8'; fi
exit 0 ;;
info)
[[ -z ${RT_NO_INFO:-} ]] || exit 1
case $podman,$3 in
'true,{{.Host.Security.Rootless}}') echo "${RT_ROOTLESS:-true}" ;;
'false,{{json .SecurityOptions}}')
o='"name=seccomp,profile=builtin"'
[[ ${RT_ROOTLESS:-false} != true ]] || o+=',"name=rootless"'
echo "[$o]" ;;
*) echo "info: no fake for $*" >&2; exit 1 ;;
esac
exit 0 ;;
rm)
[[ $2 == -f ]] || { echo "runtime: no fake for $*" >&2; exit 1; }
[[ ! -f $WORK/run-$3.pid ]] || tree "$(cat "$WORK/run-$3.pid")"
exit 0 ;;
run) ;;
*) echo "runtime: no fake for $*" >&2; exit 1 ;;
esac
shift
from=() to=() dir= entry=()
while [[ $1 == -* ]]; do
case $1 in
--rm) shift ;;
--platform | --user | --security-opt | --cap-drop | --pids-limit | --memory | --network) shift 2 ;;
--name)
s=${2#devvm-release-}
[[ -d ${TMPDIR:-/tmp}/devvm-release.${s%-*} ]] || { echo "runtime: --name $2 isn't its run's" >&2; exit 1; }
echo $$ > "$WORK/run-$2.pid"; shift 2 ;;
--entrypoint) entry=("$2"); shift 2 ;;
-v)
IFS=: read -r h c _ <<<"$2"; from+=("$c"); to+=("$h")
[[ $c != /out ]] || export RT_OUT=$h
[[ $c != /in ]] || { ls "$h" > "$WORK/go-in.log"; cp "$h/release.sh" "$WORK/container-modules.sh"; }
shift 2 ;;
-w) dir=$2; shift 2 ;;
-e) export "${2?}"; shift 2 ;;
*) echo "runtime: no fake for $1" >&2; exit 1 ;;
esac
done
shift
set -- ${entry[@]+"${entry[@]}"} "$@"
map() {
local a=$1 i
for i in "${!from[@]}"; do [[ $a != "${from[i]}"* ]] || a=${to[i]}${a#"${from[i]}"}; done
printf '%s' "$a"
}
args=()
for a in "$@"; do args+=("$(map "$a")"); done
cd "$(map "$dir")"
exec "${args[@]}"
-- key.sh --
# install.sh's key is the test key's.
grep "^minisign_key=\"$(sed -n 2p keys/test.pub)\"$" repo/dist/install.sh >/dev/null && echo trusted
-- key.want --
trusted
-- sums.sh --
# The signed SHA256SUMS has install.sh's checksum, as it's written in
# dist/, so you can check the script before you run it.
cd repo/dist
{ sha256sum -c --ignore-missing SHA256SUMS 2>/dev/null || shasum -a 256 -c --ignore-missing SHA256SUMS; } | grep '^install.sh'
-- sums.want --
install.sh: OK
-- formula.sh --
# Formula $1's each platform's URL, and the checksum after it, against each
# archive's own and SHA256SUMS's line for it.
f=repo/dist/$1
grep -A1 '^ url ' "$f" | grep -v '^--$' | sed -n 'N;s/\n/ /;p' | while read -r _ u _ s; do
u=${u//\"/}; s=${s//\"/}; a=${u##*/}
sha=$({ sha256sum 2>/dev/null || shasum -a 256; } < "repo/dist/$a" | cut -c1-64)
[ "$s" = "$sha" ] && grep -q "^$sha $a$" repo/dist/SHA256SUMS && echo "$u checksum"
done
# Nothing left to fill in, and the comments as the template has them.
grep -v '^#' "$f" | grep '@' || true
diff <(grep '^#' repo/packaging/homebrew/devvm.rb) <(grep '^#' "$f") && echo comments
-- formula.want --
https://github.com/devvmhq/devvm/releases/download/v1.2.3/devvm-1.2.3-darwin-arm64.tar.gz checksum
https://github.com/devvmhq/devvm/releases/download/v1.2.3/devvm-1.2.3-darwin-amd64.tar.gz checksum
https://github.com/devvmhq/devvm/releases/download/v1.2.3/devvm-1.2.3-linux-arm64.tar.gz checksum
https://github.com/devvmhq/devvm/releases/download/v1.2.3/devvm-1.2.3-linux-amd64.tar.gz checksum
comments
-- formulas.diff --
6c6
< class Devvm < Formula
---
> class DevvmRc < Formula
35c35
< conflicts_with "devvmhq/tap/devvm-rc", because: "both install the devvm binary"
---
> conflicts_with "devvmhq/tap/devvm", because: "both install the devvm binary"
-- sums.rc --
1111111111111111111111111111111111111111111111111111111111111111 devvm-1.3.0-rc.1-darwin-arm64.tar.gz
2222222222222222222222222222222222222222222222222222222222222222 devvm-1.3.0-rc.1-darwin-amd64.tar.gz
3333333333333333333333333333333333333333333333333333333333333333 devvm-1.3.0-rc.1-linux-arm64.tar.gz
4444444444444444444444444444444444444444444444444444444444444444 devvm-1.3.0-rc.1-linux-amd64.tar.gz
-- devvm-rc.want --
class DevvmRc < Formula
desc "Isolated Lima VM per project folder, with shared read-only toolchains"
homepage "https://github.com/devvmhq/devvm"
license "MIT"
depends_on "lima"
on_macos do
on_arm do
url "https://github.com/devvmhq/devvm/releases/download/v1.3.0-rc.1/devvm-1.3.0-rc.1-darwin-arm64.tar.gz"
sha256 "1111111111111111111111111111111111111111111111111111111111111111"
end
on_intel do
url "https://github.com/devvmhq/devvm/releases/download/v1.3.0-rc.1/devvm-1.3.0-rc.1-darwin-amd64.tar.gz"
sha256 "2222222222222222222222222222222222222222222222222222222222222222"
end
end
on_linux do
on_arm do
url "https://github.com/devvmhq/devvm/releases/download/v1.3.0-rc.1/devvm-1.3.0-rc.1-linux-arm64.tar.gz"
sha256 "3333333333333333333333333333333333333333333333333333333333333333"
end
on_intel do
url "https://github.com/devvmhq/devvm/releases/download/v1.3.0-rc.1/devvm-1.3.0-rc.1-linux-amd64.tar.gz"
sha256 "4444444444444444444444444444444444444444444444444444444444444444"
end
end
conflicts_with "devvmhq/tap/devvm", because: "both install the devvm binary"
def install
bin.install "devvm"
end
test do
assert_equal version.to_s, shell_output("#{bin}/devvm --version").strip
end
end
-- log.want --
release --clean --skip=publish --snapshot DEVVM_VERSION=1.2.3 GORELEASER_CURRENT_TAG= tags= refs= other=absent shared=0 origin=https://github.com/devvmhq/devvm.git proxy=./example.com/m/@v/v1.0.0.mod
-- bin/goreleaser --
#!/bin/bash
# Logs its call, with what its repository holds: its tags and refs, whether
# it has the other branch's commit, how many of its files are linked to
# others, and its origin, which GoReleaser needs. It copies the build's own release.sh to container-release.sh, and
# writes a dist/ like GoReleaser's: each system's and processor's build, a
# script printing $GR_VERSION, else $DEVVM_VERSION, the Linux archives, the
# source tarball and SHA256SUMS. With $GR_FAIL, it fails, and with
# $GR_SLEEP, it never ends, its pid in gr.pid. GR_OUT writes to the
# container's /out ($RT_OUT) as a build could: link, a link; swap, /out
# itself a link to another folder; setuid, a file of mode 4755; setgid,
# one of mode 2755; writable, one of mode 0666; private, one of mode 0600;
# sticky, a folder of mode 1755; writable-folder, one of mode 0777; big, a
# sparse file a byte over 2 GiB.
set -eu
echo "$* DEVVM_VERSION=$DEVVM_VERSION GORELEASER_CURRENT_TAG=${GORELEASER_CURRENT_TAG:-}" \
"tags=$(git tag -l | paste -sd, -) refs=$(git for-each-ref --format='%(refname)' | paste -sd, -)" \
"other=$(git cat-file -t "$(cat "$WORK/other.sha")" 2>/dev/null || echo absent)" \
"shared=$(find .git/objects -type f -links +1 | wc -l | tr -d ' ')" \
"origin=$(git remote get-url origin 2>/dev/null || echo none)" \
"proxy=$(cd "${GOPROXY#file://}" && find . -type f | paste -sd, -)" >> "$WORK/log"
cp ../release.sh "$WORK/container-release.sh"
[[ -z ${GR_FAIL:-} ]] || exit 1
[[ -z ${GR_SLEEP:-} ]] || { echo $$ > "$WORK/gr.pid"; sleep 60; }
rm -rf dist
for os in darwin linux; do
for a in arm64 amd64; do
mkdir -p "dist/devvm_${os}_$a"
printf '#!/bin/sh\necho %s\n' "${GR_VERSION:-$DEVVM_VERSION}" > "dist/devvm_${os}_$a/devvm"
chmod 755 "dist/devvm_${os}_$a/devvm"
done
done
for os in darwin linux; do
for a in arm64 amd64; do
mkdir -p "dist/x/devvm-$DEVVM_VERSION-$os-$a"
cp "dist/devvm_${os}_$a/devvm" "dist/x/devvm-$DEVVM_VERSION-$os-$a/devvm"
tar -czf "dist/devvm-$DEVVM_VERSION-$os-$a.tar.gz" -C dist/x "devvm-$DEVVM_VERSION-$os-$a"
done
done
rm -rf dist/x
git archive --prefix="devvm-$DEVVM_VERSION/" HEAD | gzip -n > "dist/devvm-$DEVVM_VERSION.tar.gz"
(cd dist && { sha256sum devvm-*.tar.gz 2>/dev/null || shasum -a 256 devvm-*.tar.gz; } > SHA256SUMS)
case ${GR_OUT:-} in
link) ln -s "$WORK/secret" dist/leak ;;
swap) mkdir -p "$WORK/victim" && rm -rf "$RT_OUT" && ln -s "$WORK/victim" "$RT_OUT" ;;
setuid) printf '#!/bin/sh\n' > "$RT_OUT/su" && chmod 4755 "$RT_OUT/su" ;;
writable) printf 'x\n' > "$RT_OUT/notes" && chmod 666 "$RT_OUT/notes" ;;
private) printf 'x\n' > "$RT_OUT/private" && chmod 600 "$RT_OUT/private" ;;
setgid) printf '#!/bin/sh\n' > "$RT_OUT/sg" && chmod 2755 "$RT_OUT/sg" ;;
sticky) mkdir "$RT_OUT/tmp" && chmod 1755 "$RT_OUT/tmp" ;;
writable-folder) mkdir "$RT_OUT/shared" && chmod 777 "$RT_OUT/shared" ;;
big) dd if=/dev/null of="$RT_OUT/big" bs=1 seek=$(((2 << 30) + 1)) count=0 2>/dev/null ;;
esac