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) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5
parent
38c1352f6d
commit
9174fbf851
+1
-1
@@ -37,7 +37,7 @@ fi
|
||||
cat > "$LOG_FILE" <<EOF
|
||||
Date: $(date)
|
||||
Hostname: $(hostname)
|
||||
Omarchy Package: $(pacman -Q omarchy 2>/dev/null || echo "unknown")
|
||||
Omarchy Package: $(pacman -Q omarchy-dev 2>/dev/null || pacman -Q omarchy 2>/dev/null || echo "unknown")
|
||||
|
||||
=========================================
|
||||
SYSTEM INFORMATION
|
||||
|
||||
@@ -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"
|
||||
|
||||
|
||||
+6
-1
@@ -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"
|
||||
|
||||
@@ -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"
|
||||
Reference in New Issue
Block a user