From f7cca17a9e6e5b9e8be996768cd7beb9f2e3b5a5 Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Sun, 27 Sep 2026 21:33:04 +0000 Subject: [PATCH 1/2] Soften yay go-mod caches and warn on AUR update failure Go leaves module-cache trees read-only under yay's srcdir, so the next rebuild fails. Soften those trees before yay and warn instead of failing the whole update (#13334). Co-authored-by: AnPod --- bin/omarchy-update-aur-pkgs | 20 ++++++++- test/shell.d/update-aur-pkgs-test.sh | 66 ++++++++++++++++++++++++++++ 2 files changed, 85 insertions(+), 1 deletion(-) create mode 100755 test/shell.d/update-aur-pkgs-test.sh diff --git a/bin/omarchy-update-aur-pkgs b/bin/omarchy-update-aur-pkgs index a860a97d3083..830a5331e844 100755 --- a/bin/omarchy-update-aur-pkgs +++ b/bin/omarchy-update-aur-pkgs @@ -9,10 +9,28 @@ if [[ ${OMARCHY_SUDO_NO_UPDATE:-0} == "1" ]]; then sudo_options=(--sudo "$sudo_wrapper" --sudoloop=false) fi +# Go leaves module-cache trees read-only (dr-xr-xr-x). PKGBUILDs that set +# GOMODCACHE under $srcdir then fail on the next rebuild when makepkg cannot +# remove the previous $srcdir. Make those trees writable so --cleanafter and +# the next build can delete them (#13334). +writable_yay_go_mod_caches() { + local yay_cache="${XDG_CACHE_HOME:-$HOME/.cache}/yay" + [[ -d $yay_cache ]] || return 0 + local go_mod + while IFS= read -r -d '' go_mod; do + chmod -R u+w -- "$go_mod" 2>/dev/null || true + done < <(find "$yay_cache" -type d -path '*/src/go-mod' -print0 2>/dev/null) +} + if pacman -Qem >/dev/null; then if omarchy-pkg-aur-accessible; then echo -e "\e[32m\nUpdate AUR packages\e[0m" - yay "${sudo_options[@]}" -Sua --noconfirm --cleanafter --ignore gcc14,gcc14-libs || exit 1 + writable_yay_go_mod_caches + if ! yay "${sudo_options[@]}" -Sua --noconfirm --cleanafter --ignore gcc14,gcc14-libs; then + # System packages and migrations already finished. One user AUR package + # that fails to rebuild must not paint the whole update as a failure. + echo -e "\e[33mAUR package update failed; system packages were updated. Fix the failing AUR package and rerun, or update it with yay directly.\e[0m" >&2 + fi echo else echo -e "\e[31m\nAUR is unavailable (so skipping updates)\e[0m" diff --git a/test/shell.d/update-aur-pkgs-test.sh b/test/shell.d/update-aur-pkgs-test.sh new file mode 100755 index 000000000000..bfd8222d570a --- /dev/null +++ b/test/shell.d/update-aur-pkgs-test.sh @@ -0,0 +1,66 @@ +#!/bin/bash + +set -euo pipefail + +source "$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)/base-test.sh" + +TMPDIR=$(mktemp -d) +trap 'chmod -R u+w "$TMPDIR" 2>/dev/null || true; rm -rf "$TMPDIR"' EXIT + +STUB_DIR="$TMPDIR/stub" +mkdir -p "$STUB_DIR" "$TMPDIR/cache/yay/hyprmoncfg/src/go-mod/github.com/pkg" "$TMPDIR/home" + +# Simulate Go's read-only module cache left from a previous yay build. +touch "$TMPDIR/cache/yay/hyprmoncfg/src/go-mod/github.com/pkg/LICENSE" +chmod a-w "$TMPDIR/cache/yay/hyprmoncfg/src/go-mod/github.com/pkg/LICENSE" +chmod a-w "$TMPDIR/cache/yay/hyprmoncfg/src/go-mod/github.com/pkg" +chmod a-w "$TMPDIR/cache/yay/hyprmoncfg/src/go-mod" + +cat >"$STUB_DIR/pacman" <<'STUB' +#!/bin/bash +[[ $1 == "-Qem" ]] || exit 90 +exit 0 +STUB + +cat >"$STUB_DIR/omarchy-pkg-aur-accessible" <<'STUB' +#!/bin/bash +exit 0 +STUB + +cat >"$STUB_DIR/yay" <<'STUB' +#!/bin/bash +printf 'yay %s\n' "$*" >>"$FAKE_CALLS" +exit 1 +STUB + +chmod +x "$STUB_DIR"/* + +FAKE_CALLS="$TMPDIR/calls" +export FAKE_CALLS +: >"$FAKE_CALLS" + +aur_pkgs=$(cat "$ROOT/bin/omarchy-update-aur-pkgs") +[[ $aur_pkgs == *'writable_yay_go_mod_caches'* ]] || fail "AUR update must soften read-only yay go-mod caches" +[[ $aur_pkgs == *'src/go-mod'* ]] || fail "AUR update must look for go-mod trees under yay's cache" +[[ $aur_pkgs != *'yay '* ]] || true +if grep -Eq 'yay .*\|\| exit 1' <<<"$aur_pkgs"; then + fail "AUR update must not abort the whole update on yay failure" +fi +[[ $aur_pkgs == *'AUR package update failed'* ]] || fail "AUR update must warn when yay fails" +pass "AUR update softens go-mod caches and warns instead of aborting" + +HOME="$TMPDIR/home" \ + XDG_CACHE_HOME="$TMPDIR/cache" \ + PATH="$STUB_DIR:$PATH" \ + OMARCHY_PATH="$ROOT" \ + bash "$ROOT/bin/omarchy-update-aur-pkgs" >"$TMPDIR/out" 2>"$TMPDIR/err" || fail "AUR helper exited non-zero" "$(cat "$TMPDIR/err")" + +grep -q 'yay ' "$FAKE_CALLS" || fail "AUR helper did not invoke yay" "$(cat "$FAKE_CALLS")" +pass "AUR helper still runs yay when foreign packages are installed" + +[[ -w $TMPDIR/cache/yay/hyprmoncfg/src/go-mod ]] || fail "go-mod cache stayed read-only" +[[ -w $TMPDIR/cache/yay/hyprmoncfg/src/go-mod/github.com/pkg/LICENSE ]] || fail "go-mod file stayed read-only" +pass "read-only yay go-mod caches become writable before yay" + +grep -q 'AUR package update failed' "$TMPDIR/err" || fail "yay failure was not reported as a warning" "$(cat "$TMPDIR/err")" +pass "yay failure is reported without failing the update" From 113310e773e3d27a5776e432e1b5a9a2f4f39de6 Mon Sep 17 00:00:00 2001 From: "andrej@podgorsek.de" Date: Wed, 7 Oct 2026 15:38:15 +0000 Subject: [PATCH 2/2] Cover Go cache layouts and notify on failed AUR updates --- bin/omarchy-update-aur-pkgs | 8 +- test/shell.d/update-aur-pkgs-test.sh | 110 +++++++++++++-------------- 2 files changed, 58 insertions(+), 60 deletions(-) diff --git a/bin/omarchy-update-aur-pkgs b/bin/omarchy-update-aur-pkgs index 830a5331e844..fd8dffe66d8e 100755 --- a/bin/omarchy-update-aur-pkgs +++ b/bin/omarchy-update-aur-pkgs @@ -19,17 +19,19 @@ writable_yay_go_mod_caches() { local go_mod while IFS= read -r -d '' go_mod; do chmod -R u+w -- "$go_mod" 2>/dev/null || true - done < <(find "$yay_cache" -type d -path '*/src/go-mod' -print0 2>/dev/null) + done < <(find "$yay_cache" -type d \( -path '*/src/go-mod' -o -path '*/pkg/mod' \) -print0 2>/dev/null) } if pacman -Qem >/dev/null; then if omarchy-pkg-aur-accessible; then echo -e "\e[32m\nUpdate AUR packages\e[0m" writable_yay_go_mod_caches - if ! yay "${sudo_options[@]}" -Sua --noconfirm --cleanafter --ignore gcc14,gcc14-libs; then + if ! GOFLAGS="${GOFLAGS:+$GOFLAGS }-modcacherw" yay "${sudo_options[@]}" -Sua --noconfirm --cleanafter --ignore gcc14,gcc14-libs; then # System packages and migrations already finished. One user AUR package # that fails to rebuild must not paint the whole update as a failure. - echo -e "\e[33mAUR package update failed; system packages were updated. Fix the failing AUR package and rerun, or update it with yay directly.\e[0m" >&2 + echo -e "\e[33mAUR package update failed. Review the output, fix the failing package, and rerun yay.\e[0m" >&2 + omarchy-notification-send --app-name "Omarchy Update" -u normal \ + "AUR update needs attention" "Some AUR packages failed to update. Review the terminal output and rerun yay after fixing the failing package." || true fi echo else diff --git a/test/shell.d/update-aur-pkgs-test.sh b/test/shell.d/update-aur-pkgs-test.sh index bfd8222d570a..35c7cbd856fc 100755 --- a/test/shell.d/update-aur-pkgs-test.sh +++ b/test/shell.d/update-aur-pkgs-test.sh @@ -1,66 +1,62 @@ #!/bin/bash set -euo pipefail - source "$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)/base-test.sh" -TMPDIR=$(mktemp -d) -trap 'chmod -R u+w "$TMPDIR" 2>/dev/null || true; rm -rf "$TMPDIR"' EXIT - -STUB_DIR="$TMPDIR/stub" -mkdir -p "$STUB_DIR" "$TMPDIR/cache/yay/hyprmoncfg/src/go-mod/github.com/pkg" "$TMPDIR/home" - -# Simulate Go's read-only module cache left from a previous yay build. -touch "$TMPDIR/cache/yay/hyprmoncfg/src/go-mod/github.com/pkg/LICENSE" -chmod a-w "$TMPDIR/cache/yay/hyprmoncfg/src/go-mod/github.com/pkg/LICENSE" -chmod a-w "$TMPDIR/cache/yay/hyprmoncfg/src/go-mod/github.com/pkg" -chmod a-w "$TMPDIR/cache/yay/hyprmoncfg/src/go-mod" - -cat >"$STUB_DIR/pacman" <<'STUB' +test_tmp=$(mktemp -d) +trap 'chmod -R u+w "$test_tmp" 2>/dev/null || true; rm -rf "$test_tmp"' EXIT +mkdir -p "$test_tmp/bin" "$test_tmp/home" +export FAKE_CALLS="$test_tmp/calls" FAKE_NOTIFICATIONS="$test_tmp/notifications" +for layout in hyprmoncfg/src/go-mod standard/src/pkg/mod nested/src/gopath/pkg/mod; do + mkdir -p "$test_tmp/cache/yay/$layout/module" + touch "$test_tmp/cache/yay/$layout/module/LICENSE" + chmod -R a-w "$test_tmp/cache/yay/$layout" +done +cat >"$test_tmp/bin/pacman" <<'SH' #!/bin/bash [[ $1 == "-Qem" ]] || exit 90 -exit 0 -STUB - -cat >"$STUB_DIR/omarchy-pkg-aur-accessible" <<'STUB' +exit "${TEST_NO_AUR:-0}" +SH +cat >"$test_tmp/bin/omarchy-pkg-aur-accessible" <<'SH' #!/bin/bash -exit 0 -STUB - -cat >"$STUB_DIR/yay" <<'STUB' +exit "${TEST_AUR_UNAVAILABLE:-0}" +SH +cat >"$test_tmp/bin/yay" <<'SH' #!/bin/bash -printf 'yay %s\n' "$*" >>"$FAKE_CALLS" -exit 1 -STUB - -chmod +x "$STUB_DIR"/* - -FAKE_CALLS="$TMPDIR/calls" -export FAKE_CALLS -: >"$FAKE_CALLS" - -aur_pkgs=$(cat "$ROOT/bin/omarchy-update-aur-pkgs") -[[ $aur_pkgs == *'writable_yay_go_mod_caches'* ]] || fail "AUR update must soften read-only yay go-mod caches" -[[ $aur_pkgs == *'src/go-mod'* ]] || fail "AUR update must look for go-mod trees under yay's cache" -[[ $aur_pkgs != *'yay '* ]] || true -if grep -Eq 'yay .*\|\| exit 1' <<<"$aur_pkgs"; then - fail "AUR update must not abort the whole update on yay failure" -fi -[[ $aur_pkgs == *'AUR package update failed'* ]] || fail "AUR update must warn when yay fails" -pass "AUR update softens go-mod caches and warns instead of aborting" - -HOME="$TMPDIR/home" \ - XDG_CACHE_HOME="$TMPDIR/cache" \ - PATH="$STUB_DIR:$PATH" \ - OMARCHY_PATH="$ROOT" \ - bash "$ROOT/bin/omarchy-update-aur-pkgs" >"$TMPDIR/out" 2>"$TMPDIR/err" || fail "AUR helper exited non-zero" "$(cat "$TMPDIR/err")" - -grep -q 'yay ' "$FAKE_CALLS" || fail "AUR helper did not invoke yay" "$(cat "$FAKE_CALLS")" -pass "AUR helper still runs yay when foreign packages are installed" - -[[ -w $TMPDIR/cache/yay/hyprmoncfg/src/go-mod ]] || fail "go-mod cache stayed read-only" -[[ -w $TMPDIR/cache/yay/hyprmoncfg/src/go-mod/github.com/pkg/LICENSE ]] || fail "go-mod file stayed read-only" -pass "read-only yay go-mod caches become writable before yay" - -grep -q 'AUR package update failed' "$TMPDIR/err" || fail "yay failure was not reported as a warning" "$(cat "$TMPDIR/err")" -pass "yay failure is reported without failing the update" +printf '%s\n%s\n' "$GOFLAGS" "$*" >>"$FAKE_CALLS" +exit "${TEST_YAY_STATUS:-1}" +SH +cat >"$test_tmp/bin/omarchy-notification-send" <<'SH' +#!/bin/bash +printf '%s\n' "$*" >>"$FAKE_NOTIFICATIONS" +exit "${TEST_NOTIFICATION_STATUS:-0}" +SH +chmod +x "$test_tmp/bin/"* +run() { + : >"$FAKE_CALLS" + : >"$FAKE_NOTIFICATIONS" + HOME="$test_tmp/home" XDG_CACHE_HOME="$test_tmp/cache" PATH="$test_tmp/bin:$PATH" OMARCHY_PATH="$ROOT" \ + bash "$ROOT/bin/omarchy-update-aur-pkgs" >"$test_tmp/out" 2>"$test_tmp/err" +} +GOFLAGS='-trimpath -tags=custom' run || fail "failed AUR build stays nonfatal" +[[ $(head -1 "$FAKE_CALLS") == '-trimpath -tags=custom -modcacherw' ]] || fail "yay receives existing Go flags plus writable-cache flag" +for layout in hyprmoncfg/src/go-mod standard/src/pkg/mod nested/src/gopath/pkg/mod; do + for path in "$test_tmp/cache/yay/$layout" "$test_tmp/cache/yay/$layout/module/LICENSE"; do + mode=$(stat -c %a "$path") + (( (8#$mode & 0200) != 0 )) || fail "Go cache remains read-only: $layout" + done +done +pass "all supported Go cache layouts become writable and GOFLAGS are preserved" +grep -q 'AUR package update failed' "$test_tmp/err" || fail "AUR failure prints a terminal warning" +grep -q 'AUR update needs attention' "$FAKE_NOTIFICATIONS" || fail "AUR failure sends a desktop notification" +pass "failed AUR update remains visible without aborting" +TEST_NOTIFICATION_STATUS=1 run || fail "notification failure must not abort the update" +pass "failed desktop notification leaves the terminal warning and remains nonfatal" +GOFLAGS='' TEST_YAY_STATUS=0 run || fail "successful AUR update succeeds" +[[ $(head -1 "$FAKE_CALLS") == '-modcacherw' && ! -s $FAKE_NOTIFICATIONS && ! -s $test_tmp/err ]] || fail "successful update adds flag without warning" +pass "successful AUR update emits no failure notification" +TEST_NO_AUR=1 run +[[ ! -s $FAKE_CALLS && ! -s $FAKE_NOTIFICATIONS ]] || fail "no foreign packages skips yay" +TEST_AUR_UNAVAILABLE=1 run +[[ ! -s $FAKE_CALLS && ! -s $FAKE_NOTIFICATIONS ]] || fail "unavailable AUR skips yay" +pass "missing packages and unavailable AUR do not report a build failure"