Shield Omarchy pacman transactions from desktop session teardown
Upgrading systemd runs its post_upgrade scriptlet mid-transaction, which reexecs both the system manager and every user manager. When pacman runs inside a user-session scope (the floating update terminal), that reexec can SIGKILL it and abandon the transaction halfway, with packages upgraded but none of the post-transaction hooks run. Route every Omarchy-owned system mutation through a new hidden omarchy-update-pacman helper that registers the transaction as a PID 1 scope via systemd-run, keeping it out of the user manager's cgroups. System scopes survive the system manager's own reexec, and as a bonus the transaction now also survives its terminal window closing. On unbooted systems (the installer chroot) the helper runs pacman directly. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
1b001a69d3
commit
f5194e3ff5
7 files changed
+53
-16
No files matched your search
@@ -85,7 +85,7 @@ fi
|
||||
|
||||
omarchy-refresh-pacman "$pacman_channel"
|
||||
# --ask 4 accepts omarchy <-> omarchy-dev replacement prompts without file overwrites.
|
||||
sudo env OMARCHY_UPDATE_PACMAN=1 pacman -S --needed --noconfirm --ask 4 "${packages[@]}"
|
||||
omarchy-update-pacman -S --needed --noconfirm --ask 4 "${packages[@]}"
|
||||
|
||||
if [[ -z $dev_checkout ]]; then
|
||||
omarchy-dev-unlink --no-reboot
|
||||
|
||||
@@ -23,4 +23,4 @@ sudo cp -f "$OMARCHY_PATH/default/pacman/mirrorlist-$channel" /etc/pacman.d/mirr
|
||||
omarchy-hook pre-refresh-pacman
|
||||
|
||||
# Reset all package DBs and then update
|
||||
sudo env OMARCHY_UPDATE_PACMAN=1 pacman -Syyuu --noconfirm
|
||||
omarchy-update-pacman -Syyuu --noconfirm
|
||||
@@ -11,8 +11,8 @@ set -e
|
||||
omarchy-refresh-pacman
|
||||
|
||||
# Downgrade any packages to the stable setup
|
||||
sudo env OMARCHY_UPDATE_PACMAN=1 pacman -Suu --noconfirm
|
||||
omarchy-update-pacman -Suu --noconfirm
|
||||
|
||||
# Ensure all packages are installed
|
||||
mapfile -t packages < <(grep -v '^#' "$OMARCHY_PATH/install/omarchy-base.packages" | grep -v '^$')
|
||||
sudo env OMARCHY_UPDATE_PACMAN=1 pacman -Syu --noconfirm --needed "${packages[@]}"
|
||||
omarchy-update-pacman -Syu --noconfirm --needed "${packages[@]}"
|
||||
Executable
+25
@@ -0,0 +1,25 @@
|
||||
#!/bin/bash
|
||||
|
||||
# omarchy:summary=Run a pacman transaction for the Omarchy update flow, shielded from desktop session teardown.
|
||||
# omarchy:args=<pacman-args>
|
||||
# omarchy:hidden=true
|
||||
# omarchy:requires-sudo=true
|
||||
|
||||
# Upgrading systemd runs its post_upgrade scriptlet mid-transaction, which
|
||||
# reexecs both the system manager and every user manager. A pacman running
|
||||
# inside a user-session scope can be SIGKILLed by that reexec, abandoning the
|
||||
# transaction halfway. Registering the transaction as a PID 1 scope keeps it
|
||||
# out of the user manager's cgroups entirely, and system scopes survive the
|
||||
# system manager's own reexec.
|
||||
scope=()
|
||||
if [[ -d /run/systemd/system && ! -L /run/systemd/system ]]; then
|
||||
scope=(systemd-run --scope --quiet --collect)
|
||||
fi
|
||||
|
||||
# LC_ALL passes through so callers that parse pacman's stderr can pin the locale.
|
||||
env_args=(OMARCHY_UPDATE_PACMAN=1)
|
||||
if [[ -n ${LC_ALL:-} ]]; then
|
||||
env_args+=(LC_ALL="$LC_ALL")
|
||||
fi
|
||||
|
||||
exec sudo env "${env_args[@]}" "${scope[@]}" pacman "$@"
|
||||
@@ -10,7 +10,7 @@ set -e
|
||||
# a stream, because an upgrade without --noconfirm prompts on stderr. The
|
||||
# handler has already said why, so no heading here either.
|
||||
if [[ ${OMARCHY_UPDATE_CONFLICT:-} == 1 && ${OMARCHY_UPDATE_INTERACTIVE:-} == 1 ]]; then
|
||||
exec sudo env OMARCHY_UPDATE_PACMAN=1 pacman -Syu --overwrite '/usr/share/omarchy/*'
|
||||
exec omarchy-update-pacman -Syu --overwrite '/usr/share/omarchy/*'
|
||||
fi
|
||||
|
||||
echo -e "\e[32m\nUpdate system packages\e[0m"
|
||||
@@ -23,7 +23,7 @@ trap 'rm -f "$errors"' EXIT
|
||||
#
|
||||
# Progress bars stay on stdout. Errors are on stderr, kept for the conflict
|
||||
# handler below; LC_ALL=C is what keeps them parseable in any locale.
|
||||
if sudo env LC_ALL=C OMARCHY_UPDATE_PACMAN=1 pacman -Syu --noconfirm \
|
||||
if LC_ALL=C omarchy-update-pacman -Syu --noconfirm \
|
||||
--overwrite '/usr/share/omarchy/*' 2>"$errors"; then
|
||||
cat "$errors" >&2
|
||||
exit 0
|
||||
|
||||
Reference in new issue
Block a user