From 9174fbf8515f4c057c91071ec39af731602adb92 Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Wed, 29 Jul 2026 09:15:53 -0700 Subject: [PATCH] Recognize the omarchy-dev package in omarchy-version The edge channel installs omarchy-dev, but omarchy-version only queried omarchy, so it exited 1 there. omarchy-snapshot runs under set -e, so the failed lookup aborted the whole update over a snapshot label. It only worked at all because omarchy-dev declares provides=(omarchy) from the installer repo. Builds without it fail, so check both packages here instead of relying on a declaration from another tree. Co-Authored-By: Claude Opus 5 (1M context) --- bin/omarchy-debug | 2 +- bin/omarchy-snapshot | 3 +- bin/omarchy-version | 7 +++- test/shell.d/version-test.sh | 63 ++++++++++++++++++++++++++++++++++++ 4 files changed, 72 insertions(+), 3 deletions(-) create mode 100644 test/shell.d/version-test.sh diff --git a/bin/omarchy-debug b/bin/omarchy-debug index 237a07d7..59fbc4fc 100755 --- a/bin/omarchy-debug +++ b/bin/omarchy-debug @@ -37,7 +37,7 @@ fi cat > "$LOG_FILE" </dev/null || echo "unknown") +Omarchy Package: $(pacman -Q omarchy-dev 2>/dev/null || pacman -Q omarchy 2>/dev/null || echo "unknown") ========================================= SYSTEM INFORMATION diff --git a/bin/omarchy-snapshot b/bin/omarchy-snapshot index f173f1e1..261d1883 100755 --- a/bin/omarchy-snapshot +++ b/bin/omarchy-snapshot @@ -19,7 +19,8 @@ fi case "$COMMAND" in create) - DESC="$(omarchy-version)" + # The description is just a label, so never let it abort the snapshot. + DESC="$(omarchy-version 2>/dev/null || echo unknown)" echo -e "\e[32mCreate system snapshot\e[0m" diff --git a/bin/omarchy-version b/bin/omarchy-version index eaa203a6..40b10a34 100755 --- a/bin/omarchy-version +++ b/bin/omarchy-version @@ -17,7 +17,12 @@ if [[ $omarchy_path != "/usr/share/omarchy" ]]; then exit 0 fi -version=$(pacman -Q omarchy 2>/dev/null | awk '{ print $2 }') +# The edge channel installs omarchy-dev instead of omarchy, so check both. +for package in omarchy-dev omarchy; do + version=$(pacman -Q "$package" 2>/dev/null | awk '{ print $2 }') + [[ -n $version ]] && break +done + [[ -n $version ]] || exit 1 echo "$version" diff --git a/test/shell.d/version-test.sh b/test/shell.d/version-test.sh new file mode 100644 index 00000000..6b71d864 --- /dev/null +++ b/test/shell.d/version-test.sh @@ -0,0 +1,63 @@ +#!/bin/bash + +set -euo pipefail + +source "$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)/base-test.sh" + +test_tmp=$(mktemp -d) +trap 'rm -rf "$test_tmp"' EXIT + +stub_bin="$test_tmp/bin" +mkdir -p "$stub_bin" + +# The edge channel installs omarchy-dev. Older builds did not declare +# provides=(omarchy), so a query for plain omarchy finds nothing there. +cat >"$stub_bin/pacman" <<'STUB' +#!/bin/bash +[[ $1 == "-Q" ]] || exit 1 +shift +for package in "$@"; do + case ",${OMARCHY_TEST_PACKAGES:-}," in + *",$package,"*) + echo "$package ${OMARCHY_TEST_VERSION:-4.0.0-1}" + exit 0 + ;; + esac +done +echo "error: package '$1' was not found" >&2 +exit 1 +STUB +chmod +x "$stub_bin/pacman" + +version() { + OMARCHY_TEST_PACKAGES="$1" \ + OMARCHY_PATH="${2:-/usr/share/omarchy}" \ + PATH="$stub_bin:$PATH" \ + "$ROOT/bin/omarchy-version" +} + +[[ $(version omarchy) == "4.0.0-1" ]] || fail "version reports the stable package" +pass "version reports the stable package" + +[[ $(version omarchy-dev) == "4.0.0-1" ]] || fail "version reports the edge package" +pass "version reports the edge package" + +# A checkout reports its hash instead, so packages are irrelevant there. +[[ $(version "" "$test_tmp/checkout") == "dev" ]] || fail "version reports a dev checkout" +pass "version reports a dev checkout" + +if version "" >/dev/null 2>&1; then + fail "version fails when no Omarchy package is installed" +fi +pass "version fails when no Omarchy package is installed" + +# The snapshot description is only a label, so a failed lookup must not abort +# the update under set -e. +snapshot_desc=$( + set -e + PATH="$stub_bin:$PATH" OMARCHY_TEST_PACKAGES="" OMARCHY_PATH=/usr/share/omarchy \ + bash -c 'DESC="$(omarchy-version 2>/dev/null || echo unknown)"; echo "$DESC"' 2>/dev/null +) || fail "snapshot survives an unknown version" + +[[ $snapshot_desc == "unknown" ]] || fail "snapshot labels an unknown version" "actual: $snapshot_desc" +pass "snapshot survives an unknown version"