Files
omarchycn/migrations/1785944594.sh
T
b85ae70ebd Stop pipefail from turning grep -q SIGPIPE exits into false negatives (#6614)
* Stop pipefail from turning grep -q SIGPIPE exits into false negatives

grep -q exits at the first match, and when the producer is still writing
it dies with SIGPIPE. Under pipefail that 141 becomes the pipeline's
status, so hardware checks like lspci | grep -q read as "not found" on
exactly the machines they target. The T2 defaults migration hit this and
silently skipped real T2 Macs (#6608).

Redirect grep to /dev/null instead of -q wherever a pipeline feeds grep
in a pipefail context, so grep reads all input and the producer never
gets killed. The install-time T2 checks aren't run under pipefail today
but are switched too, since they're the same detection line the issue
calls out.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* Re-run the T2 defaults migration its broken hardware check skipped

The SIGPIPE bug marked 1785944594 as applied without doing anything on
affected T2 Macs. The original migration is idempotent, so a fresh
migration can just source it now that the guard is fixed.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* Address Copilot review: fix OCR grep pipeline and prove the T2 repair

screen_contains piped tesseract into grep -Fqi under the acceptance
suite's pipefail, the same SIGPIPE false negative the rest of the branch
fixes. The T2 test's lspci stub now keeps writing past the pipe buffer
after the match so every scenario exercises the SIGPIPE case, and a new
case runs the rerun migration against fixtures a bitten install would
have.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
2026-08-07 23:43:49 +02:00

58 lines
1.9 KiB
Bash

echo "Update T2 Mac suspend, Touch Bar, and fan defaults"
if ! lspci -nn | grep "106b:180[12]" >/dev/null; then
exit 0
fi
limine_conf="${OMARCHY_T2_LIMINE_CONF:-/etc/limine-entry-tool.d/t2-mac.conf}"
fan_conf="${OMARCHY_T2_FAN_CONF:-/etc/t2fand.conf}"
running_cmdline="${OMARCHY_T2_RUNNING_CMDLINE:-/proc/cmdline}"
repair_marker="${OMARCHY_T2_REPAIR_MARKER:-/var/lib/omarchy/migrations/1785944594}"
needs_limine_rebuild=0
if [[ -f $limine_conf ]] && grep -q 'pcie_ports=compat' "$limine_conf"; then
sudo sed -i \
's/pcie_ports=compat/pm_async=off mem_sleep_default=deep/' \
"$limine_conf"
needs_limine_rebuild=1
fi
# t2fanrd reads one section per detected fan and fails when a section is
# missing. Extra sections are ignored, so this also remains safe on one-fan
# models.
if [[ -f $fan_conf ]] && ! grep -Eq '^[[:space:]]*\[Fan2\][[:space:]]*$' "$fan_conf"; then
sudo tee -a "$fan_conf" >/dev/null <<'EOF'
[Fan2]
low_temp=55
high_temp=75
speed_curve=linear
always_full_speed=false
EOF
fi
# The kernel's built-in Boot Camp-style Touch Bar works without tiny-dfr. The
# optional daemon holds stale device descriptors across suspend with t2bce.
if omarchy-pkg-present tiny-dfr; then
sudo systemctl disable --now tiny-dfr.service || true
omarchy-pkg-drop tiny-dfr
fi
# The current kernel keeps its old command line until reboot. Record a
# successful machine-wide rebuild so another user's migration does not repeat
# it before then, while a missing marker still retries an interrupted rebuild.
if [[ -f $limine_conf ]] &&
[[ ! -e $repair_marker ]] &&
grep -q 'pm_async=off' "$limine_conf" &&
grep -q 'mem_sleep_default=deep' "$limine_conf" &&
{ [[ ! -r $running_cmdline ]] ||
! grep -Eq '(^| )pm_async=off( |$)' "$running_cmdline" ||
! grep -Eq '(^| )mem_sleep_default=deep( |$)' "$running_cmdline"; }; then
needs_limine_rebuild=1
fi
if (( needs_limine_rebuild )); then
sudo limine-mkinitcpio
sudo install -Dm644 /dev/null "$repair_marker"
fi