mirror of
https://github.com/devvmhq/devvm.git
synced 2026-12-01 06:23:17 -10:00
devvm upgrade and install.sh accept a release's SHA256SUMS when any two
of three release keys signed it (CI's, the co-signer's and an offline
recovery key's), each in SHA256SUMS.<role>.minisig, checked only against
its own role's key, with the trusted comment devvm-release <version>
compared exactly; one signer counts once. While releases bridge from it,
the old release key's single SHA256SUMS.minisig (devvm <version>) still
passes alone, so 0.1 and 0.2 keep upgrading and --to/--version can
install them; install.sh now checks that key's trusted comment too.
The keys themselves aren't made yet, so packaging/keys holds none and
install.sh's three key lines are empty: a devvm built so checks each
release with the old release key alone, and a release that only the
release keys signed is refused. Releases go out as before, signed with
the old key, until the keys are made and added, all three at once.
- internal/minisign: the one owner of signature checks (moved from
internal/upgrade): ParsePublicKey, PublicKey.Check (comment always
compared), Role (CI, Cosign, Recovery), Kind (Release, Base),
Kind.Comment, SigName, KeyFile, Keys/NewKeys/Keys.Check (two of three,
distinct keys and key IDs). minisigntest/ signs for tests. Stdlib and
blake2b only (depguard), a leaf; FuzzCheck, FuzzKeysCheck,
FuzzParsePublicKey.
- The structure test's signatures rule: outside internal/minisign no
code calls ed25519/rsa/ecdsa's Verify functions or imports blake2b,
but signatureFree's files (ubuntu/pgp.go, proxy/nixcache.go).
- internal/upgrade: Source.Keys, checkSums (signatures.go); the bridge
in legacy.go (checkLegacy, legacyKey, Source.Key); FuzzSumOf.
- packaging/keys/release-{ci,cosign,recovery}.pub, none yet;
packaging.Key ("" without one). TestReleaseKeys (checkReleaseKeys:
none, or three distinct minisign keys, none the old key),
TestCheckReleaseKeys (fixture keys from minisigntest),
TestInstallScriptKeys (checkInstallScriptKeys: one line per role,
empty without keys), TestReleaseRefusesPlaceholders (no key in keys/
marked PLACEHOLDER).
- scripts/release.sh (a tag, --check, --tag; never a snapshot) needs
none or all three of packaging/keys' release keys. With none,
install.sh's release_<role>_key lines are empty or missing; with all
three, each is a minisign key, distinct, not the old release key, not
marked PLACEHOLDER (placeholder), and equal to its install.sh line.
- install.sh checks with minisign -VHQm: prehashed signatures only.
- The structure guard also flags dot imports of the verifier packages
and calls of x509's CheckSignature* method names.
- install.sh: release_<role>_key lines, download_signatures (a role's
signature only when the script has its key), check_signature,
signed_by_two, check_legacy; plainer warning without minisign, with
the commands to check by hand.
- Tests: signatures_test.go (TestFetchWithoutReleaseKeys among them),
upgrade.txtar (-legacy, -keys, and the keys built in, none),
install.txtar (stub minisign with -Q; NO_KEYS), install_minisign.txtar
(real minisign), release.txtar (none, nolines, nokeyline, old, marked
and the rest); DEVVM_RELEASE_KEYS override.
- Docs: internals/install.md, using/upgrading.md, maintaining.md's
Release keys, structure, tests, testing, SECURITY.md, CHANGELOG,
releases/0.2.0.md.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
694 lines
26 KiB
Plaintext
694 lines
26 KiB
Plaintext
# install.sh: the host and its archive, which release, the signature and
|
|
# checksum, where it goes, older versions, Lima, and the dependency fixes.
|
|
# Each case sources install.sh (lib.sh) and installs into $WORK/prefix from
|
|
# file:// releases under $WORK/repo; no fix runs for real.
|
|
env PATH=$WORK/bin:$PATH
|
|
chmod 755 bin/minisign
|
|
chmod 755 bin/brew
|
|
chmod 755 bin/sudo
|
|
|
|
# The host as archives name it: macOS or Linux, arm64 or x86_64; Apple
|
|
# silicon under Rosetta is arm64.
|
|
exec bash host.sh
|
|
cmp stdout host.want
|
|
env UN=Linux:riscv64
|
|
! exec bash bad_host.sh
|
|
stderr '^install: devvm runs on arm64 and x86_64 hosts, not riscv64$'
|
|
env UN=FreeBSD:arm64
|
|
! exec bash bad_host.sh
|
|
stderr '^install: devvm runs on macOS and Linux$'
|
|
env UN=
|
|
|
|
# Checksums with sha256sum or shasum, whichever the host has (Fedora has
|
|
# no shasum, macOS may have no sha256sum); with neither, it stops first.
|
|
! exec bash sums.sh
|
|
cmp stdout sums.want
|
|
stderr '^install: needs sha256sum or shasum$'
|
|
|
|
# Which release: --version, else this script's own, else the latest. A
|
|
# version goes into URLs and paths, so it has to look like one.
|
|
exec bash version.sh
|
|
cmp stdout version.want
|
|
|
|
# Downloads and redirects are HTTPS only.
|
|
exec bash fetch.sh
|
|
stdout '^--proto =https --proto-redir =https -fsSL -o x https://example.com/a$'
|
|
|
|
# A fix devvm suggests runs as words: no globs, no shell syntax.
|
|
exec bash run_fix.sh
|
|
stdout '^\* ;id$'
|
|
|
|
# This host's archive, checked and unpacked, the binary linked, older
|
|
# versions dropped. A script that isn't from a release, with no old
|
|
# release key, and a release with no signatures: only the checksum
|
|
# checked.
|
|
exec bash fresh.sh
|
|
cmp stdout fresh.want
|
|
stderr '^install: this install.sh isn''t from a release and devvm 0.1.0 has no signatures it can check, so only its checksum is checked$'
|
|
|
|
# Reinstalling the same version swaps it in, leaving nothing behind.
|
|
exec bash reinstall.sh
|
|
cmp stdout reinstall.want
|
|
|
|
# An older version a running process names (a VM's proxy) is kept.
|
|
exec bash in_use.sh
|
|
stdout '^==> keeping devvm 0.0.9: a running VM uses it$'
|
|
stdout '^left: 0.0.9 0.1.0$'
|
|
stdout '^ps: in use, not in use$'
|
|
|
|
# A release's install.sh checks SHA256SUMS's signatures: any two of the
|
|
# three release keys', each with its own role's key and the trusted
|
|
# comment devvm-release VERSION. testdata/script/install_minisign.txtar
|
|
# checks the same with the real minisign.
|
|
exec bash signed.sh 'good RWCI devvm-release 0.1.0' 'good RWCOSIGN devvm-release 0.1.0' '' ''
|
|
stdout '^==> signatures checked: two of devvm''s three release keys$'
|
|
exists prefix/bin/devvm
|
|
exec bash signed.sh 'good RWCI devvm-release 0.1.0' '' 'good RWRECOVERY devvm-release 0.1.0' ''
|
|
stdout '^==> signatures checked: two of devvm''s three release keys$'
|
|
exec bash signed.sh '' 'good RWCOSIGN devvm-release 0.1.0' 'good RWRECOVERY devvm-release 0.1.0' ''
|
|
stdout '^==> signatures checked: two of devvm''s three release keys$'
|
|
|
|
# Less than that isn't installed: one key's alone, one signed for
|
|
# another release, one with the old key's comment, one by another key,
|
|
# or two roles with one key, which counts once.
|
|
! exec bash signed.sh 'good RWCI devvm-release 0.1.0' '' '' ''
|
|
stderr '^install: devvm''s SHA256SUMS isn''t signed with devvm''s release keys: not installed$'
|
|
! exists prefix/bin/devvm
|
|
! exists prefix/lib/devvm/0.1.0
|
|
! exec bash signed.sh 'good RWCI devvm-release 0.1.0' 'good RWCOSIGN devvm-release 0.0.9' '' ''
|
|
stderr 'isn''t signed with devvm''s release keys: not installed$'
|
|
! exec bash signed.sh 'good RWCI devvm-release 0.1.0' 'good RWCOSIGN devvm 0.1.0' '' ''
|
|
stderr 'isn''t signed with devvm''s release keys: not installed$'
|
|
! exec bash signed.sh 'good RWCI devvm-release 0.1.0' 'good RWCI devvm-release 0.1.0' '' ''
|
|
stderr 'isn''t signed with devvm''s release keys: not installed$'
|
|
env SAME_KEY=1
|
|
! exec bash signed.sh 'good RWCI devvm-release 0.1.0' 'good RWCI devvm-release 0.1.0' '' ''
|
|
stderr 'isn''t signed with devvm''s release keys: not installed$'
|
|
env SAME_KEY=
|
|
! exists prefix/bin/devvm
|
|
|
|
# While releases bridge from the old release key, its signature alone
|
|
# installs too, with its trusted comment devvm VERSION, as 0.1 and 0.2's
|
|
# releases have it, and when the release keys' don't check out.
|
|
exec bash signed.sh '' '' '' 'good RWTESTKEY devvm 0.1.0'
|
|
stdout '^==> signature checked: devvm''s old release key$'
|
|
exec bash signed.sh 'good RWOTHER devvm-release 0.1.0' 'good RWOTHER2 devvm-release 0.1.0' '' 'good RWTESTKEY devvm 0.1.0'
|
|
stdout '^==> signature checked: devvm''s old release key$'
|
|
exec bash signed.sh 'good RWCI devvm-release 0.1.0' 'good RWCOSIGN devvm-release 0.1.0' '' 'good RWTESTKEY devvm 0.1.0'
|
|
stdout '^==> signatures checked: two of devvm''s three release keys$'
|
|
! exec bash signed.sh '' '' '' 'good RWOTHERKEY devvm 0.1.0'
|
|
stderr '^install: devvm''s SHA256SUMS isn''t signed with devvm''s release keys: not installed$'
|
|
! exec bash signed.sh '' '' '' 'good RWTESTKEY devvm 0.0.9'
|
|
stderr 'isn''t signed with devvm''s release keys: not installed$'
|
|
! exec bash signed.sh '' '' '' 'good RWTESTKEY devvm-release 0.1.0'
|
|
stderr 'isn''t signed with devvm''s release keys: not installed$'
|
|
! exists prefix/bin/devvm
|
|
|
|
# Without minisign it says that only the checksum is checked and how to
|
|
# check the signatures by hand, and installs.
|
|
exec bash no_minisign.sh
|
|
stderr '^install: minisign isn''t installed, so only devvm''s checksum is checked, which can''t tell who made the release$'
|
|
stderr '^ to check it yourself, two of these must each print "Trusted comment: devvm-release 0.1.0":$'
|
|
stderr '^ minisign -Vm SHA256SUMS -x SHA256SUMS.ci.minisig -P RWCI$'
|
|
stderr '^ minisign -Vm SHA256SUMS -x SHA256SUMS.cosign.minisig -P RWCOSIGN$'
|
|
! stderr 'recovery'
|
|
stdout '^0.1.0$'
|
|
exec bash no_minisign.sh legacy
|
|
stderr '^ to check it yourself, this must print "Trusted comment: devvm 0.1.0":$'
|
|
stderr '^ minisign -Vm SHA256SUMS -P RWTESTKEY$'
|
|
stdout '^0.1.0$'
|
|
|
|
# A release without its signature files isn't installed.
|
|
! exec bash signed.sh '' '' '' ''
|
|
stderr '^install: couldn''t download devvm 0.1.0''s signatures \(SHA256SUMS.ci.minisig, SHA256SUMS.cosign.minisig, SHA256SUMS.recovery.minisig or SHA256SUMS.minisig\)$'
|
|
! exists prefix/bin/devvm
|
|
|
|
# A script without the release keys, as before they're made, checks the
|
|
# old release key's signature alone: the release keys' signatures, good
|
|
# or not, never install without it, and never stop it.
|
|
env NO_KEYS=1
|
|
exec bash signed.sh 'good RWCI devvm-release 0.1.0' 'good RWCOSIGN devvm-release 0.1.0' '' 'good RWTESTKEY devvm 0.1.0'
|
|
stdout '^==> signature checked: devvm''s old release key$'
|
|
! stdout 'release keys'
|
|
exec bash signed.sh 'bad' 'bad' '' 'good RWTESTKEY devvm 0.1.0'
|
|
stdout '^==> signature checked: devvm''s old release key$'
|
|
! exec bash signed.sh 'good RWCI devvm-release 0.1.0' 'good RWCOSIGN devvm-release 0.1.0' 'good RWRECOVERY devvm-release 0.1.0' ''
|
|
stderr '^install: couldn''t download devvm 0.1.0''s signatures \(SHA256SUMS.minisig\)$'
|
|
! exists prefix/bin/devvm
|
|
! exec bash signed.sh 'good RWCI devvm-release 0.1.0' 'good RWCOSIGN devvm-release 0.1.0' '' 'good RWOTHERKEY devvm 0.1.0'
|
|
stderr '^install: devvm''s SHA256SUMS isn''t signed with devvm''s release key: not installed$'
|
|
! exec bash signed.sh 'good RWCI devvm-release 0.1.0' 'good RWCOSIGN devvm-release 0.1.0' '' 'good RWTESTKEY devvm-release 0.1.0'
|
|
stderr 'isn''t signed with devvm''s release key: not installed$'
|
|
! exists prefix/bin/devvm
|
|
exec bash no_minisign.sh
|
|
stderr '^ to check it yourself, this must print "Trusted comment: devvm 0.1.0":$'
|
|
! stderr 'SHA256SUMS.ci.minisig'
|
|
stdout '^0.1.0$'
|
|
env NO_KEYS=
|
|
|
|
# An archive that doesn't match its checksum, or none for this host:
|
|
# nothing installed.
|
|
! exec bash bad_sum.sh
|
|
stderr '^install: devvm-0.1.0-[a-z]+-[a-z0-9]+.tar.gz doesn''t match its checksum: not installed$'
|
|
! exists prefix/bin/devvm
|
|
! exists prefix/lib/devvm/0.1.0
|
|
! exec bash no_archive.sh
|
|
stderr '^install: couldn''t download devvm-0.1.0-[a-z]+-[a-z0-9]+.tar.gz$'
|
|
! exists prefix/bin/devvm
|
|
|
|
# Lima's latest release for this host, checked against its SHA256SUMS.
|
|
exec bash lima.sh
|
|
stdout '^==> installed Lima 2.3.0: \S+/prefix/bin/limactl$'
|
|
stdout '^limactl says 2.3.0$'
|
|
env UN=Linux:aarch64
|
|
exec bash lima.sh Linux-aarch64
|
|
stdout '^limactl says 2.3.0$'
|
|
env UN=
|
|
! exec bash lima.sh tampered
|
|
stderr '^install: lima-2.3.0-\S+.tar.gz doesn''t match its checksum: not installed$'
|
|
! exists prefix/bin/limactl
|
|
|
|
# The PATH hint, only when the prefix's bin isn't on PATH; on it, nothing
|
|
# when the devvm first on PATH is the one installed, by any link.
|
|
exec bash path_hint.sh
|
|
stdout '^ export PATH="\S+/prefix/bin:\$PATH"$'
|
|
stdout '^on PATH: $'
|
|
stdout '^linked: $'
|
|
! stderr .
|
|
|
|
# Another devvm before it on PATH: a warning naming it, never run.
|
|
exec bash path_hint.sh other
|
|
stderr '^install: another devvm comes first on your PATH: \S+/other/devvm$'
|
|
stderr '^ remove it, or put \S+/prefix/bin before its folder in PATH$'
|
|
! stderr 'isn''t on your PATH'
|
|
! exists other-ran
|
|
|
|
# The fixes devvm suggests run once allowed; what it can't fix is shown,
|
|
# its escapes read.
|
|
exec bash deps.sh yes fixes.json
|
|
stdout '^ /dev/kvm not found: turn on "virtualization" \\ in the firmware$'
|
|
stdout '^checked$'
|
|
cmp ran ran-fixes.want
|
|
|
|
# After joining the kvm group: log in again, no check.
|
|
exec bash deps.sh yes kvm.json
|
|
stdout 'Log out and back in'
|
|
! stdout '^checked$'
|
|
cmp ran ran-kvm.want
|
|
|
|
# Nothing runs without a yes.
|
|
exec bash deps.sh no kvm.json
|
|
stdout '^ skipped: sudo usermod -aG kvm me$'
|
|
! exists ran
|
|
|
|
# No Lima and no Homebrew: Lima's release, once allowed.
|
|
exec bash deps.sh lima lima.json
|
|
stdout '^==> installed Lima 2.3.0: '
|
|
exists prefix/bin/limactl
|
|
|
|
# Nothing missing, nothing asked.
|
|
exec bash deps.sh asked none.json
|
|
cmp stdout deps-none.want
|
|
|
|
# The whole script: options, a release, the PATH hint.
|
|
exec bash main.sh --no-deps --version v0.1.0
|
|
stdout '^==> installed devvm 0.1.0: \S+/prefix/bin/devvm$'
|
|
stdout 'isn''t on your PATH'
|
|
exec bash main.sh --help
|
|
stdout '^usage: install.sh \[--yes\] \[--version VERSION\] \[--no-deps\] \[--force\]$'
|
|
! exec bash main.sh --nope
|
|
stderr '^install: unknown option: --nope \(see --help\)$'
|
|
! exec bash main.sh --version
|
|
stderr '^install: --version needs a version$'
|
|
! exec bash main.sh --no-deps --version '1.2.3/../x'
|
|
stderr '^install: not a devvm version: ''1.2.3/../x''$'
|
|
|
|
# A prerelease, by --version or DEVVM_VERSION, checked as a release is;
|
|
# without either, the latest release, not the prerelease.
|
|
exec bash prerelease.sh --no-deps --version 0.2.0-rc.1
|
|
stdout '^==> signatures checked: two of devvm''s three release keys$'
|
|
stdout '^==> installed devvm 0.2.0-rc.1: \S+/prefix/bin/devvm$'
|
|
stdout '^runs 0.2.0-rc.1$'
|
|
env DEVVM_VERSION=v0.2.0-rc.1
|
|
exec bash prerelease.sh --no-deps
|
|
stdout '^==> installed devvm 0.2.0-rc.1: '
|
|
env DEVVM_VERSION=
|
|
exec bash prerelease.sh --no-deps
|
|
stdout '^==> installed devvm 0.1.0: '
|
|
env SIG='good RWOTHERKEY devvm-release 0.2.0-rc.1'
|
|
! exec bash prerelease.sh --no-deps --version 0.2.0-rc.1
|
|
stderr '^install: devvm''s SHA256SUMS isn''t signed with devvm''s release keys: not installed$'
|
|
env SIG=
|
|
|
|
# Homebrew's devvm, a keg in the Cellar next to the brew on PATH: the
|
|
# script stops before downloading anything, terminal or not, without
|
|
# running brew; --force installs a second copy.
|
|
mkdir Cellar/devvm/0.0.9
|
|
! exec bash main.sh --no-deps --version 0.1.0
|
|
stderr '^install: Homebrew installed devvm: run brew upgrade devvm to upgrade it, or brew uninstall devvm first to use this script \(--force installs a second copy\)$'
|
|
! stdout downloading
|
|
! exists prefix/bin/devvm
|
|
! exists ran
|
|
exec bash main.sh --no-deps --version 0.1.0 --force
|
|
stdout '^==> installed devvm 0.1.0: \S+/prefix/bin/devvm$'
|
|
rm Cellar/devvm/0.0.9
|
|
# devvm-rc's keg, the formula that follows prereleases, too.
|
|
mkdir Cellar/devvm-rc/0.1.0-rc.1
|
|
! exec bash main.sh --no-deps --version 0.1.0
|
|
stderr '^install: Homebrew installed devvm: run brew upgrade devvm-rc to upgrade it, or brew uninstall devvm-rc first to use this script \(--force installs a second copy\)$'
|
|
rm Cellar/devvm-rc/0.1.0-rc.1
|
|
# An empty rack isn't a keg.
|
|
exec bash main.sh --no-deps --version 0.1.0
|
|
stdout '^==> installed devvm 0.1.0: \S+/prefix/bin/devvm$'
|
|
# HOMEBREW_CELLAR's, HOMEBREW_PREFIX's and a usual prefix's Cellar.
|
|
mkdir cellar/devvm/0.0.9 hbprefix/Cellar/devvm/0.0.9 usual/Cellar/devvm/0.0.9
|
|
env HOMEBREW_CELLAR=$WORK/cellar
|
|
! exec bash main.sh --no-deps --version 0.1.0
|
|
stderr '^install: Homebrew installed devvm'
|
|
env HOMEBREW_CELLAR=
|
|
env HOMEBREW_PREFIX=$WORK/hbprefix
|
|
! exec bash main.sh --no-deps --version 0.1.0
|
|
stderr '^install: Homebrew installed devvm'
|
|
env HOMEBREW_PREFIX=
|
|
env BREW_PREFIXES=$WORK/usual
|
|
! exec bash main.sh --no-deps --version 0.1.0
|
|
stderr '^install: Homebrew installed devvm'
|
|
# No brew on PATH: no check.
|
|
exec bash nobrew.sh --no-deps --version 0.1.0
|
|
stdout '^==> installed devvm 0.1.0: \S+/prefix/bin/devvm$'
|
|
env BREW_PREFIXES=
|
|
! exists ran
|
|
|
|
# devvm itself, installed: its files are in it, and its own check (the
|
|
# sandbox's stubs) finds nothing missing; devvm doctor runs after it.
|
|
exec bash real.sh
|
|
stdout '^fzf$'
|
|
stdout '^==> everything devvm needs is installed$'
|
|
stdout '^doctor_ok backend=lima '
|
|
|
|
-- lib.sh --
|
|
# Sourced by each case: install.sh's functions, set to install into
|
|
# $WORK/prefix from file:// releases under $WORK/repo.
|
|
rm -rf "$WORK/prefix" "$WORK/repo" "$WORK/dl" "$WORK/build" "$WORK/ran"
|
|
# shellcheck source=/dev/null
|
|
DEVVM_INSTALL_TEST=1 source "$DEVVM_REPO/install.sh"
|
|
prefix=$WORK/prefix repo_url=file://$WORK/repo protos="=https,file"
|
|
# The release keys, as the stub minisign reads them; $SAME_KEY gives the
|
|
# co-signer CI's key, and $NO_KEYS none, as before the keys are made.
|
|
release_ci_key=RWCI release_cosign_key=RWCOSIGN release_recovery_key=RWRECOVERY
|
|
[[ -z ${SAME_KEY:-} ]] || release_cosign_key=RWCI
|
|
[[ -z ${NO_KEYS:-} ]] || release_ci_key="" release_cosign_key="" release_recovery_key=""
|
|
# Homebrew's usual prefixes: only $BREW_PREFIXES, never this host's.
|
|
brew_prefixes=()
|
|
[[ -z ${BREW_PREFIXES:-} ]] || brew_prefixes=("$BREW_PREFIXES")
|
|
mkdir -p "$WORK/dl"
|
|
tmp=$(mktemp -d "$WORK/dl/t.XXXXXX")
|
|
[[ $prefix == "$WORK/"* ]] || exit 1
|
|
# $UN (OS:ARCH) stands in for uname when set.
|
|
if [[ -n ${UN:-} ]]; then
|
|
uname() { case $1 in -s) echo "${UN%:*}" ;; -m) echo "${UN#*:}" ;; esac; }
|
|
fi
|
|
|
|
# release VERSION [CONTENT]: a release whose archive for this host holds a
|
|
# devvm printing CONTENT (default: VERSION) and a README.md.
|
|
release() {
|
|
local v=$1 d=$WORK/repo/releases/download/v$1 n
|
|
n=devvm-$v-$(platform)
|
|
mkdir -p "$d" "$WORK/build/$n"
|
|
printf '#!/bin/sh\necho %s\n' "${2:-$v}" > "$WORK/build/$n/devvm"
|
|
chmod 755 "$WORK/build/$n/devvm"
|
|
echo readme > "$WORK/build/$n/README.md"
|
|
tar -czf "$d/$n.tar.gz" -C "$WORK/build" "$n"
|
|
echo "$(sha256 "$d/$n.tar.gz") $n.tar.gz" > "$d/SHA256SUMS"
|
|
}
|
|
|
|
# lima_release VERSION [OS-ARCH]: a Lima release under $lima_url for this
|
|
# host (or OS-ARCH), with its SHA256SUMS, and the latest.
|
|
lima_release() {
|
|
local d=$WORK/lima/releases/download/v$1 w=$WORK/limabuild f
|
|
f=lima-$1-${2:-$(uname -s)-$(uname -m)}.tar.gz
|
|
rm -rf "$WORK/lima" "$w"
|
|
mkdir -p "$d" "$w/bin"
|
|
printf '#!/bin/sh\necho %s\n' "$1" > "$w/bin/limactl"
|
|
chmod 755 "$w/bin/limactl"
|
|
tar -czf "$d/$f" -C "$w" bin
|
|
{ echo "0000000000000000000000000000000000000000000000000000000000000000 lima-other.tar.gz"
|
|
echo "$(sha256 "$d/$f") $f"; } > "$d/SHA256SUMS"
|
|
lima_url=file://$WORK/lima
|
|
latest_lima=$1
|
|
latest_release() { [[ $1 == "$lima_url" ]] && echo "$latest_lima"; }
|
|
}
|
|
-- host.sh --
|
|
. "$WORK/lib.sh"
|
|
sysctl() { echo 0; }
|
|
for UN in Darwin:arm64 Darwin:x86_64 Linux:aarch64 Linux:arm64 Linux:x86_64; do
|
|
uname() { case $1 in -s) echo "${UN%:*}" ;; -m) echo "${UN#*:}" ;; esac; }
|
|
echo "$UN $(platform)"
|
|
done
|
|
UN=Darwin:x86_64
|
|
sysctl() { [[ $* == "-in hw.optional.arm64" ]] && echo 1; }
|
|
echo "rosetta $(platform)"
|
|
-- host.want --
|
|
Darwin:arm64 darwin-arm64
|
|
Darwin:x86_64 darwin-amd64
|
|
Linux:aarch64 linux-arm64
|
|
Linux:arm64 linux-arm64
|
|
Linux:x86_64 linux-amd64
|
|
rosetta darwin-arm64
|
|
-- bad_host.sh --
|
|
. "$WORK/lib.sh"
|
|
check_host
|
|
-- sums.sh --
|
|
# A PATH of only what check_host and sha256 run, and the made-up sums.
|
|
. "$WORK/lib.sh"
|
|
host=$PATH o=$WORK/only
|
|
mkdir -p "$o"
|
|
for c in cut uname curl tar; do ln -sf "$(command -v "$c")" "$o/$c"; done
|
|
chmod 755 "$WORK/sums/shasum" "$WORK/sums/sha256sum"
|
|
echo x > "$WORK/f"
|
|
ln -s "$WORK/sums/shasum" "$o/shasum"
|
|
PATH=$o; check_host; echo "shasum $(sha256 "$WORK/f")"; PATH=$host
|
|
ln -s "$WORK/sums/sha256sum" "$o/sha256sum"
|
|
PATH=$o; check_host; echo "both $(sha256 "$WORK/f")"; PATH=$host
|
|
rm "$o/shasum"
|
|
PATH=$o; check_host; echo "sha256sum $(sha256 "$WORK/f")"; PATH=$host
|
|
rm "$o/sha256sum"
|
|
PATH=$o; check_host; echo "not reached"
|
|
-- sums.want --
|
|
shasum aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
|
|
both bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
|
|
sha256sum bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
|
|
-- sums/shasum --
|
|
#!/bin/sh
|
|
# macOS's shasum -a 256 FILE, with a made-up sum.
|
|
[ "$1 $2" = "-a 256" ] || exit 1
|
|
echo "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa $3"
|
|
-- sums/sha256sum --
|
|
#!/bin/sh
|
|
# coreutils' sha256sum FILE, with a made-up sum.
|
|
echo "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb $1"
|
|
-- version.sh --
|
|
. "$WORK/lib.sh"
|
|
curl() { echo "https://github.com/devvmhq/devvm/releases/tag/v0.3.0"; }
|
|
version=v0.2.0 release_version=0.1.5
|
|
resolve_version
|
|
version=""
|
|
resolve_version
|
|
release_version=""
|
|
resolve_version
|
|
for v in 0.1.0 1.20.3 2.0.0-rc.1; do valid_version "$v" && echo "valid $v"; done
|
|
for v in "" 1.2 "1.2.3/../x" "1.2.3 x" "1.2.3';id"; do valid_version "$v" || echo "invalid '$v'"; done
|
|
curl() { echo "https://github.com/devvmhq/devvm/releases/tag/v1.2.3%2F..%2Fx"; }
|
|
(latest_release https://github.com/devvmhq/devvm) 2>/dev/null || echo "odd latest refused"
|
|
curl() { echo "https://github.com/devvmhq/devvm/releases/tag/v0.4.0-rc.1"; }
|
|
(latest_release https://github.com/devvmhq/devvm) 2>/dev/null || echo "prerelease latest refused"
|
|
-- version.want --
|
|
0.2.0
|
|
0.1.5
|
|
0.3.0
|
|
valid 0.1.0
|
|
valid 1.20.3
|
|
valid 2.0.0-rc.1
|
|
invalid ''
|
|
invalid '1.2'
|
|
invalid '1.2.3/../x'
|
|
invalid '1.2.3 x'
|
|
invalid '1.2.3';id'
|
|
odd latest refused
|
|
prerelease latest refused
|
|
-- fetch.sh --
|
|
. "$WORK/lib.sh"
|
|
curl() { echo "$*"; }
|
|
protos="=https"
|
|
fetch -o x https://example.com/a
|
|
-- run_fix.sh --
|
|
. "$WORK/lib.sh"
|
|
mkdir -p "$WORK/g"
|
|
cd "$WORK/g"
|
|
touch a b
|
|
run_fix "echo * ;id"
|
|
-- fresh.sh --
|
|
. "$WORK/lib.sh"
|
|
release 0.1.0
|
|
mkdir -p "$prefix/lib/devvm/0.0.9"
|
|
install_devvm 0.1.0 >/dev/null
|
|
[[ "$(readlink "$prefix/bin/devvm")" == "$prefix/lib/devvm/0.1.0/devvm" ]] && echo linked
|
|
"$prefix/bin/devvm"
|
|
cat "$prefix/lib/devvm/0.1.0/README.md"
|
|
ls -A "$prefix/lib/devvm"
|
|
-- fresh.want --
|
|
linked
|
|
0.1.0
|
|
readme
|
|
0.1.0
|
|
-- reinstall.sh --
|
|
. "$WORK/lib.sh"
|
|
release 0.1.0
|
|
install_devvm 0.1.0 >/dev/null 2>&1
|
|
mkdir -p "$prefix/lib/devvm/.0.0.5.new.1" # left by an interrupted install
|
|
release 0.1.0 again
|
|
install_devvm 0.1.0 >/dev/null 2>&1
|
|
[[ "$(readlink "$prefix/bin/devvm")" == "$prefix/lib/devvm/0.1.0/devvm" ]] && echo linked
|
|
"$prefix/bin/devvm"
|
|
ls -A "$prefix/lib/devvm"
|
|
-- reinstall.want --
|
|
linked
|
|
again
|
|
0.1.0
|
|
-- in_use.sh --
|
|
. "$WORK/lib.sh"
|
|
release 0.1.0
|
|
mkdir -p "$prefix/lib/devvm/0.0.9" "$prefix/lib/devvm/0.0.8"
|
|
ps() { echo "$prefix/lib/devvm/0.0.9/devvm _proxy -config /x/run/proxy.json"; }
|
|
install_devvm 0.1.0 2>/dev/null
|
|
echo "left: $(cd "$prefix/lib/devvm" && echo *)"
|
|
# The real ps sees a process naming a folder in its arguments.
|
|
unset -f ps
|
|
(exec -a "$prefix/lib/devvm/0.0.9/devvm" sleep 30) >/dev/null 2>&1 &
|
|
sleep 0.2
|
|
a=$(in_use "$prefix/lib/devvm/0.0.9" && echo "in use" || echo "not in use")
|
|
b=$(in_use "$prefix/lib/devvm/0.0.8" && echo "in use" || echo "not in use")
|
|
kill $!
|
|
echo "ps: $a, $b"
|
|
-- signed.sh --
|
|
# signed.sh CI COSIGN RECOVERY OLD: a release whose SHA256SUMS.ci.minisig,
|
|
# SHA256SUMS.cosign.minisig, SHA256SUMS.recovery.minisig and
|
|
# SHA256SUMS.minisig read each argument (none if it's empty), for a
|
|
# script whose old release key is RWTESTKEY.
|
|
. "$WORK/lib.sh"
|
|
release 0.1.0
|
|
d=$WORK/repo/releases/download/v0.1.0
|
|
n=0
|
|
for f in SHA256SUMS.ci.minisig SHA256SUMS.cosign.minisig SHA256SUMS.recovery.minisig SHA256SUMS.minisig; do
|
|
n=$((n + 1))
|
|
[[ -z ${!n} ]] || echo "${!n}" > "$d/$f"
|
|
done
|
|
minisign_key=RWTESTKEY
|
|
install_devvm 0.1.0
|
|
-- no_minisign.sh --
|
|
# no_minisign.sh [legacy]: a release signed by CI's and the co-signer's
|
|
# keys and the old release key, or with legacy by the old key alone, on a
|
|
# host without minisign.
|
|
. "$WORK/lib.sh"
|
|
release 0.1.0
|
|
d=$WORK/repo/releases/download/v0.1.0
|
|
echo "good RWTESTKEY devvm 0.1.0" > "$d/SHA256SUMS.minisig"
|
|
if [[ ${1:-} != legacy ]]; then
|
|
echo "good RWCI devvm-release 0.1.0" > "$d/SHA256SUMS.ci.minisig"
|
|
echo "good RWCOSIGN devvm-release 0.1.0" > "$d/SHA256SUMS.cosign.minisig"
|
|
fi
|
|
minisign_key=RWTESTKEY
|
|
command() { [[ $1 == -v && $2 == minisign ]] && return 1; builtin command "$@"; }
|
|
install_devvm 0.1.0 >/dev/null
|
|
"$prefix/bin/devvm"
|
|
-- bad_sum.sh --
|
|
. "$WORK/lib.sh"
|
|
release 0.1.0
|
|
f=$(cd "$WORK/repo/releases/download/v0.1.0" && echo devvm-*.tar.gz)
|
|
echo "0000000000000000000000000000000000000000000000000000000000000000 $f" \
|
|
> "$WORK/repo/releases/download/v0.1.0/SHA256SUMS"
|
|
install_devvm 0.1.0
|
|
-- no_archive.sh --
|
|
. "$WORK/lib.sh"
|
|
release 0.1.0
|
|
rm "$WORK/repo/releases/download/v0.1.0/"devvm-*.tar.gz
|
|
install_devvm 0.1.0
|
|
-- lima.sh --
|
|
# lima.sh [OS-ARCH|tampered]: Lima's release installed into the prefix.
|
|
. "$WORK/lib.sh"
|
|
case ${1:-} in
|
|
tampered)
|
|
lima_release 2.3.0
|
|
echo tampered >> "$WORK/lima/releases/download/v2.3.0/"lima-2.3.0-*.tar.gz ;;
|
|
*) lima_release 2.3.0 "${1:-}" ;;
|
|
esac
|
|
install_lima_tarball
|
|
echo "limactl says $("$prefix/bin/limactl")"
|
|
-- path_hint.sh --
|
|
# path_hint.sh [other]: the hint off PATH, then on it, after an install;
|
|
# other: a devvm that logs being run, before it on PATH.
|
|
. "$WORK/lib.sh"
|
|
release 0.1.0
|
|
install_devvm 0.1.0 >/dev/null 2>&1
|
|
rm -rf "$WORK/other" "$WORK/other-ran" "$WORK/links"
|
|
if [[ ${1:-} == other ]]; then
|
|
mkdir -p "$WORK/other"
|
|
printf '#!/bin/sh\ntouch "$WORK/other-ran"\n' > "$WORK/other/devvm"
|
|
chmod 755 "$WORK/other/devvm"
|
|
PATH="$WORK/other:$prefix/bin:$PATH" path_hint
|
|
exit
|
|
fi
|
|
path_hint
|
|
echo "on PATH: $(PATH="$prefix/bin:$PATH" path_hint)"
|
|
mkdir -p "$WORK/links"
|
|
ln -s "$prefix/lib/devvm/0.1.0/devvm" "$WORK/links/devvm"
|
|
echo "linked: $(PATH="$WORK/links:$prefix/bin:$PATH" path_hint)"
|
|
-- deps.sh --
|
|
# deps.sh ANSWER FILE: install_deps with a devvm whose doctor --json
|
|
# prints $WORK/FILE and whose doctor prints "checked"; the brew and sudo
|
|
# in bin/ log to $WORK/ran. ANSWER: yes (--yes), no (every question
|
|
# answered no), lima (yes, with a Lima release to install), asked (a
|
|
# question prints "asked").
|
|
. "$WORK/lib.sh"
|
|
mkdir -p "$WORK/fake"
|
|
printf '#!/bin/sh\n[ "$2" = --json ] && cat "$WORK/%s" || echo checked\n' "$2" > "$WORK/fake/devvm"
|
|
chmod 755 "$WORK/fake/devvm"
|
|
case $1 in
|
|
yes) yes=true ;;
|
|
no) ask() { return 1; } ;;
|
|
lima) yes=true; lima_release 2.3.0 ;;
|
|
asked) ask() { echo asked; } ;;
|
|
esac
|
|
install_deps "$WORK/fake/devvm"
|
|
-- fixes.json --
|
|
{
|
|
"version": 1,
|
|
"backend": "lima",
|
|
"problems": [
|
|
{
|
|
"key": "qemu",
|
|
"fix": "sudo apt-get install -y qemu-system-arm",
|
|
"message": "QEMU not found"
|
|
},
|
|
{
|
|
"key": "kvm",
|
|
"fix": null,
|
|
"message": "/dev/kvm not found: turn on \"virtualization\" \\ in the firmware"
|
|
},
|
|
{
|
|
"key": "lima",
|
|
"fix": "brew install lima",
|
|
"message": "Lima not found,"
|
|
}
|
|
],
|
|
"warnings": [],
|
|
"docker": false,
|
|
"features": {
|
|
"lima": {
|
|
"ssh": "native"
|
|
}
|
|
}
|
|
}
|
|
-- kvm.json --
|
|
{
|
|
"version": 1,
|
|
"backend": "lima",
|
|
"problems": [
|
|
{
|
|
"key": "kvm-access",
|
|
"fix": "sudo usermod -aG kvm me",
|
|
"message": "no access to /dev/kvm"
|
|
}
|
|
],
|
|
"warnings": [],
|
|
"docker": false,
|
|
"features": {}
|
|
}
|
|
-- lima.json --
|
|
{
|
|
"version": 1,
|
|
"backend": "lima",
|
|
"problems": [
|
|
{
|
|
"key": "lima",
|
|
"fix": null,
|
|
"message": "Lima not found"
|
|
}
|
|
],
|
|
"warnings": [],
|
|
"docker": false,
|
|
"features": {}
|
|
}
|
|
-- none.json --
|
|
{
|
|
"version": 1,
|
|
"backend": "lima",
|
|
"problems": [],
|
|
"warnings": [],
|
|
"docker": false,
|
|
"features": {}
|
|
}
|
|
-- deps-none.want --
|
|
==> everything devvm needs is installed
|
|
checked
|
|
-- ran-fixes.want --
|
|
sudo apt-get install -y qemu-system-arm
|
|
brew install lima
|
|
-- ran-kvm.want --
|
|
sudo usermod -aG kvm me
|
|
-- main.sh --
|
|
. "$WORK/lib.sh"
|
|
release 0.1.0
|
|
main "$@"
|
|
-- prerelease.sh --
|
|
# main.sh with a release, 0.1.0, the latest, signed by the old release
|
|
# key RWTESTKEY, and a prerelease, 0.2.0-rc.1, signed by CI's key, whose
|
|
# signature reads $SIG (default: good), and the co-signer's.
|
|
. "$WORK/lib.sh"
|
|
release 0.1.0
|
|
release 0.2.0-rc.1
|
|
echo "good RWTESTKEY devvm 0.1.0" > "$WORK/repo/releases/download/v0.1.0/SHA256SUMS.minisig"
|
|
echo "${SIG:-good RWCI devvm-release 0.2.0-rc.1}" > "$WORK/repo/releases/download/v0.2.0-rc.1/SHA256SUMS.ci.minisig"
|
|
echo "good RWCOSIGN devvm-release 0.2.0-rc.1" > "$WORK/repo/releases/download/v0.2.0-rc.1/SHA256SUMS.cosign.minisig"
|
|
minisign_key=RWTESTKEY
|
|
latest_release() { echo 0.1.0; }
|
|
main "$@"
|
|
echo "runs $("$prefix/bin/devvm")"
|
|
-- nobrew.sh --
|
|
# main.sh without a brew on PATH.
|
|
. "$WORK/lib.sh"
|
|
release 0.1.0
|
|
command() { if [[ $1 == -v && $2 == brew ]]; then return 1; fi; builtin command "$@"; }
|
|
main "$@"
|
|
-- real.sh --
|
|
# The devvm the tests built, alone, as a release.
|
|
. "$WORK/lib.sh"
|
|
n=devvm-1.2.3-$(platform)
|
|
d=$WORK/repo/releases/download/v1.2.3
|
|
mkdir -p "$d" "$WORK/build"
|
|
cp -R "$DEVVM_BIN" "$WORK/build/$n"
|
|
tar -czf "$d/$n.tar.gz" -C "$WORK/build" "$n"
|
|
echo "$(sha256 "$d/$n.tar.gz") $n.tar.gz" > "$d/SHA256SUMS"
|
|
install_devvm 1.2.3 >/dev/null 2>&1
|
|
cd "$WORK"
|
|
"$prefix/bin/devvm" __complete setup --features ''
|
|
install_deps "$prefix/lib/devvm/1.2.3/devvm"
|
|
-- bin/minisign --
|
|
#!/bin/bash
|
|
# Stand-in for minisign: a signature file reading "good KEY COMMENT"
|
|
# verifies with -P KEY, and with -Q (-VQm) it prints COMMENT, its trusted
|
|
# comment.
|
|
q=false
|
|
while (($#)); do case $1 in -x) sig=$2; shift ;; -P) key=$2; shift ;; -*Q*) q=true ;; esac; shift; done
|
|
read -r word k comment < "$sig" || true
|
|
[[ $word == good && $k == "$key" ]] || exit 1
|
|
! $q || echo "$comment"
|
|
-- bin/brew --
|
|
#!/bin/sh
|
|
# Stand-in for Homebrew: every command logs to $WORK/ran. Its Cellar is
|
|
# $WORK/Cellar, so a devvm keg is a folder in $WORK/Cellar/devvm.
|
|
echo "brew $*" >> "$WORK/ran"
|
|
-- bin/sudo --
|
|
#!/bin/sh
|
|
echo "sudo $*" >> "$WORK/ran"
|