/ de-omarchy / bin / omarchy-update-pacman-guard
swadhinbiswas Initial de-omarchy: Omarchy UI layer for Arch-based distros · 8/22/2026
9f393b2
65 lines · 1.3 KB
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
#!/bin/bash

# omarchy:summary=Prevent direct pacman system upgrades from bypassing omarchy update.
# omarchy:hidden=true

set -euo pipefail

if [[ ${OMARCHY_UPDATE_PACMAN:-} == "1" || ${OMARCHY_ALLOW_DIRECT_PACMAN:-} == "1" ]]; then
  exit 0
fi

pacman_args=()
if [[ -n ${OMARCHY_PACMAN_CMDLINE:-} ]]; then
  read -r -a pacman_args <<<"$OMARCHY_PACMAN_CMDLINE"
elif [[ -r /proc/$PPID/cmdline ]]; then
  mapfile -d '' -t pacman_args <"/proc/$PPID/cmdline" || true
fi

is_system_upgrade=0
has_sync=0
has_sysupgrade=0

for arg in "${pacman_args[@]}"; do
  case "$arg" in
    --sync)
      has_sync=1
      ;;
    --sysupgrade)
      has_sysupgrade=1
      ;;
    --*)
      ;;
    -*)
      [[ $arg == *S* ]] && has_sync=1
      [[ $arg == *u* ]] && has_sysupgrade=1
      ;;
  esac
done

if (( has_sync && has_sysupgrade )); then
  is_system_upgrade=1
fi

(( is_system_upgrade )) || exit 0

cat >&2 <<'MESSAGE'

Woah partner...

This looks like a direct pacman system upgrade. Omarchy updates should normally
run through:

  omarchy update

That path handles the update transcript, snapshot, keyrings, package upgrade,
migrations, post-update hooks, shell update state, and restart checks together.

If you really meant to bypass Omarchy for this transaction, rerun pacman with:

  sudo env OMARCHY_ALLOW_DIRECT_PACMAN=1 pacman -Syu

MESSAGE

exit 1