Files
omarchy-pkgs/tests/voxtype-bin-install.sh
T
eee77d5a38 voxtype-bin: update to 1.1.0 (#640)
* voxtype-bin: update to 1.1.0

Ship the signed 1.1.0 release assets, baseline and ARM binaries, and the complete Quickshell and OSD style trees. Add OpenVINO optional dependencies from #526 and select the baseline binary automatically on pre-AVX2 hosts.

* voxtype-bin: bump pkgrel past the published 1.1.0-1

voxtype-bin 1.1.0-1 is already published to edge, rc and stable from master's upstream sync. This branch changes that package's contents (baseline binary, OSD styles and recipes, the install hook, OpenVINO optdepends) without changing its version, so publish.yml would call it already published and skip it, and publish-artifact refuses different bytes under an existing filename. pacman would not offer it as an upgrade either.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* voxtype-bin: list accelerator optdepends for x86_64 only

makepkg appends optdepends_$CARCH to optdepends rather than replacing it, so optdepends_aarch64 did not drop the Vulkan, CUDA, ROCm and MIGraphX entries on aarch64: it listed all sixteen shared ones and then eleven of them a second time. The accelerator runtimes move to optdepends_x86_64 beside the OpenVINO ones, and the aarch64 array goes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* voxtype-bin: move pre-AVX2 hosts to the baseline build on upgrade

The baseline pick in _set_default_backend only runs when no backend was saved, which is a fresh install. Every release before 1.1.0 gave a CPU without AVX2 voxtype-avx2, and pre_upgrade saves that path, so post_upgrade restored the build the host cannot run and the machines the baseline binary exists for never reached it. A saved AVX2 or AVX-512 build whose instruction set the CPU lacks is now picked again; GPU and ONNX choices are left alone.

tests/voxtype-bin-install.sh covers the fresh-install pick and the upgrade cases, and runs with the other self-tests. It borrows the hook's fixed /tmp/.voxtype-backend-upgrade, so it refuses to start when anything is already there, a dangling symlink included: CI runs it as root, and writing through a planted link would land outside the test.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Codex XHigh <noreply@openai.com>

* tests: keep voxtype-bin-install's upgrade state out of /tmp

The test borrowed the hook's /tmp/.voxtype-backend-upgrade and checked it was free only once, so a real voxtype-bin upgrade writing its state during the run could have that state overwritten or deleted, and the hook would then lose the user's backend. The test now redefines the sourced _preserve_or_set_backend with the path moved into its own directory, and fails outright if the hook stops using that path rather than passing without reading it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Codex XHigh <noreply@openai.com>

* tests: never parse voxtype-bin-install's temp path as code

The redefined _preserve_or_set_backend went through eval with the mktemp path pasted in, so a TMPDIR holding shell syntax -- a directory named $HOME, or $(...) -- was expanded or run when the function was called. It now carries a reference to $SAVED, which expands to the path only at run time.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Codex XHigh <noreply@openai.com>

---------

Co-authored-by: Spencer Bull <spencer@omarchy.org>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Codex XHigh <noreply@openai.com>
2026-09-27 23:55:23 -05:00

69 lines
2.6 KiB
Bash
Executable File

#!/bin/bash
# voxtype-bin.install: a host gets a Whisper CPU build it can run, on a fresh
# install and on an upgrade from a release that had no baseline build.
set -euo pipefail
REPO_ROOT=$(realpath "${BASH_SOURCE[0]%/*}/..")
INSTALL_SCRIPT="$REPO_ROOT/pkgbuilds/voxtype-bin/voxtype-bin.install"
TEST_ROOT=$(mktemp -d)
SAVED="$TEST_ROOT/backend-upgrade"
trap 'rm -rf "$TEST_ROOT"' EXIT
fail() {
echo "not ok - $1" >&2
exit 1
}
pass() {
echo "ok - $1"
}
# shellcheck source=/dev/null
source "$INSTALL_SCRIPT"
# The hook keeps upgrade state in /tmp, where a real upgrade's could be; move
# it into the test directory.
eval "$(declare -f _preserve_or_set_backend | sed 's|/tmp/\.voxtype-backend-upgrade|${SAVED}|')"
declare -f _preserve_or_set_backend | grep -qF '${SAVED}' ||
fail "the hook no longer keeps its upgrade state at /tmp/.voxtype-backend-upgrade"
cpu_flags=""
_cpu_has() { [[ " $cpu_flags " == *" $1 "* ]]; }
_install_active_binary() { printf '%s\n' "$1" >"$TEST_ROOT/active"; }
uname() { echo x86_64; }
# What an earlier release left behind: its saved backends are real files.
mkdir -p "$TEST_ROOT/lib"
touch "$TEST_ROOT/lib/voxtype-avx2" "$TEST_ROOT/lib/voxtype-avx512" "$TEST_ROOT/lib/voxtype-vulkan"
fresh() {
local flags=$1 backend=$2 description=$3 out
cpu_flags=$flags
out=$(_set_default_backend)
[[ $out == "$backend" && $(<"$TEST_ROOT/active") == "/usr/lib/voxtype/voxtype-$backend" ]] ||
fail "$description: got $out -> $(<"$TEST_ROOT/active")"
pass "$description"
}
upgrade() {
local flags=$1 saved=$2 backend=$3 active=$4 description=$5 out
cpu_flags=$flags
printf '%s\n' "$saved" >"$SAVED"
out=$(_preserve_or_set_backend)
[[ $out == "$backend" && $(<"$TEST_ROOT/active") == "$active" ]] ||
fail "$description: got $out -> $(<"$TEST_ROOT/active")"
pass "$description"
}
fresh "sse4_2" baseline "a fresh install without AVX2 gets the baseline build"
fresh "sse4_2 avx2" avx2 "a fresh install with AVX2 gets the AVX2 build"
fresh "sse4_2 avx2 avx512f" avx512 "a fresh install with AVX-512 gets the AVX-512 build"
upgrade "sse4_2" "$TEST_ROOT/lib/voxtype-avx2" baseline /usr/lib/voxtype/voxtype-baseline \
"an upgrade without AVX2 moves off the AVX2 build an older release picked"
upgrade "sse4_2 avx2" "$TEST_ROOT/lib/voxtype-avx512" avx2 /usr/lib/voxtype/voxtype-avx2 \
"an upgrade without AVX-512 moves off the AVX-512 build"
upgrade "sse4_2 avx2" "$TEST_ROOT/lib/voxtype-avx2" avx2 "$TEST_ROOT/lib/voxtype-avx2" \
"an upgrade keeps a CPU build the host can run"
upgrade "sse4_2" "$TEST_ROOT/lib/voxtype-vulkan" vulkan "$TEST_ROOT/lib/voxtype-vulkan" \
"an upgrade keeps a GPU build the user chose"