blob: 4f561ae7167013d8c25bde770df49d73c6bf17aa (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
#!/bin/sh
# SPDX-License-Identifier: GPL-3.0-or-later
# hypr-live-update-guard - abort a live GPU/compositor library upgrade.
#
# Installed as a pacman PreTransaction hook. When an upgrade transaction
# includes GPU/compositor runtime libraries (mesa, hyprland, wayland, GPU
# drivers, ...) AND a Hyprland session is running, this aborts the
# transaction BEFORE any package is swapped. Replacing those libraries out
# from under a live compositor makes the next GPU-lib call hit a now
# "(deleted)" file and SIGABRT, taking the Wayland clients down with it
# (hit on ratio 2026-06-07: mesa + hyprland upgraded live, Hyprland crashed
# and took awww/insync/emacs with it). Aborting at PreTransaction is the
# safe point: nothing has been replaced yet, so the running session is
# untouched and the user can re-run the upgrade from a TTY.
#
# Pacman feeds the matched package names on stdin (NeedsTargets).
#
# Test seams / overrides (env):
# HYPR_GUARD_RUNNING 1/0 forces the running check (default: pgrep Hyprland)
# HYPR_ALLOW_LIVE_UPDATE 1 proceeds anyway (skip the guard)
# HYPR_GUARD_SENTINEL path whose existence also proceeds anyway
# (default /run/archsetup-allow-live-gpu-update,
# cleared on reboot since /run is tmpfs)
set -u
sentinel="${HYPR_GUARD_SENTINEL:-/run/archsetup-allow-live-gpu-update}"
# Explicit override: the user knows what they're doing.
if [ "${HYPR_ALLOW_LIVE_UPDATE:-0}" = "1" ] || [ -e "$sentinel" ]; then
exit 0
fi
hyprland_running() {
if [ -n "${HYPR_GUARD_RUNNING:-}" ]; then
[ "$HYPR_GUARD_RUNNING" = "1" ]
return
fi
pgrep -x Hyprland >/dev/null 2>&1
}
# No live session means no live swap to worry about. Let the upgrade run --
# this is exactly the from-a-TTY-after-logout path the warning points to.
hyprland_running || exit 0
# Collect the triggering packages (stdin from NeedsTargets) for the message.
pkgs=$(cat 2>/dev/null | sort -u | tr '\n' ' ')
cat >&2 <<EOF
==========================================================================
BLOCKED: live GPU/compositor library upgrade while Hyprland is running
==========================================================================
Packages in this upgrade can crash the running compositor if swapped now:
${pkgs:-(GPU/compositor runtime libraries)}
Replacing these out from under a live Hyprland session makes the next
GPU-lib call hit a deleted library and SIGABRT, taking your Wayland apps
down with it (and risking an unclean shutdown).
Do it safely instead -- from a TTY with Hyprland stopped:
1. Log out of Hyprland, or switch to a console (Ctrl+Alt+F2) and log in.
2. Re-run the upgrade there: sudo pacman -Syu
To override and proceed anyway (not recommended while Hyprland runs):
sudo touch $sentinel && sudo pacman -Syu
==========================================================================
EOF
exit 1
|