Files
omarchy/test/shell.d/synaptic-touchpad-test.sh
T
OmarchybotandClaude Opus 5 2b1d3c4606 Stop a psmouse quirk from failing every install (backport of #7236)
Backport of the synaptic touchpad quirk fix (PR #7236, merged to quattro as
20400bad) onto the v4-0-1 release branch, so 4.0.1 installs stop dying on it.

install/hardware/fix-synaptic-touchpad.sh calls modprobe against the running
kernel. On 4.0 the only thing that runs it is the ISO finalizer, inside
arch-chroot, where uname -r still names the live ISO's kernel while
/lib/modules holds the target's. The live ISO always boots linux-t2 and the
configurator gives every machine that is not a T2 Mac stock linux, so the two
never match: modprobe exits 1 with "Module psmouse not found in directory
/lib/modules/<live kernel>". run_logged returns that status and
omarchy-apply-hardware runs under set -euo pipefail, so a fresh install stops
on the first machine with a device named "synaptics" and no psmouse loaded --
reported from a ThinkPad in #6985, but nothing about it is Lenovo-specific.

Ask modprobe itself, with -qn, whether it can resolve psmouse for the running
kernel before asking it to load one, and warn instead of failing when it
declines for any other reason. The chroot mismatch becomes an unresolvable
module, skipped in silence. An optional touchpad improvement must not be able
to halt an install.

This does not make InterTouch reach the installed system: a module loaded into
the live kernel is gone at reboot, so on 4.0 this script has never applied
anything to an installed machine -- it only ever aborted installs. Persisting
it would mean writing options psmouse synaptics_intertouch=1 to
/etc/modprobe.d, which forces the SMBus transport past the kernel's own
allowlist on any touchpad merely named "synaptics". That is a
hardware-behaviour change on a wide class of machines, left as a separate
decision on quattro.

Clean cherry-pick: both files are byte-identical to #7236, so merging v4-0-1
into quattro resolves without a conflict. test/shell.d/synaptic-touchpad-test.sh
passes here, as does the rest of test/shell (183 files).

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018DEMYa9UWtroz93DhMTtcV
2026-08-24 15:37:29 +02:00

83 lines
2.6 KiB
Bash
Executable File

#!/bin/bash
set -euo pipefail
source "$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)/base-test.sh"
leaf="$ROOT/install/hardware/fix-synaptic-touchpad.sh"
all="$ROOT/install/hardware/all.sh"
grep -q 'run_logged .*hardware/fix-synaptic-touchpad.sh' "$all" ||
fail "the synaptic touchpad quirk runs during hardware setup"
pass "the synaptic touchpad quirk runs during hardware setup"
test_tmp=$(mktemp -d)
trap 'rm -rf "$test_tmp"' EXIT
mkdir -p "$test_tmp/bin"
modprobe_log="$test_tmp/modprobe.log"
# Only a real load is logged, so a case that expects nothing to happen can say
# so with an empty log even though the leaf always asks modprobe first whether
# psmouse resolves against the running kernel.
cat >"$test_tmp/bin/modprobe" <<'SH'
#!/bin/bash
if [[ $1 == "-qn" ]]; then
exit "${TEST_MODPROBE_RESOLVES:-0}"
fi
printf '%s\n' "$*" >>"$MODPROBE_LOG"
exit "${TEST_MODPROBE_STATUS:-0}"
SH
cat >"$test_tmp/bin/lsmod" <<'SH'
#!/bin/bash
printf '%s\n' 'Module Size Used by'
printf '%s\n' "${TEST_LOADED_MODULES:-}"
SH
chmod +x "$test_tmp/bin"/*
printf '%s\n' 'N: Name="SynPS/2 Synaptics TouchPad"' >"$test_tmp/devices"
# Sourced under errexit the way run_logged runs it, so a failing modprobe would
# fail the run rather than be swallowed here.
run_fix() {
: >"$modprobe_log"
MODPROBE_LOG="$modprobe_log" \
PATH="$test_tmp/bin:$PATH" \
OMARCHY_SYNAPTIC_INPUT_DEVICES="$test_tmp/devices" \
TEST_LOADED_MODULES="${1:-}" \
TEST_MODPROBE_STATUS="${2:-0}" \
TEST_MODPROBE_RESOLVES="${3:-0}" \
bash -eE -c 'source "$1"' bash "$leaf"
}
run_fix
grep -q 'psmouse synaptics_intertouch=1' "$modprobe_log" ||
fail "the synaptic touchpad quirk enables InterTouch on a booted machine"
pass "the synaptic touchpad quirk enables InterTouch on a booted machine"
# The install-breaking case: under arch-chroot the live kernel's modules are not
# the ones on disk, so psmouse does not resolve and there is nothing to load.
run_fix "" 0 1
if [[ -s $modprobe_log ]]; then
fail "the synaptic touchpad quirk skips a kernel that cannot resolve psmouse"
fi
pass "the synaptic touchpad quirk skips a kernel that cannot resolve psmouse"
run_fix psmouse
if [[ -s $modprobe_log ]]; then
fail "the synaptic touchpad quirk leaves an already-loaded psmouse alone"
fi
pass "the synaptic touchpad quirk leaves an already-loaded psmouse alone"
# An optional touchpad improvement never gets to halt an install, whatever the
# reason the module declines to load.
run_fix "" 1 2>/dev/null ||
fail "the synaptic touchpad quirk survives a failing modprobe"
pass "the synaptic touchpad quirk survives a failing modprobe"