mirror of
https://github.com/devvmhq/devvm.git
synced 2026-12-01 21:36:40 -10:00
Prereleases now reach the Homebrew tap through a second formula, `devvm-rc`. The stable `devvm` formula stays on the last final release. Co-authored-by: Claude Opus 5.5 <[email protected]>
597 lines
20 KiB
Plaintext
597 lines
20 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. No key in the script: no signature
|
|
# checked.
|
|
exec bash fresh.sh
|
|
cmp stdout fresh.want
|
|
stderr '^install: this install.sh has no release key \(not from a release\), so the signature isn''t 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 signature.
|
|
exec bash signed.sh 'good RWTESTKEY'
|
|
stdout '^==> signature checked$'
|
|
! exec bash signed.sh 'good RWOTHERKEY'
|
|
stderr '^install: devvm''s SHA256SUMS isn''t signed with the release key: not installed$'
|
|
! exists prefix/bin/devvm
|
|
! exists prefix/lib/devvm/0.1.0
|
|
|
|
# Without minisign it says how to check by hand, and installs.
|
|
exec bash no_minisign.sh
|
|
stderr '^install: minisign isn''t installed, so devvm''s signature isn''t checked, only its checksum$'
|
|
stderr '^ to check it yourself: minisign -Vm SHA256SUMS -P RWTESTKEY$'
|
|
stdout '^0.1.0$'
|
|
|
|
# A release without a signature file isn't installed.
|
|
! exec bash signed.sh ''
|
|
stderr '^install: couldn''t download devvm 0.1.0''s signature \(SHA256SUMS.minisig\)$'
|
|
! exists prefix/bin/devvm
|
|
|
|
# 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 '^==> signature checked$'
|
|
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'
|
|
! exec bash prerelease.sh --no-deps --version 0.2.0-rc.1
|
|
stderr '^install: devvm''s SHA256SUMS isn''t signed with the release key: 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"
|
|
# 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 SIG: a release whose SHA256SUMS.minisig reads SIG (none if
|
|
# empty), for a script that trusts RWTESTKEY.
|
|
. "$WORK/lib.sh"
|
|
release 0.1.0
|
|
[[ -z $1 ]] || echo "$1" > "$WORK/repo/releases/download/v0.1.0/SHA256SUMS.minisig"
|
|
minisign_key=RWTESTKEY
|
|
install_devvm 0.1.0
|
|
-- no_minisign.sh --
|
|
. "$WORK/lib.sh"
|
|
release 0.1.0
|
|
echo "good RWTESTKEY" > "$WORK/repo/releases/download/v0.1.0/SHA256SUMS.minisig"
|
|
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, and a prerelease,
|
|
# 0.2.0-rc.1, whose SHA256SUMS.minisig reads $SIG (default: good), for a
|
|
# script that trusts RWTESTKEY.
|
|
. "$WORK/lib.sh"
|
|
release 0.1.0
|
|
release 0.2.0-rc.1
|
|
echo "good RWTESTKEY" > "$WORK/repo/releases/download/v0.1.0/SHA256SUMS.minisig"
|
|
echo "${SIG:-good RWTESTKEY}" > "$WORK/repo/releases/download/v0.2.0-rc.1/SHA256SUMS.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" verifies
|
|
# with -P KEY.
|
|
while (($#)); do case $1 in -x) sig=$2; shift ;; -P) key=$2; shift ;; esac; shift; done
|
|
[[ "$(cat "$sig")" == "good $key" ]]
|
|
-- 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"
|